aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2017-11-14 10:47:01 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-11-14 10:47:01 -0500
commitf2ecc3d0787e05d9145722feed01d4a11ab6bec1 (patch)
tree8b952af40dad67d728f1e421efc640907c523982
parentb1cb7372fa822af6c06c8045963571d13ad6348b (diff)
parentc14dd9d5f8beda9d8c621683b4e7d6cb5cd3cda7 (diff)
Merge tag 'staging-4.15-rc1' into v4l_for_linus
There are some conflicts between staging and media trees, as reported by Stephen Rothwell <sfr@canb.auug.org.au>. So, merge from staging. * tag 'staging-4.15-rc1': (775 commits) staging: lustre: add SPDX identifiers to all lustre files staging: greybus: Remove redundant license text staging: greybus: add SPDX identifiers to all greybus driver files staging: ccree: simplify ioread/iowrite staging: ccree: simplify registers access staging: ccree: simplify error handling logic staging: ccree: remove dead code staging: ccree: handle limiting of DMA masks staging: ccree: copy IV to DMAable memory staging: fbtft: remove redundant initialization of buf staging: sm750fb: Fix parameter mistake in poke32 staging: wilc1000: Fix bssid buffer offset in Txq staging: fbtft: fb_ssd1331: fix mirrored display staging: android: Fix checkpatch.pl error staging: greybus: loopback: convert loopback to use generic async operations staging: greybus: operation: add private data with get/set accessors staging: greybus: loopback: Fix iteration count on async path staging: greybus: loopback: Hold per-connection mutex across operations staging: greybus/loopback: use ktime_get() for time intervals staging: fsl-dpaa2/eth: Extra headroom in RX buffers ... Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio7
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-cros-ec10
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-proximity-as39358
-rw-r--r--Documentation/core-api/kernel-api.rst14
-rw-r--r--Documentation/devicetree/bindings/iio/adc/mcp320x.txt14
-rw-r--r--Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/dac/ds4424.txt20
-rw-r--r--Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt34
-rw-r--r--Documentation/devicetree/bindings/iio/health/max30100.txt4
-rw-r--r--Documentation/devicetree/bindings/iio/health/max30102.txt2
-rw-r--r--Documentation/devicetree/bindings/iio/proximity/as3935.txt5
-rw-r--r--Documentation/devicetree/bindings/iio/st-sensors.txt4
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt6
-rw-r--r--Documentation/process/index.rst1
-rw-r--r--Documentation/process/kernel-enforcement-statement.rst147
-rw-r--r--MAINTAINERS3
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/boot/compressed/debug.S4
-rw-r--r--arch/arm/boot/dts/armada-38x.dtsi4
-rw-r--r--arch/arm/boot/dts/at91-sama5d27_som1.dtsi4
-rw-r--r--arch/arm/boot/dts/at91-sama5d2_xplained.dts16
-rw-r--r--arch/arm/boot/dts/bcm2835-rpi-zero-w.dts9
-rw-r--r--arch/arm/boot/dts/bcm2837-rpi-3-b.dts5
-rw-r--r--arch/arm/boot/dts/bcm283x.dtsi7
-rw-r--r--arch/arm/boot/dts/gemini.dtsi3
-rw-r--r--arch/arm/boot/dts/imx7d.dtsi8
-rw-r--r--arch/arm/boot/dts/moxart.dtsi3
-rw-r--r--arch/arm/boot/dts/sama5d2.dtsi1
-rw-r--r--arch/arm/boot/dts/sun6i-a31.dtsi16
-rw-r--r--arch/arm/configs/pxa_defconfig3
-rw-r--r--arch/arm/configs/raumfeld_defconfig3
-rw-r--r--arch/arm/kernel/debug.S8
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c4
-rw-r--r--arch/arm/mach-ux500/pm.c4
-rw-r--r--arch/arm/mm/nommu.c5
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts9
-rw-r--r--arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi6
-rw-r--r--arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi6
-rw-r--r--arch/arm64/boot/dts/renesas/salvator-common.dtsi10
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3328.dtsi2
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3368.dtsi2
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3399-firefly.dts4
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi4
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi4
-rw-r--r--arch/parisc/kernel/parisc_ksyms.c2
-rw-r--r--arch/parisc/kernel/syscall.S6
-rw-r--r--arch/parisc/kernel/time.c5
-rw-r--r--arch/s390/configs/zfcpdump_defconfig2
-rw-r--r--arch/s390/kernel/smp.c3
-rw-r--r--arch/x86/include/asm/io.h4
-rw-r--r--arch/x86/include/asm/tlbflush.h21
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c1
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c19
-rw-r--r--arch/x86/kernel/head32.c5
-rw-r--r--arch/x86/mm/mmap.c12
-rw-r--r--arch/x86/mm/tlb.c64
-rw-r--r--crypto/asymmetric_keys/asymmetric_type.c4
-rw-r--r--crypto/asymmetric_keys/pkcs7_parser.c3
-rw-r--r--drivers/android/binder.c11
-rw-r--r--drivers/android/binder_alloc.c24
-rw-r--r--drivers/android/binder_alloc.h1
-rw-r--r--drivers/block/nbd.c2
-rw-r--r--drivers/block/skd_main.c2
-rw-r--r--drivers/bus/mvebu-mbus.c2
-rw-r--r--drivers/clocksource/cs5535-clockevt.c3
-rw-r--r--drivers/dma/altera-msgdma.c4
-rw-r--r--drivers/gpu/drm/amd/scheduler/gpu_scheduler.c23
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c8
-rw-r--r--drivers/gpu/drm/i915/gvt/sched_policy.c22
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c63
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c7
-rw-r--r--drivers/gpu/drm/i915/intel_dpll_mgr.c2
-rw-r--r--drivers/gpu/drm/i915/intel_engine_cs.c9
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c7
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c2
-rw-r--r--drivers/hv/channel_mgmt.c5
-rw-r--r--drivers/i2c/busses/i2c-imx.c4
-rw-r--r--drivers/i2c/busses/i2c-ismt.c5
-rw-r--r--drivers/i2c/busses/i2c-omap.c14
-rw-r--r--drivers/i2c/busses/i2c-piix4.c162
-rw-r--r--drivers/iio/accel/Kconfig15
-rw-r--r--drivers/iio/accel/Makefile2
-rw-r--r--drivers/iio/accel/adxl345_core.c1
-rw-r--r--drivers/iio/accel/bma180.c2
-rw-r--r--drivers/iio/accel/bma220_spi.c1
-rw-r--r--drivers/iio/accel/bmc150-accel-core.c3
-rw-r--r--drivers/iio/accel/cros_ec_accel_legacy.c423
-rw-r--r--drivers/iio/accel/da280.c1
-rw-r--r--drivers/iio/accel/da311.c1
-rw-r--r--drivers/iio/accel/dmard06.c1
-rw-r--r--drivers/iio/accel/dmard09.c1
-rw-r--r--drivers/iio/accel/dmard10.c1
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c1
-rw-r--r--drivers/iio/accel/kxcjk-1013.c356
-rw-r--r--drivers/iio/accel/kxsd9.c1
-rw-r--r--drivers/iio/accel/mc3230.c1
-rw-r--r--drivers/iio/accel/mma7455_core.c1
-rw-r--r--drivers/iio/accel/mma7660.c1
-rw-r--r--drivers/iio/accel/mma8452.c383
-rw-r--r--drivers/iio/accel/mma9551.c1
-rw-r--r--drivers/iio/accel/mma9553.c1
-rw-r--r--drivers/iio/accel/mxc4005.c2
-rw-r--r--drivers/iio/accel/mxc6255.c1
-rw-r--r--drivers/iio/accel/sca3000.c1
-rw-r--r--drivers/iio/accel/st_accel.h4
-rw-r--r--drivers/iio/accel/st_accel_core.c248
-rw-r--r--drivers/iio/accel/st_accel_i2c.c5
-rw-r--r--drivers/iio/accel/st_accel_spi.c10
-rw-r--r--drivers/iio/accel/stk8312.c2
-rw-r--r--drivers/iio/accel/stk8ba50.c2
-rw-r--r--drivers/iio/adc/Kconfig9
-rw-r--r--drivers/iio/adc/ad7266.c1
-rw-r--r--drivers/iio/adc/ad7291.c1
-rw-r--r--drivers/iio/adc/ad7298.c1
-rw-r--r--drivers/iio/adc/ad7476.c1
-rw-r--r--drivers/iio/adc/ad7766.c2
-rw-r--r--drivers/iio/adc/ad7791.c2
-rw-r--r--drivers/iio/adc/ad7793.c2
-rw-r--r--drivers/iio/adc/ad7887.c1
-rw-r--r--drivers/iio/adc/ad7923.c1
-rw-r--r--drivers/iio/adc/ad799x.c3
-rw-r--r--drivers/iio/adc/ad_sigma_delta.c1
-rw-r--r--drivers/iio/adc/aspeed_adc.c1
-rw-r--r--drivers/iio/adc/at91-sama5d2_adc.c47
-rw-r--r--drivers/iio/adc/at91_adc.c2
-rw-r--r--drivers/iio/adc/axp20x_adc.c2
-rw-r--r--drivers/iio/adc/axp288_adc.c1
-rw-r--r--drivers/iio/adc/bcm_iproc_adc.c1
-rw-r--r--drivers/iio/adc/berlin2-adc.c1
-rw-r--r--drivers/iio/adc/cc10001_adc.c1
-rw-r--r--drivers/iio/adc/cpcap-adc.c1
-rw-r--r--drivers/iio/adc/da9150-gpadc.c1
-rw-r--r--drivers/iio/adc/dln2-adc.c6
-rw-r--r--drivers/iio/adc/envelope-detector.c1
-rw-r--r--drivers/iio/adc/ep93xx_adc.c1
-rw-r--r--drivers/iio/adc/exynos_adc.c1
-rw-r--r--drivers/iio/adc/hi8435.c1
-rw-r--r--drivers/iio/adc/hx711.c1
-rw-r--r--drivers/iio/adc/imx7d_adc.c1
-rw-r--r--drivers/iio/adc/ina2xx-adc.c20
-rw-r--r--drivers/iio/adc/lp8788_adc.c1
-rw-r--r--drivers/iio/adc/lpc18xx_adc.c1
-rw-r--r--drivers/iio/adc/lpc32xx_adc.c1
-rw-r--r--drivers/iio/adc/ltc2471.c1
-rw-r--r--drivers/iio/adc/ltc2485.c1
-rw-r--r--drivers/iio/adc/ltc2497.c1
-rw-r--r--drivers/iio/adc/max1027.c2
-rw-r--r--drivers/iio/adc/max11100.c1
-rw-r--r--drivers/iio/adc/max1118.c1
-rw-r--r--drivers/iio/adc/max1363.c2
-rw-r--r--drivers/iio/adc/max9611.c2
-rw-r--r--drivers/iio/adc/mcp320x.c235
-rw-r--r--drivers/iio/adc/mcp3422.c1
-rw-r--r--drivers/iio/adc/men_z188_adc.c1
-rw-r--r--drivers/iio/adc/meson_saradc.c1
-rw-r--r--drivers/iio/adc/mt6577_auxadc.c2
-rw-r--r--drivers/iio/adc/mxs-lradc-adc.c2
-rw-r--r--drivers/iio/adc/nau7802.c1
-rw-r--r--drivers/iio/adc/palmas_gpadc.c1
-rw-r--r--drivers/iio/adc/qcom-pm8xxx-xoadc.c1
-rw-r--r--drivers/iio/adc/qcom-spmi-iadc.c1
-rw-r--r--drivers/iio/adc/qcom-spmi-vadc.c1
-rw-r--r--drivers/iio/adc/rcar-gyroadc.c8
-rw-r--r--drivers/iio/adc/rockchip_saradc.c1
-rw-r--r--drivers/iio/adc/spear_adc.c1
-rw-r--r--drivers/iio/adc/stm32-adc-core.c13
-rw-r--r--drivers/iio/adc/stm32-adc.c2
-rw-r--r--drivers/iio/adc/stx104.c1
-rw-r--r--drivers/iio/adc/sun4i-gpadc-iio.c45
-rw-r--r--drivers/iio/adc/ti-adc081c.c1
-rw-r--r--drivers/iio/adc/ti-adc0832.c1
-rw-r--r--drivers/iio/adc/ti-adc084s021.c1
-rw-r--r--drivers/iio/adc/ti-adc108s102.c1
-rw-r--r--drivers/iio/adc/ti-adc12138.c3
-rw-r--r--drivers/iio/adc/ti-adc128s052.c1
-rw-r--r--drivers/iio/adc/ti-adc161s626.c1
-rw-r--r--drivers/iio/adc/ti-ads1015.c22
-rw-r--r--drivers/iio/adc/ti-ads7950.c1
-rw-r--r--drivers/iio/adc/ti-ads8688.c2
-rw-r--r--drivers/iio/adc/ti-tlc4541.c1
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c1
-rw-r--r--drivers/iio/adc/twl4030-madc.c1
-rw-r--r--drivers/iio/adc/twl6030-gpadc.c1
-rw-r--r--drivers/iio/adc/vf610_adc.c1
-rw-r--r--drivers/iio/adc/viperboard_adc.c1
-rw-r--r--drivers/iio/adc/xilinx-xadc-core.c2
-rw-r--r--drivers/iio/amplifiers/ad8366.c1
-rw-r--r--drivers/iio/chemical/ams-iaq-core.c1
-rw-r--r--drivers/iio/chemical/atlas-ph-sensor.c2
-rw-r--r--drivers/iio/chemical/ccs811.c87
-rw-r--r--drivers/iio/chemical/vz89x.c1
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c1
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c13
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c59
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_trigger.c16
-rw-r--r--drivers/iio/counter/104-quad-8.c1
-rw-r--r--drivers/iio/counter/stm32-lptimer-cnt.c1
-rw-r--r--drivers/iio/dac/Kconfig22
-rw-r--r--drivers/iio/dac/Makefile2
-rw-r--r--drivers/iio/dac/ad5064.c1
-rw-r--r--drivers/iio/dac/ad5360.c1
-rw-r--r--drivers/iio/dac/ad5380.c1
-rw-r--r--drivers/iio/dac/ad5421.c1
-rw-r--r--drivers/iio/dac/ad5446.c14
-rw-r--r--drivers/iio/dac/ad5449.c1
-rw-r--r--drivers/iio/dac/ad5504.c1
-rw-r--r--drivers/iio/dac/ad5592r-base.c1
-rw-r--r--drivers/iio/dac/ad5624r_spi.c1
-rw-r--r--drivers/iio/dac/ad5686.c1
-rw-r--r--drivers/iio/dac/ad5755.c1
-rw-r--r--drivers/iio/dac/ad5761.c1
-rw-r--r--drivers/iio/dac/ad5764.c1
-rw-r--r--drivers/iio/dac/ad5791.c1
-rw-r--r--drivers/iio/dac/ad7303.c1
-rw-r--r--drivers/iio/dac/ad8801.c1
-rw-r--r--drivers/iio/dac/cio-dac.c1
-rw-r--r--drivers/iio/dac/dpot-dac.c1
-rw-r--r--drivers/iio/dac/ds4424.c341
-rw-r--r--drivers/iio/dac/lpc18xx_dac.c1
-rw-r--r--drivers/iio/dac/ltc2632.c1
-rw-r--r--drivers/iio/dac/m62332.c1
-rw-r--r--drivers/iio/dac/max517.c1
-rw-r--r--drivers/iio/dac/max5821.c1
-rw-r--r--drivers/iio/dac/mcp4725.c1
-rw-r--r--drivers/iio/dac/mcp4922.c1
-rw-r--r--drivers/iio/dac/stm32-dac.c1
-rw-r--r--drivers/iio/dac/ti-dac082s085.c368
-rw-r--r--drivers/iio/dac/vf610_dac.c1
-rw-r--r--drivers/iio/dummy/Kconfig2
-rw-r--r--drivers/iio/dummy/iio_dummy_evgen.c89
-rw-r--r--drivers/iio/dummy/iio_simple_dummy.c1
-rw-r--r--drivers/iio/dummy/iio_simple_dummy_events.c1
-rw-r--r--drivers/iio/frequency/ad9523.c1
-rw-r--r--drivers/iio/frequency/adf4350.c1
-rw-r--r--drivers/iio/gyro/adis16080.c1
-rw-r--r--drivers/iio/gyro/adis16130.c1
-rw-r--r--drivers/iio/gyro/adis16136.c1
-rw-r--r--drivers/iio/gyro/adis16260.c1
-rw-r--r--drivers/iio/gyro/adxrs450.c1
-rw-r--r--drivers/iio/gyro/bmg160_core.c2
-rw-r--r--drivers/iio/gyro/hid-sensor-gyro-3d.c1
-rw-r--r--drivers/iio/gyro/itg3200_buffer.c1
-rw-r--r--drivers/iio/gyro/itg3200_core.c1
-rw-r--r--drivers/iio/gyro/mpu3050-core.c2
-rw-r--r--drivers/iio/gyro/st_gyro_core.c47
-rw-r--r--drivers/iio/health/afe4403.c2
-rw-r--r--drivers/iio/health/afe4404.c2
-rw-r--r--drivers/iio/health/max30100.c1
-rw-r--r--drivers/iio/health/max30102.c1
-rw-r--r--drivers/iio/humidity/am2315.c1
-rw-r--r--drivers/iio/humidity/dht11.c1
-rw-r--r--drivers/iio/humidity/hdc100x.c1
-rw-r--r--drivers/iio/humidity/hid-sensor-humidity.c1
-rw-r--r--drivers/iio/humidity/hts221_buffer.c1
-rw-r--r--drivers/iio/humidity/hts221_core.c1
-rw-r--r--drivers/iio/humidity/htu21.c1
-rw-r--r--drivers/iio/humidity/si7005.c1
-rw-r--r--drivers/iio/humidity/si7020.c1
-rw-r--r--drivers/iio/imu/adis16400_core.c1
-rw-r--r--drivers/iio/imu/adis16480.c1
-rw-r--r--drivers/iio/imu/adis_trigger.c1
-rw-r--r--drivers/iio/imu/bmi160/bmi160_core.c1
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c13
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c1
-rw-r--r--drivers/iio/imu/kmx61.c3
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h32
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c72
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c98
-rw-r--r--drivers/iio/industrialio-core.c35
-rw-r--r--drivers/iio/industrialio-trigger.c35
-rw-r--r--drivers/iio/light/acpi-als.c1
-rw-r--r--drivers/iio/light/adjd_s311.c1
-rw-r--r--drivers/iio/light/al3320a.c1
-rw-r--r--drivers/iio/light/apds9300.c2
-rw-r--r--drivers/iio/light/apds9960.c1
-rw-r--r--drivers/iio/light/bh1750.c1
-rw-r--r--drivers/iio/light/bh1780.c1
-rw-r--r--drivers/iio/light/cm32181.c1
-rw-r--r--drivers/iio/light/cm3232.c1
-rw-r--r--drivers/iio/light/cm3323.c1
-rw-r--r--drivers/iio/light/cm3605.c1
-rw-r--r--drivers/iio/light/cm36651.c1
-rw-r--r--drivers/iio/light/cros_ec_light_prox.c1
-rw-r--r--drivers/iio/light/gp2ap020a00f.c2
-rw-r--r--drivers/iio/light/hid-sensor-als.c1
-rw-r--r--drivers/iio/light/hid-sensor-prox.c1
-rw-r--r--drivers/iio/light/isl29018.c2
-rw-r--r--drivers/iio/light/isl29028.c1
-rw-r--r--drivers/iio/light/isl29125.c1
-rw-r--r--drivers/iio/light/jsa1212.c1
-rw-r--r--drivers/iio/light/lm3533-als.c1
-rw-r--r--drivers/iio/light/ltr501.c4
-rw-r--r--drivers/iio/light/max44000.c1
-rw-r--r--drivers/iio/light/opt3001.c1
-rw-r--r--drivers/iio/light/pa12203001.c1
-rw-r--r--drivers/iio/light/rpr0521.c2
-rw-r--r--drivers/iio/light/si1145.c3
-rw-r--r--drivers/iio/light/stk3310.c1
-rw-r--r--drivers/iio/light/tcs3414.c1
-rw-r--r--drivers/iio/light/tcs3472.c263
-rw-r--r--drivers/iio/light/tsl2563.c2
-rw-r--r--drivers/iio/light/tsl2583.c1
-rw-r--r--drivers/iio/light/tsl4531.c1
-rw-r--r--drivers/iio/light/us5182d.c1
-rw-r--r--drivers/iio/light/vcnl4000.c1
-rw-r--r--drivers/iio/light/veml6070.c1
-rw-r--r--drivers/iio/light/vl6180.c127
-rw-r--r--drivers/iio/magnetometer/ak8974.c1
-rw-r--r--drivers/iio/magnetometer/ak8975.c1
-rw-r--r--drivers/iio/magnetometer/bmc150_magn.c2
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c1
-rw-r--r--drivers/iio/magnetometer/hmc5843_core.c1
-rw-r--r--drivers/iio/magnetometer/mag3110.c1
-rw-r--r--drivers/iio/magnetometer/mmc35240.c1
-rw-r--r--drivers/iio/magnetometer/st_magn_core.c22
-rw-r--r--drivers/iio/multiplexer/iio-mux.c7
-rw-r--r--drivers/iio/orientation/hid-sensor-incl-3d.c1
-rw-r--r--drivers/iio/orientation/hid-sensor-rotation.c1
-rw-r--r--drivers/iio/potentiometer/ds1803.c1
-rw-r--r--drivers/iio/potentiometer/max5481.c2
-rw-r--r--drivers/iio/potentiometer/max5487.c2
-rw-r--r--drivers/iio/potentiometer/mcp4131.c1
-rw-r--r--drivers/iio/potentiometer/mcp4531.c1
-rw-r--r--drivers/iio/potentiometer/tpl0102.c1
-rw-r--r--drivers/iio/potentiostat/lmp91000.c2
-rw-r--r--drivers/iio/pressure/abp060mg.c1
-rw-r--r--drivers/iio/pressure/bmp280-core.c1
-rw-r--r--drivers/iio/pressure/cros_ec_baro.c3
-rw-r--r--drivers/iio/pressure/hid-sensor-press.c1
-rw-r--r--drivers/iio/pressure/hp03.c1
-rw-r--r--drivers/iio/pressure/hp206c.c1
-rw-r--r--drivers/iio/pressure/mpl115.c1
-rw-r--r--drivers/iio/pressure/mpl3115.c1
-rw-r--r--drivers/iio/pressure/ms5611_core.c1
-rw-r--r--drivers/iio/pressure/ms5637.c1
-rw-r--r--drivers/iio/pressure/st_pressure.h4
-rw-r--r--drivers/iio/pressure/st_pressure_core.c78
-rw-r--r--drivers/iio/pressure/st_pressure_i2c.c10
-rw-r--r--drivers/iio/pressure/st_pressure_spi.c10
-rw-r--r--drivers/iio/pressure/t5403.c1
-rw-r--r--drivers/iio/pressure/zpa2326.c12
-rw-r--r--drivers/iio/proximity/Kconfig10
-rw-r--r--drivers/iio/proximity/Makefile1
-rw-r--r--drivers/iio/proximity/as3935.c45
-rw-r--r--drivers/iio/proximity/pulsedlight-lidar-lite-v2.c1
-rw-r--r--drivers/iio/proximity/rfd77402.c352
-rw-r--r--drivers/iio/proximity/srf04.c1
-rw-r--r--drivers/iio/proximity/srf08.c2
-rw-r--r--drivers/iio/proximity/sx9500.c2
-rw-r--r--drivers/iio/temperature/hid-sensor-temperature.c1
-rw-r--r--drivers/iio/temperature/maxim_thermocouple.c1
-rw-r--r--drivers/iio/temperature/mlx90614.c1
-rw-r--r--drivers/iio/temperature/tmp006.c1
-rw-r--r--drivers/iio/temperature/tmp007.c1
-rw-r--r--drivers/iio/temperature/tsys01.c1
-rw-r--r--drivers/iio/temperature/tsys02d.c1
-rw-r--r--drivers/iio/trigger/iio-trig-hrtimer.c1
-rw-r--r--drivers/iio/trigger/iio-trig-interrupt.c1
-rw-r--r--drivers/iio/trigger/iio-trig-loop.c1
-rw-r--r--drivers/iio/trigger/iio-trig-sysfs.c1
-rw-r--r--drivers/iio/trigger/stm32-lptimer-trigger.c1
-rw-r--r--drivers/iio/trigger/stm32-timer-trigger.c2
-rw-r--r--drivers/input/input.c84
-rw-r--r--drivers/input/joydev.c70
-rw-r--r--drivers/input/keyboard/tca8418_keypad.c29
-rw-r--r--drivers/input/misc/axp20x-pek.c2
-rw-r--r--drivers/input/misc/ims-pcu.c16
-rw-r--r--drivers/input/mouse/synaptics.c3
-rw-r--r--drivers/input/touchscreen/goodix.c67
-rw-r--r--drivers/input/touchscreen/stmfts.c6
-rw-r--r--drivers/input/touchscreen/ti_am335x_tsc.c2
-rw-r--r--drivers/input/touchscreen/tsc2007_iio.c1
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c43
-rw-r--r--drivers/irqchip/irq-tango.c2
-rw-r--r--drivers/misc/Kconfig10
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/ti_dac7512.c103
-rw-r--r--drivers/mmc/host/sdhci-pci-core.c2
-rw-r--r--drivers/net/can/flexcan.c91
-rw-r--r--drivers/net/can/usb/esd_usb2.c2
-rw-r--r--drivers/net/can/usb/gs_usb.c10
-rw-r--r--drivers/net/dsa/mv88e6060.c10
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_ethtool.c4
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.c7
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_cfg.h8
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c157
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_hw.h5
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_nic.c39
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_nic.h4
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c14
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_vec.c3
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c21
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c89
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h3
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c69
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h18
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c99
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.h5
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c23
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c8
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c11
-rw-r--r--drivers/net/ethernet/cavium/liquidio/lio_main.c2
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c16
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_nvm.c2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c63
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/reg.h31
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c11
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_common.c20
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c8
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c17
-rw-r--r--drivers/net/geneve.c6
-rw-r--r--drivers/net/macsec.c2
-rw-r--r--drivers/net/tun.c3
-rw-r--r--drivers/net/wimax/i2400m/fw.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c3
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c197
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/7000.c1
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/8000.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/9000.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/a000.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/dbg.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/dbg.h15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h16
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c137
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/nvm.c21
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rx.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tt.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c2
-rw-r--r--drivers/net/xen-netback/interface.c2
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/of/of_mdio.c39
-rw-r--r--drivers/phy/marvell/phy-mvebu-cp110-comphy.c18
-rw-r--r--drivers/phy/mediatek/phy-mtk-tphy.c3
-rw-r--r--drivers/phy/rockchip/phy-rockchip-typec.c82
-rw-r--r--drivers/phy/tegra/xusb.c2
-rw-r--r--drivers/platform/x86/toshiba_acpi.c1
-rw-r--r--drivers/reset/reset-socfpga.c17
-rw-r--r--drivers/scsi/libfc/fc_rport.c2
-rw-r--r--drivers/scsi/libiscsi.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c3
-rw-r--r--drivers/scsi/scsi_sysfs.c10
-rw-r--r--drivers/scsi/scsi_transport_fc.c3
-rw-r--r--drivers/staging/android/TODO1
-rw-r--r--drivers/staging/android/ion/ion-ioctl.c11
-rw-r--r--drivers/staging/android/ion/ion.c2
-rw-r--r--drivers/staging/android/ion/ion.h2
-rw-r--r--drivers/staging/ccree/cc_hal.h33
-rw-r--r--drivers/staging/ccree/cc_lli_defs.h2
-rw-r--r--drivers/staging/ccree/cc_regs.h42
-rw-r--r--drivers/staging/ccree/dx_reg_base_host.h25
-rw-r--r--drivers/staging/ccree/ssi_aead.c258
-rw-r--r--drivers/staging/ccree/ssi_buffer_mgr.c438
-rw-r--r--drivers/staging/ccree/ssi_buffer_mgr.h5
-rw-r--r--drivers/staging/ccree/ssi_cipher.c189
-rw-r--r--drivers/staging/ccree/ssi_cipher.h13
-rw-r--r--drivers/staging/ccree/ssi_driver.c381
-rw-r--r--drivers/staging/ccree/ssi_driver.h55
-rw-r--r--drivers/staging/ccree/ssi_fips.c26
-rw-r--r--drivers/staging/ccree/ssi_fips.h4
-rw-r--r--drivers/staging/ccree/ssi_hash.c377
-rw-r--r--drivers/staging/ccree/ssi_ivgen.c18
-rw-r--r--drivers/staging/ccree/ssi_pm.c35
-rw-r--r--drivers/staging/ccree/ssi_request_mgr.c195
-rw-r--r--drivers/staging/ccree/ssi_sram_mgr.c33
-rw-r--r--drivers/staging/ccree/ssi_sysfs.c282
-rw-r--r--drivers/staging/comedi/Kconfig4
-rw-r--r--drivers/staging/comedi/drivers/adv_pci_dio.c26
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c18
-rw-r--r--drivers/staging/comedi/drivers/das16.c17
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c2
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c10
-rw-r--r--drivers/staging/comedi/drivers/s526.c5
-rw-r--r--drivers/staging/dgnc/dgnc_driver.c8
-rw-r--r--drivers/staging/dgnc/dgnc_driver.h16
-rw-r--r--drivers/staging/dgnc/dgnc_neo.c11
-rw-r--r--drivers/staging/fbtft/fb_ra8875.c10
-rw-r--r--drivers/staging/fbtft/fb_ssd1331.c8
-rw-r--r--drivers/staging/fbtft/fb_uc1611.c2
-rw-r--r--drivers/staging/fbtft/fb_uc1701.c2
-rw-r--r--drivers/staging/fbtft/fbtft-bus.c24
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c281
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h54
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c14
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h5
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpni.c32
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpni.h5
-rw-r--r--drivers/staging/fsl-mc/bus/dpio/dpio-service.c4
-rw-r--r--drivers/staging/fsl-mc/bus/fsl-mc-msi.c2
-rw-r--r--drivers/staging/fsl-mc/include/dpaa2-io.h6
-rw-r--r--drivers/staging/fwserial/fwserial.c16
-rw-r--r--drivers/staging/gdm724x/gdm_lte.c19
-rw-r--r--drivers/staging/greybus/Documentation/firmware/authenticate.c1
-rw-r--r--drivers/staging/greybus/Documentation/firmware/firmware.c1
-rw-r--r--drivers/staging/greybus/arche-apb-ctrl.c3
-rw-r--r--drivers/staging/greybus/arche-platform.c3
-rw-r--r--drivers/staging/greybus/arche_platform.h3
-rw-r--r--drivers/staging/greybus/arpc.h1
-rw-r--r--drivers/staging/greybus/audio_apbridgea.c3
-rw-r--r--drivers/staging/greybus/audio_apbridgea.h1
-rw-r--r--drivers/staging/greybus/audio_codec.c3
-rw-r--r--drivers/staging/greybus/audio_codec.h3
-rw-r--r--drivers/staging/greybus/audio_gb.c3
-rw-r--r--drivers/staging/greybus/audio_manager.c5
-rw-r--r--drivers/staging/greybus/audio_manager.h3
-rw-r--r--drivers/staging/greybus/audio_manager_module.c3
-rw-r--r--drivers/staging/greybus/audio_manager_private.h3
-rw-r--r--drivers/staging/greybus/audio_manager_sysfs.c3
-rw-r--r--drivers/staging/greybus/audio_module.c3
-rw-r--r--drivers/staging/greybus/audio_topology.c3
-rw-r--r--drivers/staging/greybus/authentication.c3
-rw-r--r--drivers/staging/greybus/bootrom.c3
-rw-r--r--drivers/staging/greybus/bundle.c3
-rw-r--r--drivers/staging/greybus/bundle.h3
-rw-r--r--drivers/staging/greybus/camera.c3
-rw-r--r--drivers/staging/greybus/connection.c3
-rw-r--r--drivers/staging/greybus/connection.h3
-rw-r--r--drivers/staging/greybus/control.c3
-rw-r--r--drivers/staging/greybus/control.h3
-rw-r--r--drivers/staging/greybus/core.c3
-rw-r--r--drivers/staging/greybus/debugfs.c3
-rw-r--r--drivers/staging/greybus/es2.c4
-rw-r--r--drivers/staging/greybus/firmware.h3
-rw-r--r--drivers/staging/greybus/fw-core.c3
-rw-r--r--drivers/staging/greybus/fw-download.c3
-rw-r--r--drivers/staging/greybus/fw-management.c3
-rw-r--r--drivers/staging/greybus/gb-camera.h3
-rw-r--r--drivers/staging/greybus/gbphy.c3
-rw-r--r--drivers/staging/greybus/gbphy.h3
-rw-r--r--drivers/staging/greybus/gpio.c3
-rw-r--r--drivers/staging/greybus/greybus.h3
-rw-r--r--drivers/staging/greybus/greybus_authentication.h1
-rw-r--r--drivers/staging/greybus/greybus_firmware.h1
-rw-r--r--drivers/staging/greybus/greybus_manifest.h1
-rw-r--r--drivers/staging/greybus/greybus_protocols.h1
-rw-r--r--drivers/staging/greybus/greybus_trace.h3
-rw-r--r--drivers/staging/greybus/hd.c3
-rw-r--r--drivers/staging/greybus/hd.h3
-rw-r--r--drivers/staging/greybus/hid.c3
-rw-r--r--drivers/staging/greybus/i2c.c3
-rw-r--r--drivers/staging/greybus/interface.c3
-rw-r--r--drivers/staging/greybus/interface.h3
-rw-r--r--drivers/staging/greybus/light.c11
-rw-r--r--drivers/staging/greybus/log.c3
-rw-r--r--drivers/staging/greybus/loopback.c242
-rw-r--r--drivers/staging/greybus/manifest.c3
-rw-r--r--drivers/staging/greybus/manifest.h3
-rw-r--r--drivers/staging/greybus/module.c3
-rw-r--r--drivers/staging/greybus/module.h3
-rw-r--r--drivers/staging/greybus/operation.c3
-rw-r--r--drivers/staging/greybus/operation.h16
-rw-r--r--drivers/staging/greybus/power_supply.c3
-rw-r--r--drivers/staging/greybus/pwm.c3
-rw-r--r--drivers/staging/greybus/raw.c3
-rw-r--r--drivers/staging/greybus/sdio.c3
-rw-r--r--drivers/staging/greybus/spi.c3
-rw-r--r--drivers/staging/greybus/spilib.c11
-rw-r--r--drivers/staging/greybus/spilib.h1
-rw-r--r--drivers/staging/greybus/svc.c3
-rw-r--r--drivers/staging/greybus/svc.h3
-rw-r--r--drivers/staging/greybus/svc_watchdog.c3
-rwxr-xr-xdrivers/staging/greybus/tools/lbtest1
-rw-r--r--drivers/staging/greybus/tools/loopback_test.c1
-rw-r--r--drivers/staging/greybus/uart.c3
-rw-r--r--drivers/staging/greybus/usb.c4
-rw-r--r--drivers/staging/greybus/vibrator.c3
-rw-r--r--drivers/staging/gs_fpgaboot/gs_fpgaboot.c2
-rw-r--r--drivers/staging/iio/Documentation/device.txt3
-rw-r--r--drivers/staging/iio/Documentation/trigger.txt4
-rw-r--r--drivers/staging/iio/accel/adis16201.c1
-rw-r--r--drivers/staging/iio/accel/adis16203.c1
-rw-r--r--drivers/staging/iio/accel/adis16209.c1
-rw-r--r--drivers/staging/iio/accel/adis16240.c1
-rw-r--r--drivers/staging/iio/adc/ad7192.c11
-rw-r--r--drivers/staging/iio/adc/ad7280a.c1
-rw-r--r--drivers/staging/iio/adc/ad7606.c4
-rw-r--r--drivers/staging/iio/adc/ad7780.c1
-rw-r--r--drivers/staging/iio/adc/ad7816.c1
-rw-r--r--drivers/staging/iio/addac/adt7316.c2
-rw-r--r--drivers/staging/iio/cdc/ad7150.c1
-rw-r--r--drivers/staging/iio/cdc/ad7152.c1
-rw-r--r--drivers/staging/iio/cdc/ad7746.c1
-rw-r--r--drivers/staging/iio/frequency/ad9832.c1
-rw-r--r--drivers/staging/iio/frequency/ad9834.c2
-rw-r--r--drivers/staging/iio/gyro/adis16060_core.c1
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c1
-rw-r--r--drivers/staging/iio/light/tsl2x7x.c665
-rw-r--r--drivers/staging/iio/light/tsl2x7x.h13
-rw-r--r--drivers/staging/iio/meter/ade7753.c27
-rw-r--r--drivers/staging/iio/meter/ade7754.c1
-rw-r--r--drivers/staging/iio/meter/ade7758_core.c1
-rw-r--r--drivers/staging/iio/meter/ade7758_trigger.c1
-rw-r--r--drivers/staging/iio/meter/ade7759.c30
-rw-r--r--drivers/staging/iio/meter/ade7854.c1
-rw-r--r--drivers/staging/iio/resolver/ad2s1200.c1
-rw-r--r--drivers/staging/iio/resolver/ad2s1210.c1
-rw-r--r--drivers/staging/iio/resolver/ad2s90.c1
-rw-r--r--drivers/staging/iio/trigger/iio-trig-bfin-timer.c1
-rw-r--r--drivers/staging/irda/drivers/ali-ircc.c3
-rw-r--r--drivers/staging/irda/drivers/au1k_ir.c40
-rw-r--r--drivers/staging/irda/drivers/bfin_sir.c12
-rw-r--r--drivers/staging/irda/drivers/esi-sir.c22
-rw-r--r--drivers/staging/irda/drivers/irda-usb.c24
-rw-r--r--drivers/staging/irda/drivers/irda-usb.h1
-rw-r--r--drivers/staging/irda/drivers/mcs7780.c9
-rw-r--r--drivers/staging/irda/drivers/vlsi_ir.c18
-rw-r--r--drivers/staging/irda/include/net/irda/irlmp_event.h6
-rw-r--r--drivers/staging/irda/include/net/irda/qos.h20
-rw-r--r--drivers/staging/irda/include/net/irda/timer.h11
-rw-r--r--drivers/staging/irda/net/af_irda.c7
-rw-r--r--drivers/staging/irda/net/discovery.c4
-rw-r--r--drivers/staging/irda/net/ircomm/ircomm_tty.c2
-rw-r--r--drivers/staging/irda/net/ircomm/ircomm_tty_attach.c8
-rw-r--r--drivers/staging/irda/net/irda_device.c36
-rw-r--r--drivers/staging/irda/net/iriap.c10
-rw-r--r--drivers/staging/irda/net/irlan/irlan_client.c6
-rw-r--r--drivers/staging/irda/net/irlan/irlan_common.c4
-rw-r--r--drivers/staging/irda/net/irlap.c16
-rw-r--r--drivers/staging/irda/net/irlap_event.c6
-rw-r--r--drivers/staging/irda/net/irlmp.c8
-rw-r--r--drivers/staging/irda/net/irlmp_event.c10
-rw-r--r--drivers/staging/irda/net/irqueue.c3
-rw-r--r--drivers/staging/irda/net/irttp.c11
-rw-r--r--drivers/staging/irda/net/timer.c54
-rw-r--r--drivers/staging/ks7010/ks_wlan_net.c15
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/curproc.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_private.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_string.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_time.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h1
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h1
-rw-r--r--drivers/staging/lustre/include/linux/lnet/api.h1
-rw-r--r--drivers/staging/lustre/include/linux/lnet/lib-lnet.h1
-rw-r--r--drivers/staging/lustre/include/linux/lnet/lib-types.h29
-rw-r--r--drivers/staging/lustre/include/linux/lnet/socklnd.h1
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h1
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c17
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h1
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c1
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/debug.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/fail.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/hash.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_lock.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_mem.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_string.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-module.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/module.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/prng.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/tracefile.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/tracefile.h1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/workitem.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/acceptor.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/api-ni.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/config.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-eq.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-md.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-me.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-move.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-msg.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-ptl.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-socket.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lo.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/module.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/net_fault.c2
-rw-r--r--drivers/staging/lustre/lnet/lnet/nidstrings.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/peer.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/router.c10
-rw-r--r--drivers/staging/lustre/lnet/lnet/router_proc.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/brw_test.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/conctl.c2
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/framework.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/module.c6
-rw-r--r--drivers/staging/lustre/lnet/selftest/ping_test.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/rpc.c14
-rw-r--r--drivers/staging/lustre/lnet/selftest/rpc.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/selftest.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/timer.c1
-rw-r--r--drivers/staging/lustre/lnet/selftest/timer.h1
-rw-r--r--drivers/staging/lustre/lustre/fid/fid_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/fid/fid_lib.c1
-rw-r--r--drivers/staging/lustre/lustre/fid/fid_request.c4
-rw-r--r--drivers/staging/lustre/lustre/fid/lproc_fid.c1
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_cache.c1
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_request.c4
-rw-r--r--drivers/staging/lustre/lustre/fld/lproc_fld.c1
-rw-r--r--drivers/staging/lustre/lustre/include/cl_object.h1
-rw-r--r--drivers/staging/lustre/lustre/include/interval_tree.h1
-rw-r--r--drivers/staging/lustre/lustre/include/llog_swab.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lprocfs_status.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lu_object.h5
-rw-r--r--drivers/staging/lustre/lustre/include/lu_ref.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_acl.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_compat.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_debug.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_disk.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_dlm.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_dlm_flags.h7
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_errno.h51
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_export.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_fid.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_fld.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_ha.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_handles.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_import.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_intent.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_kernelcomm.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_lib.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_linkea.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_lmv.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_log.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_mdc.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_mds.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_net.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_nrs.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_obdo.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_patchless_compat.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_req_layout.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_sec.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_swab.h1
-rw-r--r--drivers/staging/lustre/lustre/include/obd.h1
-rw-r--r--drivers/staging/lustre/lustre/include/obd_cksum.h1
-rw-r--r--drivers/staging/lustre/lustre/include/obd_class.h1
-rw-r--r--drivers/staging/lustre/lustre/include/obd_support.h1
-rw-r--r--drivers/staging/lustre/lustre/include/seq_range.h1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/interval_tree.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/l_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_extent.c4
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_flock.c215
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_internal.h3
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lib.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lock.c34
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c7
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_plain.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_pool.c7
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_request.c44
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_resource.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/dcache.c10
-rw-r--r--drivers/staging/lustre/lustre/llite/dir.c21
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c14
-rw-r--r--drivers/staging/lustre/lustre/llite/glimpse.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/lcommon_cl.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/lcommon_misc.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_internal.h19
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c30
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_mmap.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_nfs.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/lproc_llite.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c20
-rw-r--r--drivers/staging/lustre/lustre/llite/range_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/range_lock.h1
-rw-r--r--drivers/staging/lustre/lustre/llite/rw.c18
-rw-r--r--drivers/staging/lustre/lustre/llite/rw26.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/statahead.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/super25.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/symlink.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_dev.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_io.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_object.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_page.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr_cache.c3
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr_security.c1
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_fld.c1
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_intent.c1
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_obd.c1
-rw-r--r--drivers/staging/lustre/lustre/lmv/lproc_lmv.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_cl_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_dev.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_ea.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_io.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_merge.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_obd.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_object.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_offset.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_pack.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_page.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_pool.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_request.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lovsub_dev.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lovsub_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lovsub_object.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lovsub_page.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lproc_lov.c1
-rw-r--r--drivers/staging/lustre/lustre/mdc/lproc_mdc.c1
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_lib.c1
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_locks.c1
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_reint.c1
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_request.c1
-rw-r--r--drivers/staging/lustre/lustre/mgc/lproc_mgc.c1
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_request.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_io.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_object.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_page.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/class_obd.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/debug.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/genops.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/kernelcomm.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linkea.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-module.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog_cat.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog_obd.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog_swab.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_status.c5
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lu_object.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lu_ref.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lustre_handles.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lustre_peer.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_config.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_mount.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obdo.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/statfs_pack.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/uuid.c1
-rw-r--r--drivers/staging/lustre/lustre/obdecho/echo_client.c1
-rw-r--r--drivers/staging/lustre/lustre/obdecho/echo_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/osc/lproc_osc.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_cache.c2
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_cl_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_dev.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_io.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_object.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_page.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_quota.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_request.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/client.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/connection.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/errno.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/events.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/import.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/layout.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/llog_client.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/llog_net.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/niobuf.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pack_generic.c7
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pers.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pinger.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/recover.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec.c3
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_config.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_gc.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_null.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_plain.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/service.c1
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/wiretest.c1
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c27
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c2
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c8
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.c60
-rw-r--r--drivers/staging/netlogic/xlr_net.c82
-rw-r--r--drivers/staging/pi433/Documentation/pi433.txt24
-rw-r--r--drivers/staging/pi433/pi433_if.c67
-rw-r--r--drivers/staging/pi433/rf69.c236
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ap.c2
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_cmd.c4
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_efuse.c2
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_led.c7
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme.c49
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme_ext.c89
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_pwrctrl.c35
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_recv.c144
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_security.c2
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_sta_mgt.c4
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_xmit.c64
-rw-r--r--drivers/staging/rtl8188eu/hal/odm.c2
-rw-r--r--drivers/staging/rtl8188eu/hal/odm_HWConfig.c4
-rw-r--r--drivers/staging/rtl8188eu/hal/phy.c15
-rw-r--r--drivers/staging/rtl8188eu/hal/usb_halinit.c1
-rw-r--r--drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h33
-rw-r--r--drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h3
-rw-r--r--drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h28
-rw-r--r--drivers/staging/rtl8188eu/include/basic_types.h14
-rw-r--r--drivers/staging/rtl8188eu/include/drv_types.h3
-rw-r--r--drivers/staging/rtl8188eu/include/hal_intf.h6
-rw-r--r--drivers/staging/rtl8188eu/include/ieee80211.h114
-rw-r--r--drivers/staging/rtl8188eu/include/odm.h46
-rw-r--r--drivers/staging/rtl8188eu/include/osdep_intf.h2
-rw-r--r--drivers/staging/rtl8188eu/include/pwrseq.h44
-rw-r--r--drivers/staging/rtl8188eu/include/rtl8188e_hal.h29
-rw-r--r--drivers/staging/rtl8188eu/include/rtl8188e_spec.h157
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_cmd.h222
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_debug.h4
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_eeprom.h9
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_event.h40
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_led.h7
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_mlme.h44
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_mlme_ext.h33
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h19
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_pwrctrl.h22
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_qos.h3
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_recv.h82
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_rf.h6
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_security.h27
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_xmit.h12
-rw-r--r--drivers/staging/rtl8188eu/include/sta_info.h12
-rw-r--r--drivers/staging/rtl8188eu/include/wifi.h25
-rw-r--r--drivers/staging/rtl8188eu/include/wlan_bssdef.h22
-rw-r--r--drivers/staging/rtl8188eu/os_dep/mlme_linux.c19
-rw-r--r--drivers/staging/rtl8188eu/os_dep/mon.c34
-rw-r--r--drivers/staging/rtl8188eu/os_dep/recv_linux.c5
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c1
-rw-r--r--drivers/staging/rtl8192e/dot11d.c8
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.c25
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.h2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.c11
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_pm.c2
-rw-r--r--drivers/staging/rtl8192e/rtl819x_BAProc.c15
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TSProc.c56
-rw-r--r--drivers/staging/rtl8192e/rtllib.h6
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac.c23
-rw-r--r--drivers/staging/rtl8192e/rtllib_wx.c3
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211.h118
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.h2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_module.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c27
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c1
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c15
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c16
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c46
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c20
-rw-r--r--drivers/staging/rtl8192u/r8192U_dm.c9
-rw-r--r--drivers/staging/rtl8192u/r8192U_dm.h2
-rw-r--r--drivers/staging/rtl8192u/r8192U_wx.c2
-rw-r--r--drivers/staging/rtl8192u/r8192U_wx.h2
-rw-r--r--drivers/staging/rtl8712/hal_init.c4
-rw-r--r--drivers/staging/rtl8712/mlme_linux.c48
-rw-r--r--drivers/staging/rtl8712/os_intfs.c8
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmd.c4
-rw-r--r--drivers/staging/rtl8712/rtl8712_event.h1
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.c6
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.c3
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_set.c4
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.c4
-rw-r--r--drivers/staging/rtl8712/rtl871x_pwrctrl.c8
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.c5
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.h2
-rw-r--r--drivers/staging/rtl8712/usb_intf.c3
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ap.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_btcoex.c4
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_cmd.c144
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_debug.c8
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ieee80211.c6
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ioctl_set.c4
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme.c21
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme_ext.c140
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_pwrctrl.c34
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_recv.c33
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_rf.c7
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_security.c2
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_sta_mgt.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_wlan_util.c4
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_xmit.c5
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c9
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c4
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c7
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_btcoex.c11
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com_phycfg.c69
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_CfoTracking.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DIG.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_HWConfig.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_halinit.c4
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_ops.c10
-rw-r--r--drivers/staging/rtl8723bs/include/drv_types.h3
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service.h6
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service_linux.h13
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mlme.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mlme_ext.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_pwrctrl.h3
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_recv.h2
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c16
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_linux.c45
-rw-r--r--drivers/staging/rtl8723bs/os_dep/mlme_linux.c62
-rw-r--r--drivers/staging/rtl8723bs/os_dep/os_intfs.c243
-rw-r--r--drivers/staging/rtl8723bs/os_dep/osdep_service.c24
-rw-r--r--drivers/staging/rtl8723bs/os_dep/recv_linux.c5
-rw-r--r--drivers/staging/rtl8723bs/os_dep/rtw_proc.c6
-rw-r--r--drivers/staging/rtlwifi/base.c58
-rw-r--r--drivers/staging/rtlwifi/base.h4
-rw-r--r--drivers/staging/rtlwifi/core.c72
-rw-r--r--drivers/staging/rtlwifi/core.h4
-rw-r--r--drivers/staging/rtlwifi/debug.c36
-rw-r--r--drivers/staging/rtlwifi/efuse.c5
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c2
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c50
-rw-r--r--drivers/staging/rtlwifi/halmac/rtl_halmac.c2
-rw-r--r--drivers/staging/rtlwifi/pci.c2
-rw-r--r--drivers/staging/rtlwifi/phydm/halphyrf_ce.c2
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm.c8
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_adaptivity.c4
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_debug.c12
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dig.c24
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_interface.c23
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_interface.h11
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c10
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c4
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c13
-rw-r--r--drivers/staging/rtlwifi/ps.c2
-rw-r--r--drivers/staging/rtlwifi/rc.c16
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/fw.c9
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/led.c2
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/phy.c23
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/trx.c24
-rw-r--r--drivers/staging/rts5208/sd.c6
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.h2
-rw-r--r--drivers/staging/sm750fb/ddk750_dvi.c4
-rw-r--r--drivers/staging/sm750fb/ddk750_dvi.h4
-rw-r--r--drivers/staging/sm750fb/ddk750_power.c2
-rw-r--r--drivers/staging/sm750fb/ddk750_power.h7
-rw-r--r--drivers/staging/sm750fb/ddk750_sii164.c3
-rw-r--r--drivers/staging/sm750fb/ddk750_sii164.h4
-rw-r--r--drivers/staging/sm750fb/sm750_cursor.c4
-rw-r--r--drivers/staging/speakup/buffers.c4
-rw-r--r--drivers/staging/speakup/main.c4
-rw-r--r--drivers/staging/speakup/speakup_acntsa.c2
-rw-r--r--drivers/staging/speakup/speakup_apollo.c2
-rw-r--r--drivers/staging/speakup/speakup_audptr.c2
-rw-r--r--drivers/staging/speakup/speakup_bns.c2
-rw-r--r--drivers/staging/speakup/speakup_decext.c2
-rw-r--r--drivers/staging/speakup/speakup_dectlk.c2
-rw-r--r--drivers/staging/speakup/speakup_dummy.c2
-rw-r--r--drivers/staging/speakup/speakup_ltlk.c2
-rw-r--r--drivers/staging/speakup/speakup_spkout.c2
-rw-r--r--drivers/staging/speakup/speakup_txprt.c2
-rw-r--r--drivers/staging/speakup/spk_ttyio.c10
-rw-r--r--drivers/staging/typec/Kconfig10
-rw-r--r--drivers/staging/typec/Makefile2
-rw-r--r--drivers/staging/typec/TODO10
-rw-r--r--drivers/staging/typec/fusb302/TODO10
-rw-r--r--drivers/staging/typec/tcpci.c5
-rw-r--r--drivers/staging/unisys/MAINTAINERS2
-rw-r--r--drivers/staging/unisys/include/iochannel.h9
-rw-r--r--drivers/staging/unisys/include/visorbus.h159
-rw-r--r--drivers/staging/unisys/include/visorchannel.h (renamed from drivers/staging/unisys/include/channel.h)12
-rw-r--r--drivers/staging/unisys/visorbus/controlvmchannel.h3
-rw-r--r--drivers/staging/unisys/visorbus/vbuschannel.h12
-rw-r--r--drivers/staging/unisys/visorbus/visorbus_main.c271
-rw-r--r--drivers/staging/unisys/visorbus/visorbus_private.h8
-rw-r--r--drivers/staging/unisys/visorbus/visorchannel.c81
-rw-r--r--drivers/staging/unisys/visorbus/visorchipset.c298
-rw-r--r--drivers/staging/unisys/visorhba/visorhba_main.c12
-rw-r--r--drivers/staging/unisys/visorinput/visorinput.c6
-rw-r--r--drivers/staging/unisys/visornic/visornic_main.c10
-rw-r--r--drivers/staging/vboxvideo/vbox_drv.h8
-rw-r--r--drivers/staging/vboxvideo/vbox_irq.c4
-rw-r--r--drivers/staging/vboxvideo/vbox_mode.c26
-rw-r--r--drivers/staging/vc04_services/Kconfig12
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c11
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c30
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835.h2
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h24
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c2
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h2
-rw-r--r--drivers/staging/vc04_services/interface/vchi/connections/connection.h3
-rw-r--r--drivers/staging/vc04_services/interface/vchi/message_drivers/message.h5
-rw-r--r--drivers/staging/vc04_services/interface/vchi/vchi.h12
-rw-r--r--drivers/staging/vc04_services/interface/vchi/vchi_common.h6
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c57
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c177
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h6
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c13
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h1
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c3
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c47
-rw-r--r--drivers/staging/vme/devices/Kconfig13
-rw-r--r--drivers/staging/vme/devices/Makefile3
-rw-r--r--drivers/staging/vme/devices/vme_pio2.h244
-rw-r--r--drivers/staging/vme/devices/vme_pio2_cntr.c71
-rw-r--r--drivers/staging/vme/devices/vme_pio2_core.c493
-rw-r--r--drivers/staging/vme/devices/vme_pio2_gpio.c220
-rw-r--r--drivers/staging/vt6655/device_main.c3
-rw-r--r--drivers/staging/vt6655/key.c4
-rw-r--r--drivers/staging/vt6656/card.c2
-rw-r--r--drivers/staging/wilc1000/host_interface.c45
-rw-r--r--drivers/staging/wilc1000/host_interface.h5
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.c7
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.c2
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c29
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.c78
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.h2
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c6
-rw-r--r--drivers/staging/xgifb/XGI_main_26.c4
-rw-r--r--drivers/staging/xgifb/vb_setmode.c7
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/config.c6
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/hub.c11
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/host/xhci-hub.c23
-rw-r--r--drivers/usb/host/xhci-ring.c21
-rw-r--r--drivers/usb/host/xhci.c3
-rw-r--r--drivers/usb/musb/musb_core.c21
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/musb_cppi41.c94
-rw-r--r--drivers/usb/musb/sunxi.c2
-rw-r--r--drivers/usb/serial/metro-usb.c1
-rw-r--r--drivers/usb/typec/Kconfig14
-rw-r--r--drivers/usb/typec/Makefile2
-rw-r--r--drivers/usb/typec/fusb302/Kconfig (renamed from drivers/staging/typec/fusb302/Kconfig)0
-rw-r--r--drivers/usb/typec/fusb302/Makefile (renamed from drivers/staging/typec/fusb302/Makefile)0
-rw-r--r--drivers/usb/typec/fusb302/fusb302.c (renamed from drivers/staging/typec/fusb302/fusb302.c)4
-rw-r--r--drivers/usb/typec/fusb302/fusb302_reg.h (renamed from drivers/staging/typec/fusb302/fusb302_reg.h)0
-rw-r--r--drivers/usb/typec/tcpm.c (renamed from drivers/staging/typec/tcpm.c)46
-rw-r--r--fs/btrfs/super.c2
-rw-r--r--fs/crypto/keyinfo.c5
-rw-r--r--fs/direct-io.c39
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h24
-rw-r--r--fs/ecryptfs/keystore.c9
-rw-r--r--fs/exec.c1
-rw-r--r--fs/ext4/super.c4
-rw-r--r--fs/fscache/object-list.c7
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/iomap.c41
-rw-r--r--fs/namespace.c3
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c11
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h1
-rw-r--r--fs/xfs/xfs_aops.c47
-rw-r--r--fs/xfs/xfs_fsmap.c48
-rw-r--r--fs/xfs/xfs_super.c2
-rw-r--r--include/linux/filter.h2
-rw-r--r--include/linux/hid-sensor-hub.h1
-rw-r--r--include/linux/iio/common/st_sensors.h35
-rw-r--r--include/linux/iio/iio.h35
-rw-r--r--include/linux/iio/trigger.h21
-rw-r--r--include/linux/input.h7
-rw-r--r--include/linux/irq.h2
-rw-r--r--include/linux/irqchip/arm-gic-v3.h2
-rw-r--r--include/linux/key.h47
-rw-r--r--include/linux/mbus.h4
-rw-r--r--include/linux/mm_types.h3
-rw-r--r--include/linux/mod_devicetable.h3
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/linux/rculist.h2
-rw-r--r--include/linux/rcupdate.h22
-rw-r--r--include/linux/sched/mm.h16
-rw-r--r--include/linux/srcu.h1
-rw-r--r--include/linux/usb/pd.h (renamed from drivers/staging/typec/pd.h)5
-rw-r--r--include/linux/usb/pd_bdo.h (renamed from drivers/staging/typec/pd_bdo.h)0
-rw-r--r--include/linux/usb/pd_vdo.h (renamed from drivers/staging/typec/pd_vdo.h)0
-rw-r--r--include/linux/usb/tcpm.h (renamed from drivers/staging/typec/tcpm.h)57
-rw-r--r--include/net/inet_sock.h2
-rw-r--r--include/net/tcp.h5
-rw-r--r--include/sound/control.h3
-rw-r--r--include/uapi/linux/membarrier.h23
-rw-r--r--kernel/bpf/arraymap.c2
-rw-r--r--kernel/bpf/devmap.c10
-rw-r--r--kernel/bpf/hashtab.c4
-rw-r--r--kernel/bpf/sockmap.c28
-rw-r--r--kernel/bpf/verifier.c65
-rw-r--r--kernel/cpu.c5
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/irq/generic-chip.c15
-rw-r--r--kernel/rcu/srcutree.c2
-rw-r--r--kernel/rcu/sync.c9
-rw-r--r--kernel/rcu/tree.c18
-rw-r--r--kernel/sched/membarrier.c34
-rw-r--r--lib/digsig.c6
-rw-r--r--lib/ts_fsm.c2
-rw-r--r--lib/ts_kmp.c2
-rw-r--r--mm/memcontrol.c15
-rw-r--r--mm/percpu.c15
-rw-r--r--net/bridge/br_netlink.c2
-rw-r--r--net/can/af_can.c20
-rw-r--r--net/can/bcm.c5
-rw-r--r--net/core/dev.c6
-rw-r--r--net/core/dev_ioctl.c13
-rw-r--r--net/core/ethtool.c5
-rw-r--r--net/core/filter.c31
-rw-r--r--net/core/rtnetlink.c13
-rw-r--r--net/core/skbuff.c6
-rw-r--r--net/core/sock.c8
-rw-r--r--net/core/sock_reuseport.c12
-rw-r--r--net/dccp/ipv4.c13
-rw-r--r--net/dns_resolver/dns_key.c2
-rw-r--r--net/ipv4/Kconfig8
-rw-r--r--net/ipv4/cipso_ipv4.c24
-rw-r--r--net/ipv4/inet_connection_sock.c9
-rw-r--r--net/ipv4/inet_hashtables.c5
-rw-r--r--net/ipv4/syncookies.c2
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_ipv4.c22
-rw-r--r--net/ipv4/udp.c9
-rw-r--r--net/ipv6/ip6_flowlabel.c1
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/l2tp/l2tp_ppp.c3
-rw-r--r--net/mac80211/key.c21
-rw-r--r--net/ncsi/internal.h1
-rw-r--r--net/ncsi/ncsi-aen.c2
-rw-r--r--net/ncsi/ncsi-manage.c52
-rw-r--r--net/ncsi/ncsi-rsp.c2
-rw-r--r--net/netlink/af_netlink.c8
-rw-r--r--net/packet/af_packet.c24
-rw-r--r--net/rxrpc/af_rxrpc.c5
-rw-r--r--net/sched/cls_flower.c2
-rw-r--r--net/sctp/input.c2
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/vmw_vsock/hyperv_transport.c22
-rw-r--r--samples/sockmap/sockmap_kern.c2
-rw-r--r--samples/trace_events/trace-events-sample.c14
-rw-r--r--security/commoncap.c3
-rw-r--r--security/keys/Kconfig1
-rw-r--r--security/keys/big_key.c4
-rw-r--r--security/keys/encrypted-keys/encrypted.c9
-rw-r--r--security/keys/gc.c8
-rw-r--r--security/keys/key.c41
-rw-r--r--security/keys/keyctl.c9
-rw-r--r--security/keys/keyring.c14
-rw-r--r--security/keys/permission.c7
-rw-r--r--security/keys/proc.c31
-rw-r--r--security/keys/process_keys.c2
-rw-r--r--security/keys/request_key.c7
-rw-r--r--security/keys/request_key_auth.c2
-rw-r--r--security/keys/trusted.c2
-rw-r--r--security/keys/user_defined.c4
-rw-r--r--sound/core/seq/seq_lock.c4
-rw-r--r--sound/core/seq/seq_lock.h12
-rw-r--r--sound/core/vmaster.c31
-rw-r--r--sound/hda/hdac_controller.c5
-rw-r--r--sound/pci/hda/hda_codec.c97
-rw-r--r--sound/usb/quirks.c1
-rw-r--r--tools/include/uapi/linux/bpf.h3
-rw-r--r--tools/objtool/check.c9
-rw-r--r--tools/perf/Documentation/perf-record.txt4
-rwxr-xr-xtools/perf/tests/shell/trace+probe_libc_inet_pton.sh9
-rw-r--r--tools/perf/ui/hist.c9
-rw-r--r--tools/perf/util/parse-events.l17
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/xyarray.h4
-rw-r--r--tools/power/x86/turbostat/turbostat.c10
-rw-r--r--tools/testing/selftests/bpf/bpf_helpers.h2
-rw-r--r--tools/testing/selftests/bpf/sockmap_verdict_prog.c4
-rw-r--r--tools/testing/selftests/bpf/test_maps.c12
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c510
1302 files changed, 12056 insertions, 9850 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 7eead5f97e02..2e3f919485f4 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -522,6 +522,7 @@ Description:
522 Specifies the output powerdown mode. 522 Specifies the output powerdown mode.
523 DAC output stage is disconnected from the amplifier and 523 DAC output stage is disconnected from the amplifier and
524 1kohm_to_gnd: connected to ground via an 1kOhm resistor, 524 1kohm_to_gnd: connected to ground via an 1kOhm resistor,
525 2.5kohm_to_gnd: connected to ground via a 2.5kOhm resistor,
525 6kohm_to_gnd: connected to ground via a 6kOhm resistor, 526 6kohm_to_gnd: connected to ground via a 6kOhm resistor,
526 20kohm_to_gnd: connected to ground via a 20kOhm resistor, 527 20kohm_to_gnd: connected to ground via a 20kOhm resistor,
527 90kohm_to_gnd: connected to ground via a 90kOhm resistor, 528 90kohm_to_gnd: connected to ground via a 90kOhm resistor,
@@ -1242,9 +1243,9 @@ What: /sys/.../iio:deviceX/in_distance_raw
1242KernelVersion: 4.0 1243KernelVersion: 4.0
1243Contact: linux-iio@vger.kernel.org 1244Contact: linux-iio@vger.kernel.org
1244Description: 1245Description:
1245 This attribute is used to read the distance covered by the user 1246 This attribute is used to read the measured distance to an object
1246 since the last reboot while activated. Units after application 1247 or the distance covered by the user since the last reboot while
1247 of scale are meters. 1248 activated. Units after application of scale are meters.
1248 1249
1249What: /sys/bus/iio/devices/iio:deviceX/store_eeprom 1250What: /sys/bus/iio/devices/iio:deviceX/store_eeprom
1250KernelVersion: 3.4.0 1251KernelVersion: 3.4.0
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec
index 297b9720f024..0e95c2ca105c 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec
+++ b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec
@@ -16,3 +16,13 @@ Description:
16 the motion sensor is placed. For example, in a laptop a motion 16 the motion sensor is placed. For example, in a laptop a motion
17 sensor can be located on the base or on the lid. Current valid 17 sensor can be located on the base or on the lid. Current valid
18 values are 'base' and 'lid'. 18 values are 'base' and 'lid'.
19
20What: /sys/bus/iio/devices/iio:deviceX/id
21Date: Septembre 2017
22KernelVersion: 4.14
23Contact: linux-iio@vger.kernel.org
24Description:
25 This attribute is exposed by the CrOS EC legacy accelerometer
26 driver and represents the sensor ID as exposed by the EC. This
27 ID is used by the Android sensor service hardware abstraction
28 layer (sensor HAL) through the Android container on ChromeOS.
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
index 33e96f740639..147d4e8a1403 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
+++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
@@ -14,3 +14,11 @@ Description:
14 Show or set the gain boost of the amp, from 0-31 range. 14 Show or set the gain boost of the amp, from 0-31 range.
15 18 = indoors (default) 15 18 = indoors (default)
16 14 = outdoors 16 14 = outdoors
17
18What /sys/bus/iio/devices/iio:deviceX/noise_level_tripped
19Date: May 2017
20KernelVersion: 4.13
21Contact: Matt Ranostay <matt.ranostay@konsulko.com>
22Description:
23 When 1 the noise level is over the trip level and not reporting
24 valid data
diff --git a/Documentation/core-api/kernel-api.rst b/Documentation/core-api/kernel-api.rst
index 8282099e0cbf..5da10184d908 100644
--- a/Documentation/core-api/kernel-api.rst
+++ b/Documentation/core-api/kernel-api.rst
@@ -352,44 +352,30 @@ Read-Copy Update (RCU)
352---------------------- 352----------------------
353 353
354.. kernel-doc:: include/linux/rcupdate.h 354.. kernel-doc:: include/linux/rcupdate.h
355 :external:
356 355
357.. kernel-doc:: include/linux/rcupdate_wait.h 356.. kernel-doc:: include/linux/rcupdate_wait.h
358 :external:
359 357
360.. kernel-doc:: include/linux/rcutree.h 358.. kernel-doc:: include/linux/rcutree.h
361 :external:
362 359
363.. kernel-doc:: kernel/rcu/tree.c 360.. kernel-doc:: kernel/rcu/tree.c
364 :external:
365 361
366.. kernel-doc:: kernel/rcu/tree_plugin.h 362.. kernel-doc:: kernel/rcu/tree_plugin.h
367 :external:
368 363
369.. kernel-doc:: kernel/rcu/tree_exp.h 364.. kernel-doc:: kernel/rcu/tree_exp.h
370 :external:
371 365
372.. kernel-doc:: kernel/rcu/update.c 366.. kernel-doc:: kernel/rcu/update.c
373 :external:
374 367
375.. kernel-doc:: include/linux/srcu.h 368.. kernel-doc:: include/linux/srcu.h
376 :external:
377 369
378.. kernel-doc:: kernel/rcu/srcutree.c 370.. kernel-doc:: kernel/rcu/srcutree.c
379 :external:
380 371
381.. kernel-doc:: include/linux/rculist_bl.h 372.. kernel-doc:: include/linux/rculist_bl.h
382 :external:
383 373
384.. kernel-doc:: include/linux/rculist.h 374.. kernel-doc:: include/linux/rculist.h
385 :external:
386 375
387.. kernel-doc:: include/linux/rculist_nulls.h 376.. kernel-doc:: include/linux/rculist_nulls.h
388 :external:
389 377
390.. kernel-doc:: include/linux/rcu_sync.h 378.. kernel-doc:: include/linux/rcu_sync.h
391 :external:
392 379
393.. kernel-doc:: kernel/rcu/sync.c 380.. kernel-doc:: kernel/rcu/sync.c
394 :external:
395 381
diff --git a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
index bcd3ac8e6e0c..7d64753df949 100644
--- a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
@@ -29,15 +29,29 @@ Required properties:
29 "microchip,mcp3204" 29 "microchip,mcp3204"
30 "microchip,mcp3208" 30 "microchip,mcp3208"
31 "microchip,mcp3301" 31 "microchip,mcp3301"
32 "microchip,mcp3550-50"
33 "microchip,mcp3550-60"
34 "microchip,mcp3551"
35 "microchip,mcp3553"
32 36
33 NOTE: The use of the compatibles with no vendor prefix 37 NOTE: The use of the compatibles with no vendor prefix
34 is deprecated and only listed because old DT use them. 38 is deprecated and only listed because old DT use them.
35 39
40 - spi-cpha, spi-cpol (boolean):
41 Either SPI mode (0,0) or (1,1) must be used, so specify
42 none or both of spi-cpha, spi-cpol. The MCP3550/1/3
43 is more efficient in mode (1,1) as only 3 instead of
44 4 bytes need to be read from the ADC, but not all SPI
45 masters support it.
46
47 - vref-supply: Phandle to the external reference voltage supply.
48
36Examples: 49Examples:
37spi_controller { 50spi_controller {
38 mcp3x0x@0 { 51 mcp3x0x@0 {
39 compatible = "mcp3002"; 52 compatible = "mcp3002";
40 reg = <0>; 53 reg = <0>;
41 spi-max-frequency = <1000000>; 54 spi-max-frequency = <1000000>;
55 vref-supply = <&vref_reg>;
42 }; 56 };
43}; 57};
diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
index 64dc4843c180..0df9befdaecc 100644
--- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
@@ -12,6 +12,7 @@ for the Thermal Controller which holds a phandle to the AUXADC.
12Required properties: 12Required properties:
13 - compatible: Should be one of: 13 - compatible: Should be one of:
14 - "mediatek,mt2701-auxadc": For MT2701 family of SoCs 14 - "mediatek,mt2701-auxadc": For MT2701 family of SoCs
15 - "mediatek,mt2712-auxadc": For MT2712 family of SoCs
15 - "mediatek,mt7622-auxadc": For MT7622 family of SoCs 16 - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
16 - "mediatek,mt8173-auxadc": For MT8173 family of SoCs 17 - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
17 - reg: Address range of the AUXADC unit. 18 - reg: Address range of the AUXADC unit.
diff --git a/Documentation/devicetree/bindings/iio/dac/ds4424.txt b/Documentation/devicetree/bindings/iio/dac/ds4424.txt
new file mode 100644
index 000000000000..eaebbf8dab40
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/ds4424.txt
@@ -0,0 +1,20 @@
1Maxim Integrated DS4422/DS4424 7-bit Sink/Source Current DAC Device Driver
2
3Datasheet publicly available at:
4https://datasheets.maximintegrated.com/en/ds/DS4422-DS4424.pdf
5
6Required properties:
7 - compatible: Should be one of
8 maxim,ds4422
9 maxim,ds4424
10 - reg: Should contain the DAC I2C address
11
12Optional properties:
13 - vcc-supply: Power supply is optional. If not defined, driver will ignore it.
14
15Example:
16 ds4224@10 {
17 compatible = "maxim,ds4424";
18 reg = <0x10>; /* When A0, A1 pins are ground */
19 vcc-supply = <&vcc_3v3>;
20 };
diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
new file mode 100644
index 000000000000..9cb0e10df704
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
@@ -0,0 +1,34 @@
1Texas Instruments 8/10/12-bit 2/4-channel DAC driver
2
3Required properties:
4 - compatible: Must be one of:
5 "ti,dac082s085"
6 "ti,dac102s085"
7 "ti,dac122s085"
8 "ti,dac084s085"
9 "ti,dac104s085"
10 "ti,dac124s085"
11 - reg: Chip select number.
12 - spi-cpha, spi-cpol: SPI mode (0,1) or (1,0) must be used, so specify
13 either spi-cpha or spi-cpol (but not both).
14 - vref-supply: Phandle to the external reference voltage supply.
15
16For other required and optional properties of SPI slave nodes please refer to
17../../spi/spi-bus.txt.
18
19Example:
20 vref_2v5_reg: regulator-vref {
21 compatible = "regulator-fixed";
22 regulator-name = "2v5";
23 regulator-min-microvolt = <2500000>;
24 regulator-max-microvolt = <2500000>;
25 regulator-always-on;
26 };
27
28 dac@0 {
29 compatible = "ti,dac082s085";
30 reg = <0>;
31 spi-max-frequency = <40000000>;
32 spi-cpol;
33 vref-supply = <&vref_2v5_reg>;
34 };
diff --git a/Documentation/devicetree/bindings/iio/health/max30100.txt b/Documentation/devicetree/bindings/iio/health/max30100.txt
index 295a9edfa4fd..8d8176459d09 100644
--- a/Documentation/devicetree/bindings/iio/health/max30100.txt
+++ b/Documentation/devicetree/bindings/iio/health/max30100.txt
@@ -20,9 +20,9 @@ Optional properties:
20 20
21Example: 21Example:
22 22
23max30100@057 { 23max30100@57 {
24 compatible = "maxim,max30100"; 24 compatible = "maxim,max30100";
25 reg = <57>; 25 reg = <0x57>;
26 maxim,led-current-microamp = <24000 50000>; 26 maxim,led-current-microamp = <24000 50000>;
27 interrupt-parent = <&gpio1>; 27 interrupt-parent = <&gpio1>;
28 interrupts = <16 2>; 28 interrupts = <16 2>;
diff --git a/Documentation/devicetree/bindings/iio/health/max30102.txt b/Documentation/devicetree/bindings/iio/health/max30102.txt
index c695e7cbeefb..8629c18b0e78 100644
--- a/Documentation/devicetree/bindings/iio/health/max30102.txt
+++ b/Documentation/devicetree/bindings/iio/health/max30102.txt
@@ -20,7 +20,7 @@ Optional properties:
20 20
21Example: 21Example:
22 22
23max30100@57 { 23max30102@57 {
24 compatible = "maxim,max30102"; 24 compatible = "maxim,max30102";
25 reg = <0x57>; 25 reg = <0x57>;
26 maxim,red-led-current-microamp = <7000>; 26 maxim,red-led-current-microamp = <7000>;
diff --git a/Documentation/devicetree/bindings/iio/proximity/as3935.txt b/Documentation/devicetree/bindings/iio/proximity/as3935.txt
index 38d74314b7ab..b6c1afa6f02d 100644
--- a/Documentation/devicetree/bindings/iio/proximity/as3935.txt
+++ b/Documentation/devicetree/bindings/iio/proximity/as3935.txt
@@ -16,6 +16,10 @@ Optional properties:
16 - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping 16 - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping
17 value 0 - 120pF. This will require using the calibration data from 17 value 0 - 120pF. This will require using the calibration data from
18 the manufacturer. 18 the manufacturer.
19 - ams,nflwdth: Set the noise and watchdog threshold register on
20 startup. This will need to set according to the noise from the
21 MCU board, and possibly the local environment. Refer to the
22 datasheet for the threshold settings.
19 23
20Example: 24Example:
21 25
@@ -27,4 +31,5 @@ as3935@0 {
27 interrupt-parent = <&gpio1>; 31 interrupt-parent = <&gpio1>;
28 interrupts = <16 1>; 32 interrupts = <16 1>;
29 ams,tuning-capacitor-pf = <80>; 33 ams,tuning-capacitor-pf = <80>;
34 ams,nflwdth = <0x44>;
30}; 35};
diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index 9ec6f5ce54fc..6f626f73417e 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -46,6 +46,8 @@ Accelerometers:
46- st,h3lis331dl-accel 46- st,h3lis331dl-accel
47- st,lng2dm-accel 47- st,lng2dm-accel
48- st,lis3l02dq 48- st,lis3l02dq
49- st,lis2dw12
50- st,lis3dhh
49 51
50Gyroscopes: 52Gyroscopes:
51- st,l3g4200d-gyro 53- st,l3g4200d-gyro
@@ -71,3 +73,5 @@ Pressure sensors:
71- st,lps25h-press 73- st,lps25h-press
72- st,lps331ap-press 74- st,lps331ap-press
73- st,lps22hb-press 75- st,lps22hb-press
76- st,lps33hw
77- st,lps35hw
diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
index 4c29cdab0ea5..5eb108e180fa 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
@@ -99,7 +99,7 @@ Examples:
99 compatible = "arm,gic-v3-its"; 99 compatible = "arm,gic-v3-its";
100 msi-controller; 100 msi-controller;
101 #msi-cells = <1>; 101 #msi-cells = <1>;
102 reg = <0x0 0x2c200000 0 0x200000>; 102 reg = <0x0 0x2c200000 0 0x20000>;
103 }; 103 };
104 }; 104 };
105 105
@@ -124,14 +124,14 @@ Examples:
124 compatible = "arm,gic-v3-its"; 124 compatible = "arm,gic-v3-its";
125 msi-controller; 125 msi-controller;
126 #msi-cells = <1>; 126 #msi-cells = <1>;
127 reg = <0x0 0x2c200000 0 0x200000>; 127 reg = <0x0 0x2c200000 0 0x20000>;
128 }; 128 };
129 129
130 gic-its@2c400000 { 130 gic-its@2c400000 {
131 compatible = "arm,gic-v3-its"; 131 compatible = "arm,gic-v3-its";
132 msi-controller; 132 msi-controller;
133 #msi-cells = <1>; 133 #msi-cells = <1>;
134 reg = <0x0 0x2c400000 0 0x200000>; 134 reg = <0x0 0x2c400000 0 0x20000>;
135 }; 135 };
136 136
137 ppi-partitions { 137 ppi-partitions {
diff --git a/Documentation/process/index.rst b/Documentation/process/index.rst
index 82fc399fcd33..61e43cc3ed17 100644
--- a/Documentation/process/index.rst
+++ b/Documentation/process/index.rst
@@ -25,6 +25,7 @@ Below are the essential guides that every developer should read.
25 submitting-patches 25 submitting-patches
26 coding-style 26 coding-style
27 email-clients 27 email-clients
28 kernel-enforcement-statement
28 29
29Other guides to the community that are of interest to most developers are: 30Other guides to the community that are of interest to most developers are:
30 31
diff --git a/Documentation/process/kernel-enforcement-statement.rst b/Documentation/process/kernel-enforcement-statement.rst
new file mode 100644
index 000000000000..1e23d4227337
--- /dev/null
+++ b/Documentation/process/kernel-enforcement-statement.rst
@@ -0,0 +1,147 @@
1Linux Kernel Enforcement Statement
2----------------------------------
3
4As developers of the Linux kernel, we have a keen interest in how our software
5is used and how the license for our software is enforced. Compliance with the
6reciprocal sharing obligations of GPL-2.0 is critical to the long-term
7sustainability of our software and community.
8
9Although there is a right to enforce the separate copyright interests in the
10contributions made to our community, we share an interest in ensuring that
11individual enforcement actions are conducted in a manner that benefits our
12community and do not have an unintended negative impact on the health and
13growth of our software ecosystem. In order to deter unhelpful enforcement
14actions, we agree that it is in the best interests of our development
15community to undertake the following commitment to users of the Linux kernel
16on behalf of ourselves and any successors to our copyright interests:
17
18 Notwithstanding the termination provisions of the GPL-2.0, we agree that
19 it is in the best interests of our development community to adopt the
20 following provisions of GPL-3.0 as additional permissions under our
21 license with respect to any non-defensive assertion of rights under the
22 license.
23
24 However, if you cease all violation of this License, then your license
25 from a particular copyright holder is reinstated (a) provisionally,
26 unless and until the copyright holder explicitly and finally
27 terminates your license, and (b) permanently, if the copyright holder
28 fails to notify you of the violation by some reasonable means prior to
29 60 days after the cessation.
30
31 Moreover, your license from a particular copyright holder is
32 reinstated permanently if the copyright holder notifies you of the
33 violation by some reasonable means, this is the first time you have
34 received notice of violation of this License (for any work) from that
35 copyright holder, and you cure the violation prior to 30 days after
36 your receipt of the notice.
37
38Our intent in providing these assurances is to encourage more use of the
39software. We want companies and individuals to use, modify and distribute
40this software. We want to work with users in an open and transparent way to
41eliminate any uncertainty about our expectations regarding compliance or
42enforcement that might limit adoption of our software. We view legal action
43as a last resort, to be initiated only when other community efforts have
44failed to resolve the problem.
45
46Finally, once a non-compliance issue is resolved, we hope the user will feel
47welcome to join us in our efforts on this project. Working together, we will
48be stronger.
49
50Except where noted below, we speak only for ourselves, and not for any company
51we might work for today, have in the past, or will in the future.
52
53 - Bjorn Andersson (Linaro)
54 - Andrea Arcangeli (Red Hat)
55 - Neil Armstrong
56 - Jens Axboe
57 - Pablo Neira Ayuso
58 - Khalid Aziz
59 - Ralf Baechle
60 - Felipe Balbi
61 - Arnd Bergmann
62 - Ard Biesheuvel
63 - Paolo Bonzini (Red Hat)
64 - Christian Borntraeger
65 - Mark Brown (Linaro)
66 - Paul Burton
67 - Javier Martinez Canillas
68 - Rob Clark
69 - Jonathan Corbet
70 - Vivien Didelot (Savoir-faire Linux)
71 - Hans de Goede (Red Hat)
72 - Mel Gorman (SUSE)
73 - Sven Eckelmann
74 - Alex Elder (Linaro)
75 - Fabio Estevam
76 - Larry Finger
77 - Bhumika Goyal
78 - Andy Gross
79 - Juergen Gross
80 - Shawn Guo
81 - Ulf Hansson
82 - Tejun Heo
83 - Rob Herring
84 - Masami Hiramatsu
85 - Michal Hocko
86 - Simon Horman
87 - Johan Hovold (Hovold Consulting AB)
88 - Christophe JAILLET
89 - Olof Johansson
90 - Lee Jones (Linaro)
91 - Heiner Kallweit
92 - Srinivas Kandagatla
93 - Jan Kara
94 - Shuah Khan (Samsung)
95 - David Kershner
96 - Jaegeuk Kim
97 - Namhyung Kim
98 - Colin Ian King
99 - Jeff Kirsher
100 - Greg Kroah-Hartman (Linux Foundation)
101 - Christian König
102 - Vinod Koul
103 - Krzysztof Kozlowski
104 - Viresh Kumar
105 - Aneesh Kumar K.V
106 - Julia Lawall
107 - Doug Ledford (Red Hat)
108 - Chuck Lever (Oracle)
109 - Daniel Lezcano
110 - Shaohua Li
111 - Xin Long (Red Hat)
112 - Tony Luck
113 - Mike Marshall
114 - Chris Mason
115 - Paul E. McKenney
116 - David S. Miller
117 - Ingo Molnar
118 - Kuninori Morimoto
119 - Borislav Petkov
120 - Jiri Pirko
121 - Josh Poimboeuf
122 - Sebastian Reichel (Collabora)
123 - Guenter Roeck
124 - Joerg Roedel
125 - Leon Romanovsky
126 - Steven Rostedt (VMware)
127 - Ivan Safonov
128 - Ivan Safonov
129 - Anna Schumaker
130 - Jes Sorensen
131 - K.Y. Srinivasan
132 - Heiko Stuebner
133 - Jiri Kosina (SUSE)
134 - Dmitry Torokhov
135 - Linus Torvalds
136 - Thierry Reding
137 - Rik van Riel
138 - Geert Uytterhoeven (Glider bvba)
139 - Daniel Vetter
140 - Linus Walleij
141 - Richard Weinberger
142 - Dan Williams
143 - Rafael J. Wysocki
144 - Arvind Yadav
145 - Masahiro Yamada
146 - Wei Yongjun
147 - Lv Zheng
diff --git a/MAINTAINERS b/MAINTAINERS
index adbf69306e9e..ff987d898609 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9230,7 +9230,6 @@ F: include/linux/isicom.h
9230MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER 9230MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
9231M: Bin Liu <b-liu@ti.com> 9231M: Bin Liu <b-liu@ti.com>
9232L: linux-usb@vger.kernel.org 9232L: linux-usb@vger.kernel.org
9233T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
9234S: Maintained 9233S: Maintained
9235F: drivers/usb/musb/ 9234F: drivers/usb/musb/
9236 9235
@@ -10577,6 +10576,8 @@ M: Peter Zijlstra <peterz@infradead.org>
10577M: Ingo Molnar <mingo@redhat.com> 10576M: Ingo Molnar <mingo@redhat.com>
10578M: Arnaldo Carvalho de Melo <acme@kernel.org> 10577M: Arnaldo Carvalho de Melo <acme@kernel.org>
10579R: Alexander Shishkin <alexander.shishkin@linux.intel.com> 10578R: Alexander Shishkin <alexander.shishkin@linux.intel.com>
10579R: Jiri Olsa <jolsa@redhat.com>
10580R: Namhyung Kim <namhyung@kernel.org>
10580L: linux-kernel@vger.kernel.org 10581L: linux-kernel@vger.kernel.org
10581T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core 10582T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
10582S: Supported 10583S: Supported
diff --git a/Makefile b/Makefile
index 46bfb0ed2257..01875d606f44 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 14 2PATCHLEVEL = 14
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Fearless Coyote 5NAME = Fearless Coyote
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 47d3a1ab08d2..817e5cfef83a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -131,7 +131,7 @@ endif
131KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm 131KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
132KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float 132KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
133 133
134CHECKFLAGS += -D__arm__ 134CHECKFLAGS += -D__arm__ -m32
135 135
136#Default value 136#Default value
137head-y := arch/arm/kernel/head$(MMUEXT).o 137head-y := arch/arm/kernel/head$(MMUEXT).o
diff --git a/arch/arm/boot/compressed/debug.S b/arch/arm/boot/compressed/debug.S
index 5392ee63338f..8f6e37177de1 100644
--- a/arch/arm/boot/compressed/debug.S
+++ b/arch/arm/boot/compressed/debug.S
@@ -23,7 +23,11 @@ ENTRY(putc)
23 strb r0, [r1] 23 strb r0, [r1]
24 mov r0, #0x03 @ SYS_WRITEC 24 mov r0, #0x03 @ SYS_WRITEC
25 ARM( svc #0x123456 ) 25 ARM( svc #0x123456 )
26#ifdef CONFIG_CPU_V7M
27 THUMB( bkpt #0xab )
28#else
26 THUMB( svc #0xab ) 29 THUMB( svc #0xab )
30#endif
27 mov pc, lr 31 mov pc, lr
28 .align 2 32 .align 2
291: .word _GLOBAL_OFFSET_TABLE_ - . 331: .word _GLOBAL_OFFSET_TABLE_ - .
diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi
index 7ff0811e61db..4960722aab32 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -178,7 +178,7 @@
178 }; 178 };
179 179
180 i2c0: i2c@11000 { 180 i2c0: i2c@11000 {
181 compatible = "marvell,mv64xxx-i2c"; 181 compatible = "marvell,mv78230-a0-i2c", "marvell,mv64xxx-i2c";
182 reg = <0x11000 0x20>; 182 reg = <0x11000 0x20>;
183 #address-cells = <1>; 183 #address-cells = <1>;
184 #size-cells = <0>; 184 #size-cells = <0>;
@@ -189,7 +189,7 @@
189 }; 189 };
190 190
191 i2c1: i2c@11100 { 191 i2c1: i2c@11100 {
192 compatible = "marvell,mv64xxx-i2c"; 192 compatible = "marvell,mv78230-a0-i2c", "marvell,mv64xxx-i2c";
193 reg = <0x11100 0x20>; 193 reg = <0x11100 0x20>;
194 #address-cells = <1>; 194 #address-cells = <1>;
195 #size-cells = <0>; 195 #size-cells = <0>;
diff --git a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
index 63a5af898165..cf0087b4c9e1 100644
--- a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
@@ -67,8 +67,8 @@
67 pinctrl-0 = <&pinctrl_macb0_default>; 67 pinctrl-0 = <&pinctrl_macb0_default>;
68 phy-mode = "rmii"; 68 phy-mode = "rmii";
69 69
70 ethernet-phy@1 { 70 ethernet-phy@0 {
71 reg = <0x1>; 71 reg = <0x0>;
72 interrupt-parent = <&pioA>; 72 interrupt-parent = <&pioA>;
73 interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>; 73 interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>;
74 pinctrl-names = "default"; 74 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index c7e9ccf2bc87..cbc26001247b 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -309,7 +309,7 @@
309 vddana-supply = <&vdd_3v3_lp_reg>; 309 vddana-supply = <&vdd_3v3_lp_reg>;
310 vref-supply = <&vdd_3v3_lp_reg>; 310 vref-supply = <&vdd_3v3_lp_reg>;
311 pinctrl-names = "default"; 311 pinctrl-names = "default";
312 pinctrl-0 = <&pinctrl_adc_default>; 312 pinctrl-0 = <&pinctrl_adc_default &pinctrl_adtrg_default>;
313 status = "okay"; 313 status = "okay";
314 }; 314 };
315 315
@@ -340,6 +340,20 @@
340 bias-disable; 340 bias-disable;
341 }; 341 };
342 342
343 /*
344 * The ADTRG pin can work on any edge type.
345 * In here it's being pulled up, so need to
346 * connect it to ground to get an edge e.g.
347 * Trigger can be configured on falling, rise
348 * or any edge, and the pull-up can be changed
349 * to pull-down or left floating according to
350 * needs.
351 */
352 pinctrl_adtrg_default: adtrg_default {
353 pinmux = <PIN_PD31__ADTRG>;
354 bias-pull-up;
355 };
356
343 pinctrl_charger_chglev: charger_chglev { 357 pinctrl_charger_chglev: charger_chglev {
344 pinmux = <PIN_PA12__GPIO>; 358 pinmux = <PIN_PA12__GPIO>;
345 bias-disable; 359 bias-disable;
diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
index 82651c3eb682..b8565fc33eea 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
@@ -18,12 +18,9 @@
18 compatible = "raspberrypi,model-zero-w", "brcm,bcm2835"; 18 compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
19 model = "Raspberry Pi Zero W"; 19 model = "Raspberry Pi Zero W";
20 20
21 /* Needed by firmware to properly init UARTs */ 21 chosen {
22 aliases { 22 /* 8250 auxiliary UART instead of pl011 */
23 uart0 = "/soc/serial@7e201000"; 23 stdout-path = "serial1:115200n8";
24 uart1 = "/soc/serial@7e215040";
25 serial0 = "/soc/serial@7e201000";
26 serial1 = "/soc/serial@7e215040";
27 }; 24 };
28 25
29 leds { 26 leds {
diff --git a/arch/arm/boot/dts/bcm2837-rpi-3-b.dts b/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
index 20725ca487f3..c71a0d73d2a2 100644
--- a/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
+++ b/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
@@ -8,6 +8,11 @@
8 compatible = "raspberrypi,3-model-b", "brcm,bcm2837"; 8 compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
9 model = "Raspberry Pi 3 Model B"; 9 model = "Raspberry Pi 3 Model B";
10 10
11 chosen {
12 /* 8250 auxiliary UART instead of pl011 */
13 stdout-path = "serial1:115200n8";
14 };
15
11 memory { 16 memory {
12 reg = <0 0x40000000>; 17 reg = <0 0x40000000>;
13 }; 18 };
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index 431dcfc900c0..013431e3d7c3 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -20,8 +20,13 @@
20 #address-cells = <1>; 20 #address-cells = <1>;
21 #size-cells = <1>; 21 #size-cells = <1>;
22 22
23 aliases {
24 serial0 = &uart0;
25 serial1 = &uart1;
26 };
27
23 chosen { 28 chosen {
24 bootargs = "earlyprintk console=ttyAMA0"; 29 stdout-path = "serial0:115200n8";
25 }; 30 };
26 31
27 thermal-zones { 32 thermal-zones {
diff --git a/arch/arm/boot/dts/gemini.dtsi b/arch/arm/boot/dts/gemini.dtsi
index c68e8d430234..f0d178c77153 100644
--- a/arch/arm/boot/dts/gemini.dtsi
+++ b/arch/arm/boot/dts/gemini.dtsi
@@ -145,11 +145,12 @@
145 }; 145 };
146 146
147 watchdog@41000000 { 147 watchdog@41000000 {
148 compatible = "cortina,gemini-watchdog"; 148 compatible = "cortina,gemini-watchdog", "faraday,ftwdt010";
149 reg = <0x41000000 0x1000>; 149 reg = <0x41000000 0x1000>;
150 interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; 150 interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
151 resets = <&syscon GEMINI_RESET_WDOG>; 151 resets = <&syscon GEMINI_RESET_WDOG>;
152 clocks = <&syscon GEMINI_CLK_APB>; 152 clocks = <&syscon GEMINI_CLK_APB>;
153 clock-names = "PCLK";
153 }; 154 };
154 155
155 uart0: serial@42000000 { 156 uart0: serial@42000000 {
diff --git a/arch/arm/boot/dts/imx7d.dtsi b/arch/arm/boot/dts/imx7d.dtsi
index f46814a7ea44..4d308d17f040 100644
--- a/arch/arm/boot/dts/imx7d.dtsi
+++ b/arch/arm/boot/dts/imx7d.dtsi
@@ -144,10 +144,10 @@
144 interrupt-names = "msi"; 144 interrupt-names = "msi";
145 #interrupt-cells = <1>; 145 #interrupt-cells = <1>;
146 interrupt-map-mask = <0 0 0 0x7>; 146 interrupt-map-mask = <0 0 0 0x7>;
147 interrupt-map = <0 0 0 1 &intc GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>, 147 interrupt-map = <0 0 0 1 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
148 <0 0 0 2 &intc GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>, 148 <0 0 0 2 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
149 <0 0 0 3 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>, 149 <0 0 0 3 &intc GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>,
150 <0 0 0 4 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>; 150 <0 0 0 4 &intc GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
151 clocks = <&clks IMX7D_PCIE_CTRL_ROOT_CLK>, 151 clocks = <&clks IMX7D_PCIE_CTRL_ROOT_CLK>,
152 <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>, 152 <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>,
153 <&clks IMX7D_PCIE_PHY_ROOT_CLK>; 153 <&clks IMX7D_PCIE_PHY_ROOT_CLK>;
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index 1f4c795d3f72..da7b3237bfe9 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -87,9 +87,10 @@
87 }; 87 };
88 88
89 watchdog: watchdog@98500000 { 89 watchdog: watchdog@98500000 {
90 compatible = "moxa,moxart-watchdog"; 90 compatible = "moxa,moxart-watchdog", "faraday,ftwdt010";
91 reg = <0x98500000 0x10>; 91 reg = <0x98500000 0x10>;
92 clocks = <&clk_apb>; 92 clocks = <&clk_apb>;
93 clock-names = "PCLK";
93 }; 94 };
94 95
95 sdhci: sdhci@98e00000 { 96 sdhci: sdhci@98e00000 {
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 38d2216c7ead..b1a26b42d190 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -1430,6 +1430,7 @@
1430 atmel,min-sample-rate-hz = <200000>; 1430 atmel,min-sample-rate-hz = <200000>;
1431 atmel,max-sample-rate-hz = <20000000>; 1431 atmel,max-sample-rate-hz = <20000000>;
1432 atmel,startup-time-ms = <4>; 1432 atmel,startup-time-ms = <4>;
1433 atmel,trigger-edge-type = <IRQ_TYPE_EDGE_RISING>;
1433 status = "disabled"; 1434 status = "disabled";
1434 }; 1435 };
1435 1436
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index b147cb0dc14b..eef072a21acc 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -311,8 +311,8 @@
311 #size-cells = <0>; 311 #size-cells = <0>;
312 reg = <0>; 312 reg = <0>;
313 313
314 tcon1_in_drc1: endpoint@0 { 314 tcon1_in_drc1: endpoint@1 {
315 reg = <0>; 315 reg = <1>;
316 remote-endpoint = <&drc1_out_tcon1>; 316 remote-endpoint = <&drc1_out_tcon1>;
317 }; 317 };
318 }; 318 };
@@ -1012,8 +1012,8 @@
1012 #size-cells = <0>; 1012 #size-cells = <0>;
1013 reg = <1>; 1013 reg = <1>;
1014 1014
1015 be1_out_drc1: endpoint@0 { 1015 be1_out_drc1: endpoint@1 {
1016 reg = <0>; 1016 reg = <1>;
1017 remote-endpoint = <&drc1_in_be1>; 1017 remote-endpoint = <&drc1_in_be1>;
1018 }; 1018 };
1019 }; 1019 };
@@ -1042,8 +1042,8 @@
1042 #size-cells = <0>; 1042 #size-cells = <0>;
1043 reg = <0>; 1043 reg = <0>;
1044 1044
1045 drc1_in_be1: endpoint@0 { 1045 drc1_in_be1: endpoint@1 {
1046 reg = <0>; 1046 reg = <1>;
1047 remote-endpoint = <&be1_out_drc1>; 1047 remote-endpoint = <&be1_out_drc1>;
1048 }; 1048 };
1049 }; 1049 };
@@ -1053,8 +1053,8 @@
1053 #size-cells = <0>; 1053 #size-cells = <0>;
1054 reg = <1>; 1054 reg = <1>;
1055 1055
1056 drc1_out_tcon1: endpoint@0 { 1056 drc1_out_tcon1: endpoint@1 {
1057 reg = <0>; 1057 reg = <1>;
1058 remote-endpoint = <&tcon1_in_drc1>; 1058 remote-endpoint = <&tcon1_in_drc1>;
1059 }; 1059 };
1060 }; 1060 };
diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig
index d5e1370ec303..830e817a028a 100644
--- a/arch/arm/configs/pxa_defconfig
+++ b/arch/arm/configs/pxa_defconfig
@@ -219,7 +219,8 @@ CONFIG_AD525X_DPOT_I2C=m
219CONFIG_ICS932S401=m 219CONFIG_ICS932S401=m
220CONFIG_APDS9802ALS=m 220CONFIG_APDS9802ALS=m
221CONFIG_ISL29003=m 221CONFIG_ISL29003=m
222CONFIG_TI_DAC7512=m 222CONFIG_IIO=m
223CONFIG_AD5446=m
223CONFIG_EEPROM_AT24=m 224CONFIG_EEPROM_AT24=m
224CONFIG_SENSORS_LIS3_SPI=m 225CONFIG_SENSORS_LIS3_SPI=m
225CONFIG_IDE=m 226CONFIG_IDE=m
diff --git a/arch/arm/configs/raumfeld_defconfig b/arch/arm/configs/raumfeld_defconfig
index e3dc80ead465..77a56c23c6ef 100644
--- a/arch/arm/configs/raumfeld_defconfig
+++ b/arch/arm/configs/raumfeld_defconfig
@@ -37,7 +37,8 @@ CONFIG_MTD_NAND_PXA3xx=y
37CONFIG_MTD_UBI=y 37CONFIG_MTD_UBI=y
38CONFIG_BLK_DEV_LOOP=y 38CONFIG_BLK_DEV_LOOP=y
39CONFIG_ISL29003=y 39CONFIG_ISL29003=y
40CONFIG_TI_DAC7512=y 40CONFIG_IIO=y
41CONFIG_AD5446=y
41CONFIG_SCSI=y 42CONFIG_SCSI=y
42CONFIG_BLK_DEV_SD=y 43CONFIG_BLK_DEV_SD=y
43CONFIG_CHR_DEV_SG=y 44CONFIG_CHR_DEV_SG=y
diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
index ea9646cc2a0e..0a498cb3fad8 100644
--- a/arch/arm/kernel/debug.S
+++ b/arch/arm/kernel/debug.S
@@ -115,7 +115,11 @@ ENTRY(printascii)
115 mov r1, r0 115 mov r1, r0
116 mov r0, #0x04 @ SYS_WRITE0 116 mov r0, #0x04 @ SYS_WRITE0
117 ARM( svc #0x123456 ) 117 ARM( svc #0x123456 )
118#ifdef CONFIG_CPU_V7M
119 THUMB( bkpt #0xab )
120#else
118 THUMB( svc #0xab ) 121 THUMB( svc #0xab )
122#endif
119 ret lr 123 ret lr
120ENDPROC(printascii) 124ENDPROC(printascii)
121 125
@@ -124,7 +128,11 @@ ENTRY(printch)
124 strb r0, [r1] 128 strb r0, [r1]
125 mov r0, #0x03 @ SYS_WRITEC 129 mov r0, #0x03 @ SYS_WRITEC
126 ARM( svc #0x123456 ) 130 ARM( svc #0x123456 )
131#ifdef CONFIG_CPU_V7M
132 THUMB( bkpt #0xab )
133#else
127 THUMB( svc #0xab ) 134 THUMB( svc #0xab )
135#endif
128 ret lr 136 ret lr
129ENDPROC(printch) 137ENDPROC(printch)
130 138
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 71a34e8c345a..57058ac46f49 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -32,6 +32,7 @@
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33 33
34#include "db8500-regs.h" 34#include "db8500-regs.h"
35#include "pm_domains.h"
35 36
36static int __init ux500_l2x0_unlock(void) 37static int __init ux500_l2x0_unlock(void)
37{ 38{
@@ -157,6 +158,9 @@ static const struct of_device_id u8500_local_bus_nodes[] = {
157 158
158static void __init u8500_init_machine(void) 159static void __init u8500_init_machine(void)
159{ 160{
161 /* Initialize ux500 power domains */
162 ux500_pm_domains_init();
163
160 /* automatically probe child nodes of dbx5x0 devices */ 164 /* automatically probe child nodes of dbx5x0 devices */
161 if (of_machine_is_compatible("st-ericsson,u8540")) 165 if (of_machine_is_compatible("st-ericsson,u8540"))
162 of_platform_populate(NULL, u8500_local_bus_nodes, 166 of_platform_populate(NULL, u8500_local_bus_nodes,
diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
index a970e7fcba9e..f6c33a0c1c61 100644
--- a/arch/arm/mach-ux500/pm.c
+++ b/arch/arm/mach-ux500/pm.c
@@ -19,7 +19,6 @@
19#include <linux/of_address.h> 19#include <linux/of_address.h>
20 20
21#include "db8500-regs.h" 21#include "db8500-regs.h"
22#include "pm_domains.h"
23 22
24/* ARM WFI Standby signal register */ 23/* ARM WFI Standby signal register */
25#define PRCM_ARM_WFI_STANDBY (prcmu_base + 0x130) 24#define PRCM_ARM_WFI_STANDBY (prcmu_base + 0x130)
@@ -203,7 +202,4 @@ void __init ux500_pm_init(u32 phy_base, u32 size)
203 202
204 /* Set up ux500 suspend callbacks. */ 203 /* Set up ux500 suspend callbacks. */
205 suspend_set_ops(UX500_SUSPEND_OPS); 204 suspend_set_ops(UX500_SUSPEND_OPS);
206
207 /* Initialize ux500 power domains */
208 ux500_pm_domains_init();
209} 205}
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 3b8e728cc944..91537d90f5f5 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -344,6 +344,11 @@ void __init arm_mm_memblock_reserve(void)
344 * reserved here. 344 * reserved here.
345 */ 345 */
346#endif 346#endif
347 /*
348 * In any case, always ensure address 0 is never used as many things
349 * get very confused if 0 is returned as a legitimate address.
350 */
351 memblock_reserve(0, 1);
347} 352}
348 353
349void __init adjust_lowmem_bounds(void) 354void __init adjust_lowmem_bounds(void)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
index caf8b6fbe5e3..d06e34b5d192 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
@@ -61,13 +61,6 @@
61 chosen { 61 chosen {
62 stdout-path = "serial0:115200n8"; 62 stdout-path = "serial0:115200n8";
63 }; 63 };
64
65 reg_vcc3v3: vcc3v3 {
66 compatible = "regulator-fixed";
67 regulator-name = "vcc3v3";
68 regulator-min-microvolt = <3300000>;
69 regulator-max-microvolt = <3300000>;
70 };
71}; 64};
72 65
73&ehci0 { 66&ehci0 {
@@ -91,7 +84,7 @@
91&mmc0 { 84&mmc0 {
92 pinctrl-names = "default"; 85 pinctrl-names = "default";
93 pinctrl-0 = <&mmc0_pins>; 86 pinctrl-0 = <&mmc0_pins>;
94 vmmc-supply = <&reg_vcc3v3>; 87 vmmc-supply = <&reg_dcdc1>;
95 cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; 88 cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
96 cd-inverted; 89 cd-inverted;
97 disable-wp; 90 disable-wp;
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
index 8263a8a504a8..f2aa2a81de4d 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
@@ -336,7 +336,7 @@
336 /* non-prefetchable memory */ 336 /* non-prefetchable memory */
337 0x82000000 0 0xf6000000 0 0xf6000000 0 0xf00000>; 337 0x82000000 0 0xf6000000 0 0xf6000000 0 0xf00000>;
338 interrupt-map-mask = <0 0 0 0>; 338 interrupt-map-mask = <0 0 0 0>;
339 interrupt-map = <0 0 0 0 &cpm_icu 0 ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>; 339 interrupt-map = <0 0 0 0 &cpm_icu ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>;
340 interrupts = <ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>; 340 interrupts = <ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>;
341 num-lanes = <1>; 341 num-lanes = <1>;
342 clocks = <&cpm_clk 1 13>; 342 clocks = <&cpm_clk 1 13>;
@@ -362,7 +362,7 @@
362 /* non-prefetchable memory */ 362 /* non-prefetchable memory */
363 0x82000000 0 0xf7000000 0 0xf7000000 0 0xf00000>; 363 0x82000000 0 0xf7000000 0 0xf7000000 0 0xf00000>;
364 interrupt-map-mask = <0 0 0 0>; 364 interrupt-map-mask = <0 0 0 0>;
365 interrupt-map = <0 0 0 0 &cpm_icu 0 ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>; 365 interrupt-map = <0 0 0 0 &cpm_icu ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>;
366 interrupts = <ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>; 366 interrupts = <ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>;
367 367
368 num-lanes = <1>; 368 num-lanes = <1>;
@@ -389,7 +389,7 @@
389 /* non-prefetchable memory */ 389 /* non-prefetchable memory */
390 0x82000000 0 0xf8000000 0 0xf8000000 0 0xf00000>; 390 0x82000000 0 0xf8000000 0 0xf8000000 0 0xf00000>;
391 interrupt-map-mask = <0 0 0 0>; 391 interrupt-map-mask = <0 0 0 0>;
392 interrupt-map = <0 0 0 0 &cpm_icu 0 ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>; 392 interrupt-map = <0 0 0 0 &cpm_icu ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>;
393 interrupts = <ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>; 393 interrupts = <ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>;
394 394
395 num-lanes = <1>; 395 num-lanes = <1>;
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
index b71ee6c83668..4fe70323abb3 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
@@ -335,7 +335,7 @@
335 /* non-prefetchable memory */ 335 /* non-prefetchable memory */
336 0x82000000 0 0xfa000000 0 0xfa000000 0 0xf00000>; 336 0x82000000 0 0xfa000000 0 0xfa000000 0 0xf00000>;
337 interrupt-map-mask = <0 0 0 0>; 337 interrupt-map-mask = <0 0 0 0>;
338 interrupt-map = <0 0 0 0 &cps_icu 0 ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>; 338 interrupt-map = <0 0 0 0 &cps_icu ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>;
339 interrupts = <ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>; 339 interrupts = <ICU_GRP_NSR 22 IRQ_TYPE_LEVEL_HIGH>;
340 num-lanes = <1>; 340 num-lanes = <1>;
341 clocks = <&cps_clk 1 13>; 341 clocks = <&cps_clk 1 13>;
@@ -361,7 +361,7 @@
361 /* non-prefetchable memory */ 361 /* non-prefetchable memory */
362 0x82000000 0 0xfb000000 0 0xfb000000 0 0xf00000>; 362 0x82000000 0 0xfb000000 0 0xfb000000 0 0xf00000>;
363 interrupt-map-mask = <0 0 0 0>; 363 interrupt-map-mask = <0 0 0 0>;
364 interrupt-map = <0 0 0 0 &cps_icu 0 ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>; 364 interrupt-map = <0 0 0 0 &cps_icu ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>;
365 interrupts = <ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>; 365 interrupts = <ICU_GRP_NSR 24 IRQ_TYPE_LEVEL_HIGH>;
366 366
367 num-lanes = <1>; 367 num-lanes = <1>;
@@ -388,7 +388,7 @@
388 /* non-prefetchable memory */ 388 /* non-prefetchable memory */
389 0x82000000 0 0xfc000000 0 0xfc000000 0 0xf00000>; 389 0x82000000 0 0xfc000000 0 0xfc000000 0 0xf00000>;
390 interrupt-map-mask = <0 0 0 0>; 390 interrupt-map-mask = <0 0 0 0>;
391 interrupt-map = <0 0 0 0 &cps_icu 0 ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>; 391 interrupt-map = <0 0 0 0 &cps_icu ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>;
392 interrupts = <ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>; 392 interrupts = <ICU_GRP_NSR 23 IRQ_TYPE_LEVEL_HIGH>;
393 393
394 num-lanes = <1>; 394 num-lanes = <1>;
diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
index 4786c67b5e65..d9d885006a8e 100644
--- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi
+++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
@@ -62,6 +62,7 @@
62 brightness-levels = <256 128 64 16 8 4 0>; 62 brightness-levels = <256 128 64 16 8 4 0>;
63 default-brightness-level = <6>; 63 default-brightness-level = <6>;
64 64
65 power-supply = <&reg_12v>;
65 enable-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>; 66 enable-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
66 }; 67 };
67 68
@@ -83,6 +84,15 @@
83 regulator-always-on; 84 regulator-always-on;
84 }; 85 };
85 86
87 reg_12v: regulator2 {
88 compatible = "regulator-fixed";
89 regulator-name = "fixed-12V";
90 regulator-min-microvolt = <12000000>;
91 regulator-max-microvolt = <12000000>;
92 regulator-boot-on;
93 regulator-always-on;
94 };
95
86 rsnd_ak4613: sound { 96 rsnd_ak4613: sound {
87 compatible = "simple-audio-card"; 97 compatible = "simple-audio-card";
88 98
diff --git a/arch/arm64/boot/dts/rockchip/rk3328.dtsi b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
index 6d615cb6e64d..41d61840fb99 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
@@ -582,7 +582,7 @@
582 vop_mmu: iommu@ff373f00 { 582 vop_mmu: iommu@ff373f00 {
583 compatible = "rockchip,iommu"; 583 compatible = "rockchip,iommu";
584 reg = <0x0 0xff373f00 0x0 0x100>; 584 reg = <0x0 0xff373f00 0x0 0x100>;
585 interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH 0>; 585 interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
586 interrupt-names = "vop_mmu"; 586 interrupt-names = "vop_mmu";
587 #iommu-cells = <0>; 587 #iommu-cells = <0>;
588 status = "disabled"; 588 status = "disabled";
diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index 19fbaa5e7bdd..1070c8264c13 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -740,7 +740,7 @@
740 iep_mmu: iommu@ff900800 { 740 iep_mmu: iommu@ff900800 {
741 compatible = "rockchip,iommu"; 741 compatible = "rockchip,iommu";
742 reg = <0x0 0xff900800 0x0 0x100>; 742 reg = <0x0 0xff900800 0x0 0x100>;
743 interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH 0>; 743 interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
744 interrupt-names = "iep_mmu"; 744 interrupt-names = "iep_mmu";
745 #iommu-cells = <0>; 745 #iommu-cells = <0>;
746 status = "disabled"; 746 status = "disabled";
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
index 7fd4bfcaa38e..fef82274a39d 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
@@ -371,10 +371,10 @@
371 regulator-always-on; 371 regulator-always-on;
372 regulator-boot-on; 372 regulator-boot-on;
373 regulator-min-microvolt = <1800000>; 373 regulator-min-microvolt = <1800000>;
374 regulator-max-microvolt = <3300000>; 374 regulator-max-microvolt = <3000000>;
375 regulator-state-mem { 375 regulator-state-mem {
376 regulator-on-in-suspend; 376 regulator-on-in-suspend;
377 regulator-suspend-microvolt = <3300000>; 377 regulator-suspend-microvolt = <3000000>;
378 }; 378 };
379 }; 379 };
380 380
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
index 53ff3d191a1d..910628d18add 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
@@ -325,12 +325,12 @@
325 vcc_sd: LDO_REG4 { 325 vcc_sd: LDO_REG4 {
326 regulator-name = "vcc_sd"; 326 regulator-name = "vcc_sd";
327 regulator-min-microvolt = <1800000>; 327 regulator-min-microvolt = <1800000>;
328 regulator-max-microvolt = <3300000>; 328 regulator-max-microvolt = <3000000>;
329 regulator-always-on; 329 regulator-always-on;
330 regulator-boot-on; 330 regulator-boot-on;
331 regulator-state-mem { 331 regulator-state-mem {
332 regulator-on-in-suspend; 332 regulator-on-in-suspend;
333 regulator-suspend-microvolt = <3300000>; 333 regulator-suspend-microvolt = <3000000>;
334 }; 334 };
335 }; 335 };
336 336
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi
index 6c30bb02210d..0f873c897d0d 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi
@@ -315,10 +315,10 @@
315 regulator-always-on; 315 regulator-always-on;
316 regulator-boot-on; 316 regulator-boot-on;
317 regulator-min-microvolt = <1800000>; 317 regulator-min-microvolt = <1800000>;
318 regulator-max-microvolt = <3300000>; 318 regulator-max-microvolt = <3000000>;
319 regulator-state-mem { 319 regulator-state-mem {
320 regulator-on-in-suspend; 320 regulator-on-in-suspend;
321 regulator-suspend-microvolt = <3300000>; 321 regulator-suspend-microvolt = <3000000>;
322 }; 322 };
323 }; 323 };
324 324
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
index c6d6272a934f..7baa2265d439 100644
--- a/arch/parisc/kernel/parisc_ksyms.c
+++ b/arch/parisc/kernel/parisc_ksyms.c
@@ -35,12 +35,12 @@ EXPORT_SYMBOL(memset);
35EXPORT_SYMBOL(__xchg8); 35EXPORT_SYMBOL(__xchg8);
36EXPORT_SYMBOL(__xchg32); 36EXPORT_SYMBOL(__xchg32);
37EXPORT_SYMBOL(__cmpxchg_u32); 37EXPORT_SYMBOL(__cmpxchg_u32);
38EXPORT_SYMBOL(__cmpxchg_u64);
38#ifdef CONFIG_SMP 39#ifdef CONFIG_SMP
39EXPORT_SYMBOL(__atomic_hash); 40EXPORT_SYMBOL(__atomic_hash);
40#endif 41#endif
41#ifdef CONFIG_64BIT 42#ifdef CONFIG_64BIT
42EXPORT_SYMBOL(__xchg64); 43EXPORT_SYMBOL(__xchg64);
43EXPORT_SYMBOL(__cmpxchg_u64);
44#endif 44#endif
45 45
46#include <linux/uaccess.h> 46#include <linux/uaccess.h>
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 23de307c3052..41e60a9c7db2 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -742,7 +742,7 @@ lws_compare_and_swap_2:
74210: ldd 0(%r25), %r25 74210: ldd 0(%r25), %r25
74311: ldd 0(%r24), %r24 74311: ldd 0(%r24), %r24
744#else 744#else
745 /* Load new value into r22/r23 - high/low */ 745 /* Load old value into r22/r23 - high/low */
74610: ldw 0(%r25), %r22 74610: ldw 0(%r25), %r22
74711: ldw 4(%r25), %r23 74711: ldw 4(%r25), %r23
748 /* Load new value into fr4 for atomic store later */ 748 /* Load new value into fr4 for atomic store later */
@@ -834,11 +834,11 @@ cas2_action:
834 copy %r0, %r28 834 copy %r0, %r28
835#else 835#else
836 /* Compare first word */ 836 /* Compare first word */
83719: ldw,ma 0(%r26), %r29 83719: ldw 0(%r26), %r29
838 sub,= %r29, %r22, %r0 838 sub,= %r29, %r22, %r0
839 b,n cas2_end 839 b,n cas2_end
840 /* Compare second word */ 840 /* Compare second word */
84120: ldw,ma 4(%r26), %r29 84120: ldw 4(%r26), %r29
842 sub,= %r29, %r23, %r0 842 sub,= %r29, %r23, %r0
843 b,n cas2_end 843 b,n cas2_end
844 /* Perform the store */ 844 /* Perform the store */
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 2d956aa0a38a..8c0105a49839 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -253,7 +253,10 @@ static int __init init_cr16_clocksource(void)
253 cpu0_loc = per_cpu(cpu_data, 0).cpu_loc; 253 cpu0_loc = per_cpu(cpu_data, 0).cpu_loc;
254 254
255 for_each_online_cpu(cpu) { 255 for_each_online_cpu(cpu) {
256 if (cpu0_loc == per_cpu(cpu_data, cpu).cpu_loc) 256 if (cpu == 0)
257 continue;
258 if ((cpu0_loc != 0) &&
259 (cpu0_loc == per_cpu(cpu_data, cpu).cpu_loc))
257 continue; 260 continue;
258 261
259 clocksource_cr16.name = "cr16_unstable"; 262 clocksource_cr16.name = "cr16_unstable";
diff --git a/arch/s390/configs/zfcpdump_defconfig b/arch/s390/configs/zfcpdump_defconfig
index afa46a7406ea..04e042edbab7 100644
--- a/arch/s390/configs/zfcpdump_defconfig
+++ b/arch/s390/configs/zfcpdump_defconfig
@@ -27,6 +27,7 @@ CONFIG_NET=y
27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
28CONFIG_DEVTMPFS=y 28CONFIG_DEVTMPFS=y
29# CONFIG_FIRMWARE_IN_KERNEL is not set 29# CONFIG_FIRMWARE_IN_KERNEL is not set
30CONFIG_BLK_DEV_RAM=y
30# CONFIG_BLK_DEV_XPRAM is not set 31# CONFIG_BLK_DEV_XPRAM is not set
31# CONFIG_DCSSBLK is not set 32# CONFIG_DCSSBLK is not set
32# CONFIG_DASD is not set 33# CONFIG_DASD is not set
@@ -59,6 +60,7 @@ CONFIG_CONFIGFS_FS=y
59# CONFIG_NETWORK_FILESYSTEMS is not set 60# CONFIG_NETWORK_FILESYSTEMS is not set
60CONFIG_PRINTK_TIME=y 61CONFIG_PRINTK_TIME=y
61CONFIG_DEBUG_INFO=y 62CONFIG_DEBUG_INFO=y
63CONFIG_DEBUG_FS=y
62CONFIG_DEBUG_KERNEL=y 64CONFIG_DEBUG_KERNEL=y
63CONFIG_PANIC_ON_OOPS=y 65CONFIG_PANIC_ON_OOPS=y
64# CONFIG_SCHED_DEBUG is not set 66# CONFIG_SCHED_DEBUG is not set
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 1cee6753d47a..495ff6959dec 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -293,7 +293,10 @@ static void pcpu_attach_task(struct pcpu *pcpu, struct task_struct *tsk)
293 lc->lpp = LPP_MAGIC; 293 lc->lpp = LPP_MAGIC;
294 lc->current_pid = tsk->pid; 294 lc->current_pid = tsk->pid;
295 lc->user_timer = tsk->thread.user_timer; 295 lc->user_timer = tsk->thread.user_timer;
296 lc->guest_timer = tsk->thread.guest_timer;
296 lc->system_timer = tsk->thread.system_timer; 297 lc->system_timer = tsk->thread.system_timer;
298 lc->hardirq_timer = tsk->thread.hardirq_timer;
299 lc->softirq_timer = tsk->thread.softirq_timer;
297 lc->steal_timer = 0; 300 lc->steal_timer = 0;
298} 301}
299 302
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index c40a95c33bb8..322d25ae23ab 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -110,6 +110,10 @@ build_mmio_write(__writeq, "q", unsigned long, "r", )
110 110
111#endif 111#endif
112 112
113#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
114extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
115extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
116
113/** 117/**
114 * virt_to_phys - map virtual addresses to physical 118 * virt_to_phys - map virtual addresses to physical
115 * @address: address to remap 119 * @address: address to remap
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index d362161d3291..c4aed0de565e 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -82,12 +82,21 @@ static inline u64 inc_mm_tlb_gen(struct mm_struct *mm)
82#define __flush_tlb_single(addr) __native_flush_tlb_single(addr) 82#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
83#endif 83#endif
84 84
85/* 85static inline bool tlb_defer_switch_to_init_mm(void)
86 * If tlb_use_lazy_mode is true, then we try to avoid switching CR3 to point 86{
87 * to init_mm when we switch to a kernel thread (e.g. the idle thread). If 87 /*
88 * it's false, then we immediately switch CR3 when entering a kernel thread. 88 * If we have PCID, then switching to init_mm is reasonably
89 */ 89 * fast. If we don't have PCID, then switching to init_mm is
90DECLARE_STATIC_KEY_TRUE(tlb_use_lazy_mode); 90 * quite slow, so we try to defer it in the hopes that we can
91 * avoid it entirely. The latter approach runs the risk of
92 * receiving otherwise unnecessary IPIs.
93 *
94 * This choice is just a heuristic. The tlb code can handle this
95 * function returning true or false regardless of whether we have
96 * PCID.
97 */
98 return !static_cpu_has(X86_FEATURE_PCID);
99}
91 100
92/* 101/*
93 * 6 because 6 should be plenty and struct tlb_state will fit in 102 * 6 because 6 should be plenty and struct tlb_state will fit in
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 24f749324c0f..9990a71e311f 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -831,7 +831,6 @@ static int __cache_amd_cpumap_setup(unsigned int cpu, int index,
831 } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { 831 } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
832 unsigned int apicid, nshared, first, last; 832 unsigned int apicid, nshared, first, last;
833 833
834 this_leaf = this_cpu_ci->info_list + index;
835 nshared = base->eax.split.num_threads_sharing + 1; 834 nshared = base->eax.split.num_threads_sharing + 1;
836 apicid = cpu_data(cpu).apicid; 835 apicid = cpu_data(cpu).apicid;
837 first = apicid - (apicid % nshared); 836 first = apicid - (apicid % nshared);
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 8f7a9bbad514..7dbcb7adf797 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -34,6 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35 35
36#include <asm/microcode_intel.h> 36#include <asm/microcode_intel.h>
37#include <asm/intel-family.h>
37#include <asm/processor.h> 38#include <asm/processor.h>
38#include <asm/tlbflush.h> 39#include <asm/tlbflush.h>
39#include <asm/setup.h> 40#include <asm/setup.h>
@@ -918,6 +919,18 @@ static int get_ucode_fw(void *to, const void *from, size_t n)
918 return 0; 919 return 0;
919} 920}
920 921
922static bool is_blacklisted(unsigned int cpu)
923{
924 struct cpuinfo_x86 *c = &cpu_data(cpu);
925
926 if (c->x86 == 6 && c->x86_model == INTEL_FAM6_BROADWELL_X) {
927 pr_err_once("late loading on model 79 is disabled.\n");
928 return true;
929 }
930
931 return false;
932}
933
921static enum ucode_state request_microcode_fw(int cpu, struct device *device, 934static enum ucode_state request_microcode_fw(int cpu, struct device *device,
922 bool refresh_fw) 935 bool refresh_fw)
923{ 936{
@@ -926,6 +939,9 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
926 const struct firmware *firmware; 939 const struct firmware *firmware;
927 enum ucode_state ret; 940 enum ucode_state ret;
928 941
942 if (is_blacklisted(cpu))
943 return UCODE_NFOUND;
944
929 sprintf(name, "intel-ucode/%02x-%02x-%02x", 945 sprintf(name, "intel-ucode/%02x-%02x-%02x",
930 c->x86, c->x86_model, c->x86_mask); 946 c->x86, c->x86_model, c->x86_mask);
931 947
@@ -950,6 +966,9 @@ static int get_ucode_user(void *to, const void *from, size_t n)
950static enum ucode_state 966static enum ucode_state
951request_microcode_user(int cpu, const void __user *buf, size_t size) 967request_microcode_user(int cpu, const void __user *buf, size_t size)
952{ 968{
969 if (is_blacklisted(cpu))
970 return UCODE_NFOUND;
971
953 return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user); 972 return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
954} 973}
955 974
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index cf2ce063f65a..2902ca4d5993 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -30,10 +30,11 @@ static void __init i386_default_early_setup(void)
30 30
31asmlinkage __visible void __init i386_start_kernel(void) 31asmlinkage __visible void __init i386_start_kernel(void)
32{ 32{
33 cr4_init_shadow(); 33 /* Make sure IDT is set up before any exception happens */
34
35 idt_setup_early_handler(); 34 idt_setup_early_handler();
36 35
36 cr4_init_shadow();
37
37 sanitize_boot_params(&boot_params); 38 sanitize_boot_params(&boot_params);
38 39
39 x86_early_init_platform_quirks(); 40 x86_early_init_platform_quirks();
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index a99679826846..320c6237e1d1 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -174,3 +174,15 @@ const char *arch_vma_name(struct vm_area_struct *vma)
174 return "[mpx]"; 174 return "[mpx]";
175 return NULL; 175 return NULL;
176} 176}
177
178int valid_phys_addr_range(phys_addr_t addr, size_t count)
179{
180 return addr + count <= __pa(high_memory);
181}
182
183int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
184{
185 phys_addr_t addr = (phys_addr_t)pfn << PAGE_SHIFT;
186
187 return valid_phys_addr_range(addr, count);
188}
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 658bf0090565..0f3d0cea4d00 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -30,7 +30,6 @@
30 30
31atomic64_t last_mm_ctx_id = ATOMIC64_INIT(1); 31atomic64_t last_mm_ctx_id = ATOMIC64_INIT(1);
32 32
33DEFINE_STATIC_KEY_TRUE(tlb_use_lazy_mode);
34 33
35static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, 34static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen,
36 u16 *new_asid, bool *need_flush) 35 u16 *new_asid, bool *need_flush)
@@ -147,8 +146,8 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
147 this_cpu_write(cpu_tlbstate.is_lazy, false); 146 this_cpu_write(cpu_tlbstate.is_lazy, false);
148 147
149 if (real_prev == next) { 148 if (real_prev == next) {
150 VM_BUG_ON(this_cpu_read(cpu_tlbstate.ctxs[prev_asid].ctx_id) != 149 VM_WARN_ON(this_cpu_read(cpu_tlbstate.ctxs[prev_asid].ctx_id) !=
151 next->context.ctx_id); 150 next->context.ctx_id);
152 151
153 /* 152 /*
154 * We don't currently support having a real mm loaded without 153 * We don't currently support having a real mm loaded without
@@ -213,6 +212,9 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
213} 212}
214 213
215/* 214/*
215 * Please ignore the name of this function. It should be called
216 * switch_to_kernel_thread().
217 *
216 * enter_lazy_tlb() is a hint from the scheduler that we are entering a 218 * enter_lazy_tlb() is a hint from the scheduler that we are entering a
217 * kernel thread or other context without an mm. Acceptable implementations 219 * kernel thread or other context without an mm. Acceptable implementations
218 * include doing nothing whatsoever, switching to init_mm, or various clever 220 * include doing nothing whatsoever, switching to init_mm, or various clever
@@ -227,7 +229,7 @@ void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
227 if (this_cpu_read(cpu_tlbstate.loaded_mm) == &init_mm) 229 if (this_cpu_read(cpu_tlbstate.loaded_mm) == &init_mm)
228 return; 230 return;
229 231
230 if (static_branch_unlikely(&tlb_use_lazy_mode)) { 232 if (tlb_defer_switch_to_init_mm()) {
231 /* 233 /*
232 * There's a significant optimization that may be possible 234 * There's a significant optimization that may be possible
233 * here. We have accurate enough TLB flush tracking that we 235 * here. We have accurate enough TLB flush tracking that we
@@ -626,57 +628,3 @@ static int __init create_tlb_single_page_flush_ceiling(void)
626 return 0; 628 return 0;
627} 629}
628late_initcall(create_tlb_single_page_flush_ceiling); 630late_initcall(create_tlb_single_page_flush_ceiling);
629
630static ssize_t tlblazy_read_file(struct file *file, char __user *user_buf,
631 size_t count, loff_t *ppos)
632{
633 char buf[2];
634
635 buf[0] = static_branch_likely(&tlb_use_lazy_mode) ? '1' : '0';
636 buf[1] = '\n';
637
638 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
639}
640
641static ssize_t tlblazy_write_file(struct file *file,
642 const char __user *user_buf, size_t count, loff_t *ppos)
643{
644 bool val;
645
646 if (kstrtobool_from_user(user_buf, count, &val))
647 return -EINVAL;
648
649 if (val)
650 static_branch_enable(&tlb_use_lazy_mode);
651 else
652 static_branch_disable(&tlb_use_lazy_mode);
653
654 return count;
655}
656
657static const struct file_operations fops_tlblazy = {
658 .read = tlblazy_read_file,
659 .write = tlblazy_write_file,
660 .llseek = default_llseek,
661};
662
663static int __init init_tlb_use_lazy_mode(void)
664{
665 if (boot_cpu_has(X86_FEATURE_PCID)) {
666 /*
667 * Heuristic: with PCID on, switching to and from
668 * init_mm is reasonably fast, but remote flush IPIs
669 * as expensive as ever, so turn off lazy TLB mode.
670 *
671 * We can't do this in setup_pcid() because static keys
672 * haven't been initialized yet, and it would blow up
673 * badly.
674 */
675 static_branch_disable(&tlb_use_lazy_mode);
676 }
677
678 debugfs_create_file("tlb_use_lazy_mode", S_IRUSR | S_IWUSR,
679 arch_debugfs_dir, NULL, &fops_tlblazy);
680 return 0;
681}
682late_initcall(init_tlb_use_lazy_mode);
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index e4b0ed386bc8..39aecad286fe 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -57,6 +57,8 @@ struct key *find_asymmetric_key(struct key *keyring,
57 char *req, *p; 57 char *req, *p;
58 int len; 58 int len;
59 59
60 BUG_ON(!id_0 && !id_1);
61
60 if (id_0) { 62 if (id_0) {
61 lookup = id_0->data; 63 lookup = id_0->data;
62 len = id_0->len; 64 len = id_0->len;
@@ -105,7 +107,7 @@ struct key *find_asymmetric_key(struct key *keyring,
105 if (id_0 && id_1) { 107 if (id_0 && id_1) {
106 const struct asymmetric_key_ids *kids = asymmetric_key_ids(key); 108 const struct asymmetric_key_ids *kids = asymmetric_key_ids(key);
107 109
108 if (!kids->id[0]) { 110 if (!kids->id[1]) {
109 pr_debug("First ID matches, but second is missing\n"); 111 pr_debug("First ID matches, but second is missing\n");
110 goto reject; 112 goto reject;
111 } 113 }
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c
index af4cd8649117..d140d8bb2c96 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -88,6 +88,9 @@ static int pkcs7_check_authattrs(struct pkcs7_message *msg)
88 bool want = false; 88 bool want = false;
89 89
90 sinfo = msg->signed_infos; 90 sinfo = msg->signed_infos;
91 if (!sinfo)
92 goto inconsistent;
93
91 if (sinfo->authattrs) { 94 if (sinfo->authattrs) {
92 want = true; 95 want = true;
93 msg->have_authattrs = true; 96 msg->have_authattrs = true;
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 0621a95b8597..fddf76ef5bd6 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3662,12 +3662,6 @@ static void binder_stat_br(struct binder_proc *proc,
3662 } 3662 }
3663} 3663}
3664 3664
3665static int binder_has_thread_work(struct binder_thread *thread)
3666{
3667 return !binder_worklist_empty(thread->proc, &thread->todo) ||
3668 thread->looper_need_return;
3669}
3670
3671static int binder_put_node_cmd(struct binder_proc *proc, 3665static int binder_put_node_cmd(struct binder_proc *proc,
3672 struct binder_thread *thread, 3666 struct binder_thread *thread,
3673 void __user **ptrp, 3667 void __user **ptrp,
@@ -4297,12 +4291,9 @@ static unsigned int binder_poll(struct file *filp,
4297 4291
4298 binder_inner_proc_unlock(thread->proc); 4292 binder_inner_proc_unlock(thread->proc);
4299 4293
4300 if (binder_has_work(thread, wait_for_proc_work))
4301 return POLLIN;
4302
4303 poll_wait(filp, &thread->wait, wait); 4294 poll_wait(filp, &thread->wait, wait);
4304 4295
4305 if (binder_has_thread_work(thread)) 4296 if (binder_has_work(thread, wait_for_proc_work))
4306 return POLLIN; 4297 return POLLIN;
4307 4298
4308 return 0; 4299 return 0;
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 064f5e31ec55..c2819a3d58a6 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -215,17 +215,12 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
215 } 215 }
216 } 216 }
217 217
218 if (!vma && need_mm) 218 if (!vma && need_mm && mmget_not_zero(alloc->vma_vm_mm))
219 mm = get_task_mm(alloc->tsk); 219 mm = alloc->vma_vm_mm;
220 220
221 if (mm) { 221 if (mm) {
222 down_write(&mm->mmap_sem); 222 down_write(&mm->mmap_sem);
223 vma = alloc->vma; 223 vma = alloc->vma;
224 if (vma && mm != alloc->vma_vm_mm) {
225 pr_err("%d: vma mm and task mm mismatch\n",
226 alloc->pid);
227 vma = NULL;
228 }
229 } 224 }
230 225
231 if (!vma && need_mm) { 226 if (!vma && need_mm) {
@@ -565,7 +560,7 @@ static void binder_delete_free_buffer(struct binder_alloc *alloc,
565 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, 560 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
566 "%d: merge free, buffer %pK do not share page with %pK or %pK\n", 561 "%d: merge free, buffer %pK do not share page with %pK or %pK\n",
567 alloc->pid, buffer->data, 562 alloc->pid, buffer->data,
568 prev->data, next->data); 563 prev->data, next ? next->data : NULL);
569 binder_update_page_range(alloc, 0, buffer_start_page(buffer), 564 binder_update_page_range(alloc, 0, buffer_start_page(buffer),
570 buffer_start_page(buffer) + PAGE_SIZE, 565 buffer_start_page(buffer) + PAGE_SIZE,
571 NULL); 566 NULL);
@@ -720,6 +715,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
720 barrier(); 715 barrier();
721 alloc->vma = vma; 716 alloc->vma = vma;
722 alloc->vma_vm_mm = vma->vm_mm; 717 alloc->vma_vm_mm = vma->vm_mm;
718 mmgrab(alloc->vma_vm_mm);
723 719
724 return 0; 720 return 0;
725 721
@@ -795,6 +791,8 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc)
795 vfree(alloc->buffer); 791 vfree(alloc->buffer);
796 } 792 }
797 mutex_unlock(&alloc->mutex); 793 mutex_unlock(&alloc->mutex);
794 if (alloc->vma_vm_mm)
795 mmdrop(alloc->vma_vm_mm);
798 796
799 binder_alloc_debug(BINDER_DEBUG_OPEN_CLOSE, 797 binder_alloc_debug(BINDER_DEBUG_OPEN_CLOSE,
800 "%s: %d buffers %d, pages %d\n", 798 "%s: %d buffers %d, pages %d\n",
@@ -889,7 +887,6 @@ int binder_alloc_get_allocated_count(struct binder_alloc *alloc)
889void binder_alloc_vma_close(struct binder_alloc *alloc) 887void binder_alloc_vma_close(struct binder_alloc *alloc)
890{ 888{
891 WRITE_ONCE(alloc->vma, NULL); 889 WRITE_ONCE(alloc->vma, NULL);
892 WRITE_ONCE(alloc->vma_vm_mm, NULL);
893} 890}
894 891
895/** 892/**
@@ -926,9 +923,9 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
926 page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; 923 page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE;
927 vma = alloc->vma; 924 vma = alloc->vma;
928 if (vma) { 925 if (vma) {
929 mm = get_task_mm(alloc->tsk); 926 if (!mmget_not_zero(alloc->vma_vm_mm))
930 if (!mm) 927 goto err_mmget;
931 goto err_get_task_mm_failed; 928 mm = alloc->vma_vm_mm;
932 if (!down_write_trylock(&mm->mmap_sem)) 929 if (!down_write_trylock(&mm->mmap_sem))
933 goto err_down_write_mmap_sem_failed; 930 goto err_down_write_mmap_sem_failed;
934 } 931 }
@@ -963,7 +960,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
963 960
964err_down_write_mmap_sem_failed: 961err_down_write_mmap_sem_failed:
965 mmput_async(mm); 962 mmput_async(mm);
966err_get_task_mm_failed: 963err_mmget:
967err_page_already_freed: 964err_page_already_freed:
968 mutex_unlock(&alloc->mutex); 965 mutex_unlock(&alloc->mutex);
969err_get_alloc_mutex_failed: 966err_get_alloc_mutex_failed:
@@ -1002,7 +999,6 @@ struct shrinker binder_shrinker = {
1002 */ 999 */
1003void binder_alloc_init(struct binder_alloc *alloc) 1000void binder_alloc_init(struct binder_alloc *alloc)
1004{ 1001{
1005 alloc->tsk = current->group_leader;
1006 alloc->pid = current->group_leader->pid; 1002 alloc->pid = current->group_leader->pid;
1007 mutex_init(&alloc->mutex); 1003 mutex_init(&alloc->mutex);
1008 INIT_LIST_HEAD(&alloc->buffers); 1004 INIT_LIST_HEAD(&alloc->buffers);
diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
index a3a3602c689c..2dd33b6df104 100644
--- a/drivers/android/binder_alloc.h
+++ b/drivers/android/binder_alloc.h
@@ -100,7 +100,6 @@ struct binder_lru_page {
100 */ 100 */
101struct binder_alloc { 101struct binder_alloc {
102 struct mutex mutex; 102 struct mutex mutex;
103 struct task_struct *tsk;
104 struct vm_area_struct *vma; 103 struct vm_area_struct *vma;
105 struct mm_struct *vma_vm_mm; 104 struct mm_struct *vma_vm_mm;
106 void *buffer; 105 void *buffer;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 883dfebd3014..baebbdfd74d5 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -243,7 +243,6 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
243 struct nbd_config *config = nbd->config; 243 struct nbd_config *config = nbd->config;
244 config->blksize = blocksize; 244 config->blksize = blocksize;
245 config->bytesize = blocksize * nr_blocks; 245 config->bytesize = blocksize * nr_blocks;
246 nbd_size_update(nbd);
247} 246}
248 247
249static void nbd_complete_rq(struct request *req) 248static void nbd_complete_rq(struct request *req)
@@ -1094,6 +1093,7 @@ static int nbd_start_device(struct nbd_device *nbd)
1094 args->index = i; 1093 args->index = i;
1095 queue_work(recv_workqueue, &args->work); 1094 queue_work(recv_workqueue, &args->work);
1096 } 1095 }
1096 nbd_size_update(nbd);
1097 return error; 1097 return error;
1098} 1098}
1099 1099
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 7cedb4295e9d..64d0fc17c174 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -2604,7 +2604,7 @@ static void *skd_alloc_dma(struct skd_device *skdev, struct kmem_cache *s,
2604 return NULL; 2604 return NULL;
2605 *dma_handle = dma_map_single(dev, buf, s->size, dir); 2605 *dma_handle = dma_map_single(dev, buf, s->size, dir);
2606 if (dma_mapping_error(dev, *dma_handle)) { 2606 if (dma_mapping_error(dev, *dma_handle)) {
2607 kfree(buf); 2607 kmem_cache_free(s, buf);
2608 buf = NULL; 2608 buf = NULL;
2609 } 2609 }
2610 return buf; 2610 return buf;
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index c7f396903184..70db4d5638a6 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus)
720 if (mbus->hw_io_coherency) 720 if (mbus->hw_io_coherency)
721 w->mbus_attr |= ATTR_HW_COHERENCY; 721 w->mbus_attr |= ATTR_HW_COHERENCY;
722 w->base = base & DDR_BASE_CS_LOW_MASK; 722 w->base = base & DDR_BASE_CS_LOW_MASK;
723 w->size = (size | ~DDR_SIZE_MASK) + 1; 723 w->size = (u64)(size | ~DDR_SIZE_MASK) + 1;
724 } 724 }
725 } 725 }
726 mvebu_mbus_dram_info.num_cs = cs; 726 mvebu_mbus_dram_info.num_cs = cs;
diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
index a1df588343f2..1de8cac99a0e 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -117,7 +117,8 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
117 /* Turn off the clock (and clear the event) */ 117 /* Turn off the clock (and clear the event) */
118 disable_timer(cs5535_event_clock); 118 disable_timer(cs5535_event_clock);
119 119
120 if (clockevent_state_shutdown(&cs5535_clockevent)) 120 if (clockevent_state_detached(&cs5535_clockevent) ||
121 clockevent_state_shutdown(&cs5535_clockevent))
121 return IRQ_HANDLED; 122 return IRQ_HANDLED;
122 123
123 /* Clear the counter */ 124 /* Clear the counter */
diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 339186f25a2a..55f9c62ee54b 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -344,7 +344,7 @@ msgdma_prep_memcpy(struct dma_chan *dchan, dma_addr_t dma_dst,
344 344
345 spin_lock_irqsave(&mdev->lock, irqflags); 345 spin_lock_irqsave(&mdev->lock, irqflags);
346 if (desc_cnt > mdev->desc_free_cnt) { 346 if (desc_cnt > mdev->desc_free_cnt) {
347 spin_unlock_bh(&mdev->lock); 347 spin_unlock_irqrestore(&mdev->lock, irqflags);
348 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); 348 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev);
349 return NULL; 349 return NULL;
350 } 350 }
@@ -407,7 +407,7 @@ msgdma_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
407 407
408 spin_lock_irqsave(&mdev->lock, irqflags); 408 spin_lock_irqsave(&mdev->lock, irqflags);
409 if (desc_cnt > mdev->desc_free_cnt) { 409 if (desc_cnt > mdev->desc_free_cnt) {
410 spin_unlock_bh(&mdev->lock); 410 spin_unlock_irqrestore(&mdev->lock, irqflags);
411 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); 411 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev);
412 return NULL; 412 return NULL;
413 } 413 }
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 97c94f9683fa..38cea6fb25a8 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -205,32 +205,17 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched,
205 struct amd_sched_entity *entity) 205 struct amd_sched_entity *entity)
206{ 206{
207 struct amd_sched_rq *rq = entity->rq; 207 struct amd_sched_rq *rq = entity->rq;
208 int r;
209 208
210 if (!amd_sched_entity_is_initialized(sched, entity)) 209 if (!amd_sched_entity_is_initialized(sched, entity))
211 return; 210 return;
211
212 /** 212 /**
213 * The client will not queue more IBs during this fini, consume existing 213 * The client will not queue more IBs during this fini, consume existing
214 * queued IBs or discard them on SIGKILL 214 * queued IBs
215 */ 215 */
216 if ((current->flags & PF_SIGNALED) && current->exit_code == SIGKILL) 216 wait_event(sched->job_scheduled, amd_sched_entity_is_idle(entity));
217 r = -ERESTARTSYS;
218 else
219 r = wait_event_killable(sched->job_scheduled,
220 amd_sched_entity_is_idle(entity));
221 amd_sched_rq_remove_entity(rq, entity);
222 if (r) {
223 struct amd_sched_job *job;
224 217
225 /* Park the kernel for a moment to make sure it isn't processing 218 amd_sched_rq_remove_entity(rq, entity);
226 * our enity.
227 */
228 kthread_park(sched->thread);
229 kthread_unpark(sched->thread);
230 while (kfifo_out(&entity->job_queue, &job, sizeof(job)))
231 sched->ops->free_job(job);
232
233 }
234 kfifo_free(&entity->job_queue); 219 kfifo_free(&entity->job_queue);
235} 220}
236 221
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index e651a58c18cf..82b72425a42f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -168,11 +168,13 @@ static struct drm_driver exynos_drm_driver = {
168static int exynos_drm_suspend(struct device *dev) 168static int exynos_drm_suspend(struct device *dev)
169{ 169{
170 struct drm_device *drm_dev = dev_get_drvdata(dev); 170 struct drm_device *drm_dev = dev_get_drvdata(dev);
171 struct exynos_drm_private *private = drm_dev->dev_private; 171 struct exynos_drm_private *private;
172 172
173 if (pm_runtime_suspended(dev) || !drm_dev) 173 if (pm_runtime_suspended(dev) || !drm_dev)
174 return 0; 174 return 0;
175 175
176 private = drm_dev->dev_private;
177
176 drm_kms_helper_poll_disable(drm_dev); 178 drm_kms_helper_poll_disable(drm_dev);
177 exynos_drm_fbdev_suspend(drm_dev); 179 exynos_drm_fbdev_suspend(drm_dev);
178 private->suspend_state = drm_atomic_helper_suspend(drm_dev); 180 private->suspend_state = drm_atomic_helper_suspend(drm_dev);
@@ -188,11 +190,12 @@ static int exynos_drm_suspend(struct device *dev)
188static int exynos_drm_resume(struct device *dev) 190static int exynos_drm_resume(struct device *dev)
189{ 191{
190 struct drm_device *drm_dev = dev_get_drvdata(dev); 192 struct drm_device *drm_dev = dev_get_drvdata(dev);
191 struct exynos_drm_private *private = drm_dev->dev_private; 193 struct exynos_drm_private *private;
192 194
193 if (pm_runtime_suspended(dev) || !drm_dev) 195 if (pm_runtime_suspended(dev) || !drm_dev)
194 return 0; 196 return 0;
195 197
198 private = drm_dev->dev_private;
196 drm_atomic_helper_resume(drm_dev, private->suspend_state); 199 drm_atomic_helper_resume(drm_dev, private->suspend_state);
197 exynos_drm_fbdev_resume(drm_dev); 200 exynos_drm_fbdev_resume(drm_dev);
198 drm_kms_helper_poll_enable(drm_dev); 201 drm_kms_helper_poll_enable(drm_dev);
@@ -427,6 +430,7 @@ static void exynos_drm_unbind(struct device *dev)
427 430
428 kfree(drm->dev_private); 431 kfree(drm->dev_private);
429 drm->dev_private = NULL; 432 drm->dev_private = NULL;
433 dev_set_drvdata(dev, NULL);
430 434
431 drm_dev_unref(drm); 435 drm_dev_unref(drm);
432} 436}
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 436377da41ba..03532dfc0cd5 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -308,20 +308,8 @@ static int tbs_sched_init_vgpu(struct intel_vgpu *vgpu)
308 308
309static void tbs_sched_clean_vgpu(struct intel_vgpu *vgpu) 309static void tbs_sched_clean_vgpu(struct intel_vgpu *vgpu)
310{ 310{
311 struct intel_gvt_workload_scheduler *scheduler = &vgpu->gvt->scheduler;
312 int ring_id;
313
314 kfree(vgpu->sched_data); 311 kfree(vgpu->sched_data);
315 vgpu->sched_data = NULL; 312 vgpu->sched_data = NULL;
316
317 spin_lock_bh(&scheduler->mmio_context_lock);
318 for (ring_id = 0; ring_id < I915_NUM_ENGINES; ring_id++) {
319 if (scheduler->engine_owner[ring_id] == vgpu) {
320 intel_gvt_switch_mmio(vgpu, NULL, ring_id);
321 scheduler->engine_owner[ring_id] = NULL;
322 }
323 }
324 spin_unlock_bh(&scheduler->mmio_context_lock);
325} 313}
326 314
327static void tbs_sched_start_schedule(struct intel_vgpu *vgpu) 315static void tbs_sched_start_schedule(struct intel_vgpu *vgpu)
@@ -388,6 +376,7 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
388{ 376{
389 struct intel_gvt_workload_scheduler *scheduler = 377 struct intel_gvt_workload_scheduler *scheduler =
390 &vgpu->gvt->scheduler; 378 &vgpu->gvt->scheduler;
379 int ring_id;
391 380
392 gvt_dbg_core("vgpu%d: stop schedule\n", vgpu->id); 381 gvt_dbg_core("vgpu%d: stop schedule\n", vgpu->id);
393 382
@@ -401,4 +390,13 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
401 scheduler->need_reschedule = true; 390 scheduler->need_reschedule = true;
402 scheduler->current_vgpu = NULL; 391 scheduler->current_vgpu = NULL;
403 } 392 }
393
394 spin_lock_bh(&scheduler->mmio_context_lock);
395 for (ring_id = 0; ring_id < I915_NUM_ENGINES; ring_id++) {
396 if (scheduler->engine_owner[ring_id] == vgpu) {
397 intel_gvt_switch_mmio(vgpu, NULL, ring_id);
398 scheduler->engine_owner[ring_id] = NULL;
399 }
400 }
401 spin_unlock_bh(&scheduler->mmio_context_lock);
404} 402}
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index af289d35b77a..32e857dc507c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2657,6 +2657,9 @@ i915_gem_object_pwrite_gtt(struct drm_i915_gem_object *obj,
2657 if (READ_ONCE(obj->mm.pages)) 2657 if (READ_ONCE(obj->mm.pages))
2658 return -ENODEV; 2658 return -ENODEV;
2659 2659
2660 if (obj->mm.madv != I915_MADV_WILLNEED)
2661 return -EFAULT;
2662
2660 /* Before the pages are instantiated the object is treated as being 2663 /* Before the pages are instantiated the object is treated as being
2661 * in the CPU domain. The pages will be clflushed as required before 2664 * in the CPU domain. The pages will be clflushed as required before
2662 * use, and we can freely write into the pages directly. If userspace 2665 * use, and we can freely write into the pages directly. If userspace
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 4df039ef2ce3..e161d383b526 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -33,21 +33,20 @@
33#include "intel_drv.h" 33#include "intel_drv.h"
34#include "i915_trace.h" 34#include "i915_trace.h"
35 35
36static bool ggtt_is_idle(struct drm_i915_private *dev_priv) 36static bool ggtt_is_idle(struct drm_i915_private *i915)
37{ 37{
38 struct i915_ggtt *ggtt = &dev_priv->ggtt; 38 struct intel_engine_cs *engine;
39 struct intel_engine_cs *engine; 39 enum intel_engine_id id;
40 enum intel_engine_id id;
41 40
42 for_each_engine(engine, dev_priv, id) { 41 if (i915->gt.active_requests)
43 struct intel_timeline *tl; 42 return false;
44 43
45 tl = &ggtt->base.timeline.engine[engine->id]; 44 for_each_engine(engine, i915, id) {
46 if (i915_gem_active_isset(&tl->last_request)) 45 if (engine->last_retired_context != i915->kernel_context)
47 return false; 46 return false;
48 } 47 }
49 48
50 return true; 49 return true;
51} 50}
52 51
53static int ggtt_flush(struct drm_i915_private *i915) 52static int ggtt_flush(struct drm_i915_private *i915)
@@ -157,7 +156,8 @@ i915_gem_evict_something(struct i915_address_space *vm,
157 min_size, alignment, cache_level, 156 min_size, alignment, cache_level,
158 start, end, mode); 157 start, end, mode);
159 158
160 /* Retire before we search the active list. Although we have 159 /*
160 * Retire before we search the active list. Although we have
161 * reasonable accuracy in our retirement lists, we may have 161 * reasonable accuracy in our retirement lists, we may have
162 * a stray pin (preventing eviction) that can only be resolved by 162 * a stray pin (preventing eviction) that can only be resolved by
163 * retiring. 163 * retiring.
@@ -182,7 +182,8 @@ search_again:
182 BUG_ON(ret); 182 BUG_ON(ret);
183 } 183 }
184 184
185 /* Can we unpin some objects such as idle hw contents, 185 /*
186 * Can we unpin some objects such as idle hw contents,
186 * or pending flips? But since only the GGTT has global entries 187 * or pending flips? But since only the GGTT has global entries
187 * such as scanouts, rinbuffers and contexts, we can skip the 188 * such as scanouts, rinbuffers and contexts, we can skip the
188 * purge when inspecting per-process local address spaces. 189 * purge when inspecting per-process local address spaces.
@@ -190,19 +191,33 @@ search_again:
190 if (!i915_is_ggtt(vm) || flags & PIN_NONBLOCK) 191 if (!i915_is_ggtt(vm) || flags & PIN_NONBLOCK)
191 return -ENOSPC; 192 return -ENOSPC;
192 193
193 if (ggtt_is_idle(dev_priv)) { 194 /*
194 /* If we still have pending pageflip completions, drop 195 * Not everything in the GGTT is tracked via VMA using
195 * back to userspace to give our workqueues time to 196 * i915_vma_move_to_active(), otherwise we could evict as required
196 * acquire our locks and unpin the old scanouts. 197 * with minimal stalling. Instead we are forced to idle the GPU and
197 */ 198 * explicitly retire outstanding requests which will then remove
198 return intel_has_pending_fb_unpin(dev_priv) ? -EAGAIN : -ENOSPC; 199 * the pinning for active objects such as contexts and ring,
199 } 200 * enabling us to evict them on the next iteration.
201 *
202 * To ensure that all user contexts are evictable, we perform
203 * a switch to the perma-pinned kernel context. This all also gives
204 * us a termination condition, when the last retired context is
205 * the kernel's there is no more we can evict.
206 */
207 if (!ggtt_is_idle(dev_priv)) {
208 ret = ggtt_flush(dev_priv);
209 if (ret)
210 return ret;
200 211
201 ret = ggtt_flush(dev_priv); 212 goto search_again;
202 if (ret) 213 }
203 return ret;
204 214
205 goto search_again; 215 /*
216 * If we still have pending pageflip completions, drop
217 * back to userspace to give our workqueues time to
218 * acquire our locks and unpin the old scanouts.
219 */
220 return intel_has_pending_fb_unpin(dev_priv) ? -EAGAIN : -ENOSPC;
206 221
207found: 222found:
208 /* drm_mm doesn't allow any other other operations while 223 /* drm_mm doesn't allow any other other operations while
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index ed7cd9ee2c2a..c9bcc6c45012 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6998,6 +6998,7 @@ enum {
6998 */ 6998 */
6999#define L3_GENERAL_PRIO_CREDITS(x) (((x) >> 1) << 19) 6999#define L3_GENERAL_PRIO_CREDITS(x) (((x) >> 1) << 19)
7000#define L3_HIGH_PRIO_CREDITS(x) (((x) >> 1) << 14) 7000#define L3_HIGH_PRIO_CREDITS(x) (((x) >> 1) << 14)
7001#define L3_PRIO_CREDITS_MASK ((0x1f << 19) | (0x1f << 14))
7001 7002
7002#define GEN7_L3CNTLREG1 _MMIO(0xB01C) 7003#define GEN7_L3CNTLREG1 _MMIO(0xB01C)
7003#define GEN7_WA_FOR_GEN7_L3_CONTROL 0x3C47FF8C 7004#define GEN7_WA_FOR_GEN7_L3_CONTROL 0x3C47FF8C
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 476681d5940c..5e5fe03b638c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -664,8 +664,8 @@ intel_ddi_get_buf_trans_fdi(struct drm_i915_private *dev_priv,
664 int *n_entries) 664 int *n_entries)
665{ 665{
666 if (IS_BROADWELL(dev_priv)) { 666 if (IS_BROADWELL(dev_priv)) {
667 *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); 667 *n_entries = ARRAY_SIZE(bdw_ddi_translations_fdi);
668 return hsw_ddi_translations_fdi; 668 return bdw_ddi_translations_fdi;
669 } else if (IS_HASWELL(dev_priv)) { 669 } else if (IS_HASWELL(dev_priv)) {
670 *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); 670 *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi);
671 return hsw_ddi_translations_fdi; 671 return hsw_ddi_translations_fdi;
@@ -2102,8 +2102,7 @@ static void intel_ddi_clk_select(struct intel_encoder *encoder,
2102 * register writes. 2102 * register writes.
2103 */ 2103 */
2104 val = I915_READ(DPCLKA_CFGCR0); 2104 val = I915_READ(DPCLKA_CFGCR0);
2105 val &= ~(DPCLKA_CFGCR0_DDI_CLK_OFF(port) | 2105 val &= ~DPCLKA_CFGCR0_DDI_CLK_OFF(port);
2106 DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(port));
2107 I915_WRITE(DPCLKA_CFGCR0, val); 2106 I915_WRITE(DPCLKA_CFGCR0, val);
2108 } else if (IS_GEN9_BC(dev_priv)) { 2107 } else if (IS_GEN9_BC(dev_priv)) {
2109 /* DDI -> PLL mapping */ 2108 /* DDI -> PLL mapping */
diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
index a2a3d93d67bd..df808a94c511 100644
--- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
+++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
@@ -1996,7 +1996,7 @@ static void cnl_ddi_pll_enable(struct drm_i915_private *dev_priv,
1996 1996
1997 /* 3. Configure DPLL_CFGCR0 */ 1997 /* 3. Configure DPLL_CFGCR0 */
1998 /* Avoid touch CFGCR1 if HDMI mode is not enabled */ 1998 /* Avoid touch CFGCR1 if HDMI mode is not enabled */
1999 if (pll->state.hw_state.cfgcr0 & DPLL_CTRL1_HDMI_MODE(pll->id)) { 1999 if (pll->state.hw_state.cfgcr0 & DPLL_CFGCR0_HDMI_MODE) {
2000 val = pll->state.hw_state.cfgcr1; 2000 val = pll->state.hw_state.cfgcr1;
2001 I915_WRITE(CNL_DPLL_CFGCR1(pll->id), val); 2001 I915_WRITE(CNL_DPLL_CFGCR1(pll->id), val);
2002 /* 4. Reab back to ensure writes completed */ 2002 /* 4. Reab back to ensure writes completed */
diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index 9ab596941372..3c2d9cf22ed5 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1048,9 +1048,12 @@ static int bxt_init_workarounds(struct intel_engine_cs *engine)
1048 } 1048 }
1049 1049
1050 /* WaProgramL3SqcReg1DefaultForPerf:bxt */ 1050 /* WaProgramL3SqcReg1DefaultForPerf:bxt */
1051 if (IS_BXT_REVID(dev_priv, BXT_REVID_B0, REVID_FOREVER)) 1051 if (IS_BXT_REVID(dev_priv, BXT_REVID_B0, REVID_FOREVER)) {
1052 I915_WRITE(GEN8_L3SQCREG1, L3_GENERAL_PRIO_CREDITS(62) | 1052 u32 val = I915_READ(GEN8_L3SQCREG1);
1053 L3_HIGH_PRIO_CREDITS(2)); 1053 val &= ~L3_PRIO_CREDITS_MASK;
1054 val |= L3_GENERAL_PRIO_CREDITS(62) | L3_HIGH_PRIO_CREDITS(2);
1055 I915_WRITE(GEN8_L3SQCREG1, val);
1056 }
1054 1057
1055 /* WaToEnableHwFixForPushConstHWBug:bxt */ 1058 /* WaToEnableHwFixForPushConstHWBug:bxt */
1056 if (IS_BXT_REVID(dev_priv, BXT_REVID_C0, REVID_FOREVER)) 1059 if (IS_BXT_REVID(dev_priv, BXT_REVID_C0, REVID_FOREVER))
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index ed662937ec3c..0a09f8ff6aff 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -8245,14 +8245,17 @@ static void gen8_set_l3sqc_credits(struct drm_i915_private *dev_priv,
8245 int high_prio_credits) 8245 int high_prio_credits)
8246{ 8246{
8247 u32 misccpctl; 8247 u32 misccpctl;
8248 u32 val;
8248 8249
8249 /* WaTempDisableDOPClkGating:bdw */ 8250 /* WaTempDisableDOPClkGating:bdw */
8250 misccpctl = I915_READ(GEN7_MISCCPCTL); 8251 misccpctl = I915_READ(GEN7_MISCCPCTL);
8251 I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); 8252 I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE);
8252 8253
8253 I915_WRITE(GEN8_L3SQCREG1, 8254 val = I915_READ(GEN8_L3SQCREG1);
8254 L3_GENERAL_PRIO_CREDITS(general_prio_credits) | 8255 val &= ~L3_PRIO_CREDITS_MASK;
8255 L3_HIGH_PRIO_CREDITS(high_prio_credits)); 8256 val |= L3_GENERAL_PRIO_CREDITS(general_prio_credits);
8257 val |= L3_HIGH_PRIO_CREDITS(high_prio_credits);
8258 I915_WRITE(GEN8_L3SQCREG1, val);
8256 8259
8257 /* 8260 /*
8258 * Wait at least 100 clocks before re-enabling clock gating. 8261 * Wait at least 100 clocks before re-enabling clock gating.
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index f7707849bb53..2b12d82aac15 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -223,7 +223,7 @@ void
223nouveau_fbcon_accel_save_disable(struct drm_device *dev) 223nouveau_fbcon_accel_save_disable(struct drm_device *dev)
224{ 224{
225 struct nouveau_drm *drm = nouveau_drm(dev); 225 struct nouveau_drm *drm = nouveau_drm(dev);
226 if (drm->fbcon) { 226 if (drm->fbcon && drm->fbcon->helper.fbdev) {
227 drm->fbcon->saved_flags = drm->fbcon->helper.fbdev->flags; 227 drm->fbcon->saved_flags = drm->fbcon->helper.fbdev->flags;
228 drm->fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED; 228 drm->fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED;
229 } 229 }
@@ -233,7 +233,7 @@ void
233nouveau_fbcon_accel_restore(struct drm_device *dev) 233nouveau_fbcon_accel_restore(struct drm_device *dev)
234{ 234{
235 struct nouveau_drm *drm = nouveau_drm(dev); 235 struct nouveau_drm *drm = nouveau_drm(dev);
236 if (drm->fbcon) { 236 if (drm->fbcon && drm->fbcon->helper.fbdev) {
237 drm->fbcon->helper.fbdev->flags = drm->fbcon->saved_flags; 237 drm->fbcon->helper.fbdev->flags = drm->fbcon->saved_flags;
238 } 238 }
239} 239}
@@ -245,7 +245,8 @@ nouveau_fbcon_accel_fini(struct drm_device *dev)
245 struct nouveau_fbdev *fbcon = drm->fbcon; 245 struct nouveau_fbdev *fbcon = drm->fbcon;
246 if (fbcon && drm->channel) { 246 if (fbcon && drm->channel) {
247 console_lock(); 247 console_lock();
248 fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED; 248 if (fbcon->helper.fbdev)
249 fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED;
249 console_unlock(); 250 console_unlock();
250 nouveau_channel_idle(drm->channel); 251 nouveau_channel_idle(drm->channel);
251 nvif_object_fini(&fbcon->twod); 252 nvif_object_fini(&fbcon->twod);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 2dbf62a2ac41..e4751f92b342 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -3265,11 +3265,14 @@ nv50_mstm = {
3265void 3265void
3266nv50_mstm_service(struct nv50_mstm *mstm) 3266nv50_mstm_service(struct nv50_mstm *mstm)
3267{ 3267{
3268 struct drm_dp_aux *aux = mstm->mgr.aux; 3268 struct drm_dp_aux *aux = mstm ? mstm->mgr.aux : NULL;
3269 bool handled = true; 3269 bool handled = true;
3270 int ret; 3270 int ret;
3271 u8 esi[8] = {}; 3271 u8 esi[8] = {};
3272 3272
3273 if (!aux)
3274 return;
3275
3273 while (handled) { 3276 while (handled) {
3274 ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8); 3277 ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8);
3275 if (ret != 8) { 3278 if (ret != 8) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c
index 8e2e24a74774..44e116f7880d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c
@@ -39,5 +39,5 @@ int
39g84_bsp_new(struct nvkm_device *device, int index, struct nvkm_engine **pengine) 39g84_bsp_new(struct nvkm_device *device, int index, struct nvkm_engine **pengine)
40{ 40{
41 return nvkm_xtensa_new_(&g84_bsp, device, index, 41 return nvkm_xtensa_new_(&g84_bsp, device, index,
42 true, 0x103000, pengine); 42 device->chipset != 0x92, 0x103000, pengine);
43} 43}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index d06ad2c372bf..455da298227f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -241,6 +241,8 @@ nvkm_vm_unmap_pgt(struct nvkm_vm *vm, int big, u32 fpde, u32 lpde)
241 mmu->func->map_pgt(vpgd->obj, pde, vpgt->mem); 241 mmu->func->map_pgt(vpgd->obj, pde, vpgt->mem);
242 } 242 }
243 243
244 mmu->func->flush(vm);
245
244 nvkm_memory_del(&pgt); 246 nvkm_memory_del(&pgt);
245 } 247 }
246} 248}
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 018d2e0f8ec5..379b0df123be 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -937,7 +937,10 @@ void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
937{ 937{
938 BUG_ON(!is_hvsock_channel(channel)); 938 BUG_ON(!is_hvsock_channel(channel));
939 939
940 channel->rescind = true; 940 /* We always get a rescind msg when a connection is closed. */
941 while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind))
942 msleep(1);
943
941 vmbus_device_unregister(channel->device_obj); 944 vmbus_device_unregister(channel->device_obj);
942} 945}
943EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister); 946EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 54a47b40546f..f96830ffd9f1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -1021,7 +1021,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
1021 } 1021 }
1022 1022
1023 dev_dbg(&pdev->dev, "using scl-gpio %d and sda-gpio %d for recovery\n", 1023 dev_dbg(&pdev->dev, "using scl-gpio %d and sda-gpio %d for recovery\n",
1024 rinfo->sda_gpio, rinfo->scl_gpio); 1024 rinfo->scl_gpio, rinfo->sda_gpio);
1025 1025
1026 rinfo->prepare_recovery = i2c_imx_prepare_recovery; 1026 rinfo->prepare_recovery = i2c_imx_prepare_recovery;
1027 rinfo->unprepare_recovery = i2c_imx_unprepare_recovery; 1027 rinfo->unprepare_recovery = i2c_imx_unprepare_recovery;
@@ -1100,7 +1100,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
1100 } 1100 }
1101 1101
1102 /* Request IRQ */ 1102 /* Request IRQ */
1103 ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, 0, 1103 ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, IRQF_SHARED,
1104 pdev->name, i2c_imx); 1104 pdev->name, i2c_imx);
1105 if (ret) { 1105 if (ret) {
1106 dev_err(&pdev->dev, "can't claim irq %d\n", irq); 1106 dev_err(&pdev->dev, "can't claim irq %d\n", irq);
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 22ffcb73c185..b51adffa4841 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -340,12 +340,15 @@ static int ismt_process_desc(const struct ismt_desc *desc,
340 data->word = dma_buffer[0] | (dma_buffer[1] << 8); 340 data->word = dma_buffer[0] | (dma_buffer[1] << 8);
341 break; 341 break;
342 case I2C_SMBUS_BLOCK_DATA: 342 case I2C_SMBUS_BLOCK_DATA:
343 case I2C_SMBUS_I2C_BLOCK_DATA:
344 if (desc->rxbytes != dma_buffer[0] + 1) 343 if (desc->rxbytes != dma_buffer[0] + 1)
345 return -EMSGSIZE; 344 return -EMSGSIZE;
346 345
347 memcpy(data->block, dma_buffer, desc->rxbytes); 346 memcpy(data->block, dma_buffer, desc->rxbytes);
348 break; 347 break;
348 case I2C_SMBUS_I2C_BLOCK_DATA:
349 memcpy(&data->block[1], dma_buffer, desc->rxbytes);
350 data->block[0] = desc->rxbytes;
351 break;
349 } 352 }
350 return 0; 353 return 0;
351 } 354 }
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1ebb5e947e0b..23c2ea2baedc 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -360,6 +360,7 @@ static int omap_i2c_init(struct omap_i2c_dev *omap)
360 unsigned long fclk_rate = 12000000; 360 unsigned long fclk_rate = 12000000;
361 unsigned long internal_clk = 0; 361 unsigned long internal_clk = 0;
362 struct clk *fclk; 362 struct clk *fclk;
363 int error;
363 364
364 if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) { 365 if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) {
365 /* 366 /*
@@ -378,6 +379,13 @@ static int omap_i2c_init(struct omap_i2c_dev *omap)
378 * do this bit unconditionally. 379 * do this bit unconditionally.
379 */ 380 */
380 fclk = clk_get(omap->dev, "fck"); 381 fclk = clk_get(omap->dev, "fck");
382 if (IS_ERR(fclk)) {
383 error = PTR_ERR(fclk);
384 dev_err(omap->dev, "could not get fck: %i\n", error);
385
386 return error;
387 }
388
381 fclk_rate = clk_get_rate(fclk); 389 fclk_rate = clk_get_rate(fclk);
382 clk_put(fclk); 390 clk_put(fclk);
383 391
@@ -410,6 +418,12 @@ static int omap_i2c_init(struct omap_i2c_dev *omap)
410 else 418 else
411 internal_clk = 4000; 419 internal_clk = 4000;
412 fclk = clk_get(omap->dev, "fck"); 420 fclk = clk_get(omap->dev, "fck");
421 if (IS_ERR(fclk)) {
422 error = PTR_ERR(fclk);
423 dev_err(omap->dev, "could not get fck: %i\n", error);
424
425 return error;
426 }
413 fclk_rate = clk_get_rate(fclk) / 1000; 427 fclk_rate = clk_get_rate(fclk) / 1000;
414 clk_put(fclk); 428 clk_put(fclk);
415 429
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 0ecdb47a23ab..174579d32e5f 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -85,6 +85,9 @@
85/* SB800 constants */ 85/* SB800 constants */
86#define SB800_PIIX4_SMB_IDX 0xcd6 86#define SB800_PIIX4_SMB_IDX 0xcd6
87 87
88#define KERNCZ_IMC_IDX 0x3e
89#define KERNCZ_IMC_DATA 0x3f
90
88/* 91/*
89 * SB800 port is selected by bits 2:1 of the smb_en register (0x2c) 92 * SB800 port is selected by bits 2:1 of the smb_en register (0x2c)
90 * or the smb_sel register (0x2e), depending on bit 0 of register 0x2f. 93 * or the smb_sel register (0x2e), depending on bit 0 of register 0x2f.
@@ -94,6 +97,12 @@
94#define SB800_PIIX4_PORT_IDX_ALT 0x2e 97#define SB800_PIIX4_PORT_IDX_ALT 0x2e
95#define SB800_PIIX4_PORT_IDX_SEL 0x2f 98#define SB800_PIIX4_PORT_IDX_SEL 0x2f
96#define SB800_PIIX4_PORT_IDX_MASK 0x06 99#define SB800_PIIX4_PORT_IDX_MASK 0x06
100#define SB800_PIIX4_PORT_IDX_SHIFT 1
101
102/* On kerncz, SmBus0Sel is at bit 20:19 of PMx00 DecodeEn */
103#define SB800_PIIX4_PORT_IDX_KERNCZ 0x02
104#define SB800_PIIX4_PORT_IDX_MASK_KERNCZ 0x18
105#define SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ 3
97 106
98/* insmod parameters */ 107/* insmod parameters */
99 108
@@ -149,6 +158,8 @@ static const struct dmi_system_id piix4_dmi_ibm[] = {
149 */ 158 */
150static DEFINE_MUTEX(piix4_mutex_sb800); 159static DEFINE_MUTEX(piix4_mutex_sb800);
151static u8 piix4_port_sel_sb800; 160static u8 piix4_port_sel_sb800;
161static u8 piix4_port_mask_sb800;
162static u8 piix4_port_shift_sb800;
152static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = { 163static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = {
153 " port 0", " port 2", " port 3", " port 4" 164 " port 0", " port 2", " port 3", " port 4"
154}; 165};
@@ -159,6 +170,7 @@ struct i2c_piix4_adapdata {
159 170
160 /* SB800 */ 171 /* SB800 */
161 bool sb800_main; 172 bool sb800_main;
173 bool notify_imc;
162 u8 port; /* Port number, shifted */ 174 u8 port; /* Port number, shifted */
163}; 175};
164 176
@@ -347,7 +359,19 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
347 359
348 /* Find which register is used for port selection */ 360 /* Find which register is used for port selection */
349 if (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD) { 361 if (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD) {
350 piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_ALT; 362 switch (PIIX4_dev->device) {
363 case PCI_DEVICE_ID_AMD_KERNCZ_SMBUS:
364 piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_KERNCZ;
365 piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK_KERNCZ;
366 piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ;
367 break;
368 case PCI_DEVICE_ID_AMD_HUDSON2_SMBUS:
369 default:
370 piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_ALT;
371 piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK;
372 piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT;
373 break;
374 }
351 } else { 375 } else {
352 mutex_lock(&piix4_mutex_sb800); 376 mutex_lock(&piix4_mutex_sb800);
353 outb_p(SB800_PIIX4_PORT_IDX_SEL, SB800_PIIX4_SMB_IDX); 377 outb_p(SB800_PIIX4_PORT_IDX_SEL, SB800_PIIX4_SMB_IDX);
@@ -355,6 +379,8 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
355 piix4_port_sel_sb800 = (port_sel & 0x01) ? 379 piix4_port_sel_sb800 = (port_sel & 0x01) ?
356 SB800_PIIX4_PORT_IDX_ALT : 380 SB800_PIIX4_PORT_IDX_ALT :
357 SB800_PIIX4_PORT_IDX; 381 SB800_PIIX4_PORT_IDX;
382 piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK;
383 piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT;
358 mutex_unlock(&piix4_mutex_sb800); 384 mutex_unlock(&piix4_mutex_sb800);
359 } 385 }
360 386
@@ -572,6 +598,67 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
572 return 0; 598 return 0;
573} 599}
574 600
601static uint8_t piix4_imc_read(uint8_t idx)
602{
603 outb_p(idx, KERNCZ_IMC_IDX);
604 return inb_p(KERNCZ_IMC_DATA);
605}
606
607static void piix4_imc_write(uint8_t idx, uint8_t value)
608{
609 outb_p(idx, KERNCZ_IMC_IDX);
610 outb_p(value, KERNCZ_IMC_DATA);
611}
612
613static int piix4_imc_sleep(void)
614{
615 int timeout = MAX_TIMEOUT;
616
617 if (!request_muxed_region(KERNCZ_IMC_IDX, 2, "smbus_kerncz_imc"))
618 return -EBUSY;
619
620 /* clear response register */
621 piix4_imc_write(0x82, 0x00);
622 /* request ownership flag */
623 piix4_imc_write(0x83, 0xB4);
624 /* kick off IMC Mailbox command 96 */
625 piix4_imc_write(0x80, 0x96);
626
627 while (timeout--) {
628 if (piix4_imc_read(0x82) == 0xfa) {
629 release_region(KERNCZ_IMC_IDX, 2);
630 return 0;
631 }
632 usleep_range(1000, 2000);
633 }
634
635 release_region(KERNCZ_IMC_IDX, 2);
636 return -ETIMEDOUT;
637}
638
639static void piix4_imc_wakeup(void)
640{
641 int timeout = MAX_TIMEOUT;
642
643 if (!request_muxed_region(KERNCZ_IMC_IDX, 2, "smbus_kerncz_imc"))
644 return;
645
646 /* clear response register */
647 piix4_imc_write(0x82, 0x00);
648 /* release ownership flag */
649 piix4_imc_write(0x83, 0xB5);
650 /* kick off IMC Mailbox command 96 */
651 piix4_imc_write(0x80, 0x96);
652
653 while (timeout--) {
654 if (piix4_imc_read(0x82) == 0xfa)
655 break;
656 usleep_range(1000, 2000);
657 }
658
659 release_region(KERNCZ_IMC_IDX, 2);
660}
661
575/* 662/*
576 * Handles access to multiple SMBus ports on the SB800. 663 * Handles access to multiple SMBus ports on the SB800.
577 * The port is selected by bits 2:1 of the smb_en register (0x2c). 664 * The port is selected by bits 2:1 of the smb_en register (0x2c).
@@ -612,12 +699,47 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
612 return -EBUSY; 699 return -EBUSY;
613 } 700 }
614 701
702 /*
703 * Notify the IMC (Integrated Micro Controller) if required.
704 * Among other responsibilities, the IMC is in charge of monitoring
705 * the System fans and temperature sensors, and act accordingly.
706 * All this is done through SMBus and can/will collide
707 * with our transactions if they are long (BLOCK_DATA).
708 * Therefore we need to request the ownership flag during those
709 * transactions.
710 */
711 if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc) {
712 int ret;
713
714 ret = piix4_imc_sleep();
715 switch (ret) {
716 case -EBUSY:
717 dev_warn(&adap->dev,
718 "IMC base address index region 0x%x already in use.\n",
719 KERNCZ_IMC_IDX);
720 break;
721 case -ETIMEDOUT:
722 dev_warn(&adap->dev,
723 "Failed to communicate with the IMC.\n");
724 break;
725 default:
726 break;
727 }
728
729 /* If IMC communication fails do not retry */
730 if (ret) {
731 dev_warn(&adap->dev,
732 "Continuing without IMC notification.\n");
733 adapdata->notify_imc = false;
734 }
735 }
736
615 outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); 737 outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
616 smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); 738 smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
617 739
618 port = adapdata->port; 740 port = adapdata->port;
619 if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != port) 741 if ((smba_en_lo & piix4_port_mask_sb800) != port)
620 outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | port, 742 outb_p((smba_en_lo & ~piix4_port_mask_sb800) | port,
621 SB800_PIIX4_SMB_IDX + 1); 743 SB800_PIIX4_SMB_IDX + 1);
622 744
623 retval = piix4_access(adap, addr, flags, read_write, 745 retval = piix4_access(adap, addr, flags, read_write,
@@ -628,6 +750,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
628 /* Release the semaphore */ 750 /* Release the semaphore */
629 outb_p(smbslvcnt | 0x20, SMBSLVCNT); 751 outb_p(smbslvcnt | 0x20, SMBSLVCNT);
630 752
753 if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc)
754 piix4_imc_wakeup();
755
631 mutex_unlock(&piix4_mutex_sb800); 756 mutex_unlock(&piix4_mutex_sb800);
632 757
633 return retval; 758 return retval;
@@ -679,7 +804,7 @@ static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
679static struct i2c_adapter *piix4_aux_adapter; 804static struct i2c_adapter *piix4_aux_adapter;
680 805
681static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, 806static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
682 bool sb800_main, u8 port, 807 bool sb800_main, u8 port, bool notify_imc,
683 const char *name, struct i2c_adapter **padap) 808 const char *name, struct i2c_adapter **padap)
684{ 809{
685 struct i2c_adapter *adap; 810 struct i2c_adapter *adap;
@@ -706,7 +831,8 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
706 831
707 adapdata->smba = smba; 832 adapdata->smba = smba;
708 adapdata->sb800_main = sb800_main; 833 adapdata->sb800_main = sb800_main;
709 adapdata->port = port << 1; 834 adapdata->port = port << piix4_port_shift_sb800;
835 adapdata->notify_imc = notify_imc;
710 836
711 /* set up the sysfs linkage to our parent device */ 837 /* set up the sysfs linkage to our parent device */
712 adap->dev.parent = &dev->dev; 838 adap->dev.parent = &dev->dev;
@@ -728,14 +854,15 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
728 return 0; 854 return 0;
729} 855}
730 856
731static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba) 857static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
858 bool notify_imc)
732{ 859{
733 struct i2c_piix4_adapdata *adapdata; 860 struct i2c_piix4_adapdata *adapdata;
734 int port; 861 int port;
735 int retval; 862 int retval;
736 863
737 for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) { 864 for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
738 retval = piix4_add_adapter(dev, smba, true, port, 865 retval = piix4_add_adapter(dev, smba, true, port, notify_imc,
739 piix4_main_port_names_sb800[port], 866 piix4_main_port_names_sb800[port],
740 &piix4_main_adapters[port]); 867 &piix4_main_adapters[port]);
741 if (retval < 0) 868 if (retval < 0)
@@ -769,6 +896,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
769 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && 896 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
770 dev->revision >= 0x40) || 897 dev->revision >= 0x40) ||
771 dev->vendor == PCI_VENDOR_ID_AMD) { 898 dev->vendor == PCI_VENDOR_ID_AMD) {
899 bool notify_imc = false;
772 is_sb800 = true; 900 is_sb800 = true;
773 901
774 if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) { 902 if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) {
@@ -778,6 +906,20 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
778 return -EBUSY; 906 return -EBUSY;
779 } 907 }
780 908
909 if (dev->vendor == PCI_VENDOR_ID_AMD &&
910 dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) {
911 u8 imc;
912
913 /*
914 * Detect if IMC is active or not, this method is
915 * described on coreboot's AMD IMC notes
916 */
917 pci_bus_read_config_byte(dev->bus, PCI_DEVFN(0x14, 3),
918 0x40, &imc);
919 if (imc & 0x80)
920 notify_imc = true;
921 }
922
781 /* base address location etc changed in SB800 */ 923 /* base address location etc changed in SB800 */
782 retval = piix4_setup_sb800(dev, id, 0); 924 retval = piix4_setup_sb800(dev, id, 0);
783 if (retval < 0) { 925 if (retval < 0) {
@@ -789,7 +931,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
789 * Try to register multiplexed main SMBus adapter, 931 * Try to register multiplexed main SMBus adapter,
790 * give up if we can't 932 * give up if we can't
791 */ 933 */
792 retval = piix4_add_adapters_sb800(dev, retval); 934 retval = piix4_add_adapters_sb800(dev, retval, notify_imc);
793 if (retval < 0) { 935 if (retval < 0) {
794 release_region(SB800_PIIX4_SMB_IDX, 2); 936 release_region(SB800_PIIX4_SMB_IDX, 2);
795 return retval; 937 return retval;
@@ -800,7 +942,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
800 return retval; 942 return retval;
801 943
802 /* Try to register main SMBus adapter, give up if we can't */ 944 /* Try to register main SMBus adapter, give up if we can't */
803 retval = piix4_add_adapter(dev, retval, false, 0, "", 945 retval = piix4_add_adapter(dev, retval, false, 0, false, "",
804 &piix4_main_adapters[0]); 946 &piix4_main_adapters[0]);
805 if (retval < 0) 947 if (retval < 0)
806 return retval; 948 return retval;
@@ -827,7 +969,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
827 if (retval > 0) { 969 if (retval > 0) {
828 /* Try to add the aux adapter if it exists, 970 /* Try to add the aux adapter if it exists,
829 * piix4_add_adapter will clean up if this fails */ 971 * piix4_add_adapter will clean up if this fails */
830 piix4_add_adapter(dev, retval, false, 0, 972 piix4_add_adapter(dev, retval, false, 0, false,
831 is_sb800 ? piix4_aux_port_name_sb800 : "", 973 is_sb800 ? piix4_aux_port_name_sb800 : "",
832 &piix4_aux_adapter); 974 &piix4_aux_adapter);
833 } 975 }
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 15de262015df..c6d9517d7611 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -148,6 +148,17 @@ config HID_SENSOR_ACCEL_3D
148 To compile this driver as a module, choose M here: the 148 To compile this driver as a module, choose M here: the
149 module will be called hid-sensor-accel-3d. 149 module will be called hid-sensor-accel-3d.
150 150
151config IIO_CROS_EC_ACCEL_LEGACY
152 tristate "ChromeOS EC Legacy Accelerometer Sensor"
153 select IIO_BUFFER
154 select IIO_TRIGGERED_BUFFER
155 select CROS_EC_LPC_REGISTER_DEVICE
156 help
157 Say yes here to get support for accelerometers on Chromebook using
158 legacy EC firmware.
159 Sensor data is retrieved through IO memory.
160 Newer devices should use IIO_CROS_EC_SENSORS.
161
151config IIO_ST_ACCEL_3AXIS 162config IIO_ST_ACCEL_3AXIS
152 tristate "STMicroelectronics accelerometers 3-Axis Driver" 163 tristate "STMicroelectronics accelerometers 3-Axis Driver"
153 depends on (I2C || SPI_MASTER) && SYSFS 164 depends on (I2C || SPI_MASTER) && SYSFS
@@ -219,8 +230,8 @@ config KXCJK1013
219 select IIO_TRIGGERED_BUFFER 230 select IIO_TRIGGERED_BUFFER
220 help 231 help
221 Say Y here if you want to build a driver for the Kionix KXCJK-1013 232 Say Y here if you want to build a driver for the Kionix KXCJK-1013
222 triaxial acceleration sensor. This driver also supports KXCJ9-1008 233 triaxial acceleration sensor. This driver also supports KXCJ9-1008,
223 and KXTJ2-1009. 234 KXTJ2-1009 and KXTF9.
224 235
225 To compile this driver as a module, choose M here: the module will 236 To compile this driver as a module, choose M here: the module will
226 be called kxcjk-1013. 237 be called kxcjk-1013.
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 31fba1974e95..fdd054af636c 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -43,6 +43,8 @@ obj-$(CONFIG_SCA3000) += sca3000.o
43obj-$(CONFIG_STK8312) += stk8312.o 43obj-$(CONFIG_STK8312) += stk8312.o
44obj-$(CONFIG_STK8BA50) += stk8ba50.o 44obj-$(CONFIG_STK8BA50) += stk8ba50.o
45 45
46obj-$(CONFIG_IIO_CROS_EC_ACCEL_LEGACY) += cros_ec_accel_legacy.o
47
46obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o 48obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o
47 49
48obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o 50obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 9ccb5828db98..7251d0e63d74 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -95,7 +95,6 @@ static int adxl345_read_raw(struct iio_dev *indio_dev,
95} 95}
96 96
97static const struct iio_info adxl345_info = { 97static const struct iio_info adxl345_info = {
98 .driver_module = THIS_MODULE,
99 .read_raw = adxl345_read_raw, 98 .read_raw = adxl345_read_raw,
100}; 99};
101 100
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 3dec972ca672..cb9765a3de60 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -536,7 +536,6 @@ static const struct iio_info bma180_info = {
536 .attrs = &bma180_attrs_group, 536 .attrs = &bma180_attrs_group,
537 .read_raw = bma180_read_raw, 537 .read_raw = bma180_read_raw,
538 .write_raw = bma180_write_raw, 538 .write_raw = bma180_write_raw,
539 .driver_module = THIS_MODULE,
540}; 539};
541 540
542static const char * const bma180_power_modes[] = { "low_noise", "low_power" }; 541static const char * const bma180_power_modes[] = { "low_noise", "low_power" };
@@ -700,7 +699,6 @@ static int bma180_trig_try_reen(struct iio_trigger *trig)
700static const struct iio_trigger_ops bma180_trigger_ops = { 699static const struct iio_trigger_ops bma180_trigger_ops = {
701 .set_trigger_state = bma180_data_rdy_trigger_set_state, 700 .set_trigger_state = bma180_data_rdy_trigger_set_state,
702 .try_reenable = bma180_trig_try_reen, 701 .try_reenable = bma180_trig_try_reen,
703 .owner = THIS_MODULE,
704}; 702};
705 703
706static int bma180_probe(struct i2c_client *client, 704static int bma180_probe(struct i2c_client *client,
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index 5099f295dd37..e25d91c017ed 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -186,7 +186,6 @@ static int bma220_write_raw(struct iio_dev *indio_dev,
186} 186}
187 187
188static const struct iio_info bma220_info = { 188static const struct iio_info bma220_info = {
189 .driver_module = THIS_MODULE,
190 .read_raw = bma220_read_raw, 189 .read_raw = bma220_read_raw,
191 .write_raw = bma220_write_raw, 190 .write_raw = bma220_write_raw,
192 .attrs = &bma220_attribute_group, 191 .attrs = &bma220_attribute_group,
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 807299dd45eb..870f92ef61c2 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -1094,7 +1094,6 @@ static const struct iio_info bmc150_accel_info = {
1094 .write_event_value = bmc150_accel_write_event, 1094 .write_event_value = bmc150_accel_write_event,
1095 .write_event_config = bmc150_accel_write_event_config, 1095 .write_event_config = bmc150_accel_write_event_config,
1096 .read_event_config = bmc150_accel_read_event_config, 1096 .read_event_config = bmc150_accel_read_event_config,
1097 .driver_module = THIS_MODULE,
1098}; 1097};
1099 1098
1100static const struct iio_info bmc150_accel_info_fifo = { 1099static const struct iio_info bmc150_accel_info_fifo = {
@@ -1108,7 +1107,6 @@ static const struct iio_info bmc150_accel_info_fifo = {
1108 .validate_trigger = bmc150_accel_validate_trigger, 1107 .validate_trigger = bmc150_accel_validate_trigger,
1109 .hwfifo_set_watermark = bmc150_accel_set_watermark, 1108 .hwfifo_set_watermark = bmc150_accel_set_watermark,
1110 .hwfifo_flush_to_buffer = bmc150_accel_fifo_flush, 1109 .hwfifo_flush_to_buffer = bmc150_accel_fifo_flush,
1111 .driver_module = THIS_MODULE,
1112}; 1110};
1113 1111
1114static const unsigned long bmc150_accel_scan_masks[] = { 1112static const unsigned long bmc150_accel_scan_masks[] = {
@@ -1200,7 +1198,6 @@ static int bmc150_accel_trigger_set_state(struct iio_trigger *trig,
1200static const struct iio_trigger_ops bmc150_accel_trigger_ops = { 1198static const struct iio_trigger_ops bmc150_accel_trigger_ops = {
1201 .set_trigger_state = bmc150_accel_trigger_set_state, 1199 .set_trigger_state = bmc150_accel_trigger_set_state,
1202 .try_reenable = bmc150_accel_trig_try_reen, 1200 .try_reenable = bmc150_accel_trig_try_reen,
1203 .owner = THIS_MODULE,
1204}; 1201};
1205 1202
1206static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev) 1203static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c
new file mode 100644
index 000000000000..063e89eff791
--- /dev/null
+++ b/drivers/iio/accel/cros_ec_accel_legacy.c
@@ -0,0 +1,423 @@
1/*
2 * Driver for older Chrome OS EC accelerometer
3 *
4 * Copyright 2017 Google, Inc
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * This driver uses the memory mapper cros-ec interface to communicate
16 * with the Chrome OS EC about accelerometer data.
17 * Accelerometer access is presented through iio sysfs.
18 */
19
20#include <linux/delay.h>
21#include <linux/device.h>
22#include <linux/iio/buffer.h>
23#include <linux/iio/iio.h>
24#include <linux/iio/kfifo_buf.h>
25#include <linux/iio/trigger_consumer.h>
26#include <linux/iio/triggered_buffer.h>
27#include <linux/kernel.h>
28#include <linux/mfd/cros_ec.h>
29#include <linux/mfd/cros_ec_commands.h>
30#include <linux/module.h>
31#include <linux/slab.h>
32#include <linux/sysfs.h>
33#include <linux/platform_device.h>
34
35#define DRV_NAME "cros-ec-accel-legacy"
36
37/*
38 * Sensor scale hard coded at 10 bits per g, computed as:
39 * g / (2^10 - 1) = 0.009586168; with g = 9.80665 m.s^-2
40 */
41#define ACCEL_LEGACY_NSCALE 9586168
42
43/* Indices for EC sensor values. */
44enum {
45 X,
46 Y,
47 Z,
48 MAX_AXIS,
49};
50
51/* State data for cros_ec_accel_legacy iio driver. */
52struct cros_ec_accel_legacy_state {
53 struct cros_ec_device *ec;
54
55 /*
56 * Array holding data from a single capture. 2 bytes per channel
57 * for the 3 channels plus the timestamp which is always last and
58 * 8-bytes aligned.
59 */
60 s16 capture_data[8];
61 s8 sign[MAX_AXIS];
62 u8 sensor_num;
63};
64
65static int ec_cmd_read_u8(struct cros_ec_device *ec, unsigned int offset,
66 u8 *dest)
67{
68 return ec->cmd_readmem(ec, offset, 1, dest);
69}
70
71static int ec_cmd_read_u16(struct cros_ec_device *ec, unsigned int offset,
72 u16 *dest)
73{
74 __le16 tmp;
75 int ret = ec->cmd_readmem(ec, offset, 2, &tmp);
76
77 *dest = le16_to_cpu(tmp);
78
79 return ret;
80}
81
82/**
83 * read_ec_until_not_busy() - Read from EC status byte until it reads not busy.
84 * @st: Pointer to state information for device.
85 *
86 * This function reads EC status until its busy bit gets cleared. It does not
87 * wait indefinitely and returns -EIO if the EC status is still busy after a
88 * few hundreds milliseconds.
89 *
90 * Return: 8-bit status if ok, -EIO on error
91 */
92static int read_ec_until_not_busy(struct cros_ec_accel_legacy_state *st)
93{
94 struct cros_ec_device *ec = st->ec;
95 u8 status;
96 int attempts = 0;
97
98 ec_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS, &status);
99 while (status & EC_MEMMAP_ACC_STATUS_BUSY_BIT) {
100 /* Give up after enough attempts, return error. */
101 if (attempts++ >= 50)
102 return -EIO;
103
104 /* Small delay every so often. */
105 if (attempts % 5 == 0)
106 msleep(25);
107
108 ec_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS, &status);
109 }
110
111 return status;
112}
113
114/**
115 * read_ec_accel_data_unsafe() - Read acceleration data from EC shared memory.
116 * @st: Pointer to state information for device.
117 * @scan_mask: Bitmap of the sensor indices to scan.
118 * @data: Location to store data.
119 *
120 * This is the unsafe function for reading the EC data. It does not guarantee
121 * that the EC will not modify the data as it is being read in.
122 */
123static void read_ec_accel_data_unsafe(struct cros_ec_accel_legacy_state *st,
124 unsigned long scan_mask, s16 *data)
125{
126 int i = 0;
127 int num_enabled = bitmap_weight(&scan_mask, MAX_AXIS);
128
129 /* Read all sensors enabled in scan_mask. Each value is 2 bytes. */
130 while (num_enabled--) {
131 i = find_next_bit(&scan_mask, MAX_AXIS, i);
132 ec_cmd_read_u16(st->ec,
133 EC_MEMMAP_ACC_DATA +
134 sizeof(s16) *
135 (1 + i + st->sensor_num * MAX_AXIS),
136 data);
137 *data *= st->sign[i];
138 i++;
139 data++;
140 }
141}
142
143/**
144 * read_ec_accel_data() - Read acceleration data from EC shared memory.
145 * @st: Pointer to state information for device.
146 * @scan_mask: Bitmap of the sensor indices to scan.
147 * @data: Location to store data.
148 *
149 * This is the safe function for reading the EC data. It guarantees that
150 * the data sampled was not modified by the EC while being read.
151 *
152 * Return: 0 if ok, -ve on error
153 */
154static int read_ec_accel_data(struct cros_ec_accel_legacy_state *st,
155 unsigned long scan_mask, s16 *data)
156{
157 u8 samp_id = 0xff;
158 u8 status = 0;
159 int ret;
160 int attempts = 0;
161
162 /*
163 * Continually read all data from EC until the status byte after
164 * all reads reflects that the EC is not busy and the sample id
165 * matches the sample id from before all reads. This guarantees
166 * that data read in was not modified by the EC while reading.
167 */
168 while ((status & (EC_MEMMAP_ACC_STATUS_BUSY_BIT |
169 EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK)) != samp_id) {
170 /* If we have tried to read too many times, return error. */
171 if (attempts++ >= 5)
172 return -EIO;
173
174 /* Read status byte until EC is not busy. */
175 ret = read_ec_until_not_busy(st);
176 if (ret < 0)
177 return ret;
178 status = ret;
179
180 /*
181 * Store the current sample id so that we can compare to the
182 * sample id after reading the data.
183 */
184 samp_id = status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
185
186 /* Read all EC data, format it, and store it into data. */
187 read_ec_accel_data_unsafe(st, scan_mask, data);
188
189 /* Read status byte. */
190 ec_cmd_read_u8(st->ec, EC_MEMMAP_ACC_STATUS, &status);
191 }
192
193 return 0;
194}
195
196static int cros_ec_accel_legacy_read(struct iio_dev *indio_dev,
197 struct iio_chan_spec const *chan,
198 int *val, int *val2, long mask)
199{
200 struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
201 s16 data = 0;
202 int ret = IIO_VAL_INT;
203
204 switch (mask) {
205 case IIO_CHAN_INFO_RAW:
206 ret = read_ec_accel_data(st, (1 << chan->scan_index), &data);
207 if (ret)
208 return ret;
209 *val = data;
210 return IIO_VAL_INT;
211 case IIO_CHAN_INFO_SCALE:
212 *val = 0;
213 *val2 = ACCEL_LEGACY_NSCALE;
214 return IIO_VAL_INT_PLUS_NANO;
215 case IIO_CHAN_INFO_CALIBBIAS:
216 /* Calibration not supported. */
217 *val = 0;
218 return IIO_VAL_INT;
219 default:
220 return -EINVAL;
221 }
222}
223
224static int cros_ec_accel_legacy_write(struct iio_dev *indio_dev,
225 struct iio_chan_spec const *chan,
226 int val, int val2, long mask)
227{
228 /*
229 * Do nothing but don't return an error code to allow calibration
230 * script to work.
231 */
232 if (mask == IIO_CHAN_INFO_CALIBBIAS)
233 return 0;
234
235 return -EINVAL;
236}
237
238static const struct iio_info cros_ec_accel_legacy_info = {
239 .read_raw = &cros_ec_accel_legacy_read,
240 .write_raw = &cros_ec_accel_legacy_write,
241};
242
243/**
244 * cros_ec_accel_legacy_capture() - The trigger handler function
245 * @irq: The interrupt number.
246 * @p: Private data - always a pointer to the poll func.
247 *
248 * On a trigger event occurring, if the pollfunc is attached then this
249 * handler is called as a threaded interrupt (and hence may sleep). It
250 * is responsible for grabbing data from the device and pushing it into
251 * the associated buffer.
252 *
253 * Return: IRQ_HANDLED
254 */
255static irqreturn_t cros_ec_accel_legacy_capture(int irq, void *p)
256{
257 struct iio_poll_func *pf = p;
258 struct iio_dev *indio_dev = pf->indio_dev;
259 struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
260
261 /* Clear capture data. */
262 memset(st->capture_data, 0, sizeof(st->capture_data));
263
264 /*
265 * Read data based on which channels are enabled in scan mask. Note
266 * that on a capture we are always reading the calibrated data.
267 */
268 read_ec_accel_data(st, *indio_dev->active_scan_mask, st->capture_data);
269
270 iio_push_to_buffers_with_timestamp(indio_dev, (void *)st->capture_data,
271 iio_get_time_ns(indio_dev));
272
273 /*
274 * Tell the core we are done with this trigger and ready for the
275 * next one.
276 */
277 iio_trigger_notify_done(indio_dev->trig);
278
279 return IRQ_HANDLED;
280}
281
282static char *cros_ec_accel_legacy_loc_strings[] = {
283 [MOTIONSENSE_LOC_BASE] = "base",
284 [MOTIONSENSE_LOC_LID] = "lid",
285 [MOTIONSENSE_LOC_MAX] = "unknown",
286};
287
288static ssize_t cros_ec_accel_legacy_loc(struct iio_dev *indio_dev,
289 uintptr_t private,
290 const struct iio_chan_spec *chan,
291 char *buf)
292{
293 struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
294
295 return sprintf(buf, "%s\n",
296 cros_ec_accel_legacy_loc_strings[st->sensor_num +
297 MOTIONSENSE_LOC_BASE]);
298}
299
300static ssize_t cros_ec_accel_legacy_id(struct iio_dev *indio_dev,
301 uintptr_t private,
302 const struct iio_chan_spec *chan,
303 char *buf)
304{
305 struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
306
307 return sprintf(buf, "%d\n", st->sensor_num);
308}
309
310static const struct iio_chan_spec_ext_info cros_ec_accel_legacy_ext_info[] = {
311 {
312 .name = "id",
313 .shared = IIO_SHARED_BY_ALL,
314 .read = cros_ec_accel_legacy_id,
315 },
316 {
317 .name = "location",
318 .shared = IIO_SHARED_BY_ALL,
319 .read = cros_ec_accel_legacy_loc,
320 },
321 { }
322};
323
324#define CROS_EC_ACCEL_LEGACY_CHAN(_axis) \
325 { \
326 .type = IIO_ACCEL, \
327 .channel2 = IIO_MOD_X + (_axis), \
328 .modified = 1, \
329 .info_mask_separate = \
330 BIT(IIO_CHAN_INFO_RAW) | \
331 BIT(IIO_CHAN_INFO_SCALE) | \
332 BIT(IIO_CHAN_INFO_CALIBBIAS), \
333 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SCALE), \
334 .ext_info = cros_ec_accel_legacy_ext_info, \
335 .scan_type = { \
336 .sign = 's', \
337 .realbits = 16, \
338 .storagebits = 16, \
339 }, \
340 } \
341
342static struct iio_chan_spec ec_accel_channels[] = {
343 CROS_EC_ACCEL_LEGACY_CHAN(X),
344 CROS_EC_ACCEL_LEGACY_CHAN(Y),
345 CROS_EC_ACCEL_LEGACY_CHAN(Z),
346 IIO_CHAN_SOFT_TIMESTAMP(MAX_AXIS)
347};
348
349static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
350{
351 struct device *dev = &pdev->dev;
352 struct cros_ec_dev *ec = dev_get_drvdata(dev->parent);
353 struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
354 struct iio_dev *indio_dev;
355 struct cros_ec_accel_legacy_state *state;
356 int ret, i;
357
358 if (!ec || !ec->ec_dev) {
359 dev_warn(&pdev->dev, "No EC device found.\n");
360 return -EINVAL;
361 }
362
363 if (!ec->ec_dev->cmd_readmem) {
364 dev_warn(&pdev->dev, "EC does not support direct reads.\n");
365 return -EINVAL;
366 }
367
368 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*state));
369 if (!indio_dev)
370 return -ENOMEM;
371
372 platform_set_drvdata(pdev, indio_dev);
373 state = iio_priv(indio_dev);
374 state->ec = ec->ec_dev;
375 state->sensor_num = sensor_platform->sensor_num;
376
377 indio_dev->dev.parent = dev;
378 indio_dev->name = pdev->name;
379 indio_dev->channels = ec_accel_channels;
380 /*
381 * Present the channel using HTML5 standard:
382 * need to invert X and Y and invert some lid axis.
383 */
384 for (i = X ; i < MAX_AXIS; i++) {
385 switch (i) {
386 case X:
387 ec_accel_channels[X].scan_index = Y;
388 case Y:
389 ec_accel_channels[Y].scan_index = X;
390 case Z:
391 ec_accel_channels[Z].scan_index = Z;
392 }
393 if (state->sensor_num == MOTIONSENSE_LOC_LID && i != Y)
394 state->sign[i] = -1;
395 else
396 state->sign[i] = 1;
397 }
398 indio_dev->num_channels = ARRAY_SIZE(ec_accel_channels);
399 indio_dev->dev.parent = &pdev->dev;
400 indio_dev->info = &cros_ec_accel_legacy_info;
401 indio_dev->modes = INDIO_DIRECT_MODE;
402
403 ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
404 cros_ec_accel_legacy_capture,
405 NULL);
406 if (ret)
407 return ret;
408
409 return devm_iio_device_register(dev, indio_dev);
410}
411
412static struct platform_driver cros_ec_accel_platform_driver = {
413 .driver = {
414 .name = DRV_NAME,
415 },
416 .probe = cros_ec_accel_legacy_probe,
417};
418module_platform_driver(cros_ec_accel_platform_driver);
419
420MODULE_DESCRIPTION("ChromeOS EC legacy accelerometer driver");
421MODULE_AUTHOR("Gwendal Grignou <gwendal@chromium.org>");
422MODULE_LICENSE("GPL");
423MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c
index ed8343aeac9c..6c214783241c 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -88,7 +88,6 @@ static int da280_read_raw(struct iio_dev *indio_dev,
88} 88}
89 89
90static const struct iio_info da280_info = { 90static const struct iio_info da280_info = {
91 .driver_module = THIS_MODULE,
92 .read_raw = da280_read_raw, 91 .read_raw = da280_read_raw,
93}; 92};
94 93
diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index c0c1620d2a2f..aa64bca00955 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -212,7 +212,6 @@ static int da311_read_raw(struct iio_dev *indio_dev,
212} 212}
213 213
214static const struct iio_info da311_info = { 214static const struct iio_info da311_info = {
215 .driver_module = THIS_MODULE,
216 .read_raw = da311_read_raw, 215 .read_raw = da311_read_raw,
217}; 216};
218 217
diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
index 656ca8e1927f..d87e2c751475 100644
--- a/drivers/iio/accel/dmard06.c
+++ b/drivers/iio/accel/dmard06.c
@@ -124,7 +124,6 @@ static int dmard06_read_raw(struct iio_dev *indio_dev,
124} 124}
125 125
126static const struct iio_info dmard06_info = { 126static const struct iio_info dmard06_info = {
127 .driver_module = THIS_MODULE,
128 .read_raw = dmard06_read_raw, 127 .read_raw = dmard06_read_raw,
129}; 128};
130 129
diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c
index d3a28f96565c..16a7e74f5e9a 100644
--- a/drivers/iio/accel/dmard09.c
+++ b/drivers/iio/accel/dmard09.c
@@ -93,7 +93,6 @@ static int dmard09_read_raw(struct iio_dev *indio_dev,
93} 93}
94 94
95static const struct iio_info dmard09_info = { 95static const struct iio_info dmard09_info = {
96 .driver_module = THIS_MODULE,
97 .read_raw = dmard09_read_raw, 96 .read_raw = dmard09_read_raw,
98}; 97};
99 98
diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c
index b8736cc75656..9518ea00167e 100644
--- a/drivers/iio/accel/dmard10.c
+++ b/drivers/iio/accel/dmard10.c
@@ -170,7 +170,6 @@ static int dmard10_read_raw(struct iio_dev *indio_dev,
170} 170}
171 171
172static const struct iio_info dmard10_info = { 172static const struct iio_info dmard10_info = {
173 .driver_module = THIS_MODULE,
174 .read_raw = dmard10_read_raw, 173 .read_raw = dmard10_read_raw,
175}; 174};
176 175
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2238a26aba63..c066a3bdbff7 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -225,7 +225,6 @@ static int accel_3d_write_raw(struct iio_dev *indio_dev,
225} 225}
226 226
227static const struct iio_info accel_3d_info = { 227static const struct iio_info accel_3d_info = {
228 .driver_module = THIS_MODULE,
229 .read_raw = &accel_3d_read_raw, 228 .read_raw = &accel_3d_read_raw,
230 .write_raw = &accel_3d_write_raw, 229 .write_raw = &accel_3d_write_raw,
231}; 230};
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 3f968c46e667..af53a1084ee5 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -34,6 +34,13 @@
34#define KXCJK1013_DRV_NAME "kxcjk1013" 34#define KXCJK1013_DRV_NAME "kxcjk1013"
35#define KXCJK1013_IRQ_NAME "kxcjk1013_event" 35#define KXCJK1013_IRQ_NAME "kxcjk1013_event"
36 36
37#define KXTF9_REG_HP_XOUT_L 0x00
38#define KXTF9_REG_HP_XOUT_H 0x01
39#define KXTF9_REG_HP_YOUT_L 0x02
40#define KXTF9_REG_HP_YOUT_H 0x03
41#define KXTF9_REG_HP_ZOUT_L 0x04
42#define KXTF9_REG_HP_ZOUT_H 0x05
43
37#define KXCJK1013_REG_XOUT_L 0x06 44#define KXCJK1013_REG_XOUT_L 0x06
38/* 45/*
39 * From low byte X axis register, all the other addresses of Y and Z can be 46 * From low byte X axis register, all the other addresses of Y and Z can be
@@ -48,17 +55,33 @@
48 55
49#define KXCJK1013_REG_DCST_RESP 0x0C 56#define KXCJK1013_REG_DCST_RESP 0x0C
50#define KXCJK1013_REG_WHO_AM_I 0x0F 57#define KXCJK1013_REG_WHO_AM_I 0x0F
51#define KXCJK1013_REG_INT_SRC1 0x16 58#define KXTF9_REG_TILT_POS_CUR 0x10
59#define KXTF9_REG_TILT_POS_PREV 0x11
60#define KXTF9_REG_INT_SRC1 0x15
61#define KXCJK1013_REG_INT_SRC1 0x16 /* compatible, but called INT_SRC2 in KXTF9 ds */
52#define KXCJK1013_REG_INT_SRC2 0x17 62#define KXCJK1013_REG_INT_SRC2 0x17
53#define KXCJK1013_REG_STATUS_REG 0x18 63#define KXCJK1013_REG_STATUS_REG 0x18
54#define KXCJK1013_REG_INT_REL 0x1A 64#define KXCJK1013_REG_INT_REL 0x1A
55#define KXCJK1013_REG_CTRL1 0x1B 65#define KXCJK1013_REG_CTRL1 0x1B
56#define KXCJK1013_REG_CTRL2 0x1D 66#define KXTF9_REG_CTRL2 0x1C
67#define KXCJK1013_REG_CTRL2 0x1D /* mostly compatible, CTRL_REG3 in KTXF9 ds */
57#define KXCJK1013_REG_INT_CTRL1 0x1E 68#define KXCJK1013_REG_INT_CTRL1 0x1E
58#define KXCJK1013_REG_INT_CTRL2 0x1F 69#define KXCJK1013_REG_INT_CTRL2 0x1F
70#define KXTF9_REG_INT_CTRL3 0x20
59#define KXCJK1013_REG_DATA_CTRL 0x21 71#define KXCJK1013_REG_DATA_CTRL 0x21
72#define KXTF9_REG_TILT_TIMER 0x28
60#define KXCJK1013_REG_WAKE_TIMER 0x29 73#define KXCJK1013_REG_WAKE_TIMER 0x29
74#define KXTF9_REG_TDT_TIMER 0x2B
75#define KXTF9_REG_TDT_THRESH_H 0x2C
76#define KXTF9_REG_TDT_THRESH_L 0x2D
77#define KXTF9_REG_TDT_TAP_TIMER 0x2E
78#define KXTF9_REG_TDT_TOTAL_TIMER 0x2F
79#define KXTF9_REG_TDT_LATENCY_TIMER 0x30
80#define KXTF9_REG_TDT_WINDOW_TIMER 0x31
61#define KXCJK1013_REG_SELF_TEST 0x3A 81#define KXCJK1013_REG_SELF_TEST 0x3A
82#define KXTF9_REG_WAKE_THRESH 0x5A
83#define KXTF9_REG_TILT_ANGLE 0x5C
84#define KXTF9_REG_HYST_SET 0x5F
62#define KXCJK1013_REG_WAKE_THRES 0x6A 85#define KXCJK1013_REG_WAKE_THRES 0x6A
63 86
64#define KXCJK1013_REG_CTRL1_BIT_PC1 BIT(7) 87#define KXCJK1013_REG_CTRL1_BIT_PC1 BIT(7)
@@ -67,14 +90,33 @@
67#define KXCJK1013_REG_CTRL1_BIT_GSEL1 BIT(4) 90#define KXCJK1013_REG_CTRL1_BIT_GSEL1 BIT(4)
68#define KXCJK1013_REG_CTRL1_BIT_GSEL0 BIT(3) 91#define KXCJK1013_REG_CTRL1_BIT_GSEL0 BIT(3)
69#define KXCJK1013_REG_CTRL1_BIT_WUFE BIT(1) 92#define KXCJK1013_REG_CTRL1_BIT_WUFE BIT(1)
70#define KXCJK1013_REG_INT_REG1_BIT_IEA BIT(4) 93
71#define KXCJK1013_REG_INT_REG1_BIT_IEN BIT(5) 94#define KXCJK1013_REG_INT_CTRL1_BIT_IEU BIT(2) /* KXTF9 */
95#define KXCJK1013_REG_INT_CTRL1_BIT_IEL BIT(3)
96#define KXCJK1013_REG_INT_CTRL1_BIT_IEA BIT(4)
97#define KXCJK1013_REG_INT_CTRL1_BIT_IEN BIT(5)
98
99#define KXTF9_REG_TILT_BIT_LEFT_EDGE BIT(5)
100#define KXTF9_REG_TILT_BIT_RIGHT_EDGE BIT(4)
101#define KXTF9_REG_TILT_BIT_LOWER_EDGE BIT(3)
102#define KXTF9_REG_TILT_BIT_UPPER_EDGE BIT(2)
103#define KXTF9_REG_TILT_BIT_FACE_DOWN BIT(1)
104#define KXTF9_REG_TILT_BIT_FACE_UP BIT(0)
72 105
73#define KXCJK1013_DATA_MASK_12_BIT 0x0FFF 106#define KXCJK1013_DATA_MASK_12_BIT 0x0FFF
74#define KXCJK1013_MAX_STARTUP_TIME_US 100000 107#define KXCJK1013_MAX_STARTUP_TIME_US 100000
75 108
76#define KXCJK1013_SLEEP_DELAY_MS 2000 109#define KXCJK1013_SLEEP_DELAY_MS 2000
77 110
111#define KXCJK1013_REG_INT_SRC1_BIT_TPS BIT(0) /* KXTF9 */
112#define KXCJK1013_REG_INT_SRC1_BIT_WUFS BIT(1)
113#define KXCJK1013_REG_INT_SRC1_MASK_TDTS (BIT(2) | BIT(3)) /* KXTF9 */
114#define KXCJK1013_REG_INT_SRC1_TAP_NONE 0
115#define KXCJK1013_REG_INT_SRC1_TAP_SINGLE BIT(2)
116#define KXCJK1013_REG_INT_SRC1_TAP_DOUBLE BIT(3)
117#define KXCJK1013_REG_INT_SRC1_BIT_DRDY BIT(4)
118
119/* KXCJK: INT_SOURCE2: motion detect, KXTF9: INT_SRC_REG1: tap detect */
78#define KXCJK1013_REG_INT_SRC2_BIT_ZP BIT(0) 120#define KXCJK1013_REG_INT_SRC2_BIT_ZP BIT(0)
79#define KXCJK1013_REG_INT_SRC2_BIT_ZN BIT(1) 121#define KXCJK1013_REG_INT_SRC2_BIT_ZN BIT(1)
80#define KXCJK1013_REG_INT_SRC2_BIT_YP BIT(2) 122#define KXCJK1013_REG_INT_SRC2_BIT_YP BIT(2)
@@ -88,6 +130,7 @@ enum kx_chipset {
88 KXCJK1013, 130 KXCJK1013,
89 KXCJ91008, 131 KXCJ91008,
90 KXTJ21009, 132 KXTJ21009,
133 KXTF9,
91 KX_MAX_CHIPS /* this must be last */ 134 KX_MAX_CHIPS /* this must be last */
92}; 135};
93 136
@@ -128,15 +171,42 @@ enum kxcjk1013_range {
128 KXCJK1013_RANGE_8G, 171 KXCJK1013_RANGE_8G,
129}; 172};
130 173
131static const struct { 174struct kx_odr_map {
132 int val; 175 int val;
133 int val2; 176 int val2;
134 int odr_bits; 177 int odr_bits;
135} samp_freq_table[] = { {0, 781000, 0x08}, {1, 563000, 0x09}, 178 int wuf_bits;
136 {3, 125000, 0x0A}, {6, 250000, 0x0B}, {12, 500000, 0}, 179};
137 {25, 0, 0x01}, {50, 0, 0x02}, {100, 0, 0x03}, 180
138 {200, 0, 0x04}, {400, 0, 0x05}, {800, 0, 0x06}, 181static const struct kx_odr_map samp_freq_table[] = {
139 {1600, 0, 0x07} }; 182 { 0, 781000, 0x08, 0x00 },
183 { 1, 563000, 0x09, 0x01 },
184 { 3, 125000, 0x0A, 0x02 },
185 { 6, 250000, 0x0B, 0x03 },
186 { 12, 500000, 0x00, 0x04 },
187 { 25, 0, 0x01, 0x05 },
188 { 50, 0, 0x02, 0x06 },
189 { 100, 0, 0x03, 0x06 },
190 { 200, 0, 0x04, 0x06 },
191 { 400, 0, 0x05, 0x06 },
192 { 800, 0, 0x06, 0x06 },
193 { 1600, 0, 0x07, 0x06 },
194};
195
196static const char *const kxcjk1013_samp_freq_avail =
197 "0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800 1600";
198
199static const struct kx_odr_map kxtf9_samp_freq_table[] = {
200 { 25, 0, 0x01, 0x00 },
201 { 50, 0, 0x02, 0x01 },
202 { 100, 0, 0x03, 0x01 },
203 { 200, 0, 0x04, 0x01 },
204 { 400, 0, 0x05, 0x01 },
205 { 800, 0, 0x06, 0x01 },
206};
207
208static const char *const kxtf9_samp_freq_avail =
209 "25 50 100 200 400 800";
140 210
141/* Refer to section 4 of the specification */ 211/* Refer to section 4 of the specification */
142static const struct { 212static const struct {
@@ -188,6 +258,15 @@ static const struct {
188 {0x06, 3000}, 258 {0x06, 3000},
189 {0x07, 2000}, 259 {0x07, 2000},
190 }, 260 },
261 /* KXTF9 */
262 {
263 {0x01, 81000},
264 {0x02, 41000},
265 {0x03, 21000},
266 {0x04, 11000},
267 {0x05, 5100},
268 {0x06, 2700},
269 },
191}; 270};
192 271
193static const struct { 272static const struct {
@@ -198,23 +277,6 @@ static const struct {
198 {19163, 1, 0}, 277 {19163, 1, 0},
199 {38326, 0, 1} }; 278 {38326, 0, 1} };
200 279
201static const struct {
202 int val;
203 int val2;
204 int odr_bits;
205} wake_odr_data_rate_table[] = { {0, 781000, 0x00},
206 {1, 563000, 0x01},
207 {3, 125000, 0x02},
208 {6, 250000, 0x03},
209 {12, 500000, 0x04},
210 {25, 0, 0x05},
211 {50, 0, 0x06},
212 {100, 0, 0x06},
213 {200, 0, 0x06},
214 {400, 0, 0x06},
215 {800, 0, 0x06},
216 {1600, 0, 0x06} };
217
218static int kxcjk1013_set_mode(struct kxcjk1013_data *data, 280static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
219 enum kxcjk1013_mode mode) 281 enum kxcjk1013_mode mode)
220{ 282{
@@ -341,9 +403,9 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
341 } 403 }
342 404
343 if (data->active_high_intr) 405 if (data->active_high_intr)
344 ret |= KXCJK1013_REG_INT_REG1_BIT_IEA; 406 ret |= KXCJK1013_REG_INT_CTRL1_BIT_IEA;
345 else 407 else
346 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEA; 408 ret &= ~KXCJK1013_REG_INT_CTRL1_BIT_IEA;
347 409
348 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1, 410 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
349 ret); 411 ret);
@@ -401,7 +463,7 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on)
401 463
402static int kxcjk1013_chip_update_thresholds(struct kxcjk1013_data *data) 464static int kxcjk1013_chip_update_thresholds(struct kxcjk1013_data *data)
403{ 465{
404 int ret; 466 int waketh_reg, ret;
405 467
406 ret = i2c_smbus_write_byte_data(data->client, 468 ret = i2c_smbus_write_byte_data(data->client,
407 KXCJK1013_REG_WAKE_TIMER, 469 KXCJK1013_REG_WAKE_TIMER,
@@ -412,8 +474,9 @@ static int kxcjk1013_chip_update_thresholds(struct kxcjk1013_data *data)
412 return ret; 474 return ret;
413 } 475 }
414 476
415 ret = i2c_smbus_write_byte_data(data->client, 477 waketh_reg = data->chipset == KXTF9 ?
416 KXCJK1013_REG_WAKE_THRES, 478 KXTF9_REG_WAKE_THRESH : KXCJK1013_REG_WAKE_THRES;
479 ret = i2c_smbus_write_byte_data(data->client, waketh_reg,
417 data->wake_thres); 480 data->wake_thres);
418 if (ret < 0) { 481 if (ret < 0) {
419 dev_err(&data->client->dev, "Error writing reg_wake_thres\n"); 482 dev_err(&data->client->dev, "Error writing reg_wake_thres\n");
@@ -449,9 +512,9 @@ static int kxcjk1013_setup_any_motion_interrupt(struct kxcjk1013_data *data,
449 } 512 }
450 513
451 if (status) 514 if (status)
452 ret |= KXCJK1013_REG_INT_REG1_BIT_IEN; 515 ret |= KXCJK1013_REG_INT_CTRL1_BIT_IEN;
453 else 516 else
454 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEN; 517 ret &= ~KXCJK1013_REG_INT_CTRL1_BIT_IEN;
455 518
456 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1, 519 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
457 ret); 520 ret);
@@ -509,9 +572,9 @@ static int kxcjk1013_setup_new_data_interrupt(struct kxcjk1013_data *data,
509 } 572 }
510 573
511 if (status) 574 if (status)
512 ret |= KXCJK1013_REG_INT_REG1_BIT_IEN; 575 ret |= KXCJK1013_REG_INT_CTRL1_BIT_IEN;
513 else 576 else
514 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEN; 577 ret &= ~KXCJK1013_REG_INT_CTRL1_BIT_IEN;
515 578
516 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1, 579 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
517 ret); 580 ret);
@@ -547,28 +610,30 @@ static int kxcjk1013_setup_new_data_interrupt(struct kxcjk1013_data *data,
547 return 0; 610 return 0;
548} 611}
549 612
550static int kxcjk1013_convert_freq_to_bit(int val, int val2) 613static const struct kx_odr_map *kxcjk1013_find_odr_value(
614 const struct kx_odr_map *map, size_t map_size, int val, int val2)
551{ 615{
552 int i; 616 int i;
553 617
554 for (i = 0; i < ARRAY_SIZE(samp_freq_table); ++i) { 618 for (i = 0; i < map_size; ++i) {
555 if (samp_freq_table[i].val == val && 619 if (map[i].val == val && map[i].val2 == val2)
556 samp_freq_table[i].val2 == val2) { 620 return &map[i];
557 return samp_freq_table[i].odr_bits;
558 }
559 } 621 }
560 622
561 return -EINVAL; 623 return ERR_PTR(-EINVAL);
562} 624}
563 625
564static int kxcjk1013_convert_wake_odr_to_bit(int val, int val2) 626static int kxcjk1013_convert_odr_value(const struct kx_odr_map *map,
627 size_t map_size, int odr_bits,
628 int *val, int *val2)
565{ 629{
566 int i; 630 int i;
567 631
568 for (i = 0; i < ARRAY_SIZE(wake_odr_data_rate_table); ++i) { 632 for (i = 0; i < map_size; ++i) {
569 if (wake_odr_data_rate_table[i].val == val && 633 if (map[i].odr_bits == odr_bits) {
570 wake_odr_data_rate_table[i].val2 == val2) { 634 *val = map[i].val;
571 return wake_odr_data_rate_table[i].odr_bits; 635 *val2 = map[i].val2;
636 return IIO_VAL_INT_PLUS_MICRO;
572 } 637 }
573 } 638 }
574 639
@@ -578,16 +643,24 @@ static int kxcjk1013_convert_wake_odr_to_bit(int val, int val2)
578static int kxcjk1013_set_odr(struct kxcjk1013_data *data, int val, int val2) 643static int kxcjk1013_set_odr(struct kxcjk1013_data *data, int val, int val2)
579{ 644{
580 int ret; 645 int ret;
581 int odr_bits;
582 enum kxcjk1013_mode store_mode; 646 enum kxcjk1013_mode store_mode;
647 const struct kx_odr_map *odr_setting;
583 648
584 ret = kxcjk1013_get_mode(data, &store_mode); 649 ret = kxcjk1013_get_mode(data, &store_mode);
585 if (ret < 0) 650 if (ret < 0)
586 return ret; 651 return ret;
587 652
588 odr_bits = kxcjk1013_convert_freq_to_bit(val, val2); 653 if (data->chipset == KXTF9)
589 if (odr_bits < 0) 654 odr_setting = kxcjk1013_find_odr_value(kxtf9_samp_freq_table,
590 return odr_bits; 655 ARRAY_SIZE(kxtf9_samp_freq_table),
656 val, val2);
657 else
658 odr_setting = kxcjk1013_find_odr_value(samp_freq_table,
659 ARRAY_SIZE(samp_freq_table),
660 val, val2);
661
662 if (IS_ERR(odr_setting))
663 return PTR_ERR(odr_setting);
591 664
592 /* To change ODR, the chip must be set to STANDBY as per spec */ 665 /* To change ODR, the chip must be set to STANDBY as per spec */
593 ret = kxcjk1013_set_mode(data, STANDBY); 666 ret = kxcjk1013_set_mode(data, STANDBY);
@@ -595,20 +668,16 @@ static int kxcjk1013_set_odr(struct kxcjk1013_data *data, int val, int val2)
595 return ret; 668 return ret;
596 669
597 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_DATA_CTRL, 670 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_DATA_CTRL,
598 odr_bits); 671 odr_setting->odr_bits);
599 if (ret < 0) { 672 if (ret < 0) {
600 dev_err(&data->client->dev, "Error writing data_ctrl\n"); 673 dev_err(&data->client->dev, "Error writing data_ctrl\n");
601 return ret; 674 return ret;
602 } 675 }
603 676
604 data->odr_bits = odr_bits; 677 data->odr_bits = odr_setting->odr_bits;
605
606 odr_bits = kxcjk1013_convert_wake_odr_to_bit(val, val2);
607 if (odr_bits < 0)
608 return odr_bits;
609 678
610 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_CTRL2, 679 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_CTRL2,
611 odr_bits); 680 odr_setting->wuf_bits);
612 if (ret < 0) { 681 if (ret < 0) {
613 dev_err(&data->client->dev, "Error writing reg_ctrl2\n"); 682 dev_err(&data->client->dev, "Error writing reg_ctrl2\n");
614 return ret; 683 return ret;
@@ -625,17 +694,14 @@ static int kxcjk1013_set_odr(struct kxcjk1013_data *data, int val, int val2)
625 694
626static int kxcjk1013_get_odr(struct kxcjk1013_data *data, int *val, int *val2) 695static int kxcjk1013_get_odr(struct kxcjk1013_data *data, int *val, int *val2)
627{ 696{
628 int i; 697 if (data->chipset == KXTF9)
629 698 return kxcjk1013_convert_odr_value(kxtf9_samp_freq_table,
630 for (i = 0; i < ARRAY_SIZE(samp_freq_table); ++i) { 699 ARRAY_SIZE(kxtf9_samp_freq_table),
631 if (samp_freq_table[i].odr_bits == data->odr_bits) { 700 data->odr_bits, val, val2);
632 *val = samp_freq_table[i].val; 701 else
633 *val2 = samp_freq_table[i].val2; 702 return kxcjk1013_convert_odr_value(samp_freq_table,
634 return IIO_VAL_INT_PLUS_MICRO; 703 ARRAY_SIZE(samp_freq_table),
635 } 704 data->odr_bits, val, val2);
636 }
637
638 return -EINVAL;
639} 705}
640 706
641static int kxcjk1013_get_acc_reg(struct kxcjk1013_data *data, int axis) 707static int kxcjk1013_get_acc_reg(struct kxcjk1013_data *data, int axis)
@@ -886,13 +952,29 @@ static int kxcjk1013_buffer_postdisable(struct iio_dev *indio_dev)
886 return kxcjk1013_set_power_state(data, false); 952 return kxcjk1013_set_power_state(data, false);
887} 953}
888 954
889static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( 955static ssize_t kxcjk1013_get_samp_freq_avail(struct device *dev,
890 "0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800 1600"); 956 struct device_attribute *attr,
957 char *buf)
958{
959 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
960 struct kxcjk1013_data *data = iio_priv(indio_dev);
961 const char *str;
962
963 if (data->chipset == KXTF9)
964 str = kxtf9_samp_freq_avail;
965 else
966 str = kxcjk1013_samp_freq_avail;
967
968 return sprintf(buf, "%s\n", str);
969}
970
971static IIO_DEVICE_ATTR(in_accel_sampling_frequency_available, S_IRUGO,
972 kxcjk1013_get_samp_freq_avail, NULL, 0);
891 973
892static IIO_CONST_ATTR(in_accel_scale_available, "0.009582 0.019163 0.038326"); 974static IIO_CONST_ATTR(in_accel_scale_available, "0.009582 0.019163 0.038326");
893 975
894static struct attribute *kxcjk1013_attributes[] = { 976static struct attribute *kxcjk1013_attributes[] = {
895 &iio_const_attr_sampling_frequency_available.dev_attr.attr, 977 &iio_dev_attr_in_accel_sampling_frequency_available.dev_attr.attr,
896 &iio_const_attr_in_accel_scale_available.dev_attr.attr, 978 &iio_const_attr_in_accel_scale_available.dev_attr.attr,
897 NULL, 979 NULL,
898}; 980};
@@ -950,7 +1032,6 @@ static const struct iio_info kxcjk1013_info = {
950 .write_event_value = kxcjk1013_write_event, 1032 .write_event_value = kxcjk1013_write_event,
951 .write_event_config = kxcjk1013_write_event_config, 1033 .write_event_config = kxcjk1013_write_event_config,
952 .read_event_config = kxcjk1013_read_event_config, 1034 .read_event_config = kxcjk1013_read_event_config,
953 .driver_module = THIS_MODULE,
954}; 1035};
955 1036
956static const unsigned long kxcjk1013_scan_masks[] = {0x7, 0}; 1037static const unsigned long kxcjk1013_scan_masks[] = {0x7, 0};
@@ -1036,9 +1117,74 @@ static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig,
1036static const struct iio_trigger_ops kxcjk1013_trigger_ops = { 1117static const struct iio_trigger_ops kxcjk1013_trigger_ops = {
1037 .set_trigger_state = kxcjk1013_data_rdy_trigger_set_state, 1118 .set_trigger_state = kxcjk1013_data_rdy_trigger_set_state,
1038 .try_reenable = kxcjk1013_trig_try_reen, 1119 .try_reenable = kxcjk1013_trig_try_reen,
1039 .owner = THIS_MODULE,
1040}; 1120};
1041 1121
1122static void kxcjk1013_report_motion_event(struct iio_dev *indio_dev)
1123{
1124 struct kxcjk1013_data *data = iio_priv(indio_dev);
1125
1126 int ret = i2c_smbus_read_byte_data(data->client,
1127 KXCJK1013_REG_INT_SRC2);
1128 if (ret < 0) {
1129 dev_err(&data->client->dev, "Error reading reg_int_src2\n");
1130 return;
1131 }
1132
1133 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN)
1134 iio_push_event(indio_dev,
1135 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1136 0,
1137 IIO_MOD_X,
1138 IIO_EV_TYPE_THRESH,
1139 IIO_EV_DIR_FALLING),
1140 data->timestamp);
1141
1142 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP)
1143 iio_push_event(indio_dev,
1144 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1145 0,
1146 IIO_MOD_X,
1147 IIO_EV_TYPE_THRESH,
1148 IIO_EV_DIR_RISING),
1149 data->timestamp);
1150
1151 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN)
1152 iio_push_event(indio_dev,
1153 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1154 0,
1155 IIO_MOD_Y,
1156 IIO_EV_TYPE_THRESH,
1157 IIO_EV_DIR_FALLING),
1158 data->timestamp);
1159
1160 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP)
1161 iio_push_event(indio_dev,
1162 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1163 0,
1164 IIO_MOD_Y,
1165 IIO_EV_TYPE_THRESH,
1166 IIO_EV_DIR_RISING),
1167 data->timestamp);
1168
1169 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZN)
1170 iio_push_event(indio_dev,
1171 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1172 0,
1173 IIO_MOD_Z,
1174 IIO_EV_TYPE_THRESH,
1175 IIO_EV_DIR_FALLING),
1176 data->timestamp);
1177
1178 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP)
1179 iio_push_event(indio_dev,
1180 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1181 0,
1182 IIO_MOD_Z,
1183 IIO_EV_TYPE_THRESH,
1184 IIO_EV_DIR_RISING),
1185 data->timestamp);
1186}
1187
1042static irqreturn_t kxcjk1013_event_handler(int irq, void *private) 1188static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
1043{ 1189{
1044 struct iio_dev *indio_dev = private; 1190 struct iio_dev *indio_dev = private;
@@ -1051,66 +1197,17 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
1051 goto ack_intr; 1197 goto ack_intr;
1052 } 1198 }
1053 1199
1054 if (ret & 0x02) { 1200 if (ret & KXCJK1013_REG_INT_SRC1_BIT_WUFS) {
1055 ret = i2c_smbus_read_byte_data(data->client, 1201 if (data->chipset == KXTF9)
1056 KXCJK1013_REG_INT_SRC2);
1057 if (ret < 0) {
1058 dev_err(&data->client->dev,
1059 "Error reading reg_int_src2\n");
1060 goto ack_intr;
1061 }
1062
1063 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN)
1064 iio_push_event(indio_dev,
1065 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1066 0,
1067 IIO_MOD_X,
1068 IIO_EV_TYPE_THRESH,
1069 IIO_EV_DIR_FALLING),
1070 data->timestamp);
1071 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP)
1072 iio_push_event(indio_dev,
1073 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1074 0,
1075 IIO_MOD_X,
1076 IIO_EV_TYPE_THRESH,
1077 IIO_EV_DIR_RISING),
1078 data->timestamp);
1079
1080
1081 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN)
1082 iio_push_event(indio_dev,
1083 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1084 0,
1085 IIO_MOD_Y,
1086 IIO_EV_TYPE_THRESH,
1087 IIO_EV_DIR_FALLING),
1088 data->timestamp);
1089 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP)
1090 iio_push_event(indio_dev,
1091 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1092 0,
1093 IIO_MOD_Y,
1094 IIO_EV_TYPE_THRESH,
1095 IIO_EV_DIR_RISING),
1096 data->timestamp);
1097
1098 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZN)
1099 iio_push_event(indio_dev,
1100 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1101 0,
1102 IIO_MOD_Z,
1103 IIO_EV_TYPE_THRESH,
1104 IIO_EV_DIR_FALLING),
1105 data->timestamp);
1106 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP)
1107 iio_push_event(indio_dev, 1202 iio_push_event(indio_dev,
1108 IIO_MOD_EVENT_CODE(IIO_ACCEL, 1203 IIO_MOD_EVENT_CODE(IIO_ACCEL,
1109 0, 1204 0,
1110 IIO_MOD_Z, 1205 IIO_MOD_X_AND_Y_AND_Z,
1111 IIO_EV_TYPE_THRESH, 1206 IIO_EV_TYPE_THRESH,
1112 IIO_EV_DIR_RISING), 1207 IIO_EV_DIR_RISING),
1113 data->timestamp); 1208 data->timestamp);
1209 else
1210 kxcjk1013_report_motion_event(indio_dev);
1114 } 1211 }
1115 1212
1116ack_intr: 1213ack_intr:
@@ -1403,6 +1500,7 @@ static const struct i2c_device_id kxcjk1013_id[] = {
1403 {"kxcjk1013", KXCJK1013}, 1500 {"kxcjk1013", KXCJK1013},
1404 {"kxcj91008", KXCJ91008}, 1501 {"kxcj91008", KXCJ91008},
1405 {"kxtj21009", KXTJ21009}, 1502 {"kxtj21009", KXTJ21009},
1503 {"kxtf9", KXTF9},
1406 {"SMO8500", KXCJ91008}, 1504 {"SMO8500", KXCJ91008},
1407 {} 1505 {}
1408}; 1506};
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 9af60ac70738..0c0df4fce420 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -390,7 +390,6 @@ static const struct iio_info kxsd9_info = {
390 .read_raw = &kxsd9_read_raw, 390 .read_raw = &kxsd9_read_raw,
391 .write_raw = &kxsd9_write_raw, 391 .write_raw = &kxsd9_write_raw,
392 .attrs = &kxsd9_attribute_group, 392 .attrs = &kxsd9_attribute_group,
393 .driver_module = THIS_MODULE,
394}; 393};
395 394
396/* Four channels apart from timestamp, scan mask = 0x0f */ 395/* Four channels apart from timestamp, scan mask = 0x0f */
diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index 4ea2ff623a6d..8b11604eed63 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -107,7 +107,6 @@ static int mc3230_read_raw(struct iio_dev *indio_dev,
107} 107}
108 108
109static const struct iio_info mc3230_info = { 109static const struct iio_info mc3230_info = {
110 .driver_module = THIS_MODULE,
111 .read_raw = mc3230_read_raw, 110 .read_raw = mc3230_read_raw,
112}; 111};
113 112
diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index 6551085bedd7..da0ceaac46b5 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -199,7 +199,6 @@ static const struct iio_info mma7455_info = {
199 .attrs = &mma7455_group, 199 .attrs = &mma7455_group,
200 .read_raw = mma7455_read_raw, 200 .read_raw = mma7455_read_raw,
201 .write_raw = mma7455_write_raw, 201 .write_raw = mma7455_write_raw,
202 .driver_module = THIS_MODULE,
203}; 202};
204 203
205#define MMA7455_CHANNEL(axis, idx) { \ 204#define MMA7455_CHANNEL(axis, idx) { \
diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c
index 42fa57e41bdd..f1a13724efb3 100644
--- a/drivers/iio/accel/mma7660.c
+++ b/drivers/iio/accel/mma7660.c
@@ -168,7 +168,6 @@ static int mma7660_read_raw(struct iio_dev *indio_dev,
168} 168}
169 169
170static const struct iio_info mma7660_info = { 170static const struct iio_info mma7660_info = {
171 .driver_module = THIS_MODULE,
172 .read_raw = mma7660_read_raw, 171 .read_raw = mma7660_read_raw,
173 .attrs = &mma7660_attribute_group, 172 .attrs = &mma7660_attribute_group,
174}; 173};
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index eb6e3dc789b2..bfd4bc806fc2 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -59,7 +59,9 @@
59#define MMA8452_FF_MT_THS 0x17 59#define MMA8452_FF_MT_THS 0x17
60#define MMA8452_FF_MT_THS_MASK 0x7f 60#define MMA8452_FF_MT_THS_MASK 0x7f
61#define MMA8452_FF_MT_COUNT 0x18 61#define MMA8452_FF_MT_COUNT 0x18
62#define MMA8452_FF_MT_CHAN_SHIFT 3
62#define MMA8452_TRANSIENT_CFG 0x1d 63#define MMA8452_TRANSIENT_CFG 0x1d
64#define MMA8452_TRANSIENT_CFG_CHAN(chan) BIT(chan + 1)
63#define MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0) 65#define MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0)
64#define MMA8452_TRANSIENT_CFG_ELE BIT(4) 66#define MMA8452_TRANSIENT_CFG_ELE BIT(4)
65#define MMA8452_TRANSIENT_SRC 0x1e 67#define MMA8452_TRANSIENT_SRC 0x1e
@@ -69,6 +71,7 @@
69#define MMA8452_TRANSIENT_THS 0x1f 71#define MMA8452_TRANSIENT_THS 0x1f
70#define MMA8452_TRANSIENT_THS_MASK GENMASK(6, 0) 72#define MMA8452_TRANSIENT_THS_MASK GENMASK(6, 0)
71#define MMA8452_TRANSIENT_COUNT 0x20 73#define MMA8452_TRANSIENT_COUNT 0x20
74#define MMA8452_TRANSIENT_CHAN_SHIFT 1
72#define MMA8452_CTRL_REG1 0x2a 75#define MMA8452_CTRL_REG1 0x2a
73#define MMA8452_CTRL_ACTIVE BIT(0) 76#define MMA8452_CTRL_ACTIVE BIT(0)
74#define MMA8452_CTRL_DR_MASK GENMASK(5, 3) 77#define MMA8452_CTRL_DR_MASK GENMASK(5, 3)
@@ -107,6 +110,51 @@ struct mma8452_data {
107 const struct mma_chip_info *chip_info; 110 const struct mma_chip_info *chip_info;
108}; 111};
109 112
113 /**
114 * struct mma8452_event_regs - chip specific data related to events
115 * @ev_cfg: event config register address
116 * @ev_cfg_ele: latch bit in event config register
117 * @ev_cfg_chan_shift: number of the bit to enable events in X
118 * direction; in event config register
119 * @ev_src: event source register address
120 * @ev_ths: event threshold register address
121 * @ev_ths_mask: mask for the threshold value
122 * @ev_count: event count (period) register address
123 *
124 * Since not all chips supported by the driver support comparing high pass
125 * filtered data for events (interrupts), different interrupt sources are
126 * used for different chips and the relevant registers are included here.
127 */
128struct mma8452_event_regs {
129 u8 ev_cfg;
130 u8 ev_cfg_ele;
131 u8 ev_cfg_chan_shift;
132 u8 ev_src;
133 u8 ev_ths;
134 u8 ev_ths_mask;
135 u8 ev_count;
136};
137
138static const struct mma8452_event_regs ev_regs_accel_falling = {
139 .ev_cfg = MMA8452_FF_MT_CFG,
140 .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
141 .ev_cfg_chan_shift = MMA8452_FF_MT_CHAN_SHIFT,
142 .ev_src = MMA8452_FF_MT_SRC,
143 .ev_ths = MMA8452_FF_MT_THS,
144 .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
145 .ev_count = MMA8452_FF_MT_COUNT
146};
147
148static const struct mma8452_event_regs ev_regs_accel_rising = {
149 .ev_cfg = MMA8452_TRANSIENT_CFG,
150 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
151 .ev_cfg_chan_shift = MMA8452_TRANSIENT_CHAN_SHIFT,
152 .ev_src = MMA8452_TRANSIENT_SRC,
153 .ev_ths = MMA8452_TRANSIENT_THS,
154 .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
155 .ev_count = MMA8452_TRANSIENT_COUNT,
156};
157
110/** 158/**
111 * struct mma_chip_info - chip specific data 159 * struct mma_chip_info - chip specific data
112 * @chip_id: WHO_AM_I register's value 160 * @chip_id: WHO_AM_I register's value
@@ -116,40 +164,16 @@ struct mma8452_data {
116 * @mma_scales: scale factors for converting register values 164 * @mma_scales: scale factors for converting register values
117 * to m/s^2; 3 modes: 2g, 4g, 8g; 2 integers 165 * to m/s^2; 3 modes: 2g, 4g, 8g; 2 integers
118 * per mode: m/s^2 and micro m/s^2 166 * per mode: m/s^2 and micro m/s^2
119 * @ev_cfg: event config register address 167 * @all_events: all events supported by this chip
120 * @ev_cfg_ele: latch bit in event config register 168 * @enabled_events: event flags enabled and handled by this driver
121 * @ev_cfg_chan_shift: number of the bit to enable events in X
122 * direction; in event config register
123 * @ev_src: event source register address
124 * @ev_src_xe: bit in event source register that indicates
125 * an event in X direction
126 * @ev_src_ye: bit in event source register that indicates
127 * an event in Y direction
128 * @ev_src_ze: bit in event source register that indicates
129 * an event in Z direction
130 * @ev_ths: event threshold register address
131 * @ev_ths_mask: mask for the threshold value
132 * @ev_count: event count (period) register address
133 *
134 * Since not all chips supported by the driver support comparing high pass
135 * filtered data for events (interrupts), different interrupt sources are
136 * used for different chips and the relevant registers are included here.
137 */ 169 */
138struct mma_chip_info { 170struct mma_chip_info {
139 u8 chip_id; 171 u8 chip_id;
140 const struct iio_chan_spec *channels; 172 const struct iio_chan_spec *channels;
141 int num_channels; 173 int num_channels;
142 const int mma_scales[3][2]; 174 const int mma_scales[3][2];
143 u8 ev_cfg; 175 int all_events;
144 u8 ev_cfg_ele; 176 int enabled_events;
145 u8 ev_cfg_chan_shift;
146 u8 ev_src;
147 u8 ev_src_xe;
148 u8 ev_src_ye;
149 u8 ev_src_ze;
150 u8 ev_ths;
151 u8 ev_ths_mask;
152 u8 ev_count;
153}; 177};
154 178
155enum { 179enum {
@@ -394,11 +418,11 @@ static ssize_t mma8452_show_os_ratio_avail(struct device *dev,
394} 418}
395 419
396static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mma8452_show_samp_freq_avail); 420static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mma8452_show_samp_freq_avail);
397static IIO_DEVICE_ATTR(in_accel_scale_available, S_IRUGO, 421static IIO_DEVICE_ATTR(in_accel_scale_available, 0444,
398 mma8452_show_scale_avail, NULL, 0); 422 mma8452_show_scale_avail, NULL, 0);
399static IIO_DEVICE_ATTR(in_accel_filter_high_pass_3db_frequency_available, 423static IIO_DEVICE_ATTR(in_accel_filter_high_pass_3db_frequency_available,
400 S_IRUGO, mma8452_show_hp_cutoff_avail, NULL, 0); 424 0444, mma8452_show_hp_cutoff_avail, NULL, 0);
401static IIO_DEVICE_ATTR(in_accel_oversampling_ratio_available, S_IRUGO, 425static IIO_DEVICE_ATTR(in_accel_oversampling_ratio_available, 0444,
402 mma8452_show_os_ratio_avail, NULL, 0); 426 mma8452_show_os_ratio_avail, NULL, 0);
403 427
404static int mma8452_get_samp_freq_index(struct mma8452_data *data, 428static int mma8452_get_samp_freq_index(struct mma8452_data *data,
@@ -602,9 +626,8 @@ static int mma8452_set_power_mode(struct mma8452_data *data, u8 mode)
602static int mma8452_freefall_mode_enabled(struct mma8452_data *data) 626static int mma8452_freefall_mode_enabled(struct mma8452_data *data)
603{ 627{
604 int val; 628 int val;
605 const struct mma_chip_info *chip = data->chip_info;
606 629
607 val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); 630 val = i2c_smbus_read_byte_data(data->client, MMA8452_FF_MT_CFG);
608 if (val < 0) 631 if (val < 0)
609 return val; 632 return val;
610 633
@@ -614,29 +637,28 @@ static int mma8452_freefall_mode_enabled(struct mma8452_data *data)
614static int mma8452_set_freefall_mode(struct mma8452_data *data, bool state) 637static int mma8452_set_freefall_mode(struct mma8452_data *data, bool state)
615{ 638{
616 int val; 639 int val;
617 const struct mma_chip_info *chip = data->chip_info;
618 640
619 if ((state && mma8452_freefall_mode_enabled(data)) || 641 if ((state && mma8452_freefall_mode_enabled(data)) ||
620 (!state && !(mma8452_freefall_mode_enabled(data)))) 642 (!state && !(mma8452_freefall_mode_enabled(data))))
621 return 0; 643 return 0;
622 644
623 val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); 645 val = i2c_smbus_read_byte_data(data->client, MMA8452_FF_MT_CFG);
624 if (val < 0) 646 if (val < 0)
625 return val; 647 return val;
626 648
627 if (state) { 649 if (state) {
628 val |= BIT(idx_x + chip->ev_cfg_chan_shift); 650 val |= BIT(idx_x + MMA8452_FF_MT_CHAN_SHIFT);
629 val |= BIT(idx_y + chip->ev_cfg_chan_shift); 651 val |= BIT(idx_y + MMA8452_FF_MT_CHAN_SHIFT);
630 val |= BIT(idx_z + chip->ev_cfg_chan_shift); 652 val |= BIT(idx_z + MMA8452_FF_MT_CHAN_SHIFT);
631 val &= ~MMA8452_FF_MT_CFG_OAE; 653 val &= ~MMA8452_FF_MT_CFG_OAE;
632 } else { 654 } else {
633 val &= ~BIT(idx_x + chip->ev_cfg_chan_shift); 655 val &= ~BIT(idx_x + MMA8452_FF_MT_CHAN_SHIFT);
634 val &= ~BIT(idx_y + chip->ev_cfg_chan_shift); 656 val &= ~BIT(idx_y + MMA8452_FF_MT_CHAN_SHIFT);
635 val &= ~BIT(idx_z + chip->ev_cfg_chan_shift); 657 val &= ~BIT(idx_z + MMA8452_FF_MT_CHAN_SHIFT);
636 val |= MMA8452_FF_MT_CFG_OAE; 658 val |= MMA8452_FF_MT_CFG_OAE;
637 } 659 }
638 660
639 return mma8452_change_config(data, chip->ev_cfg, val); 661 return mma8452_change_config(data, MMA8452_FF_MT_CFG, val);
640} 662}
641 663
642static int mma8452_set_hp_filter_frequency(struct mma8452_data *data, 664static int mma8452_set_hp_filter_frequency(struct mma8452_data *data,
@@ -740,7 +762,37 @@ static int mma8452_write_raw(struct iio_dev *indio_dev,
740 return ret; 762 return ret;
741} 763}
742 764
743static int mma8452_read_thresh(struct iio_dev *indio_dev, 765static int mma8452_get_event_regs(struct mma8452_data *data,
766 const struct iio_chan_spec *chan, enum iio_event_direction dir,
767 const struct mma8452_event_regs **ev_reg)
768{
769 if (!chan)
770 return -EINVAL;
771
772 switch (chan->type) {
773 case IIO_ACCEL:
774 switch (dir) {
775 case IIO_EV_DIR_RISING:
776 if ((data->chip_info->all_events
777 & MMA8452_INT_TRANS) &&
778 (data->chip_info->enabled_events
779 & MMA8452_INT_TRANS))
780 *ev_reg = &ev_regs_accel_rising;
781 else
782 *ev_reg = &ev_regs_accel_falling;
783 return 0;
784 case IIO_EV_DIR_FALLING:
785 *ev_reg = &ev_regs_accel_falling;
786 return 0;
787 default:
788 return -EINVAL;
789 }
790 default:
791 return -EINVAL;
792 }
793}
794
795static int mma8452_read_event_value(struct iio_dev *indio_dev,
744 const struct iio_chan_spec *chan, 796 const struct iio_chan_spec *chan,
745 enum iio_event_type type, 797 enum iio_event_type type,
746 enum iio_event_direction dir, 798 enum iio_event_direction dir,
@@ -749,21 +801,24 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev,
749{ 801{
750 struct mma8452_data *data = iio_priv(indio_dev); 802 struct mma8452_data *data = iio_priv(indio_dev);
751 int ret, us, power_mode; 803 int ret, us, power_mode;
804 const struct mma8452_event_regs *ev_regs;
805
806 ret = mma8452_get_event_regs(data, chan, dir, &ev_regs);
807 if (ret)
808 return ret;
752 809
753 switch (info) { 810 switch (info) {
754 case IIO_EV_INFO_VALUE: 811 case IIO_EV_INFO_VALUE:
755 ret = i2c_smbus_read_byte_data(data->client, 812 ret = i2c_smbus_read_byte_data(data->client, ev_regs->ev_ths);
756 data->chip_info->ev_ths);
757 if (ret < 0) 813 if (ret < 0)
758 return ret; 814 return ret;
759 815
760 *val = ret & data->chip_info->ev_ths_mask; 816 *val = ret & ev_regs->ev_ths_mask;
761 817
762 return IIO_VAL_INT; 818 return IIO_VAL_INT;
763 819
764 case IIO_EV_INFO_PERIOD: 820 case IIO_EV_INFO_PERIOD:
765 ret = i2c_smbus_read_byte_data(data->client, 821 ret = i2c_smbus_read_byte_data(data->client, ev_regs->ev_count);
766 data->chip_info->ev_count);
767 if (ret < 0) 822 if (ret < 0)
768 return ret; 823 return ret;
769 824
@@ -800,7 +855,7 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev,
800 } 855 }
801} 856}
802 857
803static int mma8452_write_thresh(struct iio_dev *indio_dev, 858static int mma8452_write_event_value(struct iio_dev *indio_dev,
804 const struct iio_chan_spec *chan, 859 const struct iio_chan_spec *chan,
805 enum iio_event_type type, 860 enum iio_event_type type,
806 enum iio_event_direction dir, 861 enum iio_event_direction dir,
@@ -809,14 +864,18 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev,
809{ 864{
810 struct mma8452_data *data = iio_priv(indio_dev); 865 struct mma8452_data *data = iio_priv(indio_dev);
811 int ret, reg, steps; 866 int ret, reg, steps;
867 const struct mma8452_event_regs *ev_regs;
868
869 ret = mma8452_get_event_regs(data, chan, dir, &ev_regs);
870 if (ret)
871 return ret;
812 872
813 switch (info) { 873 switch (info) {
814 case IIO_EV_INFO_VALUE: 874 case IIO_EV_INFO_VALUE:
815 if (val < 0 || val > MMA8452_TRANSIENT_THS_MASK) 875 if (val < 0 || val > ev_regs->ev_ths_mask)
816 return -EINVAL; 876 return -EINVAL;
817 877
818 return mma8452_change_config(data, data->chip_info->ev_ths, 878 return mma8452_change_config(data, ev_regs->ev_ths, val);
819 val);
820 879
821 case IIO_EV_INFO_PERIOD: 880 case IIO_EV_INFO_PERIOD:
822 ret = mma8452_get_power_mode(data); 881 ret = mma8452_get_power_mode(data);
@@ -830,8 +889,7 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev,
830 if (steps < 0 || steps > 0xff) 889 if (steps < 0 || steps > 0xff)
831 return -EINVAL; 890 return -EINVAL;
832 891
833 return mma8452_change_config(data, data->chip_info->ev_count, 892 return mma8452_change_config(data, ev_regs->ev_count, steps);
834 steps);
835 893
836 case IIO_EV_INFO_HIGH_PASS_FILTER_3DB: 894 case IIO_EV_INFO_HIGH_PASS_FILTER_3DB:
837 reg = i2c_smbus_read_byte_data(data->client, 895 reg = i2c_smbus_read_byte_data(data->client,
@@ -861,23 +919,24 @@ static int mma8452_read_event_config(struct iio_dev *indio_dev,
861 enum iio_event_direction dir) 919 enum iio_event_direction dir)
862{ 920{
863 struct mma8452_data *data = iio_priv(indio_dev); 921 struct mma8452_data *data = iio_priv(indio_dev);
864 const struct mma_chip_info *chip = data->chip_info;
865 int ret; 922 int ret;
923 const struct mma8452_event_regs *ev_regs;
924
925 ret = mma8452_get_event_regs(data, chan, dir, &ev_regs);
926 if (ret)
927 return ret;
866 928
867 switch (dir) { 929 switch (dir) {
868 case IIO_EV_DIR_FALLING: 930 case IIO_EV_DIR_FALLING:
869 return mma8452_freefall_mode_enabled(data); 931 return mma8452_freefall_mode_enabled(data);
870 case IIO_EV_DIR_RISING: 932 case IIO_EV_DIR_RISING:
871 if (mma8452_freefall_mode_enabled(data))
872 return 0;
873
874 ret = i2c_smbus_read_byte_data(data->client, 933 ret = i2c_smbus_read_byte_data(data->client,
875 data->chip_info->ev_cfg); 934 ev_regs->ev_cfg);
876 if (ret < 0) 935 if (ret < 0)
877 return ret; 936 return ret;
878 937
879 return !!(ret & BIT(chan->scan_index + 938 return !!(ret & BIT(chan->scan_index +
880 chip->ev_cfg_chan_shift)); 939 ev_regs->ev_cfg_chan_shift));
881 default: 940 default:
882 return -EINVAL; 941 return -EINVAL;
883 } 942 }
@@ -890,8 +949,12 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev,
890 int state) 949 int state)
891{ 950{
892 struct mma8452_data *data = iio_priv(indio_dev); 951 struct mma8452_data *data = iio_priv(indio_dev);
893 const struct mma_chip_info *chip = data->chip_info;
894 int val, ret; 952 int val, ret;
953 const struct mma8452_event_regs *ev_regs;
954
955 ret = mma8452_get_event_regs(data, chan, dir, &ev_regs);
956 if (ret)
957 return ret;
895 958
896 ret = mma8452_set_runtime_pm_state(data->client, state); 959 ret = mma8452_set_runtime_pm_state(data->client, state);
897 if (ret) 960 if (ret)
@@ -901,28 +964,30 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev,
901 case IIO_EV_DIR_FALLING: 964 case IIO_EV_DIR_FALLING:
902 return mma8452_set_freefall_mode(data, state); 965 return mma8452_set_freefall_mode(data, state);
903 case IIO_EV_DIR_RISING: 966 case IIO_EV_DIR_RISING:
904 val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); 967 val = i2c_smbus_read_byte_data(data->client, ev_regs->ev_cfg);
905 if (val < 0) 968 if (val < 0)
906 return val; 969 return val;
907 970
908 if (state) { 971 if (state) {
909 if (mma8452_freefall_mode_enabled(data)) { 972 if (mma8452_freefall_mode_enabled(data)) {
910 val &= ~BIT(idx_x + chip->ev_cfg_chan_shift); 973 val &= ~BIT(idx_x + ev_regs->ev_cfg_chan_shift);
911 val &= ~BIT(idx_y + chip->ev_cfg_chan_shift); 974 val &= ~BIT(idx_y + ev_regs->ev_cfg_chan_shift);
912 val &= ~BIT(idx_z + chip->ev_cfg_chan_shift); 975 val &= ~BIT(idx_z + ev_regs->ev_cfg_chan_shift);
913 val |= MMA8452_FF_MT_CFG_OAE; 976 val |= MMA8452_FF_MT_CFG_OAE;
914 } 977 }
915 val |= BIT(chan->scan_index + chip->ev_cfg_chan_shift); 978 val |= BIT(chan->scan_index +
979 ev_regs->ev_cfg_chan_shift);
916 } else { 980 } else {
917 if (mma8452_freefall_mode_enabled(data)) 981 if (mma8452_freefall_mode_enabled(data))
918 return 0; 982 return 0;
919 983
920 val &= ~BIT(chan->scan_index + chip->ev_cfg_chan_shift); 984 val &= ~BIT(chan->scan_index +
985 ev_regs->ev_cfg_chan_shift);
921 } 986 }
922 987
923 val |= chip->ev_cfg_ele; 988 val |= ev_regs->ev_cfg_ele;
924 989
925 return mma8452_change_config(data, chip->ev_cfg, val); 990 return mma8452_change_config(data, ev_regs->ev_cfg, val);
926 default: 991 default:
927 return -EINVAL; 992 return -EINVAL;
928 } 993 }
@@ -934,35 +999,25 @@ static void mma8452_transient_interrupt(struct iio_dev *indio_dev)
934 s64 ts = iio_get_time_ns(indio_dev); 999 s64 ts = iio_get_time_ns(indio_dev);
935 int src; 1000 int src;
936 1001
937 src = i2c_smbus_read_byte_data(data->client, data->chip_info->ev_src); 1002 src = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC);
938 if (src < 0) 1003 if (src < 0)
939 return; 1004 return;
940 1005
941 if (mma8452_freefall_mode_enabled(data)) { 1006 if (src & MMA8452_TRANSIENT_SRC_XTRANSE)
942 iio_push_event(indio_dev,
943 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
944 IIO_MOD_X_AND_Y_AND_Z,
945 IIO_EV_TYPE_MAG,
946 IIO_EV_DIR_FALLING),
947 ts);
948 return;
949 }
950
951 if (src & data->chip_info->ev_src_xe)
952 iio_push_event(indio_dev, 1007 iio_push_event(indio_dev,
953 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, 1008 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X,
954 IIO_EV_TYPE_MAG, 1009 IIO_EV_TYPE_MAG,
955 IIO_EV_DIR_RISING), 1010 IIO_EV_DIR_RISING),
956 ts); 1011 ts);
957 1012
958 if (src & data->chip_info->ev_src_ye) 1013 if (src & MMA8452_TRANSIENT_SRC_YTRANSE)
959 iio_push_event(indio_dev, 1014 iio_push_event(indio_dev,
960 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, 1015 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y,
961 IIO_EV_TYPE_MAG, 1016 IIO_EV_TYPE_MAG,
962 IIO_EV_DIR_RISING), 1017 IIO_EV_DIR_RISING),
963 ts); 1018 ts);
964 1019
965 if (src & data->chip_info->ev_src_ze) 1020 if (src & MMA8452_TRANSIENT_SRC_ZTRANSE)
966 iio_push_event(indio_dev, 1021 iio_push_event(indio_dev,
967 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, 1022 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z,
968 IIO_EV_TYPE_MAG, 1023 IIO_EV_TYPE_MAG,
@@ -974,7 +1029,6 @@ static irqreturn_t mma8452_interrupt(int irq, void *p)
974{ 1029{
975 struct iio_dev *indio_dev = p; 1030 struct iio_dev *indio_dev = p;
976 struct mma8452_data *data = iio_priv(indio_dev); 1031 struct mma8452_data *data = iio_priv(indio_dev);
977 const struct mma_chip_info *chip = data->chip_info;
978 int ret = IRQ_NONE; 1032 int ret = IRQ_NONE;
979 int src; 1033 int src;
980 1034
@@ -982,15 +1036,29 @@ static irqreturn_t mma8452_interrupt(int irq, void *p)
982 if (src < 0) 1036 if (src < 0)
983 return IRQ_NONE; 1037 return IRQ_NONE;
984 1038
1039 if (!(src & data->chip_info->enabled_events))
1040 return IRQ_NONE;
1041
985 if (src & MMA8452_INT_DRDY) { 1042 if (src & MMA8452_INT_DRDY) {
986 iio_trigger_poll_chained(indio_dev->trig); 1043 iio_trigger_poll_chained(indio_dev->trig);
987 ret = IRQ_HANDLED; 1044 ret = IRQ_HANDLED;
988 } 1045 }
989 1046
990 if ((src & MMA8452_INT_TRANS && 1047 if (src & MMA8452_INT_FF_MT) {
991 chip->ev_src == MMA8452_TRANSIENT_SRC) || 1048 if (mma8452_freefall_mode_enabled(data)) {
992 (src & MMA8452_INT_FF_MT && 1049 s64 ts = iio_get_time_ns(indio_dev);
993 chip->ev_src == MMA8452_FF_MT_SRC)) { 1050
1051 iio_push_event(indio_dev,
1052 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
1053 IIO_MOD_X_AND_Y_AND_Z,
1054 IIO_EV_TYPE_MAG,
1055 IIO_EV_DIR_FALLING),
1056 ts);
1057 }
1058 ret = IRQ_HANDLED;
1059 }
1060
1061 if (src & MMA8452_INT_TRANS) {
994 mma8452_transient_interrupt(indio_dev); 1062 mma8452_transient_interrupt(indio_dev);
995 ret = IRQ_HANDLED; 1063 ret = IRQ_HANDLED;
996 } 1064 }
@@ -1020,8 +1088,8 @@ done:
1020} 1088}
1021 1089
1022static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, 1090static int mma8452_reg_access_dbg(struct iio_dev *indio_dev,
1023 unsigned reg, unsigned writeval, 1091 unsigned int reg, unsigned int writeval,
1024 unsigned *readval) 1092 unsigned int *readval)
1025{ 1093{
1026 int ret; 1094 int ret;
1027 struct mma8452_data *data = iio_priv(indio_dev); 1095 struct mma8452_data *data = iio_priv(indio_dev);
@@ -1222,96 +1290,87 @@ static const struct mma_chip_info mma_chip_info_table[] = {
1222 * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665 1290 * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
1223 */ 1291 */
1224 .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} }, 1292 .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} },
1225 .ev_cfg = MMA8452_TRANSIENT_CFG, 1293 /*
1226 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, 1294 * Although we enable the interrupt sources once and for
1227 .ev_cfg_chan_shift = 1, 1295 * all here the event detection itself is not enabled until
1228 .ev_src = MMA8452_TRANSIENT_SRC, 1296 * userspace asks for it by mma8452_write_event_config()
1229 .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, 1297 */
1230 .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, 1298 .all_events = MMA8452_INT_DRDY |
1231 .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, 1299 MMA8452_INT_TRANS |
1232 .ev_ths = MMA8452_TRANSIENT_THS, 1300 MMA8452_INT_FF_MT,
1233 .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, 1301 .enabled_events = MMA8452_INT_TRANS |
1234 .ev_count = MMA8452_TRANSIENT_COUNT, 1302 MMA8452_INT_FF_MT,
1235 }, 1303 },
1236 [mma8452] = { 1304 [mma8452] = {
1237 .chip_id = MMA8452_DEVICE_ID, 1305 .chip_id = MMA8452_DEVICE_ID,
1238 .channels = mma8452_channels, 1306 .channels = mma8452_channels,
1239 .num_channels = ARRAY_SIZE(mma8452_channels), 1307 .num_channels = ARRAY_SIZE(mma8452_channels),
1240 .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} }, 1308 .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} },
1241 .ev_cfg = MMA8452_TRANSIENT_CFG, 1309 /*
1242 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, 1310 * Although we enable the interrupt sources once and for
1243 .ev_cfg_chan_shift = 1, 1311 * all here the event detection itself is not enabled until
1244 .ev_src = MMA8452_TRANSIENT_SRC, 1312 * userspace asks for it by mma8452_write_event_config()
1245 .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, 1313 */
1246 .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, 1314 .all_events = MMA8452_INT_DRDY |
1247 .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, 1315 MMA8452_INT_TRANS |
1248 .ev_ths = MMA8452_TRANSIENT_THS, 1316 MMA8452_INT_FF_MT,
1249 .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, 1317 .enabled_events = MMA8452_INT_TRANS |
1250 .ev_count = MMA8452_TRANSIENT_COUNT, 1318 MMA8452_INT_FF_MT,
1251 }, 1319 },
1252 [mma8453] = { 1320 [mma8453] = {
1253 .chip_id = MMA8453_DEVICE_ID, 1321 .chip_id = MMA8453_DEVICE_ID,
1254 .channels = mma8453_channels, 1322 .channels = mma8453_channels,
1255 .num_channels = ARRAY_SIZE(mma8453_channels), 1323 .num_channels = ARRAY_SIZE(mma8453_channels),
1256 .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} }, 1324 .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} },
1257 .ev_cfg = MMA8452_TRANSIENT_CFG, 1325 /*
1258 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, 1326 * Although we enable the interrupt sources once and for
1259 .ev_cfg_chan_shift = 1, 1327 * all here the event detection itself is not enabled until
1260 .ev_src = MMA8452_TRANSIENT_SRC, 1328 * userspace asks for it by mma8452_write_event_config()
1261 .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, 1329 */
1262 .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, 1330 .all_events = MMA8452_INT_DRDY |
1263 .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, 1331 MMA8452_INT_TRANS |
1264 .ev_ths = MMA8452_TRANSIENT_THS, 1332 MMA8452_INT_FF_MT,
1265 .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, 1333 .enabled_events = MMA8452_INT_TRANS |
1266 .ev_count = MMA8452_TRANSIENT_COUNT, 1334 MMA8452_INT_FF_MT,
1267 }, 1335 },
1268 [mma8652] = { 1336 [mma8652] = {
1269 .chip_id = MMA8652_DEVICE_ID, 1337 .chip_id = MMA8652_DEVICE_ID,
1270 .channels = mma8652_channels, 1338 .channels = mma8652_channels,
1271 .num_channels = ARRAY_SIZE(mma8652_channels), 1339 .num_channels = ARRAY_SIZE(mma8652_channels),
1272 .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} }, 1340 .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} },
1273 .ev_cfg = MMA8452_FF_MT_CFG, 1341 .all_events = MMA8452_INT_DRDY |
1274 .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE, 1342 MMA8452_INT_FF_MT,
1275 .ev_cfg_chan_shift = 3, 1343 .enabled_events = MMA8452_INT_FF_MT,
1276 .ev_src = MMA8452_FF_MT_SRC,
1277 .ev_src_xe = MMA8452_FF_MT_SRC_XHE,
1278 .ev_src_ye = MMA8452_FF_MT_SRC_YHE,
1279 .ev_src_ze = MMA8452_FF_MT_SRC_ZHE,
1280 .ev_ths = MMA8452_FF_MT_THS,
1281 .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
1282 .ev_count = MMA8452_FF_MT_COUNT,
1283 }, 1344 },
1284 [mma8653] = { 1345 [mma8653] = {
1285 .chip_id = MMA8653_DEVICE_ID, 1346 .chip_id = MMA8653_DEVICE_ID,
1286 .channels = mma8653_channels, 1347 .channels = mma8653_channels,
1287 .num_channels = ARRAY_SIZE(mma8653_channels), 1348 .num_channels = ARRAY_SIZE(mma8653_channels),
1288 .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} }, 1349 .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} },
1289 .ev_cfg = MMA8452_FF_MT_CFG, 1350 /*
1290 .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE, 1351 * Although we enable the interrupt sources once and for
1291 .ev_cfg_chan_shift = 3, 1352 * all here the event detection itself is not enabled until
1292 .ev_src = MMA8452_FF_MT_SRC, 1353 * userspace asks for it by mma8452_write_event_config()
1293 .ev_src_xe = MMA8452_FF_MT_SRC_XHE, 1354 */
1294 .ev_src_ye = MMA8452_FF_MT_SRC_YHE, 1355 .all_events = MMA8452_INT_DRDY |
1295 .ev_src_ze = MMA8452_FF_MT_SRC_ZHE, 1356 MMA8452_INT_FF_MT,
1296 .ev_ths = MMA8452_FF_MT_THS, 1357 .enabled_events = MMA8452_INT_FF_MT,
1297 .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
1298 .ev_count = MMA8452_FF_MT_COUNT,
1299 }, 1358 },
1300 [fxls8471] = { 1359 [fxls8471] = {
1301 .chip_id = FXLS8471_DEVICE_ID, 1360 .chip_id = FXLS8471_DEVICE_ID,
1302 .channels = mma8451_channels, 1361 .channels = mma8451_channels,
1303 .num_channels = ARRAY_SIZE(mma8451_channels), 1362 .num_channels = ARRAY_SIZE(mma8451_channels),
1304 .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} }, 1363 .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} },
1305 .ev_cfg = MMA8452_TRANSIENT_CFG, 1364 /*
1306 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, 1365 * Although we enable the interrupt sources once and for
1307 .ev_cfg_chan_shift = 1, 1366 * all here the event detection itself is not enabled until
1308 .ev_src = MMA8452_TRANSIENT_SRC, 1367 * userspace asks for it by mma8452_write_event_config()
1309 .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, 1368 */
1310 .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, 1369 .all_events = MMA8452_INT_DRDY |
1311 .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, 1370 MMA8452_INT_TRANS |
1312 .ev_ths = MMA8452_TRANSIENT_THS, 1371 MMA8452_INT_FF_MT,
1313 .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, 1372 .enabled_events = MMA8452_INT_TRANS |
1314 .ev_count = MMA8452_TRANSIENT_COUNT, 1373 MMA8452_INT_FF_MT,
1315 }, 1374 },
1316}; 1375};
1317 1376
@@ -1332,12 +1391,11 @@ static const struct iio_info mma8452_info = {
1332 .read_raw = &mma8452_read_raw, 1391 .read_raw = &mma8452_read_raw,
1333 .write_raw = &mma8452_write_raw, 1392 .write_raw = &mma8452_write_raw,
1334 .event_attrs = &mma8452_event_attribute_group, 1393 .event_attrs = &mma8452_event_attribute_group,
1335 .read_event_value = &mma8452_read_thresh, 1394 .read_event_value = &mma8452_read_event_value,
1336 .write_event_value = &mma8452_write_thresh, 1395 .write_event_value = &mma8452_write_event_value,
1337 .read_event_config = &mma8452_read_event_config, 1396 .read_event_config = &mma8452_read_event_config,
1338 .write_event_config = &mma8452_write_event_config, 1397 .write_event_config = &mma8452_write_event_config,
1339 .debugfs_reg_access = &mma8452_reg_access_dbg, 1398 .debugfs_reg_access = &mma8452_reg_access_dbg,
1340 .driver_module = THIS_MODULE,
1341}; 1399};
1342 1400
1343static const unsigned long mma8452_scan_masks[] = {0x7, 0}; 1401static const unsigned long mma8452_scan_masks[] = {0x7, 0};
@@ -1368,7 +1426,6 @@ static int mma8452_data_rdy_trigger_set_state(struct iio_trigger *trig,
1368static const struct iio_trigger_ops mma8452_trigger_ops = { 1426static const struct iio_trigger_ops mma8452_trigger_ops = {
1369 .set_trigger_state = mma8452_data_rdy_trigger_set_state, 1427 .set_trigger_state = mma8452_data_rdy_trigger_set_state,
1370 .validate_device = iio_trigger_validate_own_device, 1428 .validate_device = iio_trigger_validate_own_device,
1371 .owner = THIS_MODULE,
1372}; 1429};
1373 1430
1374static int mma8452_trigger_setup(struct iio_dev *indio_dev) 1431static int mma8452_trigger_setup(struct iio_dev *indio_dev)
@@ -1509,16 +1566,6 @@ static int mma8452_probe(struct i2c_client *client,
1509 return ret; 1566 return ret;
1510 1567
1511 if (client->irq) { 1568 if (client->irq) {
1512 /*
1513 * Although we enable the interrupt sources once and for
1514 * all here the event detection itself is not enabled until
1515 * userspace asks for it by mma8452_write_event_config()
1516 */
1517 int supported_interrupts = MMA8452_INT_DRDY |
1518 MMA8452_INT_TRANS |
1519 MMA8452_INT_FF_MT;
1520 int enabled_interrupts = MMA8452_INT_TRANS |
1521 MMA8452_INT_FF_MT;
1522 int irq2; 1569 int irq2;
1523 1570
1524 irq2 = of_irq_get_byname(client->dev.of_node, "INT2"); 1571 irq2 = of_irq_get_byname(client->dev.of_node, "INT2");
@@ -1527,8 +1574,8 @@ static int mma8452_probe(struct i2c_client *client,
1527 dev_dbg(&client->dev, "using interrupt line INT2\n"); 1574 dev_dbg(&client->dev, "using interrupt line INT2\n");
1528 } else { 1575 } else {
1529 ret = i2c_smbus_write_byte_data(client, 1576 ret = i2c_smbus_write_byte_data(client,
1530 MMA8452_CTRL_REG5, 1577 MMA8452_CTRL_REG5,
1531 supported_interrupts); 1578 data->chip_info->all_events);
1532 if (ret < 0) 1579 if (ret < 0)
1533 return ret; 1580 return ret;
1534 1581
@@ -1536,8 +1583,8 @@ static int mma8452_probe(struct i2c_client *client,
1536 } 1583 }
1537 1584
1538 ret = i2c_smbus_write_byte_data(client, 1585 ret = i2c_smbus_write_byte_data(client,
1539 MMA8452_CTRL_REG4, 1586 MMA8452_CTRL_REG4,
1540 enabled_interrupts); 1587 data->chip_info->enabled_events);
1541 if (ret < 0) 1588 if (ret < 0)
1542 return ret; 1589 return ret;
1543 1590
diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 1f53f08476f5..da7c21504f38 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -332,7 +332,6 @@ static const struct iio_chan_spec mma9551_channels[] = {
332}; 332};
333 333
334static const struct iio_info mma9551_info = { 334static const struct iio_info mma9551_info = {
335 .driver_module = THIS_MODULE,
336 .read_raw = mma9551_read_raw, 335 .read_raw = mma9551_read_raw,
337 .read_event_config = mma9551_read_event_config, 336 .read_event_config = mma9551_read_event_config,
338 .write_event_config = mma9551_write_event_config, 337 .write_event_config = mma9551_write_event_config,
diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index 36bf19733be0..b52a3f182190 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -987,7 +987,6 @@ static const struct iio_chan_spec mma9553_channels[] = {
987}; 987};
988 988
989static const struct iio_info mma9553_info = { 989static const struct iio_info mma9553_info = {
990 .driver_module = THIS_MODULE,
991 .read_raw = mma9553_read_raw, 990 .read_raw = mma9553_read_raw,
992 .write_raw = mma9553_write_raw, 991 .write_raw = mma9553_write_raw,
993 .read_event_config = mma9553_read_event_config, 992 .read_event_config = mma9553_read_event_config,
diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
index c23f47af7256..58099e40d717 100644
--- a/drivers/iio/accel/mxc4005.c
+++ b/drivers/iio/accel/mxc4005.c
@@ -264,7 +264,6 @@ static int mxc4005_write_raw(struct iio_dev *indio_dev,
264} 264}
265 265
266static const struct iio_info mxc4005_info = { 266static const struct iio_info mxc4005_info = {
267 .driver_module = THIS_MODULE,
268 .read_raw = mxc4005_read_raw, 267 .read_raw = mxc4005_read_raw,
269 .write_raw = mxc4005_write_raw, 268 .write_raw = mxc4005_write_raw,
270 .attrs = &mxc4005_attrs_group, 269 .attrs = &mxc4005_attrs_group,
@@ -376,7 +375,6 @@ static int mxc4005_trigger_try_reen(struct iio_trigger *trig)
376static const struct iio_trigger_ops mxc4005_trigger_ops = { 375static const struct iio_trigger_ops mxc4005_trigger_ops = {
377 .set_trigger_state = mxc4005_set_trigger_state, 376 .set_trigger_state = mxc4005_set_trigger_state,
378 .try_reenable = mxc4005_trigger_try_reen, 377 .try_reenable = mxc4005_trigger_try_reen,
379 .owner = THIS_MODULE,
380}; 378};
381 379
382static int mxc4005_chip_init(struct mxc4005_data *data) 380static int mxc4005_chip_init(struct mxc4005_data *data)
diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
index 0abad6948201..ddd50d1781c5 100644
--- a/drivers/iio/accel/mxc6255.c
+++ b/drivers/iio/accel/mxc6255.c
@@ -78,7 +78,6 @@ static int mxc6255_read_raw(struct iio_dev *indio_dev,
78} 78}
79 79
80static const struct iio_info mxc6255_info = { 80static const struct iio_info mxc6255_info = {
81 .driver_module = THIS_MODULE,
82 .read_raw = mxc6255_read_raw, 81 .read_raw = mxc6255_read_raw,
83}; 82};
84 83
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 39ab210c44f6..f33dadf7b262 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1454,7 +1454,6 @@ static const struct iio_info sca3000_info = {
1454 .write_event_value = &sca3000_write_event_value, 1454 .write_event_value = &sca3000_write_event_value,
1455 .read_event_config = &sca3000_read_event_config, 1455 .read_event_config = &sca3000_read_event_config,
1456 .write_event_config = &sca3000_write_event_config, 1456 .write_event_config = &sca3000_write_event_config,
1457 .driver_module = THIS_MODULE,
1458}; 1457};
1459 1458
1460static int sca3000_probe(struct spi_device *spi) 1459static int sca3000_probe(struct spi_device *spi)
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 0fe521609a3a..2f931e4837e5 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -32,6 +32,8 @@ enum st_accel_type {
32 H3LIS331DL, 32 H3LIS331DL,
33 LIS331DL, 33 LIS331DL,
34 LIS3LV02DL, 34 LIS3LV02DL,
35 LIS2DW12,
36 LIS3DHH,
35 ST_ACCEL_MAX, 37 ST_ACCEL_MAX,
36}; 38};
37 39
@@ -52,6 +54,8 @@ enum st_accel_type {
52#define LIS2DH12_ACCEL_DEV_NAME "lis2dh12_accel" 54#define LIS2DH12_ACCEL_DEV_NAME "lis2dh12_accel"
53#define LIS3L02DQ_ACCEL_DEV_NAME "lis3l02dq" 55#define LIS3L02DQ_ACCEL_DEV_NAME "lis3l02dq"
54#define LNG2DM_ACCEL_DEV_NAME "lng2dm" 56#define LNG2DM_ACCEL_DEV_NAME "lng2dm"
57#define LIS2DW12_ACCEL_DEV_NAME "lis2dw12"
58#define LIS3DHH_ACCEL_DEV_NAME "lis3dhh"
55 59
56/** 60/**
57* struct st_sensors_platform_data - default accel platform data 61* struct st_sensors_platform_data - default accel platform data
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 752856b3a849..460aa58e0159 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -159,12 +159,16 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
159 .mask = 0x80, 159 .mask = 0x80,
160 }, 160 },
161 .drdy_irq = { 161 .drdy_irq = {
162 .addr = 0x22, 162 .int1 = {
163 .mask_int1 = 0x10, 163 .addr = 0x22,
164 .mask_int2 = 0x00, 164 .mask = 0x10,
165 },
165 .addr_ihl = 0x25, 166 .addr_ihl = 0x25,
166 .mask_ihl = 0x02, 167 .mask_ihl = 0x02,
167 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 168 .stat_drdy = {
169 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
170 .mask = 0x07,
171 },
168 }, 172 },
169 .sim = { 173 .sim = {
170 .addr = 0x23, 174 .addr = 0x23,
@@ -229,14 +233,24 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
229 .mask = 0x80, 233 .mask = 0x80,
230 }, 234 },
231 .drdy_irq = { 235 .drdy_irq = {
232 .addr = 0x22, 236 .int1 = {
233 .mask_int1 = 0x02, 237 .addr = 0x22,
234 .mask_int2 = 0x10, 238 .mask = 0x02,
239 .addr_od = 0x22,
240 .mask_od = 0x40,
241 },
242 .int2 = {
243 .addr = 0x22,
244 .mask = 0x10,
245 .addr_od = 0x22,
246 .mask_od = 0x40,
247 },
235 .addr_ihl = 0x22, 248 .addr_ihl = 0x22,
236 .mask_ihl = 0x80, 249 .mask_ihl = 0x80,
237 .addr_od = 0x22, 250 .stat_drdy = {
238 .mask_od = 0x40, 251 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
239 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 252 .mask = 0x07,
253 },
240 }, 254 },
241 .sim = { 255 .sim = {
242 .addr = 0x23, 256 .addr = 0x23,
@@ -313,12 +327,16 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
313 .mask = 0x08, 327 .mask = 0x08,
314 }, 328 },
315 .drdy_irq = { 329 .drdy_irq = {
316 .addr = 0x23, 330 .int1 = {
317 .mask_int1 = 0x80, 331 .addr = 0x23,
318 .mask_int2 = 0x00, 332 .mask = 0x80,
333 },
319 .addr_ihl = 0x23, 334 .addr_ihl = 0x23,
320 .mask_ihl = 0x40, 335 .mask_ihl = 0x40,
321 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 336 .stat_drdy = {
337 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
338 .mask = 0x07,
339 },
322 .ig1 = { 340 .ig1 = {
323 .en_addr = 0x23, 341 .en_addr = 0x23,
324 .en_mask = 0x08, 342 .en_mask = 0x08,
@@ -387,9 +405,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
387 .mask = 0x01, 405 .mask = 0x01,
388 }, 406 },
389 .drdy_irq = { 407 .drdy_irq = {
390 .addr = 0x21, 408 .int1 = {
391 .mask_int1 = 0x04, 409 .addr = 0x21,
392 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 410 .mask = 0x04,
411 },
412 .stat_drdy = {
413 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
414 .mask = 0x07,
415 },
393 }, 416 },
394 .sim = { 417 .sim = {
395 .addr = 0x21, 418 .addr = 0x21,
@@ -444,14 +467,24 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
444 }, 467 },
445 }, 468 },
446 .drdy_irq = { 469 .drdy_irq = {
447 .addr = 0x22, 470 .int1 = {
448 .mask_int1 = 0x04, 471 .addr = 0x22,
449 .mask_int2 = 0x20, 472 .mask = 0x04,
473 .addr_od = 0x22,
474 .mask_od = 0x40,
475 },
476 .int2 = {
477 .addr = 0x22,
478 .mask = 0x20,
479 .addr_od = 0x22,
480 .mask_od = 0x40,
481 },
450 .addr_ihl = 0x22, 482 .addr_ihl = 0x22,
451 .mask_ihl = 0x80, 483 .mask_ihl = 0x80,
452 .addr_od = 0x22, 484 .stat_drdy = {
453 .mask_od = 0x40, 485 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
454 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 486 .mask = 0x07,
487 },
455 }, 488 },
456 .sim = { 489 .sim = {
457 .addr = 0x21, 490 .addr = 0x21,
@@ -513,9 +546,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
513 .mask = 0x80, 546 .mask = 0x80,
514 }, 547 },
515 .drdy_irq = { 548 .drdy_irq = {
516 .addr = 0x22, 549 .int1 = {
517 .mask_int1 = 0x02, 550 .addr = 0x22,
518 .mask_int2 = 0x10, 551 .mask = 0x02,
552 },
553 .int2 = {
554 .addr = 0x22,
555 .mask = 0x10,
556 },
519 .addr_ihl = 0x22, 557 .addr_ihl = 0x22,
520 .mask_ihl = 0x80, 558 .mask_ihl = 0x80,
521 }, 559 },
@@ -567,9 +605,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
567 .bdu = { 605 .bdu = {
568 }, 606 },
569 .drdy_irq = { 607 .drdy_irq = {
570 .addr = 0x21, 608 .int1 = {
571 .mask_int1 = 0x04, 609 .addr = 0x21,
572 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 610 .mask = 0x04,
611 },
612 .stat_drdy = {
613 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
614 .mask = 0x07,
615 },
573 }, 616 },
574 .sim = { 617 .sim = {
575 .addr = 0x21, 618 .addr = 0x21,
@@ -635,12 +678,16 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
635 }, 678 },
636 }, 679 },
637 .drdy_irq = { 680 .drdy_irq = {
638 .addr = 0x22, 681 .int1 = {
639 .mask_int1 = 0x10, 682 .addr = 0x22,
640 .mask_int2 = 0x00, 683 .mask = 0x10,
684 },
641 .addr_ihl = 0x25, 685 .addr_ihl = 0x25,
642 .mask_ihl = 0x02, 686 .mask_ihl = 0x02,
643 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 687 .stat_drdy = {
688 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
689 .mask = 0x07,
690 },
644 }, 691 },
645 .sim = { 692 .sim = {
646 .addr = 0x23, 693 .addr = 0x23,
@@ -649,6 +696,139 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
649 .multi_read_bit = true, 696 .multi_read_bit = true,
650 .bootime = 2, 697 .bootime = 2,
651 }, 698 },
699 {
700 .wai = 0x44,
701 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
702 .sensors_supported = {
703 [0] = LIS2DW12_ACCEL_DEV_NAME,
704 },
705 .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
706 .odr = {
707 .addr = 0x20,
708 .mask = 0xf0,
709 .odr_avl = {
710 { .hz = 1, .value = 0x01, },
711 { .hz = 12, .value = 0x02, },
712 { .hz = 25, .value = 0x03, },
713 { .hz = 50, .value = 0x04, },
714 { .hz = 100, .value = 0x05, },
715 { .hz = 200, .value = 0x06, },
716 },
717 },
718 .pw = {
719 .addr = 0x20,
720 .mask = 0xf0,
721 .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
722 },
723 .fs = {
724 .addr = 0x25,
725 .mask = 0x30,
726 .fs_avl = {
727 [0] = {
728 .num = ST_ACCEL_FS_AVL_2G,
729 .value = 0x00,
730 .gain = IIO_G_TO_M_S_2(976),
731 },
732 [1] = {
733 .num = ST_ACCEL_FS_AVL_4G,
734 .value = 0x01,
735 .gain = IIO_G_TO_M_S_2(1952),
736 },
737 [2] = {
738 .num = ST_ACCEL_FS_AVL_8G,
739 .value = 0x02,
740 .gain = IIO_G_TO_M_S_2(3904),
741 },
742 [3] = {
743 .num = ST_ACCEL_FS_AVL_16G,
744 .value = 0x03,
745 .gain = IIO_G_TO_M_S_2(7808),
746 },
747 },
748 },
749 .bdu = {
750 .addr = 0x21,
751 .mask = 0x08,
752 },
753 .drdy_irq = {
754 .int1 = {
755 .addr = 0x23,
756 .mask = 0x01,
757 .addr_od = 0x22,
758 .mask_od = 0x20,
759 },
760 .int2 = {
761 .addr = 0x24,
762 .mask = 0x01,
763 .addr_od = 0x22,
764 .mask_od = 0x20,
765 },
766 .addr_ihl = 0x22,
767 .mask_ihl = 0x08,
768 .stat_drdy = {
769 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
770 .mask = 0x01,
771 },
772 },
773 .sim = {
774 .addr = 0x21,
775 .value = BIT(0),
776 },
777 .multi_read_bit = false,
778 .bootime = 2,
779 },
780 {
781 .wai = 0x11,
782 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
783 .sensors_supported = {
784 [0] = LIS3DHH_ACCEL_DEV_NAME,
785 },
786 .ch = (struct iio_chan_spec *)st_accel_16bit_channels,
787 .odr = {
788 /* just ODR = 1100Hz available */
789 .odr_avl = {
790 { .hz = 1100, .value = 0x00, },
791 },
792 },
793 .pw = {
794 .addr = 0x20,
795 .mask = 0x80,
796 .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
797 .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
798 },
799 .fs = {
800 .fs_avl = {
801 [0] = {
802 .num = ST_ACCEL_FS_AVL_2G,
803 .gain = IIO_G_TO_M_S_2(76),
804 },
805 },
806 },
807 .bdu = {
808 .addr = 0x20,
809 .mask = 0x01,
810 },
811 .drdy_irq = {
812 .int1 = {
813 .addr = 0x21,
814 .mask = 0x80,
815 .addr_od = 0x23,
816 .mask_od = 0x04,
817 },
818 .int2 = {
819 .addr = 0x22,
820 .mask = 0x80,
821 .addr_od = 0x23,
822 .mask_od = 0x08,
823 },
824 .stat_drdy = {
825 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
826 .mask = 0x07,
827 },
828 },
829 .multi_read_bit = false,
830 .bootime = 2,
831 },
652}; 832};
653 833
654static int st_accel_read_raw(struct iio_dev *indio_dev, 834static int st_accel_read_raw(struct iio_dev *indio_dev,
@@ -721,7 +901,6 @@ static const struct attribute_group st_accel_attribute_group = {
721}; 901};
722 902
723static const struct iio_info accel_info = { 903static const struct iio_info accel_info = {
724 .driver_module = THIS_MODULE,
725 .attrs = &st_accel_attribute_group, 904 .attrs = &st_accel_attribute_group,
726 .read_raw = &st_accel_read_raw, 905 .read_raw = &st_accel_read_raw,
727 .write_raw = &st_accel_write_raw, 906 .write_raw = &st_accel_write_raw,
@@ -730,7 +909,6 @@ static const struct iio_info accel_info = {
730 909
731#ifdef CONFIG_IIO_TRIGGER 910#ifdef CONFIG_IIO_TRIGGER
732static const struct iio_trigger_ops st_accel_trigger_ops = { 911static const struct iio_trigger_ops st_accel_trigger_ops = {
733 .owner = THIS_MODULE,
734 .set_trigger_state = ST_ACCEL_TRIGGER_SET_STATE, 912 .set_trigger_state = ST_ACCEL_TRIGGER_SET_STATE,
735 .validate_device = st_sensors_validate_device, 913 .validate_device = st_sensors_validate_device,
736}; 914};
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index 18cafb9f2468..363429b5686c 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -94,6 +94,10 @@ static const struct of_device_id st_accel_of_match[] = {
94 .compatible = "st,lng2dm-accel", 94 .compatible = "st,lng2dm-accel",
95 .data = LNG2DM_ACCEL_DEV_NAME, 95 .data = LNG2DM_ACCEL_DEV_NAME,
96 }, 96 },
97 {
98 .compatible = "st,lis2dw12",
99 .data = LIS2DW12_ACCEL_DEV_NAME,
100 },
97 {}, 101 {},
98}; 102};
99MODULE_DEVICE_TABLE(of, st_accel_of_match); 103MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -129,6 +133,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
129 { H3LIS331DL_ACCEL_DEV_NAME, H3LIS331DL }, 133 { H3LIS331DL_ACCEL_DEV_NAME, H3LIS331DL },
130 { LIS331DL_ACCEL_DEV_NAME, LIS331DL }, 134 { LIS331DL_ACCEL_DEV_NAME, LIS331DL },
131 { LIS3LV02DL_ACCEL_DEV_NAME, LIS3LV02DL }, 135 { LIS3LV02DL_ACCEL_DEV_NAME, LIS3LV02DL },
136 { LIS2DW12_ACCEL_DEV_NAME, LIS2DW12 },
132 {}, 137 {},
133}; 138};
134MODULE_DEVICE_TABLE(i2c, st_accel_id_table); 139MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 915fa49085f7..dcc9bd243a52 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -82,6 +82,14 @@ static const struct of_device_id st_accel_of_match[] = {
82 .compatible = "st,lis331dl-accel", 82 .compatible = "st,lis331dl-accel",
83 .data = LIS331DL_ACCEL_DEV_NAME, 83 .data = LIS331DL_ACCEL_DEV_NAME,
84 }, 84 },
85 {
86 .compatible = "st,lis2dw12",
87 .data = LIS2DW12_ACCEL_DEV_NAME,
88 },
89 {
90 .compatible = "st,lis3dhh",
91 .data = LIS3DHH_ACCEL_DEV_NAME,
92 },
85 {} 93 {}
86}; 94};
87MODULE_DEVICE_TABLE(of, st_accel_of_match); 95MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -133,6 +141,8 @@ static const struct spi_device_id st_accel_id_table[] = {
133 { H3LIS331DL_ACCEL_DEV_NAME }, 141 { H3LIS331DL_ACCEL_DEV_NAME },
134 { LIS331DL_ACCEL_DEV_NAME }, 142 { LIS331DL_ACCEL_DEV_NAME },
135 { LIS3LV02DL_ACCEL_DEV_NAME }, 143 { LIS3LV02DL_ACCEL_DEV_NAME },
144 { LIS2DW12_ACCEL_DEV_NAME },
145 { LIS3DHH_ACCEL_DEV_NAME },
136 {}, 146 {},
137}; 147};
138MODULE_DEVICE_TABLE(spi, st_accel_id_table); 148MODULE_DEVICE_TABLE(spi, st_accel_id_table);
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index e31023dc5f1b..cacc0da2f874 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -237,7 +237,6 @@ static int stk8312_data_rdy_trigger_set_state(struct iio_trigger *trig,
237 237
238static const struct iio_trigger_ops stk8312_trigger_ops = { 238static const struct iio_trigger_ops stk8312_trigger_ops = {
239 .set_trigger_state = stk8312_data_rdy_trigger_set_state, 239 .set_trigger_state = stk8312_data_rdy_trigger_set_state,
240 .owner = THIS_MODULE,
241}; 240};
242 241
243static int stk8312_set_sample_rate(struct stk8312_data *data, u8 rate) 242static int stk8312_set_sample_rate(struct stk8312_data *data, u8 rate)
@@ -421,7 +420,6 @@ static int stk8312_write_raw(struct iio_dev *indio_dev,
421} 420}
422 421
423static const struct iio_info stk8312_info = { 422static const struct iio_info stk8312_info = {
424 .driver_module = THIS_MODULE,
425 .read_raw = stk8312_read_raw, 423 .read_raw = stk8312_read_raw,
426 .write_raw = stk8312_write_raw, 424 .write_raw = stk8312_write_raw,
427 .attrs = &stk8312_attribute_group, 425 .attrs = &stk8312_attribute_group,
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 300d955bad00..576b6b140f08 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -179,7 +179,6 @@ static int stk8ba50_data_rdy_trigger_set_state(struct iio_trigger *trig,
179 179
180static const struct iio_trigger_ops stk8ba50_trigger_ops = { 180static const struct iio_trigger_ops stk8ba50_trigger_ops = {
181 .set_trigger_state = stk8ba50_data_rdy_trigger_set_state, 181 .set_trigger_state = stk8ba50_data_rdy_trigger_set_state,
182 .owner = THIS_MODULE,
183}; 182};
184 183
185static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode) 184static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode)
@@ -307,7 +306,6 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
307} 306}
308 307
309static const struct iio_info stk8ba50_info = { 308static const struct iio_info stk8ba50_info = {
310 .driver_module = THIS_MODULE,
311 .read_raw = stk8ba50_read_raw, 309 .read_raw = stk8ba50_read_raw,
312 .write_raw = stk8ba50_write_raw, 310 .write_raw = stk8ba50_write_raw,
313 .attrs = &stk8ba50_attribute_group, 311 .attrs = &stk8ba50_attribute_group,
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 57625653fcb6..ef86296b8b0d 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -243,6 +243,8 @@ config DA9150_GPADC
243config DLN2_ADC 243config DLN2_ADC
244 tristate "Diolan DLN-2 ADC driver support" 244 tristate "Diolan DLN-2 ADC driver support"
245 depends on MFD_DLN2 245 depends on MFD_DLN2
246 select IIO_BUFFER
247 select IIO_TRIGGERED_BUFFER
246 help 248 help
247 Say yes here to build support for Diolan DLN-2 ADC. 249 Say yes here to build support for Diolan DLN-2 ADC.
248 250
@@ -475,12 +477,13 @@ config MAX9611
475 called max9611. 477 called max9611.
476 478
477config MCP320X 479config MCP320X
478 tristate "Microchip Technology MCP3x01/02/04/08" 480 tristate "Microchip Technology MCP3x01/02/04/08 and MCP3550/1/3"
479 depends on SPI 481 depends on SPI
480 help 482 help
481 Say yes here to build support for Microchip Technology's 483 Say yes here to build support for Microchip Technology's
482 MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204, 484 MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204,
483 MCP3208 or MCP3301 analog to digital converter. 485 MCP3208, MCP3301, MCP3550, MCP3551 and MCP3553 analog to digital
486 converters.
484 487
485 This driver can also be built as a module. If so, the module will be 488 This driver can also be built as a module. If so, the module will be
486 called mcp320x. 489 called mcp320x.
@@ -593,7 +596,7 @@ config QCOM_SPMI_VADC
593 596
594config RCAR_GYRO_ADC 597config RCAR_GYRO_ADC
595 tristate "Renesas R-Car GyroADC driver" 598 tristate "Renesas R-Car GyroADC driver"
596 depends on ARCH_RCAR_GEN2 || (ARM && COMPILE_TEST) 599 depends on ARCH_RCAR_GEN2 || COMPILE_TEST
597 help 600 help
598 Say yes here to build support for the GyroADC found in Renesas 601 Say yes here to build support for the GyroADC found in Renesas
599 R-Car Gen2 SoCs. This block is a simple SPI offload engine for 602 R-Car Gen2 SoCs. This block is a simple SPI offload engine for
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index b8d5cfd57ec4..605eb5e7e829 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -280,7 +280,6 @@ static AD7266_DECLARE_DIFF_CHANNELS_FIXED(u, 'u');
280static const struct iio_info ad7266_info = { 280static const struct iio_info ad7266_info = {
281 .read_raw = &ad7266_read_raw, 281 .read_raw = &ad7266_read_raw,
282 .update_scan_mode = &ad7266_update_scan_mode, 282 .update_scan_mode = &ad7266_update_scan_mode,
283 .driver_module = THIS_MODULE,
284}; 283};
285 284
286static const unsigned long ad7266_available_scan_masks[] = { 285static const unsigned long ad7266_available_scan_masks[] = {
diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c
index 1d90b02732bb..a862b5d8fb4b 100644
--- a/drivers/iio/adc/ad7291.c
+++ b/drivers/iio/adc/ad7291.c
@@ -461,7 +461,6 @@ static const struct iio_info ad7291_info = {
461 .write_event_config = &ad7291_write_event_config, 461 .write_event_config = &ad7291_write_event_config,
462 .read_event_value = &ad7291_read_event_value, 462 .read_event_value = &ad7291_read_event_value,
463 .write_event_value = &ad7291_write_event_value, 463 .write_event_value = &ad7291_write_event_value,
464 .driver_module = THIS_MODULE,
465}; 464};
466 465
467static int ad7291_probe(struct i2c_client *client, 466static int ad7291_probe(struct i2c_client *client,
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index e399bf04c73a..2b20c6c8ec7f 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -280,7 +280,6 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
280static const struct iio_info ad7298_info = { 280static const struct iio_info ad7298_info = {
281 .read_raw = &ad7298_read_raw, 281 .read_raw = &ad7298_read_raw,
282 .update_scan_mode = ad7298_update_scan_mode, 282 .update_scan_mode = ad7298_update_scan_mode,
283 .driver_module = THIS_MODULE,
284}; 283};
285 284
286static int ad7298_probe(struct spi_device *spi) 285static int ad7298_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index b7ecf9aab90f..b7706bf10ffe 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -195,7 +195,6 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
195}; 195};
196 196
197static const struct iio_info ad7476_info = { 197static const struct iio_info ad7476_info = {
198 .driver_module = THIS_MODULE,
199 .read_raw = &ad7476_read_raw, 198 .read_raw = &ad7476_read_raw,
200}; 199};
201 200
diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
index ce45037295d8..3ae14fc8c649 100644
--- a/drivers/iio/adc/ad7766.c
+++ b/drivers/iio/adc/ad7766.c
@@ -185,7 +185,6 @@ static const struct iio_buffer_setup_ops ad7766_buffer_setup_ops = {
185}; 185};
186 186
187static const struct iio_info ad7766_info = { 187static const struct iio_info ad7766_info = {
188 .driver_module = THIS_MODULE,
189 .read_raw = &ad7766_read_raw, 188 .read_raw = &ad7766_read_raw,
190}; 189};
191 190
@@ -208,7 +207,6 @@ static int ad7766_set_trigger_state(struct iio_trigger *trig, bool enable)
208} 207}
209 208
210static const struct iio_trigger_ops ad7766_trigger_ops = { 209static const struct iio_trigger_ops ad7766_trigger_ops = {
211 .owner = THIS_MODULE,
212 .set_trigger_state = ad7766_set_trigger_state, 210 .set_trigger_state = ad7766_set_trigger_state,
213 .validate_device = iio_trigger_validate_own_device, 211 .validate_device = iio_trigger_validate_own_device,
214}; 212};
diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index 34e353c43ac8..70fbf92f9827 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -308,13 +308,11 @@ static const struct iio_info ad7791_info = {
308 .read_raw = &ad7791_read_raw, 308 .read_raw = &ad7791_read_raw,
309 .attrs = &ad7791_attribute_group, 309 .attrs = &ad7791_attribute_group,
310 .validate_trigger = ad_sd_validate_trigger, 310 .validate_trigger = ad_sd_validate_trigger,
311 .driver_module = THIS_MODULE,
312}; 311};
313 312
314static const struct iio_info ad7791_no_filter_info = { 313static const struct iio_info ad7791_no_filter_info = {
315 .read_raw = &ad7791_read_raw, 314 .read_raw = &ad7791_read_raw,
316 .validate_trigger = ad_sd_validate_trigger, 315 .validate_trigger = ad_sd_validate_trigger,
317 .driver_module = THIS_MODULE,
318}; 316};
319 317
320static int ad7791_setup(struct ad7791_state *st, 318static int ad7791_setup(struct ad7791_state *st,
diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index 47c3d7f32900..801afb61310b 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -563,7 +563,6 @@ static const struct iio_info ad7793_info = {
563 .write_raw_get_fmt = &ad7793_write_raw_get_fmt, 563 .write_raw_get_fmt = &ad7793_write_raw_get_fmt,
564 .attrs = &ad7793_attribute_group, 564 .attrs = &ad7793_attribute_group,
565 .validate_trigger = ad_sd_validate_trigger, 565 .validate_trigger = ad_sd_validate_trigger,
566 .driver_module = THIS_MODULE,
567}; 566};
568 567
569static const struct iio_info ad7797_info = { 568static const struct iio_info ad7797_info = {
@@ -572,7 +571,6 @@ static const struct iio_info ad7797_info = {
572 .write_raw_get_fmt = &ad7793_write_raw_get_fmt, 571 .write_raw_get_fmt = &ad7793_write_raw_get_fmt,
573 .attrs = &ad7793_attribute_group, 572 .attrs = &ad7793_attribute_group,
574 .validate_trigger = ad_sd_validate_trigger, 573 .validate_trigger = ad_sd_validate_trigger,
575 .driver_module = THIS_MODULE,
576}; 574};
577 575
578#define DECLARE_AD7793_CHANNELS(_name, _b, _sb, _s) \ 576#define DECLARE_AD7793_CHANNELS(_name, _b, _sb, _s) \
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 7a483bfbd70c..205c0f1761aa 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -229,7 +229,6 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
229 229
230static const struct iio_info ad7887_info = { 230static const struct iio_info ad7887_info = {
231 .read_raw = &ad7887_read_raw, 231 .read_raw = &ad7887_read_raw,
232 .driver_module = THIS_MODULE,
233}; 232};
234 233
235static int ad7887_probe(struct spi_device *spi) 234static int ad7887_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 77a675e11ebb..ffb7e089969c 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -262,7 +262,6 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,
262static const struct iio_info ad7923_info = { 262static const struct iio_info ad7923_info = {
263 .read_raw = &ad7923_read_raw, 263 .read_raw = &ad7923_read_raw,
264 .update_scan_mode = ad7923_update_scan_mode, 264 .update_scan_mode = ad7923_update_scan_mode,
265 .driver_module = THIS_MODULE,
266}; 265};
267 266
268static int ad7923_probe(struct spi_device *spi) 267static int ad7923_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index 22426ae4af97..e1da67d5ee22 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -526,13 +526,11 @@ static const struct attribute_group ad799x_event_attrs_group = {
526 526
527static const struct iio_info ad7991_info = { 527static const struct iio_info ad7991_info = {
528 .read_raw = &ad799x_read_raw, 528 .read_raw = &ad799x_read_raw,
529 .driver_module = THIS_MODULE,
530 .update_scan_mode = ad799x_update_scan_mode, 529 .update_scan_mode = ad799x_update_scan_mode,
531}; 530};
532 531
533static const struct iio_info ad7993_4_7_8_noirq_info = { 532static const struct iio_info ad7993_4_7_8_noirq_info = {
534 .read_raw = &ad799x_read_raw, 533 .read_raw = &ad799x_read_raw,
535 .driver_module = THIS_MODULE,
536 .update_scan_mode = ad799x_update_scan_mode, 534 .update_scan_mode = ad799x_update_scan_mode,
537}; 535};
538 536
@@ -543,7 +541,6 @@ static const struct iio_info ad7993_4_7_8_irq_info = {
543 .write_event_config = &ad799x_write_event_config, 541 .write_event_config = &ad799x_write_event_config,
544 .read_event_value = &ad799x_read_event_value, 542 .read_event_value = &ad799x_read_event_value,
545 .write_event_value = &ad799x_write_event_value, 543 .write_event_value = &ad799x_write_event_value,
546 .driver_module = THIS_MODULE,
547 .update_scan_mode = ad799x_update_scan_mode, 544 .update_scan_mode = ad799x_update_scan_mode,
548}; 545};
549 546
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 22c4c17cd996..cf1b048b0665 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -463,7 +463,6 @@ int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig)
463EXPORT_SYMBOL_GPL(ad_sd_validate_trigger); 463EXPORT_SYMBOL_GPL(ad_sd_validate_trigger);
464 464
465static const struct iio_trigger_ops ad_sd_trigger_ops = { 465static const struct iio_trigger_ops ad_sd_trigger_ops = {
466 .owner = THIS_MODULE,
467}; 466};
468 467
469static int ad_sd_probe_trigger(struct iio_dev *indio_dev) 468static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index c02b23d675cb..8a958d5f1905 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -165,7 +165,6 @@ static int aspeed_adc_reg_access(struct iio_dev *indio_dev,
165} 165}
166 166
167static const struct iio_info aspeed_adc_iio_info = { 167static const struct iio_info aspeed_adc_iio_info = {
168 .driver_module = THIS_MODULE,
169 .read_raw = aspeed_adc_read_raw, 168 .read_raw = aspeed_adc_read_raw,
170 .write_raw = aspeed_adc_write_raw, 169 .write_raw = aspeed_adc_write_raw,
171 .debugfs_reg_access = aspeed_adc_reg_access, 170 .debugfs_reg_access = aspeed_adc_reg_access,
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index bc5b38e3a147..755a493c2a2c 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -225,6 +225,7 @@ struct at91_adc_trigger {
225 char *name; 225 char *name;
226 unsigned int trgmod_value; 226 unsigned int trgmod_value;
227 unsigned int edge_type; 227 unsigned int edge_type;
228 bool hw_trig;
228}; 229};
229 230
230struct at91_adc_state { 231struct at91_adc_state {
@@ -254,16 +255,25 @@ static const struct at91_adc_trigger at91_adc_trigger_list[] = {
254 .name = "external_rising", 255 .name = "external_rising",
255 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_RISE, 256 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_RISE,
256 .edge_type = IRQ_TYPE_EDGE_RISING, 257 .edge_type = IRQ_TYPE_EDGE_RISING,
258 .hw_trig = true,
257 }, 259 },
258 { 260 {
259 .name = "external_falling", 261 .name = "external_falling",
260 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_FALL, 262 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_FALL,
261 .edge_type = IRQ_TYPE_EDGE_FALLING, 263 .edge_type = IRQ_TYPE_EDGE_FALLING,
264 .hw_trig = true,
262 }, 265 },
263 { 266 {
264 .name = "external_any", 267 .name = "external_any",
265 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_ANY, 268 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_ANY,
266 .edge_type = IRQ_TYPE_EDGE_BOTH, 269 .edge_type = IRQ_TYPE_EDGE_BOTH,
270 .hw_trig = true,
271 },
272 {
273 .name = "software",
274 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_NO_TRIGGER,
275 .edge_type = IRQ_TYPE_NONE,
276 .hw_trig = false,
267 }, 277 },
268}; 278};
269 279
@@ -338,7 +348,6 @@ static int at91_adc_reenable_trigger(struct iio_trigger *trig)
338} 348}
339 349
340static const struct iio_trigger_ops at91_adc_trigger_ops = { 350static const struct iio_trigger_ops at91_adc_trigger_ops = {
341 .owner = THIS_MODULE,
342 .set_trigger_state = &at91_adc_configure_trigger, 351 .set_trigger_state = &at91_adc_configure_trigger,
343 .try_reenable = &at91_adc_reenable_trigger, 352 .try_reenable = &at91_adc_reenable_trigger,
344}; 353};
@@ -574,7 +583,6 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
574static const struct iio_info at91_adc_info = { 583static const struct iio_info at91_adc_info = {
575 .read_raw = &at91_adc_read_raw, 584 .read_raw = &at91_adc_read_raw,
576 .write_raw = &at91_adc_write_raw, 585 .write_raw = &at91_adc_write_raw,
577 .driver_module = THIS_MODULE,
578}; 586};
579 587
580static void at91_adc_hw_init(struct at91_adc_state *st) 588static void at91_adc_hw_init(struct at91_adc_state *st)
@@ -597,7 +605,7 @@ static int at91_adc_probe(struct platform_device *pdev)
597 struct at91_adc_state *st; 605 struct at91_adc_state *st;
598 struct resource *res; 606 struct resource *res;
599 int ret, i; 607 int ret, i;
600 u32 edge_type; 608 u32 edge_type = IRQ_TYPE_NONE;
601 609
602 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st)); 610 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st));
603 if (!indio_dev) 611 if (!indio_dev)
@@ -641,14 +649,14 @@ static int at91_adc_probe(struct platform_device *pdev)
641 ret = of_property_read_u32(pdev->dev.of_node, 649 ret = of_property_read_u32(pdev->dev.of_node,
642 "atmel,trigger-edge-type", &edge_type); 650 "atmel,trigger-edge-type", &edge_type);
643 if (ret) { 651 if (ret) {
644 dev_err(&pdev->dev, 652 dev_dbg(&pdev->dev,
645 "invalid or missing value for atmel,trigger-edge-type\n"); 653 "atmel,trigger-edge-type not specified, only software trigger available\n");
646 return ret;
647 } 654 }
648 655
649 st->selected_trig = NULL; 656 st->selected_trig = NULL;
650 657
651 for (i = 0; i < AT91_SAMA5D2_HW_TRIG_CNT; i++) 658 /* find the right trigger, or no trigger at all */
659 for (i = 0; i < AT91_SAMA5D2_HW_TRIG_CNT + 1; i++)
652 if (at91_adc_trigger_list[i].edge_type == edge_type) { 660 if (at91_adc_trigger_list[i].edge_type == edge_type) {
653 st->selected_trig = &at91_adc_trigger_list[i]; 661 st->selected_trig = &at91_adc_trigger_list[i];
654 break; 662 break;
@@ -717,24 +725,27 @@ static int at91_adc_probe(struct platform_device *pdev)
717 725
718 platform_set_drvdata(pdev, indio_dev); 726 platform_set_drvdata(pdev, indio_dev);
719 727
720 ret = at91_adc_buffer_init(indio_dev); 728 if (st->selected_trig->hw_trig) {
721 if (ret < 0) { 729 ret = at91_adc_buffer_init(indio_dev);
722 dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); 730 if (ret < 0) {
723 goto per_clk_disable_unprepare; 731 dev_err(&pdev->dev, "couldn't initialize the buffer.\n");
724 } 732 goto per_clk_disable_unprepare;
733 }
725 734
726 ret = at91_adc_trigger_init(indio_dev); 735 ret = at91_adc_trigger_init(indio_dev);
727 if (ret < 0) { 736 if (ret < 0) {
728 dev_err(&pdev->dev, "couldn't setup the triggers.\n"); 737 dev_err(&pdev->dev, "couldn't setup the triggers.\n");
729 goto per_clk_disable_unprepare; 738 goto per_clk_disable_unprepare;
739 }
730 } 740 }
731 741
732 ret = iio_device_register(indio_dev); 742 ret = iio_device_register(indio_dev);
733 if (ret < 0) 743 if (ret < 0)
734 goto per_clk_disable_unprepare; 744 goto per_clk_disable_unprepare;
735 745
736 dev_info(&pdev->dev, "setting up trigger as %s\n", 746 if (st->selected_trig->hw_trig)
737 st->selected_trig->name); 747 dev_info(&pdev->dev, "setting up trigger as %s\n",
748 st->selected_trig->name);
738 749
739 dev_info(&pdev->dev, "version: %x\n", 750 dev_info(&pdev->dev, "version: %x\n",
740 readl_relaxed(st->base + AT91_SAMA5D2_VERSION)); 751 readl_relaxed(st->base + AT91_SAMA5D2_VERSION));
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 15109728cae7..3836d4222a3e 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -594,7 +594,6 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
594} 594}
595 595
596static const struct iio_trigger_ops at91_adc_trigger_ops = { 596static const struct iio_trigger_ops at91_adc_trigger_ops = {
597 .owner = THIS_MODULE,
598 .set_trigger_state = &at91_adc_configure_trigger, 597 .set_trigger_state = &at91_adc_configure_trigger,
599}; 598};
600 599
@@ -976,7 +975,6 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st,
976} 975}
977 976
978static const struct iio_info at91_adc_info = { 977static const struct iio_info at91_adc_info = {
979 .driver_module = THIS_MODULE,
980 .read_raw = &at91_adc_read_raw, 978 .read_raw = &at91_adc_read_raw,
981}; 979};
982 980
diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c
index 11e177180ea0..a30a97245e91 100644
--- a/drivers/iio/adc/axp20x_adc.c
+++ b/drivers/iio/adc/axp20x_adc.c
@@ -464,12 +464,10 @@ static int axp20x_write_raw(struct iio_dev *indio_dev,
464static const struct iio_info axp20x_adc_iio_info = { 464static const struct iio_info axp20x_adc_iio_info = {
465 .read_raw = axp20x_read_raw, 465 .read_raw = axp20x_read_raw,
466 .write_raw = axp20x_write_raw, 466 .write_raw = axp20x_write_raw,
467 .driver_module = THIS_MODULE,
468}; 467};
469 468
470static const struct iio_info axp22x_adc_iio_info = { 469static const struct iio_info axp22x_adc_iio_info = {
471 .read_raw = axp22x_read_raw, 470 .read_raw = axp22x_read_raw,
472 .driver_module = THIS_MODULE,
473}; 471};
474 472
475static int axp20x_adc_rate(int rate) 473static int axp20x_adc_rate(int rate)
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 462a99c13e7a..60c9e853dd81 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -183,7 +183,6 @@ static int axp288_adc_set_state(struct regmap *regmap)
183 183
184static const struct iio_info axp288_adc_iio_info = { 184static const struct iio_info axp288_adc_iio_info = {
185 .read_raw = &axp288_adc_read_raw, 185 .read_raw = &axp288_adc_read_raw,
186 .driver_module = THIS_MODULE,
187}; 186};
188 187
189static int axp288_adc_probe(struct platform_device *pdev) 188static int axp288_adc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 7f4f9c4150e3..7af59a4bbd8d 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -492,7 +492,6 @@ static int iproc_adc_read_raw(struct iio_dev *indio_dev,
492 492
493static const struct iio_info iproc_adc_iio_info = { 493static const struct iio_info iproc_adc_iio_info = {
494 .read_raw = &iproc_adc_read_raw, 494 .read_raw = &iproc_adc_read_raw,
495 .driver_module = THIS_MODULE,
496}; 495};
497 496
498#define IPROC_ADC_CHANNEL(_index, _id) { \ 497#define IPROC_ADC_CHANNEL(_index, _id) { \
diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
index 71c806ecc722..72d8fa94ab31 100644
--- a/drivers/iio/adc/berlin2-adc.c
+++ b/drivers/iio/adc/berlin2-adc.c
@@ -277,7 +277,6 @@ static irqreturn_t berlin2_adc_tsen_irq(int irq, void *private)
277} 277}
278 278
279static const struct iio_info berlin2_adc_info = { 279static const struct iio_info berlin2_adc_info = {
280 .driver_module = THIS_MODULE,
281 .read_raw = berlin2_adc_read_raw, 280 .read_raw = berlin2_adc_read_raw,
282}; 281};
283 282
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 91636c0ba5b5..707d8b24b072 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -262,7 +262,6 @@ static int cc10001_update_scan_mode(struct iio_dev *indio_dev,
262} 262}
263 263
264static const struct iio_info cc10001_adc_info = { 264static const struct iio_info cc10001_adc_info = {
265 .driver_module = THIS_MODULE,
266 .read_raw = &cc10001_adc_read_raw, 265 .read_raw = &cc10001_adc_read_raw,
267 .update_scan_mode = &cc10001_update_scan_mode, 266 .update_scan_mode = &cc10001_update_scan_mode,
268}; 267};
diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c
index 6e419d5a7c14..3576ec73ec23 100644
--- a/drivers/iio/adc/cpcap-adc.c
+++ b/drivers/iio/adc/cpcap-adc.c
@@ -932,7 +932,6 @@ err_unlock:
932 932
933static const struct iio_info cpcap_adc_info = { 933static const struct iio_info cpcap_adc_info = {
934 .read_raw = &cpcap_adc_read, 934 .read_raw = &cpcap_adc_read,
935 .driver_module = THIS_MODULE,
936}; 935};
937 936
938/* 937/*
diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c
index 3445107e10b7..0a5d9ce79164 100644
--- a/drivers/iio/adc/da9150-gpadc.c
+++ b/drivers/iio/adc/da9150-gpadc.c
@@ -249,7 +249,6 @@ static int da9150_gpadc_read_raw(struct iio_dev *indio_dev,
249 249
250static const struct iio_info da9150_gpadc_info = { 250static const struct iio_info da9150_gpadc_info = {
251 .read_raw = &da9150_gpadc_read_raw, 251 .read_raw = &da9150_gpadc_read_raw,
252 .driver_module = THIS_MODULE,
253}; 252};
254 253
255#define DA9150_GPADC_CHANNEL(_id, _hw_id, _type, chan_info, \ 254#define DA9150_GPADC_CHANNEL(_id, _hw_id, _type, chan_info, \
diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
index ab8d6aed5085..c64c6675cae6 100644
--- a/drivers/iio/adc/dln2-adc.c
+++ b/drivers/iio/adc/dln2-adc.c
@@ -479,7 +479,6 @@ static const struct iio_info dln2_adc_info = {
479 .read_raw = dln2_adc_read_raw, 479 .read_raw = dln2_adc_read_raw,
480 .write_raw = dln2_adc_write_raw, 480 .write_raw = dln2_adc_write_raw,
481 .update_scan_mode = dln2_update_scan_mode, 481 .update_scan_mode = dln2_update_scan_mode,
482 .driver_module = THIS_MODULE,
483}; 482};
484 483
485static irqreturn_t dln2_adc_trigger_h(int irq, void *p) 484static irqreturn_t dln2_adc_trigger_h(int irq, void *p)
@@ -604,10 +603,6 @@ static void dln2_adc_event(struct platform_device *pdev, u16 echo,
604 iio_trigger_poll(dln2->trig); 603 iio_trigger_poll(dln2->trig);
605} 604}
606 605
607static const struct iio_trigger_ops dln2_adc_trigger_ops = {
608 .owner = THIS_MODULE,
609};
610
611static int dln2_adc_probe(struct platform_device *pdev) 606static int dln2_adc_probe(struct platform_device *pdev)
612{ 607{
613 struct device *dev = &pdev->dev; 608 struct device *dev = &pdev->dev;
@@ -665,7 +660,6 @@ static int dln2_adc_probe(struct platform_device *pdev)
665 dev_err(dev, "failed to allocate trigger\n"); 660 dev_err(dev, "failed to allocate trigger\n");
666 return -ENOMEM; 661 return -ENOMEM;
667 } 662 }
668 dln2->trig->ops = &dln2_adc_trigger_ops;
669 iio_trigger_set_drvdata(dln2->trig, dln2); 663 iio_trigger_set_drvdata(dln2->trig, dln2);
670 devm_iio_trigger_register(dev, dln2->trig); 664 devm_iio_trigger_register(dev, dln2->trig);
671 iio_trigger_set_immutable(indio_dev, dln2->trig); 665 iio_trigger_set_immutable(indio_dev, dln2->trig);
diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope-detector.c
index fef15c0d7c9c..4ebda8ab54fe 100644
--- a/drivers/iio/adc/envelope-detector.c
+++ b/drivers/iio/adc/envelope-detector.c
@@ -322,7 +322,6 @@ static const struct iio_chan_spec envelope_detector_iio_channel = {
322 322
323static const struct iio_info envelope_detector_info = { 323static const struct iio_info envelope_detector_info = {
324 .read_raw = &envelope_detector_read_raw, 324 .read_raw = &envelope_detector_read_raw,
325 .driver_module = THIS_MODULE,
326}; 325};
327 326
328static int envelope_detector_probe(struct platform_device *pdev) 327static int envelope_detector_probe(struct platform_device *pdev)
diff --git a/drivers/iio/adc/ep93xx_adc.c b/drivers/iio/adc/ep93xx_adc.c
index a179ac476c6d..81c901507ad2 100644
--- a/drivers/iio/adc/ep93xx_adc.c
+++ b/drivers/iio/adc/ep93xx_adc.c
@@ -150,7 +150,6 @@ static int ep93xx_read_raw(struct iio_dev *iiodev,
150} 150}
151 151
152static const struct iio_info ep93xx_adc_info = { 152static const struct iio_info ep93xx_adc_info = {
153 .driver_module = THIS_MODULE,
154 .read_raw = ep93xx_read_raw, 153 .read_raw = ep93xx_read_raw,
155}; 154};
156 155
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 6c5a7be9f8c1..f10443f92e4c 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -657,7 +657,6 @@ static int exynos_adc_reg_access(struct iio_dev *indio_dev,
657static const struct iio_info exynos_adc_iio_info = { 657static const struct iio_info exynos_adc_iio_info = {
658 .read_raw = &exynos_read_raw, 658 .read_raw = &exynos_read_raw,
659 .debugfs_reg_access = &exynos_adc_reg_access, 659 .debugfs_reg_access = &exynos_adc_reg_access,
660 .driver_module = THIS_MODULE,
661}; 660};
662 661
663#define ADC_CHANNEL(_index, _id) { \ 662#define ADC_CHANNEL(_index, _id) { \
diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c
index adf7dc712937..6f6c9a348158 100644
--- a/drivers/iio/adc/hi8435.c
+++ b/drivers/iio/adc/hi8435.c
@@ -408,7 +408,6 @@ static const struct iio_chan_spec hi8435_channels[] = {
408}; 408};
409 409
410static const struct iio_info hi8435_info = { 410static const struct iio_info hi8435_info = {
411 .driver_module = THIS_MODULE,
412 .read_raw = hi8435_read_raw, 411 .read_raw = hi8435_read_raw,
413 .read_event_config = hi8435_read_event_config, 412 .read_event_config = hi8435_read_event_config,
414 .write_event_config = hi8435_write_event_config, 413 .write_event_config = hi8435_write_event_config,
diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
index 27005d84ed73..d10b9f13d557 100644
--- a/drivers/iio/adc/hx711.c
+++ b/drivers/iio/adc/hx711.c
@@ -374,7 +374,6 @@ static const struct attribute_group hx711_attribute_group = {
374}; 374};
375 375
376static const struct iio_info hx711_iio_info = { 376static const struct iio_info hx711_iio_info = {
377 .driver_module = THIS_MODULE,
378 .read_raw = hx711_read_raw, 377 .read_raw = hx711_read_raw,
379 .write_raw = hx711_write_raw, 378 .write_raw = hx711_write_raw,
380 .write_raw_get_fmt = hx711_write_raw_get_fmt, 379 .write_raw_get_fmt = hx711_write_raw_get_fmt,
diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 254b29a68b9d..cfab31162845 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -412,7 +412,6 @@ static int imx7d_adc_reg_access(struct iio_dev *indio_dev,
412} 412}
413 413
414static const struct iio_info imx7d_adc_iio_info = { 414static const struct iio_info imx7d_adc_iio_info = {
415 .driver_module = THIS_MODULE,
416 .read_raw = &imx7d_adc_read_raw, 415 .read_raw = &imx7d_adc_read_raw,
417 .debugfs_reg_access = &imx7d_adc_reg_access, 416 .debugfs_reg_access = &imx7d_adc_reg_access,
418}; 417};
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index f387b972e4f4..84a43871f7dc 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -123,7 +123,7 @@ struct ina2xx_chip_info {
123 struct task_struct *task; 123 struct task_struct *task;
124 const struct ina2xx_config *config; 124 const struct ina2xx_config *config;
125 struct mutex state_lock; 125 struct mutex state_lock;
126 unsigned int shunt_resistor; 126 unsigned int shunt_resistor_uohm;
127 int avg; 127 int avg;
128 int int_time_vbus; /* Bus voltage integration time uS */ 128 int int_time_vbus; /* Bus voltage integration time uS */
129 int int_time_vshunt; /* Shunt voltage integration time uS */ 129 int int_time_vshunt; /* Shunt voltage integration time uS */
@@ -436,7 +436,7 @@ static ssize_t ina2xx_allow_async_readout_store(struct device *dev,
436/* 436/*
437 * Set current LSB to 1mA, shunt is in uOhms 437 * Set current LSB to 1mA, shunt is in uOhms
438 * (equation 13 in datasheet). We hardcode a Current_LSB 438 * (equation 13 in datasheet). We hardcode a Current_LSB
439 * of 1.0 x10-6. The only remaining parameter is RShunt. 439 * of 1.0 x10-3. The only remaining parameter is RShunt.
440 * There is no need to expose the CALIBRATION register 440 * There is no need to expose the CALIBRATION register
441 * to the user for now. But we need to reset this register 441 * to the user for now. But we need to reset this register
442 * if the user updates RShunt after driver init, e.g upon 442 * if the user updates RShunt after driver init, e.g upon
@@ -445,7 +445,7 @@ static ssize_t ina2xx_allow_async_readout_store(struct device *dev,
445static int ina2xx_set_calibration(struct ina2xx_chip_info *chip) 445static int ina2xx_set_calibration(struct ina2xx_chip_info *chip)
446{ 446{
447 u16 regval = DIV_ROUND_CLOSEST(chip->config->calibration_factor, 447 u16 regval = DIV_ROUND_CLOSEST(chip->config->calibration_factor,
448 chip->shunt_resistor); 448 chip->shunt_resistor_uohm);
449 449
450 return regmap_write(chip->regmap, INA2XX_CALIBRATION, regval); 450 return regmap_write(chip->regmap, INA2XX_CALIBRATION, regval);
451} 451}
@@ -455,7 +455,7 @@ static int set_shunt_resistor(struct ina2xx_chip_info *chip, unsigned int val)
455 if (val <= 0 || val > chip->config->calibration_factor) 455 if (val <= 0 || val > chip->config->calibration_factor)
456 return -EINVAL; 456 return -EINVAL;
457 457
458 chip->shunt_resistor = val; 458 chip->shunt_resistor_uohm = val;
459 459
460 return 0; 460 return 0;
461} 461}
@@ -465,8 +465,9 @@ static ssize_t ina2xx_shunt_resistor_show(struct device *dev,
465 char *buf) 465 char *buf)
466{ 466{
467 struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev)); 467 struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
468 int vals[2] = { chip->shunt_resistor_uohm, 1000000 };
468 469
469 return sprintf(buf, "%d\n", chip->shunt_resistor); 470 return iio_format_value(buf, IIO_VAL_FRACTIONAL, 1, vals);
470} 471}
471 472
472static ssize_t ina2xx_shunt_resistor_store(struct device *dev, 473static ssize_t ina2xx_shunt_resistor_store(struct device *dev,
@@ -474,14 +475,13 @@ static ssize_t ina2xx_shunt_resistor_store(struct device *dev,
474 const char *buf, size_t len) 475 const char *buf, size_t len)
475{ 476{
476 struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev)); 477 struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
477 unsigned long val; 478 int val, val_fract, ret;
478 int ret;
479 479
480 ret = kstrtoul((const char *) buf, 10, &val); 480 ret = iio_str_to_fixpoint(buf, 100000, &val, &val_fract);
481 if (ret) 481 if (ret)
482 return ret; 482 return ret;
483 483
484 ret = set_shunt_resistor(chip, val); 484 ret = set_shunt_resistor(chip, val * 1000000 + val_fract);
485 if (ret) 485 if (ret)
486 return ret; 486 return ret;
487 487
@@ -778,7 +778,6 @@ static const struct attribute_group ina226_attribute_group = {
778}; 778};
779 779
780static const struct iio_info ina219_info = { 780static const struct iio_info ina219_info = {
781 .driver_module = THIS_MODULE,
782 .attrs = &ina219_attribute_group, 781 .attrs = &ina219_attribute_group,
783 .read_raw = ina2xx_read_raw, 782 .read_raw = ina2xx_read_raw,
784 .write_raw = ina2xx_write_raw, 783 .write_raw = ina2xx_write_raw,
@@ -786,7 +785,6 @@ static const struct iio_info ina219_info = {
786}; 785};
787 786
788static const struct iio_info ina226_info = { 787static const struct iio_info ina226_info = {
789 .driver_module = THIS_MODULE,
790 .attrs = &ina226_attribute_group, 788 .attrs = &ina226_attribute_group,
791 .read_raw = ina2xx_read_raw, 789 .read_raw = ina2xx_read_raw,
792 .write_raw = ina2xx_write_raw, 790 .write_raw = ina2xx_write_raw,
diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c
index 152cfc8e1c7b..3bc4df916420 100644
--- a/drivers/iio/adc/lp8788_adc.c
+++ b/drivers/iio/adc/lp8788_adc.c
@@ -125,7 +125,6 @@ static int lp8788_adc_read_raw(struct iio_dev *indio_dev,
125 125
126static const struct iio_info lp8788_adc_info = { 126static const struct iio_info lp8788_adc_info = {
127 .read_raw = &lp8788_adc_read_raw, 127 .read_raw = &lp8788_adc_read_raw,
128 .driver_module = THIS_MODULE,
129}; 128};
130 129
131#define LP8788_CHAN(_id, _type) { \ 130#define LP8788_CHAN(_id, _type) { \
diff --git a/drivers/iio/adc/lpc18xx_adc.c b/drivers/iio/adc/lpc18xx_adc.c
index 3ef18f4b27f0..041dc4a3f66c 100644
--- a/drivers/iio/adc/lpc18xx_adc.c
+++ b/drivers/iio/adc/lpc18xx_adc.c
@@ -116,7 +116,6 @@ static int lpc18xx_adc_read_raw(struct iio_dev *indio_dev,
116 116
117static const struct iio_info lpc18xx_adc_info = { 117static const struct iio_info lpc18xx_adc_info = {
118 .read_raw = lpc18xx_adc_read_raw, 118 .read_raw = lpc18xx_adc_read_raw,
119 .driver_module = THIS_MODULE,
120}; 119};
121 120
122static int lpc18xx_adc_probe(struct platform_device *pdev) 121static int lpc18xx_adc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c
index 6a5b9a9bc662..20b36690fa4f 100644
--- a/drivers/iio/adc/lpc32xx_adc.c
+++ b/drivers/iio/adc/lpc32xx_adc.c
@@ -104,7 +104,6 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev,
104 104
105static const struct iio_info lpc32xx_adc_iio_info = { 105static const struct iio_info lpc32xx_adc_iio_info = {
106 .read_raw = &lpc32xx_read_raw, 106 .read_raw = &lpc32xx_read_raw,
107 .driver_module = THIS_MODULE,
108}; 107};
109 108
110#define LPC32XX_ADC_CHANNEL(_index) { \ 109#define LPC32XX_ADC_CHANNEL(_index) { \
diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c
index 29b7ed60cdb0..b88102b751cf 100644
--- a/drivers/iio/adc/ltc2471.c
+++ b/drivers/iio/adc/ltc2471.c
@@ -98,7 +98,6 @@ static const struct iio_chan_spec ltc2473_channel[] = {
98 98
99static const struct iio_info ltc2471_info = { 99static const struct iio_info ltc2471_info = {
100 .read_raw = ltc2471_read_raw, 100 .read_raw = ltc2471_read_raw,
101 .driver_module = THIS_MODULE,
102}; 101};
103 102
104static int ltc2471_i2c_probe(struct i2c_client *client, 103static int ltc2471_i2c_probe(struct i2c_client *client,
diff --git a/drivers/iio/adc/ltc2485.c b/drivers/iio/adc/ltc2485.c
index eab91f12454a..b24c14037fd4 100644
--- a/drivers/iio/adc/ltc2485.c
+++ b/drivers/iio/adc/ltc2485.c
@@ -90,7 +90,6 @@ static const struct iio_chan_spec ltc2485_channel[] = {
90 90
91static const struct iio_info ltc2485_info = { 91static const struct iio_info ltc2485_info = {
92 .read_raw = ltc2485_read_raw, 92 .read_raw = ltc2485_read_raw,
93 .driver_module = THIS_MODULE,
94}; 93};
95 94
96static int ltc2485_probe(struct i2c_client *client, 95static int ltc2485_probe(struct i2c_client *client,
diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
index 5bf8011dcde9..f1f7cdf66fbd 100644
--- a/drivers/iio/adc/ltc2497.c
+++ b/drivers/iio/adc/ltc2497.c
@@ -186,7 +186,6 @@ static const struct iio_chan_spec ltc2497_channel[] = {
186 186
187static const struct iio_info ltc2497_info = { 187static const struct iio_info ltc2497_info = {
188 .read_raw = ltc2497_read_raw, 188 .read_raw = ltc2497_read_raw,
189 .driver_module = THIS_MODULE,
190}; 189};
191 190
192static int ltc2497_probe(struct i2c_client *client, 191static int ltc2497_probe(struct i2c_client *client,
diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index ebc715927e63..375da6491499 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -381,13 +381,11 @@ static irqreturn_t max1027_trigger_handler(int irq, void *private)
381} 381}
382 382
383static const struct iio_trigger_ops max1027_trigger_ops = { 383static const struct iio_trigger_ops max1027_trigger_ops = {
384 .owner = THIS_MODULE,
385 .validate_device = &iio_trigger_validate_own_device, 384 .validate_device = &iio_trigger_validate_own_device,
386 .set_trigger_state = &max1027_set_trigger_state, 385 .set_trigger_state = &max1027_set_trigger_state,
387}; 386};
388 387
389static const struct iio_info max1027_info = { 388static const struct iio_info max1027_info = {
390 .driver_module = THIS_MODULE,
391 .read_raw = &max1027_read_raw, 389 .read_raw = &max1027_read_raw,
392 .validate_trigger = &max1027_validate_trigger, 390 .validate_trigger = &max1027_validate_trigger,
393 .debugfs_reg_access = &max1027_debugfs_reg_access, 391 .debugfs_reg_access = &max1027_debugfs_reg_access,
diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c
index 1180bcc22ff1..af59ab2e650c 100644
--- a/drivers/iio/adc/max11100.c
+++ b/drivers/iio/adc/max11100.c
@@ -100,7 +100,6 @@ static int max11100_read_raw(struct iio_dev *indio_dev,
100} 100}
101 101
102static const struct iio_info max11100_info = { 102static const struct iio_info max11100_info = {
103 .driver_module = THIS_MODULE,
104 .read_raw = max11100_read_raw, 103 .read_raw = max11100_read_raw,
105}; 104};
106 105
diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c
index 2e9648a078c4..49db9e9ae625 100644
--- a/drivers/iio/adc/max1118.c
+++ b/drivers/iio/adc/max1118.c
@@ -155,7 +155,6 @@ static int max1118_read_raw(struct iio_dev *indio_dev,
155 155
156static const struct iio_info max1118_info = { 156static const struct iio_info max1118_info = {
157 .read_raw = max1118_read_raw, 157 .read_raw = max1118_read_raw,
158 .driver_module = THIS_MODULE,
159}; 158};
160 159
161static irqreturn_t max1118_trigger_handler(int irq, void *p) 160static irqreturn_t max1118_trigger_handler(int irq, void *p)
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index 80eada4886b3..7f1848dac9bf 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -1029,7 +1029,6 @@ static int max1363_update_scan_mode(struct iio_dev *indio_dev,
1029 1029
1030static const struct iio_info max1238_info = { 1030static const struct iio_info max1238_info = {
1031 .read_raw = &max1363_read_raw, 1031 .read_raw = &max1363_read_raw,
1032 .driver_module = THIS_MODULE,
1033 .update_scan_mode = &max1363_update_scan_mode, 1032 .update_scan_mode = &max1363_update_scan_mode,
1034}; 1033};
1035 1034
@@ -1040,7 +1039,6 @@ static const struct iio_info max1363_info = {
1040 .write_event_config = &max1363_write_event_config, 1039 .write_event_config = &max1363_write_event_config,
1041 .read_raw = &max1363_read_raw, 1040 .read_raw = &max1363_read_raw,
1042 .update_scan_mode = &max1363_update_scan_mode, 1041 .update_scan_mode = &max1363_update_scan_mode,
1043 .driver_module = THIS_MODULE,
1044 .event_attrs = &max1363_event_attribute_group, 1042 .event_attrs = &max1363_event_attribute_group,
1045}; 1043};
1046 1044
diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index b1dd17cbce58..0538ff8c4ac1 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -460,7 +460,6 @@ static const struct attribute_group max9611_attribute_group = {
460}; 460};
461 461
462static const struct iio_info indio_info = { 462static const struct iio_info indio_info = {
463 .driver_module = THIS_MODULE,
464 .read_raw = max9611_read_raw, 463 .read_raw = max9611_read_raw,
465 .attrs = &max9611_attribute_group, 464 .attrs = &max9611_attribute_group,
466}; 465};
@@ -573,7 +572,6 @@ static int max9611_probe(struct i2c_client *client,
573static struct i2c_driver max9611_driver = { 572static struct i2c_driver max9611_driver = {
574 .driver = { 573 .driver = {
575 .name = DRIVER_NAME, 574 .name = DRIVER_NAME,
576 .owner = THIS_MODULE,
577 .of_match_table = max9611_of_table, 575 .of_match_table = max9611_of_table,
578 }, 576 },
579 .probe = max9611_probe, 577 .probe = max9611_probe,
diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
index 071dd23a33d9..a04856d8afdb 100644
--- a/drivers/iio/adc/mcp320x.c
+++ b/drivers/iio/adc/mcp320x.c
@@ -19,6 +19,11 @@
19 * ------------ 19 * ------------
20 * 13 bit converter 20 * 13 bit converter
21 * MCP3301 21 * MCP3301
22 * ------------
23 * 22 bit converter
24 * MCP3550
25 * MCP3551
26 * MCP3553
22 * 27 *
23 * Datasheet can be found here: 28 * Datasheet can be found here:
24 * http://ww1.microchip.com/downloads/en/DeviceDoc/21293C.pdf mcp3001 29 * http://ww1.microchip.com/downloads/en/DeviceDoc/21293C.pdf mcp3001
@@ -28,6 +33,7 @@
28 * http://ww1.microchip.com/downloads/en/DeviceDoc/21034D.pdf mcp3202 33 * http://ww1.microchip.com/downloads/en/DeviceDoc/21034D.pdf mcp3202
29 * http://ww1.microchip.com/downloads/en/DeviceDoc/21298c.pdf mcp3204/08 34 * http://ww1.microchip.com/downloads/en/DeviceDoc/21298c.pdf mcp3204/08
30 * http://ww1.microchip.com/downloads/en/DeviceDoc/21700E.pdf mcp3301 35 * http://ww1.microchip.com/downloads/en/DeviceDoc/21700E.pdf mcp3301
36 * http://ww1.microchip.com/downloads/en/DeviceDoc/21950D.pdf mcp3550/1/3
31 * 37 *
32 * This program is free software; you can redistribute it and/or modify 38 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License version 2 as 39 * it under the terms of the GNU General Public License version 2 as
@@ -51,25 +57,45 @@ enum {
51 mcp3204, 57 mcp3204,
52 mcp3208, 58 mcp3208,
53 mcp3301, 59 mcp3301,
60 mcp3550_50,
61 mcp3550_60,
62 mcp3551,
63 mcp3553,
54}; 64};
55 65
56struct mcp320x_chip_info { 66struct mcp320x_chip_info {
57 const struct iio_chan_spec *channels; 67 const struct iio_chan_spec *channels;
58 unsigned int num_channels; 68 unsigned int num_channels;
59 unsigned int resolution; 69 unsigned int resolution;
70 unsigned int conv_time; /* usec */
60}; 71};
61 72
73/**
74 * struct mcp320x - Microchip SPI ADC instance
75 * @spi: SPI slave (parent of the IIO device)
76 * @msg: SPI message to select a channel and receive a value from the ADC
77 * @transfer: SPI transfers used by @msg
78 * @start_conv_msg: SPI message to start a conversion by briefly asserting CS
79 * @start_conv_transfer: SPI transfer used by @start_conv_msg
80 * @reg: regulator generating Vref
81 * @lock: protects read sequences
82 * @chip_info: ADC properties
83 * @tx_buf: buffer for @transfer[0] (not used on single-channel converters)
84 * @rx_buf: buffer for @transfer[1]
85 */
62struct mcp320x { 86struct mcp320x {
63 struct spi_device *spi; 87 struct spi_device *spi;
64 struct spi_message msg; 88 struct spi_message msg;
65 struct spi_transfer transfer[2]; 89 struct spi_transfer transfer[2];
90 struct spi_message start_conv_msg;
91 struct spi_transfer start_conv_transfer;
66 92
67 struct regulator *reg; 93 struct regulator *reg;
68 struct mutex lock; 94 struct mutex lock;
69 const struct mcp320x_chip_info *chip_info; 95 const struct mcp320x_chip_info *chip_info;
70 96
71 u8 tx_buf ____cacheline_aligned; 97 u8 tx_buf ____cacheline_aligned;
72 u8 rx_buf[2]; 98 u8 rx_buf[4];
73}; 99};
74 100
75static int mcp320x_channel_to_tx_data(int device_index, 101static int mcp320x_channel_to_tx_data(int device_index,
@@ -78,10 +104,6 @@ static int mcp320x_channel_to_tx_data(int device_index,
78 int start_bit = 1; 104 int start_bit = 1;
79 105
80 switch (device_index) { 106 switch (device_index) {
81 case mcp3001:
82 case mcp3201:
83 case mcp3301:
84 return 0;
85 case mcp3002: 107 case mcp3002:
86 case mcp3202: 108 case mcp3202:
87 return ((start_bit << 4) | (!differential << 3) | 109 return ((start_bit << 4) | (!differential << 3) |
@@ -102,21 +124,24 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel,
102{ 124{
103 int ret; 125 int ret;
104 126
105 adc->rx_buf[0] = 0; 127 if (adc->chip_info->conv_time) {
106 adc->rx_buf[1] = 0; 128 ret = spi_sync(adc->spi, &adc->start_conv_msg);
107 adc->tx_buf = mcp320x_channel_to_tx_data(device_index,
108 channel, differential);
109
110 if (device_index != mcp3001 && device_index != mcp3201 && device_index != mcp3301) {
111 ret = spi_sync(adc->spi, &adc->msg);
112 if (ret < 0)
113 return ret;
114 } else {
115 ret = spi_read(adc->spi, &adc->rx_buf, sizeof(adc->rx_buf));
116 if (ret < 0) 129 if (ret < 0)
117 return ret; 130 return ret;
131
132 usleep_range(adc->chip_info->conv_time,
133 adc->chip_info->conv_time + 100);
118 } 134 }
119 135
136 memset(&adc->rx_buf, 0, sizeof(adc->rx_buf));
137 if (adc->chip_info->num_channels > 1)
138 adc->tx_buf = mcp320x_channel_to_tx_data(device_index, channel,
139 differential);
140
141 ret = spi_sync(adc->spi, &adc->msg);
142 if (ret < 0)
143 return ret;
144
120 switch (device_index) { 145 switch (device_index) {
121 case mcp3001: 146 case mcp3001:
122 *val = (adc->rx_buf[0] << 5 | adc->rx_buf[1] >> 3); 147 *val = (adc->rx_buf[0] << 5 | adc->rx_buf[1] >> 3);
@@ -138,6 +163,31 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel,
138 *val = sign_extend32((adc->rx_buf[0] & 0x1f) << 8 163 *val = sign_extend32((adc->rx_buf[0] & 0x1f) << 8
139 | adc->rx_buf[1], 12); 164 | adc->rx_buf[1], 12);
140 return 0; 165 return 0;
166 case mcp3550_50:
167 case mcp3550_60:
168 case mcp3551:
169 case mcp3553: {
170 u32 raw = be32_to_cpup((u32 *)adc->rx_buf);
171
172 if (!(adc->spi->mode & SPI_CPOL))
173 raw <<= 1; /* strip Data Ready bit in SPI mode 0,0 */
174
175 /*
176 * If the input is within -vref and vref, bit 21 is the sign.
177 * Up to 12% overrange or underrange are allowed, in which case
178 * bit 23 is the sign and bit 0 to 21 is the value.
179 */
180 raw >>= 8;
181 if (raw & BIT(22) && raw & BIT(23))
182 return -EIO; /* cannot have overrange AND underrange */
183 else if (raw & BIT(22))
184 raw &= ~BIT(22); /* overrange */
185 else if (raw & BIT(23) || raw & BIT(21))
186 raw |= GENMASK(31, 22); /* underrange or negative */
187
188 *val = (s32)raw;
189 return 0;
190 }
141 default: 191 default:
142 return -EINVAL; 192 return -EINVAL;
143 } 193 }
@@ -248,7 +298,6 @@ static const struct iio_chan_spec mcp3208_channels[] = {
248 298
249static const struct iio_info mcp320x_info = { 299static const struct iio_info mcp320x_info = {
250 .read_raw = mcp320x_read_raw, 300 .read_raw = mcp320x_read_raw,
251 .driver_module = THIS_MODULE,
252}; 301};
253 302
254static const struct mcp320x_chip_info mcp320x_chip_infos[] = { 303static const struct mcp320x_chip_info mcp320x_chip_infos[] = {
@@ -297,6 +346,31 @@ static const struct mcp320x_chip_info mcp320x_chip_infos[] = {
297 .num_channels = ARRAY_SIZE(mcp3201_channels), 346 .num_channels = ARRAY_SIZE(mcp3201_channels),
298 .resolution = 13 347 .resolution = 13
299 }, 348 },
349 [mcp3550_50] = {
350 .channels = mcp3201_channels,
351 .num_channels = ARRAY_SIZE(mcp3201_channels),
352 .resolution = 21,
353 /* 2% max deviation + 144 clock periods to exit shutdown */
354 .conv_time = 80000 * 1.02 + 144000 / 102.4,
355 },
356 [mcp3550_60] = {
357 .channels = mcp3201_channels,
358 .num_channels = ARRAY_SIZE(mcp3201_channels),
359 .resolution = 21,
360 .conv_time = 66670 * 1.02 + 144000 / 122.88,
361 },
362 [mcp3551] = {
363 .channels = mcp3201_channels,
364 .num_channels = ARRAY_SIZE(mcp3201_channels),
365 .resolution = 21,
366 .conv_time = 73100 * 1.02 + 144000 / 112.64,
367 },
368 [mcp3553] = {
369 .channels = mcp3201_channels,
370 .num_channels = ARRAY_SIZE(mcp3201_channels),
371 .resolution = 21,
372 .conv_time = 16670 * 1.02 + 144000 / 122.88,
373 },
300}; 374};
301 375
302static int mcp320x_probe(struct spi_device *spi) 376static int mcp320x_probe(struct spi_device *spi)
@@ -304,7 +378,7 @@ static int mcp320x_probe(struct spi_device *spi)
304 struct iio_dev *indio_dev; 378 struct iio_dev *indio_dev;
305 struct mcp320x *adc; 379 struct mcp320x *adc;
306 const struct mcp320x_chip_info *chip_info; 380 const struct mcp320x_chip_info *chip_info;
307 int ret; 381 int ret, device_index;
308 382
309 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); 383 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
310 if (!indio_dev) 384 if (!indio_dev)
@@ -320,7 +394,8 @@ static int mcp320x_probe(struct spi_device *spi)
320 indio_dev->info = &mcp320x_info; 394 indio_dev->info = &mcp320x_info;
321 spi_set_drvdata(spi, indio_dev); 395 spi_set_drvdata(spi, indio_dev);
322 396
323 chip_info = &mcp320x_chip_infos[spi_get_device_id(spi)->driver_data]; 397 device_index = spi_get_device_id(spi)->driver_data;
398 chip_info = &mcp320x_chip_infos[device_index];
324 indio_dev->channels = chip_info->channels; 399 indio_dev->channels = chip_info->channels;
325 indio_dev->num_channels = chip_info->num_channels; 400 indio_dev->num_channels = chip_info->num_channels;
326 401
@@ -329,10 +404,41 @@ static int mcp320x_probe(struct spi_device *spi)
329 adc->transfer[0].tx_buf = &adc->tx_buf; 404 adc->transfer[0].tx_buf = &adc->tx_buf;
330 adc->transfer[0].len = sizeof(adc->tx_buf); 405 adc->transfer[0].len = sizeof(adc->tx_buf);
331 adc->transfer[1].rx_buf = adc->rx_buf; 406 adc->transfer[1].rx_buf = adc->rx_buf;
332 adc->transfer[1].len = sizeof(adc->rx_buf); 407 adc->transfer[1].len = DIV_ROUND_UP(chip_info->resolution, 8);
408
409 if (chip_info->num_channels == 1)
410 /* single-channel converters are rx only (no MOSI pin) */
411 spi_message_init_with_transfers(&adc->msg,
412 &adc->transfer[1], 1);
413 else
414 spi_message_init_with_transfers(&adc->msg, adc->transfer,
415 ARRAY_SIZE(adc->transfer));
333 416
334 spi_message_init_with_transfers(&adc->msg, adc->transfer, 417 switch (device_index) {
335 ARRAY_SIZE(adc->transfer)); 418 case mcp3550_50:
419 case mcp3550_60:
420 case mcp3551:
421 case mcp3553:
422 /* rx len increases from 24 to 25 bit in SPI mode 0,0 */
423 if (!(spi->mode & SPI_CPOL))
424 adc->transfer[1].len++;
425
426 /* conversions are started by asserting CS pin for 8 usec */
427 adc->start_conv_transfer.delay_usecs = 8;
428 spi_message_init_with_transfers(&adc->start_conv_msg,
429 &adc->start_conv_transfer, 1);
430
431 /*
432 * If CS was previously kept low (continuous conversion mode)
433 * and then changed to high, the chip is in shutdown.
434 * Sometimes it fails to wake from shutdown and clocks out
435 * only 0xffffff. The magic sequence of performing two
436 * conversions without delay between them resets the chip
437 * and ensures all subsequent conversions succeed.
438 */
439 mcp320x_adc_conversion(adc, 0, 1, device_index, &ret);
440 mcp320x_adc_conversion(adc, 0, 1, device_index, &ret);
441 }
336 442
337 adc->reg = devm_regulator_get(&spi->dev, "vref"); 443 adc->reg = devm_regulator_get(&spi->dev, "vref");
338 if (IS_ERR(adc->reg)) 444 if (IS_ERR(adc->reg))
@@ -370,62 +476,29 @@ static int mcp320x_remove(struct spi_device *spi)
370#if defined(CONFIG_OF) 476#if defined(CONFIG_OF)
371static const struct of_device_id mcp320x_dt_ids[] = { 477static const struct of_device_id mcp320x_dt_ids[] = {
372 /* NOTE: The use of compatibles with no vendor prefix is deprecated. */ 478 /* NOTE: The use of compatibles with no vendor prefix is deprecated. */
373 { 479 { .compatible = "mcp3001" },
374 .compatible = "mcp3001", 480 { .compatible = "mcp3002" },
375 .data = &mcp320x_chip_infos[mcp3001], 481 { .compatible = "mcp3004" },
376 }, { 482 { .compatible = "mcp3008" },
377 .compatible = "mcp3002", 483 { .compatible = "mcp3201" },
378 .data = &mcp320x_chip_infos[mcp3002], 484 { .compatible = "mcp3202" },
379 }, { 485 { .compatible = "mcp3204" },
380 .compatible = "mcp3004", 486 { .compatible = "mcp3208" },
381 .data = &mcp320x_chip_infos[mcp3004], 487 { .compatible = "mcp3301" },
382 }, { 488 { .compatible = "microchip,mcp3001" },
383 .compatible = "mcp3008", 489 { .compatible = "microchip,mcp3002" },
384 .data = &mcp320x_chip_infos[mcp3008], 490 { .compatible = "microchip,mcp3004" },
385 }, { 491 { .compatible = "microchip,mcp3008" },
386 .compatible = "mcp3201", 492 { .compatible = "microchip,mcp3201" },
387 .data = &mcp320x_chip_infos[mcp3201], 493 { .compatible = "microchip,mcp3202" },
388 }, { 494 { .compatible = "microchip,mcp3204" },
389 .compatible = "mcp3202", 495 { .compatible = "microchip,mcp3208" },
390 .data = &mcp320x_chip_infos[mcp3202], 496 { .compatible = "microchip,mcp3301" },
391 }, { 497 { .compatible = "microchip,mcp3550-50" },
392 .compatible = "mcp3204", 498 { .compatible = "microchip,mcp3550-60" },
393 .data = &mcp320x_chip_infos[mcp3204], 499 { .compatible = "microchip,mcp3551" },
394 }, { 500 { .compatible = "microchip,mcp3553" },
395 .compatible = "mcp3208", 501 { }
396 .data = &mcp320x_chip_infos[mcp3208],
397 }, {
398 .compatible = "mcp3301",
399 .data = &mcp320x_chip_infos[mcp3301],
400 }, {
401 .compatible = "microchip,mcp3001",
402 .data = &mcp320x_chip_infos[mcp3001],
403 }, {
404 .compatible = "microchip,mcp3002",
405 .data = &mcp320x_chip_infos[mcp3002],
406 }, {
407 .compatible = "microchip,mcp3004",
408 .data = &mcp320x_chip_infos[mcp3004],
409 }, {
410 .compatible = "microchip,mcp3008",
411 .data = &mcp320x_chip_infos[mcp3008],
412 }, {
413 .compatible = "microchip,mcp3201",
414 .data = &mcp320x_chip_infos[mcp3201],
415 }, {
416 .compatible = "microchip,mcp3202",
417 .data = &mcp320x_chip_infos[mcp3202],
418 }, {
419 .compatible = "microchip,mcp3204",
420 .data = &mcp320x_chip_infos[mcp3204],
421 }, {
422 .compatible = "microchip,mcp3208",
423 .data = &mcp320x_chip_infos[mcp3208],
424 }, {
425 .compatible = "microchip,mcp3301",
426 .data = &mcp320x_chip_infos[mcp3301],
427 }, {
428 }
429}; 502};
430MODULE_DEVICE_TABLE(of, mcp320x_dt_ids); 503MODULE_DEVICE_TABLE(of, mcp320x_dt_ids);
431#endif 504#endif
@@ -440,6 +513,10 @@ static const struct spi_device_id mcp320x_id[] = {
440 { "mcp3204", mcp3204 }, 513 { "mcp3204", mcp3204 },
441 { "mcp3208", mcp3208 }, 514 { "mcp3208", mcp3208 },
442 { "mcp3301", mcp3301 }, 515 { "mcp3301", mcp3301 },
516 { "mcp3550-50", mcp3550_50 },
517 { "mcp3550-60", mcp3550_60 },
518 { "mcp3551", mcp3551 },
519 { "mcp3553", mcp3553 },
443 { } 520 { }
444}; 521};
445MODULE_DEVICE_TABLE(spi, mcp320x_id); 522MODULE_DEVICE_TABLE(spi, mcp320x_id);
@@ -456,5 +533,5 @@ static struct spi_driver mcp320x_driver = {
456module_spi_driver(mcp320x_driver); 533module_spi_driver(mcp320x_driver);
457 534
458MODULE_AUTHOR("Oskar Andero <oskar.andero@gmail.com>"); 535MODULE_AUTHOR("Oskar Andero <oskar.andero@gmail.com>");
459MODULE_DESCRIPTION("Microchip Technology MCP3x01/02/04/08"); 536MODULE_DESCRIPTION("Microchip Technology MCP3x01/02/04/08 and MCP3550/1/3");
460MODULE_LICENSE("GPL v2"); 537MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
index 63de705086ed..819f26011500 100644
--- a/drivers/iio/adc/mcp3422.c
+++ b/drivers/iio/adc/mcp3422.c
@@ -327,7 +327,6 @@ static const struct iio_info mcp3422_info = {
327 .write_raw = mcp3422_write_raw, 327 .write_raw = mcp3422_write_raw,
328 .write_raw_get_fmt = mcp3422_write_raw_get_fmt, 328 .write_raw_get_fmt = mcp3422_write_raw_get_fmt,
329 .attrs = &mcp3422_attribute_group, 329 .attrs = &mcp3422_attribute_group,
330 .driver_module = THIS_MODULE,
331}; 330};
332 331
333static int mcp3422_probe(struct i2c_client *client, 332static int mcp3422_probe(struct i2c_client *client,
diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
index 8f3606de4eaf..c80261748d8f 100644
--- a/drivers/iio/adc/men_z188_adc.c
+++ b/drivers/iio/adc/men_z188_adc.c
@@ -80,7 +80,6 @@ static int z188_iio_read_raw(struct iio_dev *iio_dev,
80 80
81static const struct iio_info z188_adc_info = { 81static const struct iio_info z188_adc_info = {
82 .read_raw = &z188_iio_read_raw, 82 .read_raw = &z188_iio_read_raw,
83 .driver_module = THIS_MODULE,
84}; 83};
85 84
86static void men_z188_config_channels(void __iomem *addr) 85static void men_z188_config_channels(void __iomem *addr)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 2e8dbb89c8c9..9c6932ffc0af 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -840,7 +840,6 @@ out:
840 840
841static const struct iio_info meson_sar_adc_iio_info = { 841static const struct iio_info meson_sar_adc_iio_info = {
842 .read_raw = meson_sar_adc_iio_info_read_raw, 842 .read_raw = meson_sar_adc_iio_info_read_raw,
843 .driver_module = THIS_MODULE,
844}; 843};
845 844
846static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { 845static const struct meson_sar_adc_data meson_sar_adc_meson8_data = {
diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 414cf44bf19d..95d76abb64ec 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -180,7 +180,6 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev,
180} 180}
181 181
182static const struct iio_info mt6577_auxadc_info = { 182static const struct iio_info mt6577_auxadc_info = {
183 .driver_module = THIS_MODULE,
184 .read_raw = &mt6577_auxadc_read_raw, 183 .read_raw = &mt6577_auxadc_read_raw,
185}; 184};
186 185
@@ -306,6 +305,7 @@ static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops,
306 305
307static const struct of_device_id mt6577_auxadc_of_match[] = { 306static const struct of_device_id mt6577_auxadc_of_match[] = {
308 { .compatible = "mediatek,mt2701-auxadc", }, 307 { .compatible = "mediatek,mt2701-auxadc", },
308 { .compatible = "mediatek,mt2712-auxadc", },
309 { .compatible = "mediatek,mt7622-auxadc", }, 309 { .compatible = "mediatek,mt7622-auxadc", },
310 { .compatible = "mediatek,mt8173-auxadc", }, 310 { .compatible = "mediatek,mt8173-auxadc", },
311 { } 311 { }
diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index d32b34638c2f..c627513d9f0f 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -382,7 +382,6 @@ static const struct attribute_group mxs_lradc_adc_attribute_group = {
382}; 382};
383 383
384static const struct iio_info mxs_lradc_adc_iio_info = { 384static const struct iio_info mxs_lradc_adc_iio_info = {
385 .driver_module = THIS_MODULE,
386 .read_raw = mxs_lradc_adc_read_raw, 385 .read_raw = mxs_lradc_adc_read_raw,
387 .write_raw = mxs_lradc_adc_write_raw, 386 .write_raw = mxs_lradc_adc_write_raw,
388 .write_raw_get_fmt = mxs_lradc_adc_write_raw_get_fmt, 387 .write_raw_get_fmt = mxs_lradc_adc_write_raw_get_fmt,
@@ -455,7 +454,6 @@ static int mxs_lradc_adc_configure_trigger(struct iio_trigger *trig, bool state)
455} 454}
456 455
457static const struct iio_trigger_ops mxs_lradc_adc_trigger_ops = { 456static const struct iio_trigger_ops mxs_lradc_adc_trigger_ops = {
458 .owner = THIS_MODULE,
459 .set_trigger_state = &mxs_lradc_adc_configure_trigger, 457 .set_trigger_state = &mxs_lradc_adc_configure_trigger,
460}; 458};
461 459
diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index 08f446695f97..8997e74a8847 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -402,7 +402,6 @@ static int nau7802_write_raw_get_fmt(struct iio_dev *indio_dev,
402} 402}
403 403
404static const struct iio_info nau7802_info = { 404static const struct iio_info nau7802_info = {
405 .driver_module = THIS_MODULE,
406 .read_raw = &nau7802_read_raw, 405 .read_raw = &nau7802_read_raw,
407 .write_raw = &nau7802_write_raw, 406 .write_raw = &nau7802_write_raw,
408 .write_raw_get_fmt = nau7802_write_raw_get_fmt, 407 .write_raw_get_fmt = nau7802_write_raw_get_fmt,
diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index 7d61b566e148..69b9affeef1e 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -430,7 +430,6 @@ out:
430 430
431static const struct iio_info palmas_gpadc_iio_info = { 431static const struct iio_info palmas_gpadc_iio_info = {
432 .read_raw = palmas_gpadc_read_raw, 432 .read_raw = palmas_gpadc_read_raw,
433 .driver_module = THIS_MODULE,
434}; 433};
435 434
436#define PALMAS_ADC_CHAN_IIO(chan, _type, chan_info) \ 435#define PALMAS_ADC_CHAN_IIO(chan, _type, chan_info) \
diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index cea8f1fb444a..b093ecddf1a8 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -728,7 +728,6 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
728} 728}
729 729
730static const struct iio_info pm8xxx_xoadc_info = { 730static const struct iio_info pm8xxx_xoadc_info = {
731 .driver_module = THIS_MODULE,
732 .of_xlate = pm8xxx_of_xlate, 731 .of_xlate = pm8xxx_of_xlate,
733 .read_raw = pm8xxx_read_raw, 732 .read_raw = pm8xxx_read_raw,
734}; 733};
diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c
index fabd24edc2a1..3f062cd61aba 100644
--- a/drivers/iio/adc/qcom-spmi-iadc.c
+++ b/drivers/iio/adc/qcom-spmi-iadc.c
@@ -356,7 +356,6 @@ static int iadc_read_raw(struct iio_dev *indio_dev,
356 356
357static const struct iio_info iadc_info = { 357static const struct iio_info iadc_info = {
358 .read_raw = iadc_read_raw, 358 .read_raw = iadc_read_raw,
359 .driver_module = THIS_MODULE,
360}; 359};
361 360
362static irqreturn_t iadc_isr(int irq, void *dev_id) 361static irqreturn_t iadc_isr(int irq, void *dev_id)
diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index 9e600bfd1765..3680e0d47412 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -506,7 +506,6 @@ static int vadc_of_xlate(struct iio_dev *indio_dev,
506static const struct iio_info vadc_info = { 506static const struct iio_info vadc_info = {
507 .read_raw = vadc_read_raw, 507 .read_raw = vadc_read_raw,
508 .of_xlate = vadc_of_xlate, 508 .of_xlate = vadc_of_xlate,
509 .driver_module = THIS_MODULE,
510}; 509};
511 510
512struct vadc_channels { 511struct vadc_channels {
diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index 27a318164619..dcb50172186f 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -277,7 +277,6 @@ static int rcar_gyroadc_reg_access(struct iio_dev *indio_dev,
277} 277}
278 278
279static const struct iio_info rcar_gyroadc_iio_info = { 279static const struct iio_info rcar_gyroadc_iio_info = {
280 .driver_module = THIS_MODULE,
281 .read_raw = rcar_gyroadc_read_raw, 280 .read_raw = rcar_gyroadc_read_raw,
282 .debugfs_reg_access = rcar_gyroadc_reg_access, 281 .debugfs_reg_access = rcar_gyroadc_reg_access,
283}; 282};
@@ -349,7 +348,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
349 continue; 348 continue;
350 } 349 }
351 350
352 childmode = (unsigned int)of_id->data; 351 childmode = (uintptr_t)of_id->data;
353 switch (childmode) { 352 switch (childmode) {
354 case RCAR_GYROADC_MODE_SELECT_1_MB88101A: 353 case RCAR_GYROADC_MODE_SELECT_1_MB88101A:
355 sample_width = 12; 354 sample_width = 12;
@@ -488,8 +487,6 @@ err:
488 487
489static int rcar_gyroadc_probe(struct platform_device *pdev) 488static int rcar_gyroadc_probe(struct platform_device *pdev)
490{ 489{
491 const struct of_device_id *of_id =
492 of_match_device(rcar_gyroadc_match, &pdev->dev);
493 struct device *dev = &pdev->dev; 490 struct device *dev = &pdev->dev;
494 struct rcar_gyroadc *priv; 491 struct rcar_gyroadc *priv;
495 struct iio_dev *indio_dev; 492 struct iio_dev *indio_dev;
@@ -526,7 +523,8 @@ static int rcar_gyroadc_probe(struct platform_device *pdev)
526 if (ret) 523 if (ret)
527 return ret; 524 return ret;
528 525
529 priv->model = (enum rcar_gyroadc_model)of_id->data; 526 priv->model = (enum rcar_gyroadc_model)
527 of_device_get_match_data(&pdev->dev);
530 528
531 platform_set_drvdata(pdev, indio_dev); 529 platform_set_drvdata(pdev, indio_dev);
532 530
diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index 5f612d694b33..1f98566d5b3c 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -125,7 +125,6 @@ static irqreturn_t rockchip_saradc_isr(int irq, void *dev_id)
125 125
126static const struct iio_info rockchip_saradc_iio_info = { 126static const struct iio_info rockchip_saradc_iio_info = {
127 .read_raw = rockchip_saradc_read_raw, 127 .read_raw = rockchip_saradc_read_raw,
128 .driver_module = THIS_MODULE,
129}; 128};
130 129
131#define ADC_CHANNEL(_index, _id) { \ 130#define ADC_CHANNEL(_index, _id) { \
diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
index 5dd61f6a57b9..b1da2c46107c 100644
--- a/drivers/iio/adc/spear_adc.c
+++ b/drivers/iio/adc/spear_adc.c
@@ -254,7 +254,6 @@ static int spear_adc_configure(struct spear_adc_state *st)
254static const struct iio_info spear_adc_info = { 254static const struct iio_info spear_adc_info = {
255 .read_raw = &spear_adc_read_raw, 255 .read_raw = &spear_adc_read_raw,
256 .write_raw = &spear_adc_write_raw, 256 .write_raw = &spear_adc_write_raw,
257 .driver_module = THIS_MODULE,
258}; 257};
259 258
260static int spear_adc_probe(struct platform_device *pdev) 259static int spear_adc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index 804198eb0eef..6aefef99f935 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -139,6 +139,11 @@ static int stm32f4_adc_clk_sel(struct platform_device *pdev,
139 } 139 }
140 140
141 rate = clk_get_rate(priv->aclk); 141 rate = clk_get_rate(priv->aclk);
142 if (!rate) {
143 dev_err(&pdev->dev, "Invalid clock rate: 0\n");
144 return -EINVAL;
145 }
146
142 for (i = 0; i < ARRAY_SIZE(stm32f4_pclk_div); i++) { 147 for (i = 0; i < ARRAY_SIZE(stm32f4_pclk_div); i++) {
143 if ((rate / stm32f4_pclk_div[i]) <= STM32F4_ADC_MAX_CLK_RATE) 148 if ((rate / stm32f4_pclk_div[i]) <= STM32F4_ADC_MAX_CLK_RATE)
144 break; 149 break;
@@ -216,6 +221,10 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
216 * From spec: PLL output musn't exceed max rate 221 * From spec: PLL output musn't exceed max rate
217 */ 222 */
218 rate = clk_get_rate(priv->aclk); 223 rate = clk_get_rate(priv->aclk);
224 if (!rate) {
225 dev_err(&pdev->dev, "Invalid adc clock rate: 0\n");
226 return -EINVAL;
227 }
219 228
220 for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) { 229 for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) {
221 ckmode = stm32h7_adc_ckmodes_spec[i].ckmode; 230 ckmode = stm32h7_adc_ckmodes_spec[i].ckmode;
@@ -232,6 +241,10 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
232 241
233 /* Synchronous clock modes (e.g. ckmode is 1, 2 or 3) */ 242 /* Synchronous clock modes (e.g. ckmode is 1, 2 or 3) */
234 rate = clk_get_rate(priv->bclk); 243 rate = clk_get_rate(priv->bclk);
244 if (!rate) {
245 dev_err(&pdev->dev, "Invalid bus clock rate: 0\n");
246 return -EINVAL;
247 }
235 248
236 for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) { 249 for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) {
237 ckmode = stm32h7_adc_ckmodes_spec[i].ckmode; 250 ckmode = stm32h7_adc_ckmodes_spec[i].ckmode;
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 4df32cf1650e..c9d96f935dba 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -531,6 +531,7 @@ static struct stm32_adc_trig_info stm32h7_adc_trigs[] = {
531 { TIM2_TRGO, STM32_EXT11 }, 531 { TIM2_TRGO, STM32_EXT11 },
532 { TIM4_TRGO, STM32_EXT12 }, 532 { TIM4_TRGO, STM32_EXT12 },
533 { TIM6_TRGO, STM32_EXT13 }, 533 { TIM6_TRGO, STM32_EXT13 },
534 { TIM15_TRGO, STM32_EXT14 },
534 { TIM3_CH4, STM32_EXT15 }, 535 { TIM3_CH4, STM32_EXT15 },
535 { LPTIM1_OUT, STM32_EXT18 }, 536 { LPTIM1_OUT, STM32_EXT18 },
536 { LPTIM2_OUT, STM32_EXT19 }, 537 { LPTIM2_OUT, STM32_EXT19 },
@@ -1385,7 +1386,6 @@ static const struct iio_info stm32_adc_iio_info = {
1385 .update_scan_mode = stm32_adc_update_scan_mode, 1386 .update_scan_mode = stm32_adc_update_scan_mode,
1386 .debugfs_reg_access = stm32_adc_debugfs_reg_access, 1387 .debugfs_reg_access = stm32_adc_debugfs_reg_access,
1387 .of_xlate = stm32_adc_of_xlate, 1388 .of_xlate = stm32_adc_of_xlate,
1388 .driver_module = THIS_MODULE,
1389}; 1389};
1390 1390
1391static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc) 1391static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index 2da741d27540..17b021f33180 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -172,7 +172,6 @@ static int stx104_write_raw(struct iio_dev *indio_dev,
172} 172}
173 173
174static const struct iio_info stx104_info = { 174static const struct iio_info stx104_info = {
175 .driver_module = THIS_MODULE,
176 .read_raw = stx104_read_raw, 175 .read_raw = stx104_read_raw,
177 .write_raw = stx104_write_raw 176 .write_raw = stx104_write_raw
178}; 177};
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 137f577d9432..04d7147e0110 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -352,7 +352,6 @@ static int sun4i_gpadc_read_raw(struct iio_dev *indio_dev,
352 352
353static const struct iio_info sun4i_gpadc_iio_info = { 353static const struct iio_info sun4i_gpadc_iio_info = {
354 .read_raw = sun4i_gpadc_read_raw, 354 .read_raw = sun4i_gpadc_read_raw,
355 .driver_module = THIS_MODULE,
356}; 355};
357 356
358static irqreturn_t sun4i_gpadc_temp_data_irq_handler(int irq, void *dev_id) 357static irqreturn_t sun4i_gpadc_temp_data_irq_handler(int irq, void *dev_id)
@@ -502,17 +501,15 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
502 struct iio_dev *indio_dev) 501 struct iio_dev *indio_dev)
503{ 502{
504 struct sun4i_gpadc_iio *info = iio_priv(indio_dev); 503 struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
505 const struct of_device_id *of_dev;
506 struct resource *mem; 504 struct resource *mem;
507 void __iomem *base; 505 void __iomem *base;
508 int ret; 506 int ret;
509 507
510 of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev); 508 info->data = of_device_get_match_data(&pdev->dev);
511 if (!of_dev) 509 if (!info->data)
512 return -ENODEV; 510 return -ENODEV;
513 511
514 info->no_irq = true; 512 info->no_irq = true;
515 info->data = (struct gpadc_data *)of_dev->data;
516 indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels); 513 indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
517 indio_dev->channels = sun8i_a33_gpadc_channels; 514 indio_dev->channels = sun8i_a33_gpadc_channels;
518 515
@@ -529,17 +526,10 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
529 return ret; 526 return ret;
530 } 527 }
531 528
532 if (!IS_ENABLED(CONFIG_THERMAL_OF)) 529 if (IS_ENABLED(CONFIG_THERMAL_OF))
533 return 0; 530 info->sensor_device = &pdev->dev;
534 531
535 info->sensor_device = &pdev->dev; 532 return 0;
536 info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0,
537 info, &sun4i_ts_tz_ops);
538 if (IS_ERR(info->tzd))
539 dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
540 PTR_ERR(info->tzd));
541
542 return PTR_ERR_OR_ZERO(info->tzd);
543} 533}
544 534
545static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, 535static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
@@ -586,15 +576,6 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
586 * return the temperature. 576 * return the temperature.
587 */ 577 */
588 info->sensor_device = pdev->dev.parent; 578 info->sensor_device = pdev->dev.parent;
589 info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
590 0, info,
591 &sun4i_ts_tz_ops);
592 if (IS_ERR(info->tzd)) {
593 dev_err(&pdev->dev,
594 "could not register thermal sensor: %ld\n",
595 PTR_ERR(info->tzd));
596 return PTR_ERR(info->tzd);
597 }
598 } else { 579 } else {
599 indio_dev->num_channels = 580 indio_dev->num_channels =
600 ARRAY_SIZE(sun4i_gpadc_channels_no_temp); 581 ARRAY_SIZE(sun4i_gpadc_channels_no_temp);
@@ -664,6 +645,22 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
664 pm_runtime_set_suspended(&pdev->dev); 645 pm_runtime_set_suspended(&pdev->dev);
665 pm_runtime_enable(&pdev->dev); 646 pm_runtime_enable(&pdev->dev);
666 647
648 if (IS_ENABLED(CONFIG_THERMAL_OF)) {
649 info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
650 0, info,
651 &sun4i_ts_tz_ops);
652 /*
653 * Do not fail driver probing when failing to register in
654 * thermal because no thermal DT node is found.
655 */
656 if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) {
657 dev_err(&pdev->dev,
658 "could not register thermal sensor: %ld\n",
659 PTR_ERR(info->tzd));
660 return PTR_ERR(info->tzd);
661 }
662 }
663
667 ret = devm_iio_device_register(&pdev->dev, indio_dev); 664 ret = devm_iio_device_register(&pdev->dev, indio_dev);
668 if (ret < 0) { 665 if (ret < 0) {
669 dev_err(&pdev->dev, "could not register the device\n"); 666 dev_err(&pdev->dev, "could not register the device\n");
diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
index 319172cf7da8..405e3779c0c5 100644
--- a/drivers/iio/adc/ti-adc081c.c
+++ b/drivers/iio/adc/ti-adc081c.c
@@ -124,7 +124,6 @@ static struct adcxx1c_model adcxx1c_models[] = {
124 124
125static const struct iio_info adc081c_info = { 125static const struct iio_info adc081c_info = {
126 .read_raw = adc081c_read_raw, 126 .read_raw = adc081c_read_raw,
127 .driver_module = THIS_MODULE,
128}; 127};
129 128
130static irqreturn_t adc081c_trigger_handler(int irq, void *p) 129static irqreturn_t adc081c_trigger_handler(int irq, void *p)
diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c
index e952e94a14af..188dae705bf7 100644
--- a/drivers/iio/adc/ti-adc0832.c
+++ b/drivers/iio/adc/ti-adc0832.c
@@ -195,7 +195,6 @@ static int adc0832_read_raw(struct iio_dev *iio,
195 195
196static const struct iio_info adc0832_info = { 196static const struct iio_info adc0832_info = {
197 .read_raw = adc0832_read_raw, 197 .read_raw = adc0832_read_raw,
198 .driver_module = THIS_MODULE,
199}; 198};
200 199
201static irqreturn_t adc0832_trigger_handler(int irq, void *p) 200static irqreturn_t adc0832_trigger_handler(int irq, void *p)
diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c
index a355121c11a4..25504640e126 100644
--- a/drivers/iio/adc/ti-adc084s021.c
+++ b/drivers/iio/adc/ti-adc084s021.c
@@ -186,7 +186,6 @@ static int adc084s021_buffer_postdisable(struct iio_dev *indio_dev)
186 186
187static const struct iio_info adc084s021_info = { 187static const struct iio_info adc084s021_info = {
188 .read_raw = adc084s021_read_raw, 188 .read_raw = adc084s021_read_raw,
189 .driver_module = THIS_MODULE,
190}; 189};
191 190
192static const struct iio_buffer_setup_ops adc084s021_buffer_setup_ops = { 191static const struct iio_buffer_setup_ops adc084s021_buffer_setup_ops = {
diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c
index de4e5ac98c6e..841203edaac5 100644
--- a/drivers/iio/adc/ti-adc108s102.c
+++ b/drivers/iio/adc/ti-adc108s102.c
@@ -220,7 +220,6 @@ static int adc108s102_read_raw(struct iio_dev *indio_dev,
220static const struct iio_info adc108s102_info = { 220static const struct iio_info adc108s102_info = {
221 .read_raw = &adc108s102_read_raw, 221 .read_raw = &adc108s102_read_raw,
222 .update_scan_mode = &adc108s102_update_scan_mode, 222 .update_scan_mode = &adc108s102_update_scan_mode,
223 .driver_module = THIS_MODULE,
224}; 223};
225 224
226static int adc108s102_probe(struct spi_device *spi) 225static int adc108s102_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c
index 072f03bfe6a0..703d68ae96b7 100644
--- a/drivers/iio/adc/ti-adc12138.c
+++ b/drivers/iio/adc/ti-adc12138.c
@@ -164,7 +164,7 @@ static int __adc12138_start_conv(struct adc12138 *adc,
164 void *data, int len) 164 void *data, int len)
165 165
166{ 166{
167 const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 }; 167 static const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
168 u8 mode = (ch_to_mux[channel->channel] << 4) | 168 u8 mode = (ch_to_mux[channel->channel] << 4) |
169 (channel->differential ? 0 : 0x80); 169 (channel->differential ? 0 : 0x80);
170 170
@@ -277,7 +277,6 @@ static int adc12138_read_raw(struct iio_dev *iio,
277 277
278static const struct iio_info adc12138_info = { 278static const struct iio_info adc12138_info = {
279 .read_raw = adc12138_read_raw, 279 .read_raw = adc12138_read_raw,
280 .driver_module = THIS_MODULE,
281}; 280};
282 281
283static int adc12138_init(struct adc12138 *adc) 282static int adc12138_init(struct adc12138 *adc)
diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 89dfbd31be5c..7cf39b3e2416 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -130,7 +130,6 @@ static const struct adc128_configuration adc128_config[] = {
130 130
131static const struct iio_info adc128_info = { 131static const struct iio_info adc128_info = {
132 .read_raw = adc128_read_raw, 132 .read_raw = adc128_read_raw,
133 .driver_module = THIS_MODULE,
134}; 133};
135 134
136static int adc128_probe(struct spi_device *spi) 135static int adc128_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ti-adc161s626.c b/drivers/iio/adc/ti-adc161s626.c
index 4836a0d7aef5..10fa7677ac4b 100644
--- a/drivers/iio/adc/ti-adc161s626.c
+++ b/drivers/iio/adc/ti-adc161s626.c
@@ -173,7 +173,6 @@ static int ti_adc_read_raw(struct iio_dev *indio_dev,
173} 173}
174 174
175static const struct iio_info ti_adc_info = { 175static const struct iio_info ti_adc_info = {
176 .driver_module = THIS_MODULE,
177 .read_raw = ti_adc_read_raw, 176 .read_raw = ti_adc_read_raw,
178}; 177};
179 178
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index e0dc20488335..6a114dcb4a3a 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -332,7 +332,7 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
332static 332static
333int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val) 333int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
334{ 334{
335 int ret, pga, dr, conv_time; 335 int ret, pga, dr, dr_old, conv_time;
336 unsigned int old, mask, cfg; 336 unsigned int old, mask, cfg;
337 337
338 if (chan < 0 || chan >= ADS1015_CHANNELS) 338 if (chan < 0 || chan >= ADS1015_CHANNELS)
@@ -358,17 +358,17 @@ int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
358 } 358 }
359 359
360 cfg = (old & ~mask) | (cfg & mask); 360 cfg = (old & ~mask) | (cfg & mask);
361 361 if (old != cfg) {
362 ret = regmap_write(data->regmap, ADS1015_CFG_REG, cfg); 362 ret = regmap_write(data->regmap, ADS1015_CFG_REG, cfg);
363 if (ret) 363 if (ret)
364 return ret; 364 return ret;
365 365 data->conv_invalid = true;
366 if (old != cfg || data->conv_invalid) { 366 }
367 int dr_old = (old & ADS1015_CFG_DR_MASK) >> 367 if (data->conv_invalid) {
368 ADS1015_CFG_DR_SHIFT; 368 dr_old = (old & ADS1015_CFG_DR_MASK) >> ADS1015_CFG_DR_SHIFT;
369
370 conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]); 369 conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]);
371 conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]); 370 conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]);
371 conv_time += conv_time / 10; /* 10% internal clock inaccuracy */
372 usleep_range(conv_time, conv_time + 1); 372 usleep_range(conv_time, conv_time + 1);
373 data->conv_invalid = false; 373 data->conv_invalid = false;
374 } 374 }
@@ -821,7 +821,6 @@ static const struct attribute_group ads1115_attribute_group = {
821}; 821};
822 822
823static const struct iio_info ads1015_info = { 823static const struct iio_info ads1015_info = {
824 .driver_module = THIS_MODULE,
825 .read_raw = ads1015_read_raw, 824 .read_raw = ads1015_read_raw,
826 .write_raw = ads1015_write_raw, 825 .write_raw = ads1015_write_raw,
827 .read_event_value = ads1015_read_event, 826 .read_event_value = ads1015_read_event,
@@ -832,7 +831,6 @@ static const struct iio_info ads1015_info = {
832}; 831};
833 832
834static const struct iio_info ads1115_info = { 833static const struct iio_info ads1115_info = {
835 .driver_module = THIS_MODULE,
836 .read_raw = ads1015_read_raw, 834 .read_raw = ads1015_read_raw,
837 .write_raw = ads1015_write_raw, 835 .write_raw = ads1015_write_raw,
838 .read_event_value = ads1015_read_event, 836 .read_event_value = ads1015_read_event,
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index a376190914ad..0225c1b333ab 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -372,7 +372,6 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
372static const struct iio_info ti_ads7950_info = { 372static const struct iio_info ti_ads7950_info = {
373 .read_raw = &ti_ads7950_read_raw, 373 .read_raw = &ti_ads7950_read_raw,
374 .update_scan_mode = ti_ads7950_update_scan_mode, 374 .update_scan_mode = ti_ads7950_update_scan_mode,
375 .driver_module = THIS_MODULE,
376}; 375};
377 376
378static int ti_ads7950_probe(struct spi_device *spi) 377static int ti_ads7950_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
index 4a163496d9e4..079f133144b0 100644
--- a/drivers/iio/adc/ti-ads8688.c
+++ b/drivers/iio/adc/ti-ads8688.c
@@ -369,7 +369,6 @@ static const struct iio_info ads8688_info = {
369 .write_raw = &ads8688_write_raw, 369 .write_raw = &ads8688_write_raw,
370 .write_raw_get_fmt = &ads8688_write_raw_get_fmt, 370 .write_raw_get_fmt = &ads8688_write_raw_get_fmt,
371 .attrs = &ads8688_attribute_group, 371 .attrs = &ads8688_attribute_group,
372 .driver_module = THIS_MODULE,
373}; 372};
374 373
375static const struct ads8688_chip_info ads8688_chip_info_tbl[] = { 374static const struct ads8688_chip_info ads8688_chip_info_tbl[] = {
@@ -474,7 +473,6 @@ MODULE_DEVICE_TABLE(of, ads8688_of_match);
474static struct spi_driver ads8688_driver = { 473static struct spi_driver ads8688_driver = {
475 .driver = { 474 .driver = {
476 .name = "ads8688", 475 .name = "ads8688",
477 .owner = THIS_MODULE,
478 }, 476 },
479 .probe = ads8688_probe, 477 .probe = ads8688_probe,
480 .remove = ads8688_remove, 478 .remove = ads8688_remove,
diff --git a/drivers/iio/adc/ti-tlc4541.c b/drivers/iio/adc/ti-tlc4541.c
index 78d91a069ea4..2290024c89fc 100644
--- a/drivers/iio/adc/ti-tlc4541.c
+++ b/drivers/iio/adc/ti-tlc4541.c
@@ -157,7 +157,6 @@ static int tlc4541_read_raw(struct iio_dev *indio_dev,
157 157
158static const struct iio_info tlc4541_info = { 158static const struct iio_info tlc4541_info = {
159 .read_raw = &tlc4541_read_raw, 159 .read_raw = &tlc4541_read_raw,
160 .driver_module = THIS_MODULE,
161}; 160};
162 161
163static int tlc4541_probe(struct spi_device *spi) 162static int tlc4541_probe(struct spi_device *spi)
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 6cbed7eb118a..b3e573cc6f5f 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -533,7 +533,6 @@ err_unlock:
533 533
534static const struct iio_info tiadc_info = { 534static const struct iio_info tiadc_info = {
535 .read_raw = &tiadc_read_raw, 535 .read_raw = &tiadc_read_raw,
536 .driver_module = THIS_MODULE,
537}; 536};
538 537
539static int tiadc_request_dma(struct platform_device *pdev, 538static int tiadc_request_dma(struct platform_device *pdev,
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index e3cfb91bffc6..8c019bb6625f 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -212,7 +212,6 @@ static int twl4030_madc_read(struct iio_dev *iio_dev,
212 212
213static const struct iio_info twl4030_madc_iio_info = { 213static const struct iio_info twl4030_madc_iio_info = {
214 .read_raw = &twl4030_madc_read, 214 .read_raw = &twl4030_madc_read,
215 .driver_module = THIS_MODULE,
216}; 215};
217 216
218#define TWL4030_ADC_CHANNEL(_channel, _type, _name) { \ 217#define TWL4030_ADC_CHANNEL(_channel, _type, _name) { \
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index bc0e60b9da45..dc83f8f6c3d3 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -843,7 +843,6 @@ static const struct iio_chan_spec twl6032_gpadc_iio_channels[] = {
843 843
844static const struct iio_info twl6030_gpadc_iio_info = { 844static const struct iio_info twl6030_gpadc_iio_info = {
845 .read_raw = &twl6030_gpadc_read_raw, 845 .read_raw = &twl6030_gpadc_read_raw,
846 .driver_module = THIS_MODULE,
847}; 846};
848 847
849static const struct twl6030_gpadc_platform_data twl6030_pdata = { 848static const struct twl6030_gpadc_platform_data twl6030_pdata = {
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index c168e0db329a..bbcb7a4d7edf 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -799,7 +799,6 @@ static int vf610_adc_reg_access(struct iio_dev *indio_dev,
799} 799}
800 800
801static const struct iio_info vf610_adc_iio_info = { 801static const struct iio_info vf610_adc_iio_info = {
802 .driver_module = THIS_MODULE,
803 .read_raw = &vf610_read_raw, 802 .read_raw = &vf610_read_raw,
804 .write_raw = &vf610_write_raw, 803 .write_raw = &vf610_write_raw,
805 .debugfs_reg_access = &vf610_adc_reg_access, 804 .debugfs_reg_access = &vf610_adc_reg_access,
diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
index 3be2e35721cc..53eb5a4136fe 100644
--- a/drivers/iio/adc/viperboard_adc.c
+++ b/drivers/iio/adc/viperboard_adc.c
@@ -107,7 +107,6 @@ error:
107 107
108static const struct iio_info vprbrd_adc_iio_info = { 108static const struct iio_info vprbrd_adc_iio_info = {
109 .read_raw = &vprbrd_iio_read_raw, 109 .read_raw = &vprbrd_iio_read_raw,
110 .driver_module = THIS_MODULE,
111}; 110};
112 111
113static int vprbrd_adc_probe(struct platform_device *pdev) 112static int vprbrd_adc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 4a60497a1f19..d4f21d1be6c8 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -675,7 +675,6 @@ err_out:
675} 675}
676 676
677static const struct iio_trigger_ops xadc_trigger_ops = { 677static const struct iio_trigger_ops xadc_trigger_ops = {
678 .owner = THIS_MODULE,
679 .set_trigger_state = &xadc_trigger_set_state, 678 .set_trigger_state = &xadc_trigger_set_state,
680}; 679};
681 680
@@ -1028,7 +1027,6 @@ static const struct iio_info xadc_info = {
1028 .read_event_value = &xadc_read_event_value, 1027 .read_event_value = &xadc_read_event_value,
1029 .write_event_value = &xadc_write_event_value, 1028 .write_event_value = &xadc_write_event_value,
1030 .update_scan_mode = &xadc_update_scan_mode, 1029 .update_scan_mode = &xadc_update_scan_mode,
1031 .driver_module = THIS_MODULE,
1032}; 1030};
1033 1031
1034static const struct of_device_id xadc_of_match_table[] = { 1032static const struct of_device_id xadc_of_match_table[] = {
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 102c7174da5b..43667866321e 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -117,7 +117,6 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
117static const struct iio_info ad8366_info = { 117static const struct iio_info ad8366_info = {
118 .read_raw = &ad8366_read_raw, 118 .read_raw = &ad8366_read_raw,
119 .write_raw = &ad8366_write_raw, 119 .write_raw = &ad8366_write_raw,
120 .driver_module = THIS_MODULE,
121}; 120};
122 121
123#define AD8366_CHAN(_channel) { \ 122#define AD8366_CHAN(_channel) { \
diff --git a/drivers/iio/chemical/ams-iaq-core.c b/drivers/iio/chemical/ams-iaq-core.c
index c948ad2ee9ad..d9e5950ad24a 100644
--- a/drivers/iio/chemical/ams-iaq-core.c
+++ b/drivers/iio/chemical/ams-iaq-core.c
@@ -141,7 +141,6 @@ err_out:
141 141
142static const struct iio_info ams_iaqcore_info = { 142static const struct iio_info ams_iaqcore_info = {
143 .read_raw = ams_iaqcore_read_raw, 143 .read_raw = ams_iaqcore_read_raw,
144 .driver_module = THIS_MODULE,
145}; 144};
146 145
147static int ams_iaqcore_probe(struct i2c_client *client, 146static int ams_iaqcore_probe(struct i2c_client *client,
diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c
index ef761a508630..8c4e05580091 100644
--- a/drivers/iio/chemical/atlas-ph-sensor.c
+++ b/drivers/iio/chemical/atlas-ph-sensor.c
@@ -344,7 +344,6 @@ static int atlas_buffer_predisable(struct iio_dev *indio_dev)
344} 344}
345 345
346static const struct iio_trigger_ops atlas_interrupt_trigger_ops = { 346static const struct iio_trigger_ops atlas_interrupt_trigger_ops = {
347 .owner = THIS_MODULE,
348}; 347};
349 348
350static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = { 349static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = {
@@ -499,7 +498,6 @@ static int atlas_write_raw(struct iio_dev *indio_dev,
499} 498}
500 499
501static const struct iio_info atlas_info = { 500static const struct iio_info atlas_info = {
502 .driver_module = THIS_MODULE,
503 .read_raw = atlas_read_raw, 501 .read_raw = atlas_read_raw,
504 .write_raw = atlas_write_raw, 502 .write_raw = atlas_write_raw,
505}; 503};
diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c
index 840a6cbd5f0f..97bce8345c6a 100644
--- a/drivers/iio/chemical/ccs811.c
+++ b/drivers/iio/chemical/ccs811.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/iio/iio.h> 23#include <linux/iio/iio.h>
24#include <linux/iio/buffer.h> 24#include <linux/iio/buffer.h>
25#include <linux/iio/trigger.h>
25#include <linux/iio/triggered_buffer.h> 26#include <linux/iio/triggered_buffer.h>
26#include <linux/iio/trigger_consumer.h> 27#include <linux/iio/trigger_consumer.h>
27#include <linux/module.h> 28#include <linux/module.h>
@@ -59,6 +60,8 @@
59#define CCS811_MODE_IAQ_60SEC 0x30 60#define CCS811_MODE_IAQ_60SEC 0x30
60#define CCS811_MODE_RAW_DATA 0x40 61#define CCS811_MODE_RAW_DATA 0x40
61 62
63#define CCS811_MEAS_MODE_INTERRUPT BIT(3)
64
62#define CCS811_VOLTAGE_MASK 0x3FF 65#define CCS811_VOLTAGE_MASK 0x3FF
63 66
64struct ccs811_reading { 67struct ccs811_reading {
@@ -73,6 +76,8 @@ struct ccs811_data {
73 struct i2c_client *client; 76 struct i2c_client *client;
74 struct mutex lock; /* Protect readings */ 77 struct mutex lock; /* Protect readings */
75 struct ccs811_reading buffer; 78 struct ccs811_reading buffer;
79 struct iio_trigger *drdy_trig;
80 bool drdy_trig_on;
76}; 81};
77 82
78static const struct iio_chan_spec ccs811_channels[] = { 83static const struct iio_chan_spec ccs811_channels[] = {
@@ -193,10 +198,14 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
193 198
194 switch (mask) { 199 switch (mask) {
195 case IIO_CHAN_INFO_RAW: 200 case IIO_CHAN_INFO_RAW:
201 ret = iio_device_claim_direct_mode(indio_dev);
202 if (ret)
203 return ret;
196 mutex_lock(&data->lock); 204 mutex_lock(&data->lock);
197 ret = ccs811_get_measurement(data); 205 ret = ccs811_get_measurement(data);
198 if (ret < 0) { 206 if (ret < 0) {
199 mutex_unlock(&data->lock); 207 mutex_unlock(&data->lock);
208 iio_device_release_direct_mode(indio_dev);
200 return ret; 209 return ret;
201 } 210 }
202 211
@@ -228,6 +237,7 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
228 ret = -EINVAL; 237 ret = -EINVAL;
229 } 238 }
230 mutex_unlock(&data->lock); 239 mutex_unlock(&data->lock);
240 iio_device_release_direct_mode(indio_dev);
231 241
232 return ret; 242 return ret;
233 243
@@ -270,7 +280,31 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
270 280
271static const struct iio_info ccs811_info = { 281static const struct iio_info ccs811_info = {
272 .read_raw = ccs811_read_raw, 282 .read_raw = ccs811_read_raw,
273 .driver_module = THIS_MODULE, 283};
284
285static int ccs811_set_trigger_state(struct iio_trigger *trig,
286 bool state)
287{
288 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
289 struct ccs811_data *data = iio_priv(indio_dev);
290 int ret;
291
292 ret = i2c_smbus_read_byte_data(data->client, CCS811_MEAS_MODE);
293 if (ret < 0)
294 return ret;
295
296 if (state)
297 ret |= CCS811_MEAS_MODE_INTERRUPT;
298 else
299 ret &= ~CCS811_MEAS_MODE_INTERRUPT;
300
301 data->drdy_trig_on = state;
302
303 return i2c_smbus_write_byte_data(data->client, CCS811_MEAS_MODE, ret);
304}
305
306static const struct iio_trigger_ops ccs811_trigger_ops = {
307 .set_trigger_state = ccs811_set_trigger_state,
274}; 308};
275 309
276static irqreturn_t ccs811_trigger_handler(int irq, void *p) 310static irqreturn_t ccs811_trigger_handler(int irq, void *p)
@@ -298,6 +332,17 @@ err:
298 return IRQ_HANDLED; 332 return IRQ_HANDLED;
299} 333}
300 334
335static irqreturn_t ccs811_data_rdy_trigger_poll(int irq, void *private)
336{
337 struct iio_dev *indio_dev = private;
338 struct ccs811_data *data = iio_priv(indio_dev);
339
340 if (data->drdy_trig_on)
341 iio_trigger_poll(data->drdy_trig);
342
343 return IRQ_HANDLED;
344}
345
301static int ccs811_probe(struct i2c_client *client, 346static int ccs811_probe(struct i2c_client *client,
302 const struct i2c_device_id *id) 347 const struct i2c_device_id *id)
303{ 348{
@@ -346,16 +391,48 @@ static int ccs811_probe(struct i2c_client *client,
346 indio_dev->dev.parent = &client->dev; 391 indio_dev->dev.parent = &client->dev;
347 indio_dev->name = id->name; 392 indio_dev->name = id->name;
348 indio_dev->info = &ccs811_info; 393 indio_dev->info = &ccs811_info;
394 indio_dev->modes = INDIO_DIRECT_MODE;
349 395
350 indio_dev->channels = ccs811_channels; 396 indio_dev->channels = ccs811_channels;
351 indio_dev->num_channels = ARRAY_SIZE(ccs811_channels); 397 indio_dev->num_channels = ARRAY_SIZE(ccs811_channels);
352 398
399 if (client->irq > 0) {
400 ret = devm_request_threaded_irq(&client->dev, client->irq,
401 ccs811_data_rdy_trigger_poll,
402 NULL,
403 IRQF_TRIGGER_FALLING |
404 IRQF_ONESHOT,
405 "ccs811_irq", indio_dev);
406 if (ret) {
407 dev_err(&client->dev, "irq request error %d\n", -ret);
408 goto err_poweroff;
409 }
410
411 data->drdy_trig = devm_iio_trigger_alloc(&client->dev,
412 "%s-dev%d",
413 indio_dev->name,
414 indio_dev->id);
415 if (!data->drdy_trig) {
416 ret = -ENOMEM;
417 goto err_poweroff;
418 }
419
420 data->drdy_trig->dev.parent = &client->dev;
421 data->drdy_trig->ops = &ccs811_trigger_ops;
422 iio_trigger_set_drvdata(data->drdy_trig, indio_dev);
423 indio_dev->trig = data->drdy_trig;
424 iio_trigger_get(indio_dev->trig);
425 ret = iio_trigger_register(data->drdy_trig);
426 if (ret)
427 goto err_poweroff;
428 }
429
353 ret = iio_triggered_buffer_setup(indio_dev, NULL, 430 ret = iio_triggered_buffer_setup(indio_dev, NULL,
354 ccs811_trigger_handler, NULL); 431 ccs811_trigger_handler, NULL);
355 432
356 if (ret < 0) { 433 if (ret < 0) {
357 dev_err(&client->dev, "triggered buffer setup failed\n"); 434 dev_err(&client->dev, "triggered buffer setup failed\n");
358 goto err_poweroff; 435 goto err_trigger_unregister;
359 } 436 }
360 437
361 ret = iio_device_register(indio_dev); 438 ret = iio_device_register(indio_dev);
@@ -367,6 +444,9 @@ static int ccs811_probe(struct i2c_client *client,
367 444
368err_buffer_cleanup: 445err_buffer_cleanup:
369 iio_triggered_buffer_cleanup(indio_dev); 446 iio_triggered_buffer_cleanup(indio_dev);
447err_trigger_unregister:
448 if (data->drdy_trig)
449 iio_trigger_unregister(data->drdy_trig);
370err_poweroff: 450err_poweroff:
371 i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, CCS811_MODE_IDLE); 451 i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, CCS811_MODE_IDLE);
372 452
@@ -376,9 +456,12 @@ err_poweroff:
376static int ccs811_remove(struct i2c_client *client) 456static int ccs811_remove(struct i2c_client *client)
377{ 457{
378 struct iio_dev *indio_dev = i2c_get_clientdata(client); 458 struct iio_dev *indio_dev = i2c_get_clientdata(client);
459 struct ccs811_data *data = iio_priv(indio_dev);
379 460
380 iio_device_unregister(indio_dev); 461 iio_device_unregister(indio_dev);
381 iio_triggered_buffer_cleanup(indio_dev); 462 iio_triggered_buffer_cleanup(indio_dev);
463 if (data->drdy_trig)
464 iio_trigger_unregister(data->drdy_trig);
382 465
383 return i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, 466 return i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE,
384 CCS811_MODE_IDLE); 467 CCS811_MODE_IDLE);
diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c
index f75eea6822f2..9c9095ba4227 100644
--- a/drivers/iio/chemical/vz89x.c
+++ b/drivers/iio/chemical/vz89x.c
@@ -326,7 +326,6 @@ static int vz89x_read_raw(struct iio_dev *indio_dev,
326static const struct iio_info vz89x_info = { 326static const struct iio_info vz89x_info = {
327 .attrs = &vz89x_attrs_group, 327 .attrs = &vz89x_attrs_group,
328 .read_raw = vz89x_read_raw, 328 .read_raw = vz89x_read_raw,
329 .driver_module = THIS_MODULE,
330}; 329};
331 330
332static const struct vz89x_chip_data vz89x_chips[] = { 331static const struct vz89x_chip_data vz89x_chips[] = {
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 38e8783e4b05..ed8063f2da99 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -185,7 +185,6 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
185static const struct iio_info ec_sensors_info = { 185static const struct iio_info ec_sensors_info = {
186 .read_raw = &cros_ec_sensors_read, 186 .read_raw = &cros_ec_sensors_read,
187 .write_raw = &cros_ec_sensors_write, 187 .write_raw = &cros_ec_sensors_write,
188 .driver_module = THIS_MODULE,
189}; 188};
190 189
191static int cros_ec_sensors_probe(struct platform_device *pdev) 190static int cros_ec_sensors_probe(struct platform_device *pdev)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 0e4b379ada45..cfb6588565ba 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -179,6 +179,10 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
179 int ret; 179 int ret;
180 180
181 atomic_set(&st->user_requested_state, state); 181 atomic_set(&st->user_requested_state, state);
182
183 if (atomic_add_unless(&st->runtime_pm_enable, 1, 1))
184 pm_runtime_enable(&st->pdev->dev);
185
182 if (state) 186 if (state)
183 ret = pm_runtime_get_sync(&st->pdev->dev); 187 ret = pm_runtime_get_sync(&st->pdev->dev);
184 else { 188 else {
@@ -221,7 +225,8 @@ static void hid_sensor_set_power_work(struct work_struct *work)
221 if (attrb->latency_ms > 0) 225 if (attrb->latency_ms > 0)
222 hid_sensor_set_report_latency(attrb, attrb->latency_ms); 226 hid_sensor_set_report_latency(attrb, attrb->latency_ms);
223 227
224 _hid_sensor_power_state(attrb, true); 228 if (atomic_read(&attrb->user_requested_state))
229 _hid_sensor_power_state(attrb, true);
225} 230}
226 231
227static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, 232static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
@@ -232,7 +237,9 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
232 237
233void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) 238void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
234{ 239{
235 pm_runtime_disable(&attrb->pdev->dev); 240 if (atomic_read(&attrb->runtime_pm_enable))
241 pm_runtime_disable(&attrb->pdev->dev);
242
236 pm_runtime_set_suspended(&attrb->pdev->dev); 243 pm_runtime_set_suspended(&attrb->pdev->dev);
237 pm_runtime_put_noidle(&attrb->pdev->dev); 244 pm_runtime_put_noidle(&attrb->pdev->dev);
238 245
@@ -243,7 +250,6 @@ void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
243EXPORT_SYMBOL(hid_sensor_remove_trigger); 250EXPORT_SYMBOL(hid_sensor_remove_trigger);
244 251
245static const struct iio_trigger_ops hid_sensor_trigger_ops = { 252static const struct iio_trigger_ops hid_sensor_trigger_ops = {
246 .owner = THIS_MODULE,
247 .set_trigger_state = &hid_sensor_data_rdy_trigger_set_state, 253 .set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
248}; 254};
249 255
@@ -283,7 +289,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
283 INIT_WORK(&attrb->work, hid_sensor_set_power_work); 289 INIT_WORK(&attrb->work, hid_sensor_set_power_work);
284 290
285 pm_suspend_ignore_children(&attrb->pdev->dev, true); 291 pm_suspend_ignore_children(&attrb->pdev->dev, true);
286 pm_runtime_enable(&attrb->pdev->dev);
287 /* Default to 3 seconds, but can be changed from sysfs */ 292 /* Default to 3 seconds, but can be changed from sysfs */
288 pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 293 pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
289 3000); 294 3000);
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 02e833b14db0..57db19182e95 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -93,6 +93,9 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
93 struct st_sensor_odr_avl odr_out = {0, 0}; 93 struct st_sensor_odr_avl odr_out = {0, 0};
94 struct st_sensor_data *sdata = iio_priv(indio_dev); 94 struct st_sensor_data *sdata = iio_priv(indio_dev);
95 95
96 if (!sdata->sensor_settings->odr.addr)
97 return 0;
98
96 err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out); 99 err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
97 if (err < 0) 100 if (err < 0)
98 goto st_sensors_match_odr_error; 101 goto st_sensors_match_odr_error;
@@ -221,11 +224,14 @@ EXPORT_SYMBOL(st_sensors_set_enable);
221int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) 224int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable)
222{ 225{
223 struct st_sensor_data *sdata = iio_priv(indio_dev); 226 struct st_sensor_data *sdata = iio_priv(indio_dev);
227 int err = 0;
224 228
225 return st_sensors_write_data_with_mask(indio_dev, 229 if (sdata->sensor_settings->enable_axis.addr)
230 err = st_sensors_write_data_with_mask(indio_dev,
226 sdata->sensor_settings->enable_axis.addr, 231 sdata->sensor_settings->enable_axis.addr,
227 sdata->sensor_settings->enable_axis.mask, 232 sdata->sensor_settings->enable_axis.mask,
228 axis_enable); 233 axis_enable);
234 return err;
229} 235}
230EXPORT_SYMBOL(st_sensors_set_axis_enable); 236EXPORT_SYMBOL(st_sensors_set_axis_enable);
231 237
@@ -283,7 +289,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
283 struct st_sensor_data *sdata = iio_priv(indio_dev); 289 struct st_sensor_data *sdata = iio_priv(indio_dev);
284 290
285 /* Sensor does not support interrupts */ 291 /* Sensor does not support interrupts */
286 if (sdata->sensor_settings->drdy_irq.addr == 0) { 292 if (!sdata->sensor_settings->drdy_irq.int1.addr &&
293 !sdata->sensor_settings->drdy_irq.int2.addr) {
287 if (pdata->drdy_int_pin) 294 if (pdata->drdy_int_pin)
288 dev_info(&indio_dev->dev, 295 dev_info(&indio_dev->dev,
289 "DRDY on pin INT%d specified, but sensor " 296 "DRDY on pin INT%d specified, but sensor "
@@ -294,7 +301,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
294 301
295 switch (pdata->drdy_int_pin) { 302 switch (pdata->drdy_int_pin) {
296 case 1: 303 case 1:
297 if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) { 304 if (!sdata->sensor_settings->drdy_irq.int1.mask) {
298 dev_err(&indio_dev->dev, 305 dev_err(&indio_dev->dev,
299 "DRDY on INT1 not available.\n"); 306 "DRDY on INT1 not available.\n");
300 return -EINVAL; 307 return -EINVAL;
@@ -302,7 +309,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
302 sdata->drdy_int_pin = 1; 309 sdata->drdy_int_pin = 1;
303 break; 310 break;
304 case 2: 311 case 2:
305 if (sdata->sensor_settings->drdy_irq.mask_int2 == 0) { 312 if (!sdata->sensor_settings->drdy_irq.int2.mask) {
306 dev_err(&indio_dev->dev, 313 dev_err(&indio_dev->dev,
307 "DRDY on INT2 not available.\n"); 314 "DRDY on INT2 not available.\n");
308 return -EINVAL; 315 return -EINVAL;
@@ -315,7 +322,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
315 } 322 }
316 323
317 if (pdata->open_drain) { 324 if (pdata->open_drain) {
318 if (!sdata->sensor_settings->drdy_irq.addr_od) 325 if (!sdata->sensor_settings->drdy_irq.int1.addr_od &&
326 !sdata->sensor_settings->drdy_irq.int2.addr_od)
319 dev_err(&indio_dev->dev, 327 dev_err(&indio_dev->dev,
320 "open drain requested but unsupported.\n"); 328 "open drain requested but unsupported.\n");
321 else 329 else
@@ -442,11 +450,21 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
442 } 450 }
443 451
444 if (sdata->int_pin_open_drain) { 452 if (sdata->int_pin_open_drain) {
453 u8 addr, mask;
454
455 if (sdata->drdy_int_pin == 1) {
456 addr = sdata->sensor_settings->drdy_irq.int1.addr_od;
457 mask = sdata->sensor_settings->drdy_irq.int1.mask_od;
458 } else {
459 addr = sdata->sensor_settings->drdy_irq.int2.addr_od;
460 mask = sdata->sensor_settings->drdy_irq.int2.mask_od;
461 }
462
445 dev_info(&indio_dev->dev, 463 dev_info(&indio_dev->dev,
446 "set interrupt line to open drain mode\n"); 464 "set interrupt line to open drain mode on pin %d\n",
447 err = st_sensors_write_data_with_mask(indio_dev, 465 sdata->drdy_int_pin);
448 sdata->sensor_settings->drdy_irq.addr_od, 466 err = st_sensors_write_data_with_mask(indio_dev, addr,
449 sdata->sensor_settings->drdy_irq.mask_od, 1); 467 mask, 1);
450 if (err < 0) 468 if (err < 0)
451 return err; 469 return err;
452 } 470 }
@@ -460,17 +478,18 @@ EXPORT_SYMBOL(st_sensors_init_sensor);
460int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) 478int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
461{ 479{
462 int err; 480 int err;
463 u8 drdy_mask; 481 u8 drdy_addr, drdy_mask;
464 struct st_sensor_data *sdata = iio_priv(indio_dev); 482 struct st_sensor_data *sdata = iio_priv(indio_dev);
465 483
466 if (!sdata->sensor_settings->drdy_irq.addr) { 484 if (!sdata->sensor_settings->drdy_irq.int1.addr &&
485 !sdata->sensor_settings->drdy_irq.int2.addr) {
467 /* 486 /*
468 * there are some devices (e.g. LIS3MDL) where drdy line is 487 * there are some devices (e.g. LIS3MDL) where drdy line is
469 * routed to a given pin and it is not possible to select a 488 * routed to a given pin and it is not possible to select a
470 * different one. Take into account irq status register 489 * different one. Take into account irq status register
471 * to understand if irq trigger can be properly supported 490 * to understand if irq trigger can be properly supported
472 */ 491 */
473 if (sdata->sensor_settings->drdy_irq.addr_stat_drdy) 492 if (sdata->sensor_settings->drdy_irq.stat_drdy.addr)
474 sdata->hw_irq_trigger = enable; 493 sdata->hw_irq_trigger = enable;
475 return 0; 494 return 0;
476 } 495 }
@@ -485,18 +504,20 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
485 goto st_accel_set_dataready_irq_error; 504 goto st_accel_set_dataready_irq_error;
486 } 505 }
487 506
488 if (sdata->drdy_int_pin == 1) 507 if (sdata->drdy_int_pin == 1) {
489 drdy_mask = sdata->sensor_settings->drdy_irq.mask_int1; 508 drdy_addr = sdata->sensor_settings->drdy_irq.int1.addr;
490 else 509 drdy_mask = sdata->sensor_settings->drdy_irq.int1.mask;
491 drdy_mask = sdata->sensor_settings->drdy_irq.mask_int2; 510 } else {
511 drdy_addr = sdata->sensor_settings->drdy_irq.int2.addr;
512 drdy_mask = sdata->sensor_settings->drdy_irq.int2.mask;
513 }
492 514
493 /* Flag to the poll function that the hardware trigger is in use */ 515 /* Flag to the poll function that the hardware trigger is in use */
494 sdata->hw_irq_trigger = enable; 516 sdata->hw_irq_trigger = enable;
495 517
496 /* Enable/Disable the interrupt generator for data ready. */ 518 /* Enable/Disable the interrupt generator for data ready. */
497 err = st_sensors_write_data_with_mask(indio_dev, 519 err = st_sensors_write_data_with_mask(indio_dev, drdy_addr,
498 sdata->sensor_settings->drdy_irq.addr, 520 drdy_mask, (int)enable);
499 drdy_mask, (int)enable);
500 521
501st_accel_set_dataready_irq_error: 522st_accel_set_dataready_irq_error:
502 return err; 523 return err;
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index fa73e6795359..fdcc5a891958 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -31,7 +31,7 @@ static int st_sensors_new_samples_available(struct iio_dev *indio_dev,
31 int ret; 31 int ret;
32 32
33 /* How would I know if I can't check it? */ 33 /* How would I know if I can't check it? */
34 if (!sdata->sensor_settings->drdy_irq.addr_stat_drdy) 34 if (!sdata->sensor_settings->drdy_irq.stat_drdy.addr)
35 return -EINVAL; 35 return -EINVAL;
36 36
37 /* No scan mask, no interrupt */ 37 /* No scan mask, no interrupt */
@@ -39,23 +39,15 @@ static int st_sensors_new_samples_available(struct iio_dev *indio_dev,
39 return 0; 39 return 0;
40 40
41 ret = sdata->tf->read_byte(&sdata->tb, sdata->dev, 41 ret = sdata->tf->read_byte(&sdata->tb, sdata->dev,
42 sdata->sensor_settings->drdy_irq.addr_stat_drdy, 42 sdata->sensor_settings->drdy_irq.stat_drdy.addr,
43 &status); 43 &status);
44 if (ret < 0) { 44 if (ret < 0) {
45 dev_err(sdata->dev, 45 dev_err(sdata->dev,
46 "error checking samples available\n"); 46 "error checking samples available\n");
47 return ret; 47 return ret;
48 } 48 }
49 /*
50 * the lower bits of .active_scan_mask[0] is directly mapped
51 * to the channels on the sensor: either bit 0 for
52 * one-dimensional sensors, or e.g. x,y,z for accelerometers,
53 * gyroscopes or magnetometers. No sensor use more than 3
54 * channels, so cut the other status bits here.
55 */
56 status &= 0x07;
57 49
58 if (status & (u8)indio_dev->active_scan_mask[0]) 50 if (status & sdata->sensor_settings->drdy_irq.stat_drdy.mask)
59 return 1; 51 return 1;
60 52
61 return 0; 53 return 0;
@@ -212,7 +204,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
212 * it was "our" interrupt. 204 * it was "our" interrupt.
213 */ 205 */
214 if (sdata->int_pin_open_drain && 206 if (sdata->int_pin_open_drain &&
215 sdata->sensor_settings->drdy_irq.addr_stat_drdy) 207 sdata->sensor_settings->drdy_irq.stat_drdy.addr)
216 irq_trig |= IRQF_SHARED; 208 irq_trig |= IRQF_SHARED;
217 209
218 err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev), 210 err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev),
diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c
index ba3d9030cd51..b56985078d8c 100644
--- a/drivers/iio/counter/104-quad-8.c
+++ b/drivers/iio/counter/104-quad-8.c
@@ -185,7 +185,6 @@ static int quad8_write_raw(struct iio_dev *indio_dev,
185} 185}
186 186
187static const struct iio_info quad8_info = { 187static const struct iio_info quad8_info = {
188 .driver_module = THIS_MODULE,
189 .read_raw = quad8_read_raw, 188 .read_raw = quad8_read_raw,
190 .write_raw = quad8_write_raw 189 .write_raw = quad8_write_raw
191}; 190};
diff --git a/drivers/iio/counter/stm32-lptimer-cnt.c b/drivers/iio/counter/stm32-lptimer-cnt.c
index 1c5909bb1605..81ae5f74216d 100644
--- a/drivers/iio/counter/stm32-lptimer-cnt.c
+++ b/drivers/iio/counter/stm32-lptimer-cnt.c
@@ -178,7 +178,6 @@ static int stm32_lptim_read_raw(struct iio_dev *indio_dev,
178static const struct iio_info stm32_lptim_cnt_iio_info = { 178static const struct iio_info stm32_lptim_cnt_iio_info = {
179 .read_raw = stm32_lptim_read_raw, 179 .read_raw = stm32_lptim_read_raw,
180 .write_raw = stm32_lptim_write_raw, 180 .write_raw = stm32_lptim_write_raw,
181 .driver_module = THIS_MODULE,
182}; 181};
183 182
184static const char *const stm32_lptim_quadrature_modes[] = { 183static const char *const stm32_lptim_quadrature_modes[] = {
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index 25bed2d7d2b9..965d5c0d2468 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -60,7 +60,8 @@ config AD5446
60 Say yes here to build support for Analog Devices AD5300, AD5301, AD5310, 60 Say yes here to build support for Analog Devices AD5300, AD5301, AD5310,
61 AD5311, AD5320, AD5321, AD5444, AD5446, AD5450, AD5451, AD5452, AD5453, 61 AD5311, AD5320, AD5321, AD5444, AD5446, AD5450, AD5451, AD5452, AD5453,
62 AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5602, AD5611, AD5612, 62 AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5602, AD5611, AD5612,
63 AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs. 63 AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs
64 as well as Texas Instruments DAC081S101, DAC101S101, DAC121S101.
64 65
65 To compile this driver as a module, choose M here: the 66 To compile this driver as a module, choose M here: the
66 module will be called ad5446. 67 module will be called ad5446.
@@ -221,6 +222,15 @@ config DPOT_DAC
221 To compile this driver as a module, choose M here: the module will be 222 To compile this driver as a module, choose M here: the module will be
222 called dpot-dac. 223 called dpot-dac.
223 224
225config DS4424
226 tristate "Maxim Integrated DS4422/DS4424 DAC driver"
227 depends on I2C
228 help
229 If you say yes here you get support for Maxim chips DS4422, DS4424.
230
231 This driver can also be built as a module. If so, the module
232 will be called ds4424.
233
224config LPC18XX_DAC 234config LPC18XX_DAC
225 tristate "NXP LPC18xx DAC driver" 235 tristate "NXP LPC18xx DAC driver"
226 depends on ARCH_LPC18XX || COMPILE_TEST 236 depends on ARCH_LPC18XX || COMPILE_TEST
@@ -300,6 +310,16 @@ config STM32_DAC
300config STM32_DAC_CORE 310config STM32_DAC_CORE
301 tristate 311 tristate
302 312
313config TI_DAC082S085
314 tristate "Texas Instruments 8/10/12-bit 2/4-channel DAC driver"
315 depends on SPI_MASTER
316 help
317 Driver for the Texas Instruments (formerly National Semiconductor)
318 DAC082S085, DAC102S085, DAC122S085, DAC084S085, DAC104S085 and
319 DAC124S085.
320
321 If compiled as a module, it will be called ti-dac082s085.
322
303config VF610_DAC 323config VF610_DAC
304 tristate "Vybrid vf610 DAC driver" 324 tristate "Vybrid vf610 DAC driver"
305 depends on OF 325 depends on OF
diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
index 603587cc2f07..4785858e04cc 100644
--- a/drivers/iio/dac/Makefile
+++ b/drivers/iio/dac/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_AD7303) += ad7303.o
23obj-$(CONFIG_AD8801) += ad8801.o 23obj-$(CONFIG_AD8801) += ad8801.o
24obj-$(CONFIG_CIO_DAC) += cio-dac.o 24obj-$(CONFIG_CIO_DAC) += cio-dac.o
25obj-$(CONFIG_DPOT_DAC) += dpot-dac.o 25obj-$(CONFIG_DPOT_DAC) += dpot-dac.o
26obj-$(CONFIG_DS4424) += ds4424.o
26obj-$(CONFIG_LPC18XX_DAC) += lpc18xx_dac.o 27obj-$(CONFIG_LPC18XX_DAC) += lpc18xx_dac.o
27obj-$(CONFIG_LTC2632) += ltc2632.o 28obj-$(CONFIG_LTC2632) += ltc2632.o
28obj-$(CONFIG_M62332) += m62332.o 29obj-$(CONFIG_M62332) += m62332.o
@@ -32,4 +33,5 @@ obj-$(CONFIG_MCP4725) += mcp4725.o
32obj-$(CONFIG_MCP4922) += mcp4922.o 33obj-$(CONFIG_MCP4922) += mcp4922.o
33obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o 34obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o
34obj-$(CONFIG_STM32_DAC) += stm32-dac.o 35obj-$(CONFIG_STM32_DAC) += stm32-dac.o
36obj-$(CONFIG_TI_DAC082S085) += ti-dac082s085.o
35obj-$(CONFIG_VF610_DAC) += vf610_dac.o 37obj-$(CONFIG_VF610_DAC) += vf610_dac.o
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index 3f9399c27869..bf4fc40ec84d 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -366,7 +366,6 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
366static const struct iio_info ad5064_info = { 366static const struct iio_info ad5064_info = {
367 .read_raw = ad5064_read_raw, 367 .read_raw = ad5064_read_raw,
368 .write_raw = ad5064_write_raw, 368 .write_raw = ad5064_write_raw,
369 .driver_module = THIS_MODULE,
370}; 369};
371 370
372static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { 371static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c
index 8ba0e9c50176..0209316d5566 100644
--- a/drivers/iio/dac/ad5360.c
+++ b/drivers/iio/dac/ad5360.c
@@ -425,7 +425,6 @@ static const struct iio_info ad5360_info = {
425 .read_raw = ad5360_read_raw, 425 .read_raw = ad5360_read_raw,
426 .write_raw = ad5360_write_raw, 426 .write_raw = ad5360_write_raw,
427 .attrs = &ad5360_attribute_group, 427 .attrs = &ad5360_attribute_group,
428 .driver_module = THIS_MODULE,
429}; 428};
430 429
431static const char * const ad5360_vref_name[] = { 430static const char * const ad5360_vref_name[] = {
diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 97d2c5111f43..845fd1c0fd9d 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -237,7 +237,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
237static const struct iio_info ad5380_info = { 237static const struct iio_info ad5380_info = {
238 .read_raw = ad5380_read_raw, 238 .read_raw = ad5380_read_raw,
239 .write_raw = ad5380_write_raw, 239 .write_raw = ad5380_write_raw,
240 .driver_module = THIS_MODULE,
241}; 240};
242 241
243static struct iio_chan_spec_ext_info ad5380_ext_info[] = { 242static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c
index 559061ab1982..8e9633d8de67 100644
--- a/drivers/iio/dac/ad5421.c
+++ b/drivers/iio/dac/ad5421.c
@@ -465,7 +465,6 @@ static const struct iio_info ad5421_info = {
465 .read_event_config = ad5421_read_event_config, 465 .read_event_config = ad5421_read_event_config,
466 .write_event_config = ad5421_write_event_config, 466 .write_event_config = ad5421_write_event_config,
467 .read_event_value = ad5421_read_event_value, 467 .read_event_value = ad5421_read_event_value,
468 .driver_module = THIS_MODULE,
469}; 468};
470 469
471static int ad5421_probe(struct spi_device *spi) 470static int ad5421_probe(struct spi_device *spi)
diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
index b555552a0d80..fd26a4272fc5 100644
--- a/drivers/iio/dac/ad5446.c
+++ b/drivers/iio/dac/ad5446.c
@@ -212,7 +212,6 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,
212static const struct iio_info ad5446_info = { 212static const struct iio_info ad5446_info = {
213 .read_raw = ad5446_read_raw, 213 .read_raw = ad5446_read_raw,
214 .write_raw = ad5446_write_raw, 214 .write_raw = ad5446_write_raw,
215 .driver_module = THIS_MODULE,
216}; 215};
217 216
218static int ad5446_probe(struct device *dev, const char *name, 217static int ad5446_probe(struct device *dev, const char *name,
@@ -461,10 +460,22 @@ static const struct spi_device_id ad5446_spi_ids[] = {
461 {"ad5660-2500", ID_AD5660_2500}, 460 {"ad5660-2500", ID_AD5660_2500},
462 {"ad5660-1250", ID_AD5660_1250}, 461 {"ad5660-1250", ID_AD5660_1250},
463 {"ad5662", ID_AD5662}, 462 {"ad5662", ID_AD5662},
463 {"dac081s101", ID_AD5300}, /* compatible Texas Instruments chips */
464 {"dac101s101", ID_AD5310},
465 {"dac121s101", ID_AD5320},
466 {"dac7512", ID_AD5320},
464 {} 467 {}
465}; 468};
466MODULE_DEVICE_TABLE(spi, ad5446_spi_ids); 469MODULE_DEVICE_TABLE(spi, ad5446_spi_ids);
467 470
471#ifdef CONFIG_OF
472static const struct of_device_id ad5446_of_ids[] = {
473 { .compatible = "ti,dac7512" },
474 { }
475};
476MODULE_DEVICE_TABLE(of, ad5446_of_ids);
477#endif
478
468static int ad5446_spi_probe(struct spi_device *spi) 479static int ad5446_spi_probe(struct spi_device *spi)
469{ 480{
470 const struct spi_device_id *id = spi_get_device_id(spi); 481 const struct spi_device_id *id = spi_get_device_id(spi);
@@ -481,6 +492,7 @@ static int ad5446_spi_remove(struct spi_device *spi)
481static struct spi_driver ad5446_spi_driver = { 492static struct spi_driver ad5446_spi_driver = {
482 .driver = { 493 .driver = {
483 .name = "ad5446", 494 .name = "ad5446",
495 .of_match_table = of_match_ptr(ad5446_of_ids),
484 }, 496 },
485 .probe = ad5446_spi_probe, 497 .probe = ad5446_spi_probe,
486 .remove = ad5446_spi_remove, 498 .remove = ad5446_spi_remove,
diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c
index 5f3202339420..317a74129932 100644
--- a/drivers/iio/dac/ad5449.c
+++ b/drivers/iio/dac/ad5449.c
@@ -193,7 +193,6 @@ static int ad5449_write_raw(struct iio_dev *indio_dev,
193static const struct iio_info ad5449_info = { 193static const struct iio_info ad5449_info = {
194 .read_raw = ad5449_read_raw, 194 .read_raw = ad5449_read_raw,
195 .write_raw = ad5449_write_raw, 195 .write_raw = ad5449_write_raw,
196 .driver_module = THIS_MODULE,
197}; 196};
198 197
199#define AD5449_CHANNEL(chan, bits) { \ 198#define AD5449_CHANNEL(chan, bits) { \
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 712d86b4be09..d9037ea59168 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -232,7 +232,6 @@ static const struct iio_info ad5504_info = {
232 .write_raw = ad5504_write_raw, 232 .write_raw = ad5504_write_raw,
233 .read_raw = ad5504_read_raw, 233 .read_raw = ad5504_read_raw,
234 .event_attrs = &ad5504_ev_attribute_group, 234 .event_attrs = &ad5504_ev_attribute_group,
235 .driver_module = THIS_MODULE,
236}; 235};
237 236
238static const struct iio_chan_spec_ext_info ad5504_ext_info[] = { 237static const struct iio_chan_spec_ext_info ad5504_ext_info[] = {
diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 69bde5909854..9234c6a09a93 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -474,7 +474,6 @@ static const struct iio_info ad5592r_info = {
474 .read_raw = ad5592r_read_raw, 474 .read_raw = ad5592r_read_raw,
475 .write_raw = ad5592r_write_raw, 475 .write_raw = ad5592r_write_raw,
476 .write_raw_get_fmt = ad5592r_write_raw_get_fmt, 476 .write_raw_get_fmt = ad5592r_write_raw_get_fmt,
477 .driver_module = THIS_MODULE,
478}; 477};
479 478
480static ssize_t ad5592r_show_scale_available(struct iio_dev *iio_dev, 479static ssize_t ad5592r_show_scale_available(struct iio_dev *iio_dev,
diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
index 5489ec43b95d..13fdb4dfe356 100644
--- a/drivers/iio/dac/ad5624r_spi.c
+++ b/drivers/iio/dac/ad5624r_spi.c
@@ -149,7 +149,6 @@ static ssize_t ad5624r_write_dac_powerdown(struct iio_dev *indio_dev,
149static const struct iio_info ad5624r_info = { 149static const struct iio_info ad5624r_info = {
150 .write_raw = ad5624r_write_raw, 150 .write_raw = ad5624r_write_raw,
151 .read_raw = ad5624r_read_raw, 151 .read_raw = ad5624r_read_raw,
152 .driver_module = THIS_MODULE,
153}; 152};
154 153
155static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = { 154static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = {
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index d1d8450c19f6..20254df7f9c7 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -252,7 +252,6 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
252static const struct iio_info ad5686_info = { 252static const struct iio_info ad5686_info = {
253 .read_raw = ad5686_read_raw, 253 .read_raw = ad5686_read_raw,
254 .write_raw = ad5686_write_raw, 254 .write_raw = ad5686_write_raw,
255 .driver_module = THIS_MODULE,
256}; 255};
257 256
258static const struct iio_chan_spec_ext_info ad5686_ext_info[] = { 257static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 5f7968232564..2d03cc89ba50 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -417,7 +417,6 @@ static ssize_t ad5755_write_powerdown(struct iio_dev *indio_dev, uintptr_t priv,
417static const struct iio_info ad5755_info = { 417static const struct iio_info ad5755_info = {
418 .read_raw = ad5755_read_raw, 418 .read_raw = ad5755_read_raw,
419 .write_raw = ad5755_write_raw, 419 .write_raw = ad5755_write_raw,
420 .driver_module = THIS_MODULE,
421}; 420};
422 421
423static const struct iio_chan_spec_ext_info ad5755_ext_info[] = { 422static const struct iio_chan_spec_ext_info ad5755_ext_info[] = {
diff --git a/drivers/iio/dac/ad5761.c b/drivers/iio/dac/ad5761.c
index d6510d6928b3..05017c8bbd00 100644
--- a/drivers/iio/dac/ad5761.c
+++ b/drivers/iio/dac/ad5761.c
@@ -251,7 +251,6 @@ static int ad5761_write_raw(struct iio_dev *indio_dev,
251static const struct iio_info ad5761_info = { 251static const struct iio_info ad5761_info = {
252 .read_raw = &ad5761_read_raw, 252 .read_raw = &ad5761_read_raw,
253 .write_raw = &ad5761_write_raw, 253 .write_raw = &ad5761_write_raw,
254 .driver_module = THIS_MODULE,
255}; 254};
256 255
257#define AD5761_CHAN(_bits) { \ 256#define AD5761_CHAN(_bits) { \
diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c
index 9a547bbf7d2b..033f20eca616 100644
--- a/drivers/iio/dac/ad5764.c
+++ b/drivers/iio/dac/ad5764.c
@@ -268,7 +268,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
268static const struct iio_info ad5764_info = { 268static const struct iio_info ad5764_info = {
269 .read_raw = ad5764_read_raw, 269 .read_raw = ad5764_read_raw,
270 .write_raw = ad5764_write_raw, 270 .write_raw = ad5764_write_raw,
271 .driver_module = THIS_MODULE,
272}; 271};
273 272
274static int ad5764_probe(struct spi_device *spi) 273static int ad5764_probe(struct spi_device *spi)
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index 33e4ae5c42f8..7569bf6868c2 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -340,7 +340,6 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
340static const struct iio_info ad5791_info = { 340static const struct iio_info ad5791_info = {
341 .read_raw = &ad5791_read_raw, 341 .read_raw = &ad5791_read_raw,
342 .write_raw = &ad5791_write_raw, 342 .write_raw = &ad5791_write_raw,
343 .driver_module = THIS_MODULE,
344}; 343};
345 344
346static int ad5791_probe(struct spi_device *spi) 345static int ad5791_probe(struct spi_device *spi)
diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
index 4b0f942b8914..8f3bd19b6dc3 100644
--- a/drivers/iio/dac/ad7303.c
+++ b/drivers/iio/dac/ad7303.c
@@ -161,7 +161,6 @@ static int ad7303_write_raw(struct iio_dev *indio_dev,
161static const struct iio_info ad7303_info = { 161static const struct iio_info ad7303_info = {
162 .read_raw = ad7303_read_raw, 162 .read_raw = ad7303_read_raw,
163 .write_raw = ad7303_write_raw, 163 .write_raw = ad7303_write_raw,
164 .driver_module = THIS_MODULE,
165}; 164};
166 165
167static const struct iio_chan_spec_ext_info ad7303_ext_info[] = { 166static const struct iio_chan_spec_ext_info ad7303_ext_info[] = {
diff --git a/drivers/iio/dac/ad8801.c b/drivers/iio/dac/ad8801.c
index f06faa1aec09..aef5808c9865 100644
--- a/drivers/iio/dac/ad8801.c
+++ b/drivers/iio/dac/ad8801.c
@@ -92,7 +92,6 @@ static int ad8801_read_raw(struct iio_dev *indio_dev,
92static const struct iio_info ad8801_info = { 92static const struct iio_info ad8801_info = {
93 .read_raw = ad8801_read_raw, 93 .read_raw = ad8801_read_raw,
94 .write_raw = ad8801_write_raw, 94 .write_raw = ad8801_write_raw,
95 .driver_module = THIS_MODULE,
96}; 95};
97 96
98#define AD8801_CHANNEL(chan) { \ 97#define AD8801_CHANNEL(chan) { \
diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c
index a8dffd938615..6898b0c79013 100644
--- a/drivers/iio/dac/cio-dac.c
+++ b/drivers/iio/dac/cio-dac.c
@@ -85,7 +85,6 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev,
85} 85}
86 86
87static const struct iio_info cio_dac_info = { 87static const struct iio_info cio_dac_info = {
88 .driver_module = THIS_MODULE,
89 .read_raw = cio_dac_read_raw, 88 .read_raw = cio_dac_read_raw,
90 .write_raw = cio_dac_write_raw 89 .write_raw = cio_dac_write_raw
91}; 90};
diff --git a/drivers/iio/dac/dpot-dac.c b/drivers/iio/dac/dpot-dac.c
index 960a2b430480..aaa2103d7c2b 100644
--- a/drivers/iio/dac/dpot-dac.c
+++ b/drivers/iio/dac/dpot-dac.c
@@ -128,7 +128,6 @@ static const struct iio_info dpot_dac_info = {
128 .read_raw = dpot_dac_read_raw, 128 .read_raw = dpot_dac_read_raw,
129 .read_avail = dpot_dac_read_avail, 129 .read_avail = dpot_dac_read_avail,
130 .write_raw = dpot_dac_write_raw, 130 .write_raw = dpot_dac_write_raw,
131 .driver_module = THIS_MODULE,
132}; 131};
133 132
134static int dpot_dac_channel_max_ohms(struct iio_dev *indio_dev) 133static int dpot_dac_channel_max_ohms(struct iio_dev *indio_dev)
diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
new file mode 100644
index 000000000000..883a47562055
--- /dev/null
+++ b/drivers/iio/dac/ds4424.c
@@ -0,0 +1,341 @@
1/*
2 * Maxim Integrated
3 * 7-bit, Multi-Channel Sink/Source Current DAC Driver
4 * Copyright (C) 2017 Maxim Integrated
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/i2c.h>
14#include <linux/regulator/consumer.h>
15#include <linux/err.h>
16#include <linux/delay.h>
17#include <linux/iio/iio.h>
18#include <linux/iio/driver.h>
19#include <linux/iio/machine.h>
20#include <linux/iio/consumer.h>
21
22#define DS4422_MAX_DAC_CHANNELS 2
23#define DS4424_MAX_DAC_CHANNELS 4
24
25#define DS4424_DAC_ADDR(chan) ((chan) + 0xf8)
26#define DS4424_SOURCE_I 1
27#define DS4424_SINK_I 0
28
29#define DS4424_CHANNEL(chan) { \
30 .type = IIO_CURRENT, \
31 .indexed = 1, \
32 .output = 1, \
33 .channel = chan, \
34 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
35}
36
37/*
38 * DS4424 DAC control register 8 bits
39 * [7] 0: to sink; 1: to source
40 * [6:0] steps to sink/source
41 * bit[7] looks like a sign bit, but the value of the register is
42 * not a two's complement code considering the bit[6:0] is a absolute
43 * distance from the zero point.
44 */
45union ds4424_raw_data {
46 struct {
47 u8 dx:7;
48 u8 source_bit:1;
49 };
50 u8 bits;
51};
52
53enum ds4424_device_ids {
54 ID_DS4422,
55 ID_DS4424,
56};
57
58struct ds4424_data {
59 struct i2c_client *client;
60 struct mutex lock;
61 uint8_t save[DS4424_MAX_DAC_CHANNELS];
62 struct regulator *vcc_reg;
63 uint8_t raw[DS4424_MAX_DAC_CHANNELS];
64};
65
66static const struct iio_chan_spec ds4424_channels[] = {
67 DS4424_CHANNEL(0),
68 DS4424_CHANNEL(1),
69 DS4424_CHANNEL(2),
70 DS4424_CHANNEL(3),
71};
72
73static int ds4424_get_value(struct iio_dev *indio_dev,
74 int *val, int channel)
75{
76 struct ds4424_data *data = iio_priv(indio_dev);
77 int ret;
78
79 mutex_lock(&data->lock);
80 ret = i2c_smbus_read_byte_data(data->client, DS4424_DAC_ADDR(channel));
81 if (ret < 0)
82 goto fail;
83
84 *val = ret;
85
86fail:
87 mutex_unlock(&data->lock);
88 return ret;
89}
90
91static int ds4424_set_value(struct iio_dev *indio_dev,
92 int val, struct iio_chan_spec const *chan)
93{
94 struct ds4424_data *data = iio_priv(indio_dev);
95 int ret;
96
97 mutex_lock(&data->lock);
98 ret = i2c_smbus_write_byte_data(data->client,
99 DS4424_DAC_ADDR(chan->channel), val);
100 if (ret < 0)
101 goto fail;
102
103 data->raw[chan->channel] = val;
104
105fail:
106 mutex_unlock(&data->lock);
107 return ret;
108}
109
110static int ds4424_read_raw(struct iio_dev *indio_dev,
111 struct iio_chan_spec const *chan,
112 int *val, int *val2, long mask)
113{
114 union ds4424_raw_data raw;
115 int ret;
116
117 switch (mask) {
118 case IIO_CHAN_INFO_RAW:
119 ret = ds4424_get_value(indio_dev, val, chan->channel);
120 if (ret < 0) {
121 pr_err("%s : ds4424_get_value returned %d\n",
122 __func__, ret);
123 return ret;
124 }
125 raw.bits = *val;
126 *val = raw.dx;
127 if (raw.source_bit == DS4424_SINK_I)
128 *val = -*val;
129 return IIO_VAL_INT;
130
131 default:
132 return -EINVAL;
133 }
134}
135
136static int ds4424_write_raw(struct iio_dev *indio_dev,
137 struct iio_chan_spec const *chan,
138 int val, int val2, long mask)
139{
140 union ds4424_raw_data raw;
141
142 if (val2 != 0)
143 return -EINVAL;
144
145 switch (mask) {
146 case IIO_CHAN_INFO_RAW:
147 if (val < S8_MIN || val > S8_MAX)
148 return -EINVAL;
149
150 if (val > 0) {
151 raw.source_bit = DS4424_SOURCE_I;
152 raw.dx = val;
153 } else {
154 raw.source_bit = DS4424_SINK_I;
155 raw.dx = -val;
156 }
157
158 return ds4424_set_value(indio_dev, raw.bits, chan);
159
160 default:
161 return -EINVAL;
162 }
163}
164
165static int ds4424_verify_chip(struct iio_dev *indio_dev)
166{
167 int ret, val;
168
169 ret = ds4424_get_value(indio_dev, &val, DS4424_DAC_ADDR(0));
170 if (ret < 0)
171 dev_err(&indio_dev->dev,
172 "%s failed. ret: %d\n", __func__, ret);
173
174 return ret;
175}
176
177static int __maybe_unused ds4424_suspend(struct device *dev)
178{
179 struct i2c_client *client = to_i2c_client(dev);
180 struct iio_dev *indio_dev = i2c_get_clientdata(client);
181 struct ds4424_data *data = iio_priv(indio_dev);
182 int ret = 0;
183 int i;
184
185 for (i = 0; i < indio_dev->num_channels; i++) {
186 data->save[i] = data->raw[i];
187 ret = ds4424_set_value(indio_dev, 0,
188 &indio_dev->channels[i]);
189 if (ret < 0)
190 return ret;
191 }
192 return ret;
193}
194
195static int __maybe_unused ds4424_resume(struct device *dev)
196{
197 struct i2c_client *client = to_i2c_client(dev);
198 struct iio_dev *indio_dev = i2c_get_clientdata(client);
199 struct ds4424_data *data = iio_priv(indio_dev);
200 int ret = 0;
201 int i;
202
203 for (i = 0; i < indio_dev->num_channels; i++) {
204 ret = ds4424_set_value(indio_dev, data->save[i],
205 &indio_dev->channels[i]);
206 if (ret < 0)
207 return ret;
208 }
209 return ret;
210}
211
212static SIMPLE_DEV_PM_OPS(ds4424_pm_ops, ds4424_suspend, ds4424_resume);
213
214static const struct iio_info ds4424_info = {
215 .read_raw = ds4424_read_raw,
216 .write_raw = ds4424_write_raw,
217};
218
219static int ds4424_probe(struct i2c_client *client,
220 const struct i2c_device_id *id)
221{
222 struct ds4424_data *data;
223 struct iio_dev *indio_dev;
224 int ret;
225
226 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
227 if (!indio_dev) {
228 dev_err(&client->dev, "iio dev alloc failed.\n");
229 return -ENOMEM;
230 }
231
232 data = iio_priv(indio_dev);
233 i2c_set_clientdata(client, indio_dev);
234 data->client = client;
235 indio_dev->name = id->name;
236 indio_dev->dev.of_node = client->dev.of_node;
237 indio_dev->dev.parent = &client->dev;
238
239 if (!client->dev.of_node) {
240 dev_err(&client->dev,
241 "Not found DT.\n");
242 return -ENODEV;
243 }
244
245 data->vcc_reg = devm_regulator_get(&client->dev, "vcc");
246 if (IS_ERR(data->vcc_reg)) {
247 dev_err(&client->dev,
248 "Failed to get vcc-supply regulator. err: %ld\n",
249 PTR_ERR(data->vcc_reg));
250 return PTR_ERR(data->vcc_reg);
251 }
252
253 mutex_init(&data->lock);
254 ret = regulator_enable(data->vcc_reg);
255 if (ret < 0) {
256 dev_err(&client->dev,
257 "Unable to enable the regulator.\n");
258 return ret;
259 }
260
261 usleep_range(1000, 1200);
262 ret = ds4424_verify_chip(indio_dev);
263 if (ret < 0)
264 goto fail;
265
266 switch (id->driver_data) {
267 case ID_DS4422:
268 indio_dev->num_channels = DS4422_MAX_DAC_CHANNELS;
269 break;
270 case ID_DS4424:
271 indio_dev->num_channels = DS4424_MAX_DAC_CHANNELS;
272 break;
273 default:
274 dev_err(&client->dev,
275 "ds4424: Invalid chip id.\n");
276 ret = -ENXIO;
277 goto fail;
278 }
279
280 indio_dev->channels = ds4424_channels;
281 indio_dev->modes = INDIO_DIRECT_MODE;
282 indio_dev->info = &ds4424_info;
283
284 ret = iio_device_register(indio_dev);
285 if (ret < 0) {
286 dev_err(&client->dev,
287 "iio_device_register failed. ret: %d\n", ret);
288 goto fail;
289 }
290
291 return ret;
292
293fail:
294 regulator_disable(data->vcc_reg);
295 return ret;
296}
297
298static int ds4424_remove(struct i2c_client *client)
299{
300 struct iio_dev *indio_dev = i2c_get_clientdata(client);
301 struct ds4424_data *data = iio_priv(indio_dev);
302
303 iio_device_unregister(indio_dev);
304 regulator_disable(data->vcc_reg);
305
306 return 0;
307}
308
309static const struct i2c_device_id ds4424_id[] = {
310 { "ds4422", ID_DS4422 },
311 { "ds4424", ID_DS4424 },
312 { }
313};
314
315MODULE_DEVICE_TABLE(i2c, ds4424_id);
316
317static const struct of_device_id ds4424_of_match[] = {
318 { .compatible = "maxim,ds4422" },
319 { .compatible = "maxim,ds4424" },
320 { },
321};
322
323MODULE_DEVICE_TABLE(of, ds4424_of_match);
324
325static struct i2c_driver ds4424_driver = {
326 .driver = {
327 .name = "ds4424",
328 .of_match_table = ds4424_of_match,
329 .pm = &ds4424_pm_ops,
330 },
331 .probe = ds4424_probe,
332 .remove = ds4424_remove,
333 .id_table = ds4424_id,
334};
335module_i2c_driver(ds4424_driver);
336
337MODULE_DESCRIPTION("Maxim DS4424 DAC Driver");
338MODULE_AUTHOR("Ismail H. Kose <ismail.kose@maximintegrated.com>");
339MODULE_AUTHOR("Vishal Sood <vishal.sood@maximintegrated.com>");
340MODULE_AUTHOR("David Jung <david.jung@maximintegrated.com>");
341MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/dac/lpc18xx_dac.c b/drivers/iio/dac/lpc18xx_dac.c
index 55d1456a059d..7036f77fdf23 100644
--- a/drivers/iio/dac/lpc18xx_dac.c
+++ b/drivers/iio/dac/lpc18xx_dac.c
@@ -103,7 +103,6 @@ static int lpc18xx_dac_write_raw(struct iio_dev *indio_dev,
103static const struct iio_info lpc18xx_dac_info = { 103static const struct iio_info lpc18xx_dac_info = {
104 .read_raw = lpc18xx_dac_read_raw, 104 .read_raw = lpc18xx_dac_read_raw,
105 .write_raw = lpc18xx_dac_write_raw, 105 .write_raw = lpc18xx_dac_write_raw,
106 .driver_module = THIS_MODULE,
107}; 106};
108 107
109static int lpc18xx_dac_probe(struct platform_device *pdev) 108static int lpc18xx_dac_probe(struct platform_device *pdev)
diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c
index ac5e05f6eb8b..af2ddd0dd341 100644
--- a/drivers/iio/dac/ltc2632.c
+++ b/drivers/iio/dac/ltc2632.c
@@ -159,7 +159,6 @@ static ssize_t ltc2632_write_dac_powerdown(struct iio_dev *indio_dev,
159static const struct iio_info ltc2632_info = { 159static const struct iio_info ltc2632_info = {
160 .write_raw = ltc2632_write_raw, 160 .write_raw = ltc2632_write_raw,
161 .read_raw = ltc2632_read_raw, 161 .read_raw = ltc2632_read_raw,
162 .driver_module = THIS_MODULE,
163}; 162};
164 163
165static const struct iio_chan_spec_ext_info ltc2632_ext_info[] = { 164static const struct iio_chan_spec_ext_info ltc2632_ext_info[] = {
diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index 76e8b044b979..19031943dabe 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -174,7 +174,6 @@ static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
174static const struct iio_info m62332_info = { 174static const struct iio_info m62332_info = {
175 .read_raw = m62332_read_raw, 175 .read_raw = m62332_read_raw,
176 .write_raw = m62332_write_raw, 176 .write_raw = m62332_write_raw,
177 .driver_module = THIS_MODULE,
178}; 177};
179 178
180#define M62332_CHANNEL(chan) { \ 179#define M62332_CHANNEL(chan) { \
diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index 5507b3970b4b..1d853247a205 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -137,7 +137,6 @@ static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume);
137static const struct iio_info max517_info = { 137static const struct iio_info max517_info = {
138 .read_raw = max517_read_raw, 138 .read_raw = max517_read_raw,
139 .write_raw = max517_write_raw, 139 .write_raw = max517_write_raw,
140 .driver_module = THIS_MODULE,
141}; 140};
142 141
143#define MAX517_CHANNEL(chan) { \ 142#define MAX517_CHANNEL(chan) { \
diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c
index 193fac3059a3..d0ecc1fdd8fc 100644
--- a/drivers/iio/dac/max5821.c
+++ b/drivers/iio/dac/max5821.c
@@ -300,7 +300,6 @@ static SIMPLE_DEV_PM_OPS(max5821_pm_ops, max5821_suspend, max5821_resume);
300static const struct iio_info max5821_info = { 300static const struct iio_info max5821_info = {
301 .read_raw = max5821_read_raw, 301 .read_raw = max5821_read_raw,
302 .write_raw = max5821_write_raw, 302 .write_raw = max5821_write_raw,
303 .driver_module = THIS_MODULE,
304}; 303};
305 304
306static int max5821_probe(struct i2c_client *client, 305static int max5821_probe(struct i2c_client *client,
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 6ab1f23e5a79..afa856d10c26 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -363,7 +363,6 @@ static const struct iio_info mcp4725_info = {
363 .read_raw = mcp4725_read_raw, 363 .read_raw = mcp4725_read_raw,
364 .write_raw = mcp4725_write_raw, 364 .write_raw = mcp4725_write_raw,
365 .attrs = &mcp4725_attribute_group, 365 .attrs = &mcp4725_attribute_group,
366 .driver_module = THIS_MODULE,
367}; 366};
368 367
369#ifdef CONFIG_OF 368#ifdef CONFIG_OF
diff --git a/drivers/iio/dac/mcp4922.c b/drivers/iio/dac/mcp4922.c
index 3854d201a5d6..bf9aa3fc0534 100644
--- a/drivers/iio/dac/mcp4922.c
+++ b/drivers/iio/dac/mcp4922.c
@@ -119,7 +119,6 @@ static const struct iio_chan_spec mcp4922_channels[3][MCP4922_NUM_CHANNELS] = {
119static const struct iio_info mcp4922_info = { 119static const struct iio_info mcp4922_info = {
120 .read_raw = &mcp4922_read_raw, 120 .read_raw = &mcp4922_read_raw,
121 .write_raw = &mcp4922_write_raw, 121 .write_raw = &mcp4922_write_raw,
122 .driver_module = THIS_MODULE,
123}; 122};
124 123
125static int mcp4922_probe(struct spi_device *spi) 124static int mcp4922_probe(struct spi_device *spi)
diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index c1864e8aa851..9ffab02bf9f9 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -156,7 +156,6 @@ static const struct iio_info stm32_dac_iio_info = {
156 .read_raw = stm32_dac_read_raw, 156 .read_raw = stm32_dac_read_raw,
157 .write_raw = stm32_dac_write_raw, 157 .write_raw = stm32_dac_write_raw,
158 .debugfs_reg_access = stm32_dac_debugfs_reg_access, 158 .debugfs_reg_access = stm32_dac_debugfs_reg_access,
159 .driver_module = THIS_MODULE,
160}; 159};
161 160
162static const char * const stm32_dac_powerdown_modes[] = { 161static const char * const stm32_dac_powerdown_modes[] = {
diff --git a/drivers/iio/dac/ti-dac082s085.c b/drivers/iio/dac/ti-dac082s085.c
new file mode 100644
index 000000000000..4e1e28339c84
--- /dev/null
+++ b/drivers/iio/dac/ti-dac082s085.c
@@ -0,0 +1,368 @@
1/*
2 * ti-dac082s085.c - Texas Instruments 8/10/12-bit 2/4-channel DAC driver
3 *
4 * Copyright (C) 2017 KUNBUS GmbH
5 *
6 * http://www.ti.com/lit/ds/symlink/dac082s085.pdf
7 * http://www.ti.com/lit/ds/symlink/dac102s085.pdf
8 * http://www.ti.com/lit/ds/symlink/dac122s085.pdf
9 * http://www.ti.com/lit/ds/symlink/dac084s085.pdf
10 * http://www.ti.com/lit/ds/symlink/dac104s085.pdf
11 * http://www.ti.com/lit/ds/symlink/dac124s085.pdf
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License (version 2) as
15 * published by the Free Software Foundation.
16 */
17
18#include <linux/iio/iio.h>
19#include <linux/module.h>
20#include <linux/regulator/consumer.h>
21#include <linux/spi/spi.h>
22
23enum { dual_8bit, dual_10bit, dual_12bit, quad_8bit, quad_10bit, quad_12bit };
24
25struct ti_dac_spec {
26 u8 num_channels;
27 u8 resolution;
28};
29
30static const struct ti_dac_spec ti_dac_spec[] = {
31 [dual_8bit] = { .num_channels = 2, .resolution = 8 },
32 [dual_10bit] = { .num_channels = 2, .resolution = 10 },
33 [dual_12bit] = { .num_channels = 2, .resolution = 12 },
34 [quad_8bit] = { .num_channels = 4, .resolution = 8 },
35 [quad_10bit] = { .num_channels = 4, .resolution = 10 },
36 [quad_12bit] = { .num_channels = 4, .resolution = 12 },
37};
38
39/**
40 * struct ti_dac_chip - TI DAC chip
41 * @lock: protects write sequences
42 * @vref: regulator generating Vref
43 * @mesg: SPI message to perform a write
44 * @xfer: SPI transfer used by @mesg
45 * @val: cached value of each output
46 * @powerdown: whether the chip is powered down
47 * @powerdown_mode: selected by the user
48 * @resolution: resolution of the chip
49 * @buf: buffer for @xfer
50 */
51struct ti_dac_chip {
52 struct mutex lock;
53 struct regulator *vref;
54 struct spi_message mesg;
55 struct spi_transfer xfer;
56 u16 val[4];
57 bool powerdown;
58 u8 powerdown_mode;
59 u8 resolution;
60 u8 buf[2] ____cacheline_aligned;
61};
62
63#define WRITE_NOT_UPDATE(chan) (0x00 | (chan) << 6)
64#define WRITE_AND_UPDATE(chan) (0x10 | (chan) << 6)
65#define WRITE_ALL_UPDATE 0x20
66#define POWERDOWN(mode) (0x30 | ((mode) + 1) << 6)
67
68static int ti_dac_cmd(struct ti_dac_chip *ti_dac, u8 cmd, u16 val)
69{
70 u8 shift = 12 - ti_dac->resolution;
71
72 ti_dac->buf[0] = cmd | (val >> (8 - shift));
73 ti_dac->buf[1] = (val << shift) & 0xff;
74 return spi_sync(ti_dac->mesg.spi, &ti_dac->mesg);
75}
76
77static const char * const ti_dac_powerdown_modes[] = {
78 "2.5kohm_to_gnd", "100kohm_to_gnd", "three_state",
79};
80
81static int ti_dac_get_powerdown_mode(struct iio_dev *indio_dev,
82 const struct iio_chan_spec *chan)
83{
84 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
85
86 return ti_dac->powerdown_mode;
87}
88
89static int ti_dac_set_powerdown_mode(struct iio_dev *indio_dev,
90 const struct iio_chan_spec *chan,
91 unsigned int mode)
92{
93 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
94 int ret = 0;
95
96 if (ti_dac->powerdown_mode == mode)
97 return 0;
98
99 mutex_lock(&ti_dac->lock);
100 if (ti_dac->powerdown) {
101 ret = ti_dac_cmd(ti_dac, POWERDOWN(mode), 0);
102 if (ret)
103 goto out;
104 }
105 ti_dac->powerdown_mode = mode;
106
107out:
108 mutex_unlock(&ti_dac->lock);
109 return ret;
110}
111
112static const struct iio_enum ti_dac_powerdown_mode = {
113 .items = ti_dac_powerdown_modes,
114 .num_items = ARRAY_SIZE(ti_dac_powerdown_modes),
115 .get = ti_dac_get_powerdown_mode,
116 .set = ti_dac_set_powerdown_mode,
117};
118
119static ssize_t ti_dac_read_powerdown(struct iio_dev *indio_dev,
120 uintptr_t private,
121 const struct iio_chan_spec *chan,
122 char *buf)
123{
124 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
125
126 return sprintf(buf, "%d\n", ti_dac->powerdown);
127}
128
129static ssize_t ti_dac_write_powerdown(struct iio_dev *indio_dev,
130 uintptr_t private,
131 const struct iio_chan_spec *chan,
132 const char *buf, size_t len)
133{
134 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
135 bool powerdown;
136 int ret;
137
138 ret = strtobool(buf, &powerdown);
139 if (ret)
140 return ret;
141
142 if (ti_dac->powerdown == powerdown)
143 return len;
144
145 mutex_lock(&ti_dac->lock);
146 if (powerdown)
147 ret = ti_dac_cmd(ti_dac, POWERDOWN(ti_dac->powerdown_mode), 0);
148 else
149 ret = ti_dac_cmd(ti_dac, WRITE_AND_UPDATE(0), ti_dac->val[0]);
150 if (!ret)
151 ti_dac->powerdown = powerdown;
152 mutex_unlock(&ti_dac->lock);
153
154 return ret ? ret : len;
155}
156
157static const struct iio_chan_spec_ext_info ti_dac_ext_info[] = {
158 {
159 .name = "powerdown",
160 .read = ti_dac_read_powerdown,
161 .write = ti_dac_write_powerdown,
162 .shared = IIO_SHARED_BY_TYPE,
163 },
164 IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, &ti_dac_powerdown_mode),
165 IIO_ENUM_AVAILABLE("powerdown_mode", &ti_dac_powerdown_mode),
166 { },
167};
168
169#define TI_DAC_CHANNEL(chan) { \
170 .type = IIO_VOLTAGE, \
171 .channel = (chan), \
172 .address = (chan), \
173 .indexed = true, \
174 .output = true, \
175 .datasheet_name = (const char[]){ 'A' + (chan), 0 }, \
176 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
177 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
178 .ext_info = ti_dac_ext_info, \
179}
180
181static const struct iio_chan_spec ti_dac_channels[] = {
182 TI_DAC_CHANNEL(0),
183 TI_DAC_CHANNEL(1),
184 TI_DAC_CHANNEL(2),
185 TI_DAC_CHANNEL(3),
186};
187
188static int ti_dac_read_raw(struct iio_dev *indio_dev,
189 struct iio_chan_spec const *chan,
190 int *val, int *val2, long mask)
191{
192 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
193 int ret;
194
195 switch (mask) {
196 case IIO_CHAN_INFO_RAW:
197 *val = ti_dac->val[chan->channel];
198 ret = IIO_VAL_INT;
199 break;
200
201 case IIO_CHAN_INFO_SCALE:
202 ret = regulator_get_voltage(ti_dac->vref);
203 if (ret < 0)
204 return ret;
205
206 *val = ret / 1000;
207 *val2 = ti_dac->resolution;
208 ret = IIO_VAL_FRACTIONAL_LOG2;
209 break;
210
211 default:
212 ret = -EINVAL;
213 }
214
215 return ret;
216}
217
218static int ti_dac_write_raw(struct iio_dev *indio_dev,
219 struct iio_chan_spec const *chan,
220 int val, int val2, long mask)
221{
222 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
223 int ret;
224
225 switch (mask) {
226 case IIO_CHAN_INFO_RAW:
227 if (ti_dac->val[chan->channel] == val)
228 return 0;
229
230 if (val >= (1 << ti_dac->resolution) || val < 0)
231 return -EINVAL;
232
233 if (ti_dac->powerdown)
234 return -EBUSY;
235
236 mutex_lock(&ti_dac->lock);
237 ret = ti_dac_cmd(ti_dac, WRITE_AND_UPDATE(chan->channel), val);
238 if (!ret)
239 ti_dac->val[chan->channel] = val;
240 mutex_unlock(&ti_dac->lock);
241 break;
242
243 default:
244 ret = -EINVAL;
245 }
246
247 return ret;
248}
249
250static int ti_dac_write_raw_get_fmt(struct iio_dev *indio_dev,
251 struct iio_chan_spec const *chan, long mask)
252{
253 return IIO_VAL_INT;
254}
255
256static const struct iio_info ti_dac_info = {
257 .read_raw = ti_dac_read_raw,
258 .write_raw = ti_dac_write_raw,
259 .write_raw_get_fmt = ti_dac_write_raw_get_fmt,
260};
261
262static int ti_dac_probe(struct spi_device *spi)
263{
264 struct device *dev = &spi->dev;
265 const struct ti_dac_spec *spec;
266 struct ti_dac_chip *ti_dac;
267 struct iio_dev *indio_dev;
268 int ret;
269
270 indio_dev = devm_iio_device_alloc(dev, sizeof(*ti_dac));
271 if (!indio_dev)
272 return -ENOMEM;
273
274 indio_dev->dev.parent = dev;
275 indio_dev->info = &ti_dac_info;
276 indio_dev->name = spi->modalias;
277 indio_dev->modes = INDIO_DIRECT_MODE;
278 indio_dev->channels = ti_dac_channels;
279 spi_set_drvdata(spi, indio_dev);
280
281 ti_dac = iio_priv(indio_dev);
282 ti_dac->xfer.tx_buf = &ti_dac->buf;
283 ti_dac->xfer.len = sizeof(ti_dac->buf);
284 spi_message_init_with_transfers(&ti_dac->mesg, &ti_dac->xfer, 1);
285 ti_dac->mesg.spi = spi;
286
287 spec = &ti_dac_spec[spi_get_device_id(spi)->driver_data];
288 indio_dev->num_channels = spec->num_channels;
289 ti_dac->resolution = spec->resolution;
290
291 ti_dac->vref = devm_regulator_get(dev, "vref");
292 if (IS_ERR(ti_dac->vref))
293 return PTR_ERR(ti_dac->vref);
294
295 ret = regulator_enable(ti_dac->vref);
296 if (ret < 0)
297 return ret;
298
299 mutex_init(&ti_dac->lock);
300
301 ret = ti_dac_cmd(ti_dac, WRITE_ALL_UPDATE, 0);
302 if (ret) {
303 dev_err(dev, "failed to initialize outputs to 0\n");
304 goto err;
305 }
306
307 ret = iio_device_register(indio_dev);
308 if (ret)
309 goto err;
310
311 return 0;
312
313err:
314 mutex_destroy(&ti_dac->lock);
315 regulator_disable(ti_dac->vref);
316 return ret;
317}
318
319static int ti_dac_remove(struct spi_device *spi)
320{
321 struct iio_dev *indio_dev = spi_get_drvdata(spi);
322 struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
323
324 iio_device_unregister(indio_dev);
325 mutex_destroy(&ti_dac->lock);
326 regulator_disable(ti_dac->vref);
327
328 return 0;
329}
330
331#ifdef CONFIG_OF
332static const struct of_device_id ti_dac_of_id[] = {
333 { .compatible = "ti,dac082s085" },
334 { .compatible = "ti,dac102s085" },
335 { .compatible = "ti,dac122s085" },
336 { .compatible = "ti,dac084s085" },
337 { .compatible = "ti,dac104s085" },
338 { .compatible = "ti,dac124s085" },
339 { }
340};
341MODULE_DEVICE_TABLE(of, ti_dac_of_id);
342#endif
343
344static const struct spi_device_id ti_dac_spi_id[] = {
345 { "dac082s085", dual_8bit },
346 { "dac102s085", dual_10bit },
347 { "dac122s085", dual_12bit },
348 { "dac084s085", quad_8bit },
349 { "dac104s085", quad_10bit },
350 { "dac124s085", quad_12bit },
351 { }
352};
353MODULE_DEVICE_TABLE(spi, ti_dac_spi_id);
354
355static struct spi_driver ti_dac_driver = {
356 .driver = {
357 .name = "ti-dac082s085",
358 .of_match_table = of_match_ptr(ti_dac_of_id),
359 },
360 .probe = ti_dac_probe,
361 .remove = ti_dac_remove,
362 .id_table = ti_dac_spi_id,
363};
364module_spi_driver(ti_dac_driver);
365
366MODULE_AUTHOR("Lukas Wunner <lukas@wunner.de>");
367MODULE_DESCRIPTION("Texas Instruments 8/10/12-bit 2/4-channel DAC driver");
368MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index c4ec7779b394..5dccdd16cab3 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -167,7 +167,6 @@ static int vf610_write_raw(struct iio_dev *indio_dev,
167} 167}
168 168
169static const struct iio_info vf610_dac_iio_info = { 169static const struct iio_info vf610_dac_iio_info = {
170 .driver_module = THIS_MODULE,
171 .read_raw = &vf610_read_raw, 170 .read_raw = &vf610_read_raw,
172 .write_raw = &vf610_write_raw, 171 .write_raw = &vf610_write_raw,
173}; 172};
diff --git a/drivers/iio/dummy/Kconfig b/drivers/iio/dummy/Kconfig
index aa5824d96a43..5a29fbd3c531 100644
--- a/drivers/iio/dummy/Kconfig
+++ b/drivers/iio/dummy/Kconfig
@@ -5,7 +5,7 @@ menu "IIO dummy driver"
5 depends on IIO 5 depends on IIO
6 6
7config IIO_DUMMY_EVGEN 7config IIO_DUMMY_EVGEN
8 select IRQ_WORK 8 select IRQ_SIM
9 tristate 9 tristate
10 10
11config IIO_SIMPLE_DUMMY 11config IIO_SIMPLE_DUMMY
diff --git a/drivers/iio/dummy/iio_dummy_evgen.c b/drivers/iio/dummy/iio_dummy_evgen.c
index 9e83f348df51..fe8884543da0 100644
--- a/drivers/iio/dummy/iio_dummy_evgen.c
+++ b/drivers/iio/dummy/iio_dummy_evgen.c
@@ -24,97 +24,46 @@
24#include "iio_dummy_evgen.h" 24#include "iio_dummy_evgen.h"
25#include <linux/iio/iio.h> 25#include <linux/iio/iio.h>
26#include <linux/iio/sysfs.h> 26#include <linux/iio/sysfs.h>
27#include <linux/irq_work.h> 27#include <linux/irq_sim.h>
28 28
29/* Fiddly bit of faking and irq without hardware */ 29/* Fiddly bit of faking and irq without hardware */
30#define IIO_EVENTGEN_NO 10 30#define IIO_EVENTGEN_NO 10
31 31
32/** 32/**
33 * struct iio_dummy_handle_irq - helper struct to simulate interrupt generation
34 * @work: irq_work used to run handlers from hardirq context
35 * @irq: fake irq line number to trigger an interrupt
36 */
37struct iio_dummy_handle_irq {
38 struct irq_work work;
39 int irq;
40};
41
42/**
43 * struct iio_dummy_evgen - evgen state
44 * @chip: irq chip we are faking
45 * @base: base of irq range
46 * @enabled: mask of which irqs are enabled
47 * @inuse: mask of which irqs are connected
48 * @regs: irq regs we are faking 33 * @regs: irq regs we are faking
49 * @lock: protect the evgen state 34 * @lock: protect the evgen state
50 * @handler: helper for a 'hardware-like' interrupt simulation 35 * @inuse: mask of which irqs are connected
36 * @irq_sim: interrupt simulator
37 * @base: base of irq range
51 */ 38 */
52struct iio_dummy_eventgen { 39struct iio_dummy_eventgen {
53 struct irq_chip chip;
54 int base;
55 bool enabled[IIO_EVENTGEN_NO];
56 bool inuse[IIO_EVENTGEN_NO];
57 struct iio_dummy_regs regs[IIO_EVENTGEN_NO]; 40 struct iio_dummy_regs regs[IIO_EVENTGEN_NO];
58 struct mutex lock; 41 struct mutex lock;
59 struct iio_dummy_handle_irq handler; 42 bool inuse[IIO_EVENTGEN_NO];
43 struct irq_sim irq_sim;
44 int base;
60}; 45};
61 46
62/* We can only ever have one instance of this 'device' */ 47/* We can only ever have one instance of this 'device' */
63static struct iio_dummy_eventgen *iio_evgen; 48static struct iio_dummy_eventgen *iio_evgen;
64static const char *iio_evgen_name = "iio_dummy_evgen";
65
66static void iio_dummy_event_irqmask(struct irq_data *d)
67{
68 struct irq_chip *chip = irq_data_get_irq_chip(d);
69 struct iio_dummy_eventgen *evgen =
70 container_of(chip, struct iio_dummy_eventgen, chip);
71
72 evgen->enabled[d->irq - evgen->base] = false;
73}
74
75static void iio_dummy_event_irqunmask(struct irq_data *d)
76{
77 struct irq_chip *chip = irq_data_get_irq_chip(d);
78 struct iio_dummy_eventgen *evgen =
79 container_of(chip, struct iio_dummy_eventgen, chip);
80
81 evgen->enabled[d->irq - evgen->base] = true;
82}
83
84static void iio_dummy_work_handler(struct irq_work *work)
85{
86 struct iio_dummy_handle_irq *irq_handler;
87
88 irq_handler = container_of(work, struct iio_dummy_handle_irq, work);
89 handle_simple_irq(irq_to_desc(irq_handler->irq));
90}
91 49
92static int iio_dummy_evgen_create(void) 50static int iio_dummy_evgen_create(void)
93{ 51{
94 int ret, i; 52 int ret;
95 53
96 iio_evgen = kzalloc(sizeof(*iio_evgen), GFP_KERNEL); 54 iio_evgen = kzalloc(sizeof(*iio_evgen), GFP_KERNEL);
97 if (!iio_evgen) 55 if (!iio_evgen)
98 return -ENOMEM; 56 return -ENOMEM;
99 57
100 iio_evgen->base = irq_alloc_descs(-1, 0, IIO_EVENTGEN_NO, 0); 58 ret = irq_sim_init(&iio_evgen->irq_sim, IIO_EVENTGEN_NO);
101 if (iio_evgen->base < 0) { 59 if (ret) {
102 ret = iio_evgen->base;
103 kfree(iio_evgen); 60 kfree(iio_evgen);
104 return ret; 61 return ret;
105 } 62 }
106 iio_evgen->chip.name = iio_evgen_name; 63
107 iio_evgen->chip.irq_mask = &iio_dummy_event_irqmask; 64 iio_evgen->base = irq_sim_irqnum(&iio_evgen->irq_sim, 0);
108 iio_evgen->chip.irq_unmask = &iio_dummy_event_irqunmask;
109 for (i = 0; i < IIO_EVENTGEN_NO; i++) {
110 irq_set_chip(iio_evgen->base + i, &iio_evgen->chip);
111 irq_set_handler(iio_evgen->base + i, &handle_simple_irq);
112 irq_modify_status(iio_evgen->base + i,
113 IRQ_NOREQUEST | IRQ_NOAUTOEN,
114 IRQ_NOPROBE);
115 }
116 init_irq_work(&iio_evgen->handler.work, iio_dummy_work_handler);
117 mutex_init(&iio_evgen->lock); 65 mutex_init(&iio_evgen->lock);
66
118 return 0; 67 return 0;
119} 68}
120 69
@@ -132,15 +81,17 @@ int iio_dummy_evgen_get_irq(void)
132 return -ENODEV; 81 return -ENODEV;
133 82
134 mutex_lock(&iio_evgen->lock); 83 mutex_lock(&iio_evgen->lock);
135 for (i = 0; i < IIO_EVENTGEN_NO; i++) 84 for (i = 0; i < IIO_EVENTGEN_NO; i++) {
136 if (!iio_evgen->inuse[i]) { 85 if (!iio_evgen->inuse[i]) {
137 ret = iio_evgen->base + i; 86 ret = irq_sim_irqnum(&iio_evgen->irq_sim, i);
138 iio_evgen->inuse[i] = true; 87 iio_evgen->inuse[i] = true;
139 break; 88 break;
140 } 89 }
90 }
141 mutex_unlock(&iio_evgen->lock); 91 mutex_unlock(&iio_evgen->lock);
142 if (i == IIO_EVENTGEN_NO) 92 if (i == IIO_EVENTGEN_NO)
143 return -ENOMEM; 93 return -ENOMEM;
94
144 return ret; 95 return ret;
145} 96}
146EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_irq); 97EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_irq);
@@ -167,7 +118,7 @@ EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_regs);
167 118
168static void iio_dummy_evgen_free(void) 119static void iio_dummy_evgen_free(void)
169{ 120{
170 irq_free_descs(iio_evgen->base, IIO_EVENTGEN_NO); 121 irq_sim_fini(&iio_evgen->irq_sim);
171 kfree(iio_evgen); 122 kfree(iio_evgen);
172} 123}
173 124
@@ -192,9 +143,7 @@ static ssize_t iio_evgen_poke(struct device *dev,
192 iio_evgen->regs[this_attr->address].reg_id = this_attr->address; 143 iio_evgen->regs[this_attr->address].reg_id = this_attr->address;
193 iio_evgen->regs[this_attr->address].reg_data = event; 144 iio_evgen->regs[this_attr->address].reg_data = event;
194 145
195 iio_evgen->handler.irq = iio_evgen->base + this_attr->address; 146 irq_sim_fire(&iio_evgen->irq_sim, this_attr->address);
196 if (iio_evgen->enabled[this_attr->address])
197 irq_work_queue(&iio_evgen->handler.work);
198 147
199 return len; 148 return len;
200} 149}
diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c
index ad3410e528b6..a45d01e9b8e8 100644
--- a/drivers/iio/dummy/iio_simple_dummy.c
+++ b/drivers/iio/dummy/iio_simple_dummy.c
@@ -519,7 +519,6 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,
519 * Device type specific information. 519 * Device type specific information.
520 */ 520 */
521static const struct iio_info iio_dummy_info = { 521static const struct iio_info iio_dummy_info = {
522 .driver_module = THIS_MODULE,
523 .read_raw = &iio_dummy_read_raw, 522 .read_raw = &iio_dummy_read_raw,
524 .write_raw = &iio_dummy_write_raw, 523 .write_raw = &iio_dummy_write_raw,
525#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS 524#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
diff --git a/drivers/iio/dummy/iio_simple_dummy_events.c b/drivers/iio/dummy/iio_simple_dummy_events.c
index ed63ffd849f8..7ec2a0bb0807 100644
--- a/drivers/iio/dummy/iio_simple_dummy_events.c
+++ b/drivers/iio/dummy/iio_simple_dummy_events.c
@@ -72,6 +72,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
72 st->event_en = state; 72 st->event_en = state;
73 else 73 else
74 return -EINVAL; 74 return -EINVAL;
75 break;
75 default: 76 default:
76 return -EINVAL; 77 return -EINVAL;
77 } 78 }
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 99eba524f6dd..ddb6a334ae68 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -738,7 +738,6 @@ static const struct iio_info ad9523_info = {
738 .write_raw = &ad9523_write_raw, 738 .write_raw = &ad9523_write_raw,
739 .debugfs_reg_access = &ad9523_reg_access, 739 .debugfs_reg_access = &ad9523_reg_access,
740 .attrs = &ad9523_attribute_group, 740 .attrs = &ad9523_attribute_group,
741 .driver_module = THIS_MODULE,
742}; 741};
743 742
744static int ad9523_setup(struct iio_dev *indio_dev) 743static int ad9523_setup(struct iio_dev *indio_dev)
diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
index d2d824b446f5..6d768431d90e 100644
--- a/drivers/iio/frequency/adf4350.c
+++ b/drivers/iio/frequency/adf4350.c
@@ -374,7 +374,6 @@ static const struct iio_chan_spec adf4350_chan = {
374 374
375static const struct iio_info adf4350_info = { 375static const struct iio_info adf4350_info = {
376 .debugfs_reg_access = &adf4350_reg_access, 376 .debugfs_reg_access = &adf4350_reg_access,
377 .driver_module = THIS_MODULE,
378}; 377};
379 378
380#ifdef CONFIG_OF 379#ifdef CONFIG_OF
diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c
index ad31a1372a04..a551ebde4762 100644
--- a/drivers/iio/gyro/adis16080.c
+++ b/drivers/iio/gyro/adis16080.c
@@ -163,7 +163,6 @@ static const struct iio_chan_spec adis16080_channels[] = {
163 163
164static const struct iio_info adis16080_info = { 164static const struct iio_info adis16080_info = {
165 .read_raw = &adis16080_read_raw, 165 .read_raw = &adis16080_read_raw,
166 .driver_module = THIS_MODULE,
167}; 166};
168 167
169enum { 168enum {
diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c
index e5241f41e65e..aea80ab04122 100644
--- a/drivers/iio/gyro/adis16130.c
+++ b/drivers/iio/gyro/adis16130.c
@@ -137,7 +137,6 @@ static const struct iio_chan_spec adis16130_channels[] = {
137 137
138static const struct iio_info adis16130_info = { 138static const struct iio_info adis16130_info = {
139 .read_raw = &adis16130_read_raw, 139 .read_raw = &adis16130_read_raw,
140 .driver_module = THIS_MODULE,
141}; 140};
142 141
143static int adis16130_probe(struct spi_device *spi) 142static int adis16130_probe(struct spi_device *spi)
diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
index b04faf93e1bc..90ec4bed62b7 100644
--- a/drivers/iio/gyro/adis16136.c
+++ b/drivers/iio/gyro/adis16136.c
@@ -398,7 +398,6 @@ static const struct attribute_group adis16136_attribute_group = {
398}; 398};
399 399
400static const struct iio_info adis16136_info = { 400static const struct iio_info adis16136_info = {
401 .driver_module = THIS_MODULE,
402 .attrs = &adis16136_attribute_group, 401 .attrs = &adis16136_attribute_group,
403 .read_raw = &adis16136_read_raw, 402 .read_raw = &adis16136_read_raw,
404 .write_raw = &adis16136_write_raw, 403 .write_raw = &adis16136_write_raw,
diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
index 7da8825f4791..a8cb1ca349d9 100644
--- a/drivers/iio/gyro/adis16260.c
+++ b/drivers/iio/gyro/adis16260.c
@@ -321,7 +321,6 @@ static const struct iio_info adis16260_info = {
321 .read_raw = &adis16260_read_raw, 321 .read_raw = &adis16260_read_raw,
322 .write_raw = &adis16260_write_raw, 322 .write_raw = &adis16260_write_raw,
323 .update_scan_mode = adis_update_scan_mode, 323 .update_scan_mode = adis_update_scan_mode,
324 .driver_module = THIS_MODULE,
325}; 324};
326 325
327static const char * const adis1620_status_error_msgs[] = { 326static const char * const adis1620_status_error_msgs[] = {
diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c
index a330d4288bb0..5d39fd008378 100644
--- a/drivers/iio/gyro/adxrs450.c
+++ b/drivers/iio/gyro/adxrs450.c
@@ -405,7 +405,6 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = {
405}; 405};
406 406
407static const struct iio_info adxrs450_info = { 407static const struct iio_info adxrs450_info = {
408 .driver_module = THIS_MODULE,
409 .read_raw = &adxrs450_read_raw, 408 .read_raw = &adxrs450_read_raw,
410 .write_raw = &adxrs450_write_raw, 409 .write_raw = &adxrs450_write_raw,
411}; 410};
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 821919dd245b..15046172e437 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -858,7 +858,6 @@ static const struct iio_info bmg160_info = {
858 .write_event_value = bmg160_write_event, 858 .write_event_value = bmg160_write_event,
859 .write_event_config = bmg160_write_event_config, 859 .write_event_config = bmg160_write_event_config,
860 .read_event_config = bmg160_read_event_config, 860 .read_event_config = bmg160_read_event_config,
861 .driver_module = THIS_MODULE,
862}; 861};
863 862
864static const unsigned long bmg160_accel_scan_masks[] = { 863static const unsigned long bmg160_accel_scan_masks[] = {
@@ -956,7 +955,6 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig,
956static const struct iio_trigger_ops bmg160_trigger_ops = { 955static const struct iio_trigger_ops bmg160_trigger_ops = {
957 .set_trigger_state = bmg160_data_rdy_trigger_set_state, 956 .set_trigger_state = bmg160_data_rdy_trigger_set_state,
958 .try_reenable = bmg160_trig_try_reen, 957 .try_reenable = bmg160_trig_try_reen,
959 .owner = THIS_MODULE,
960}; 958};
961 959
962static irqreturn_t bmg160_event_handler(int irq, void *private) 960static irqreturn_t bmg160_event_handler(int irq, void *private)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c67ce2ac4715..f59995a90387 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -186,7 +186,6 @@ static int gyro_3d_write_raw(struct iio_dev *indio_dev,
186} 186}
187 187
188static const struct iio_info gyro_3d_info = { 188static const struct iio_info gyro_3d_info = {
189 .driver_module = THIS_MODULE,
190 .read_raw = &gyro_3d_read_raw, 189 .read_raw = &gyro_3d_read_raw,
191 .write_raw = &gyro_3d_write_raw, 190 .write_raw = &gyro_3d_write_raw,
192}; 191};
diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
index eef50e91f17c..59770e5b6660 100644
--- a/drivers/iio/gyro/itg3200_buffer.c
+++ b/drivers/iio/gyro/itg3200_buffer.c
@@ -101,7 +101,6 @@ error_ret:
101} 101}
102 102
103static const struct iio_trigger_ops itg3200_trigger_ops = { 103static const struct iio_trigger_ops itg3200_trigger_ops = {
104 .owner = THIS_MODULE,
105 .set_trigger_state = &itg3200_data_rdy_trigger_set_state, 104 .set_trigger_state = &itg3200_data_rdy_trigger_set_state,
106}; 105};
107 106
diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
index cfa2db04a8ab..7adecb562c81 100644
--- a/drivers/iio/gyro/itg3200_core.c
+++ b/drivers/iio/gyro/itg3200_core.c
@@ -278,7 +278,6 @@ static const struct iio_chan_spec itg3200_channels[] = {
278static const struct iio_info itg3200_info = { 278static const struct iio_info itg3200_info = {
279 .read_raw = &itg3200_read_raw, 279 .read_raw = &itg3200_read_raw,
280 .write_raw = &itg3200_write_raw, 280 .write_raw = &itg3200_write_raw,
281 .driver_module = THIS_MODULE,
282}; 281};
283 282
284static const unsigned long itg3200_available_scan_masks[] = { 0xffffffff, 0x0 }; 283static const unsigned long itg3200_available_scan_masks[] = { 0xffffffff, 0x0 };
diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index e0d241a9aa30..77fac81a3adc 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -742,7 +742,6 @@ static const struct attribute_group mpu3050_attribute_group = {
742}; 742};
743 743
744static const struct iio_info mpu3050_info = { 744static const struct iio_info mpu3050_info = {
745 .driver_module = THIS_MODULE,
746 .read_raw = mpu3050_read_raw, 745 .read_raw = mpu3050_read_raw,
747 .write_raw = mpu3050_write_raw, 746 .write_raw = mpu3050_write_raw,
748 .attrs = &mpu3050_attribute_group, 747 .attrs = &mpu3050_attribute_group,
@@ -1032,7 +1031,6 @@ static int mpu3050_drdy_trigger_set_state(struct iio_trigger *trig,
1032} 1031}
1033 1032
1034static const struct iio_trigger_ops mpu3050_trigger_ops = { 1033static const struct iio_trigger_ops mpu3050_trigger_ops = {
1035 .owner = THIS_MODULE,
1036 .set_trigger_state = mpu3050_drdy_trigger_set_state, 1034 .set_trigger_state = mpu3050_drdy_trigger_set_state,
1037}; 1035};
1038 1036
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index e366422e8512..b31064ba37b9 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -111,14 +111,23 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
111 .mask = 0x80, 111 .mask = 0x80,
112 }, 112 },
113 .drdy_irq = { 113 .drdy_irq = {
114 .addr = 0x22, 114 .int2 = {
115 .mask_int2 = 0x08, 115 .addr = 0x22,
116 .mask = 0x08,
117 },
116 /* 118 /*
117 * The sensor has IHL (active low) and open 119 * The sensor has IHL (active low) and open
118 * drain settings, but only for INT1 and not 120 * drain settings, but only for INT1 and not
119 * for the DRDY line on INT2. 121 * for the DRDY line on INT2.
120 */ 122 */
121 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 123 .stat_drdy = {
124 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
125 .mask = 0x07,
126 },
127 },
128 .sim = {
129 .addr = 0x23,
130 .value = BIT(0),
122 }, 131 },
123 .multi_read_bit = true, 132 .multi_read_bit = true,
124 .bootime = 2, 133 .bootime = 2,
@@ -181,14 +190,23 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
181 .mask = 0x80, 190 .mask = 0x80,
182 }, 191 },
183 .drdy_irq = { 192 .drdy_irq = {
184 .addr = 0x22, 193 .int2 = {
185 .mask_int2 = 0x08, 194 .addr = 0x22,
195 .mask = 0x08,
196 },
186 /* 197 /*
187 * The sensor has IHL (active low) and open 198 * The sensor has IHL (active low) and open
188 * drain settings, but only for INT1 and not 199 * drain settings, but only for INT1 and not
189 * for the DRDY line on INT2. 200 * for the DRDY line on INT2.
190 */ 201 */
191 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 202 .stat_drdy = {
203 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
204 .mask = 0x07,
205 },
206 },
207 .sim = {
208 .addr = 0x23,
209 .value = BIT(0),
192 }, 210 },
193 .multi_read_bit = true, 211 .multi_read_bit = true,
194 .bootime = 2, 212 .bootime = 2,
@@ -246,14 +264,23 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
246 .mask = 0x80, 264 .mask = 0x80,
247 }, 265 },
248 .drdy_irq = { 266 .drdy_irq = {
249 .addr = 0x22, 267 .int2 = {
250 .mask_int2 = 0x08, 268 .addr = 0x22,
269 .mask = 0x08,
270 },
251 /* 271 /*
252 * The sensor has IHL (active low) and open 272 * The sensor has IHL (active low) and open
253 * drain settings, but only for INT1 and not 273 * drain settings, but only for INT1 and not
254 * for the DRDY line on INT2. 274 * for the DRDY line on INT2.
255 */ 275 */
256 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 276 .stat_drdy = {
277 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
278 .mask = 0x07,
279 },
280 },
281 .sim = {
282 .addr = 0x23,
283 .value = BIT(0),
257 }, 284 },
258 .multi_read_bit = true, 285 .multi_read_bit = true,
259 .bootime = 2, 286 .bootime = 2,
@@ -326,7 +353,6 @@ static const struct attribute_group st_gyro_attribute_group = {
326}; 353};
327 354
328static const struct iio_info gyro_info = { 355static const struct iio_info gyro_info = {
329 .driver_module = THIS_MODULE,
330 .attrs = &st_gyro_attribute_group, 356 .attrs = &st_gyro_attribute_group,
331 .read_raw = &st_gyro_read_raw, 357 .read_raw = &st_gyro_read_raw,
332 .write_raw = &st_gyro_write_raw, 358 .write_raw = &st_gyro_write_raw,
@@ -335,7 +361,6 @@ static const struct iio_info gyro_info = {
335 361
336#ifdef CONFIG_IIO_TRIGGER 362#ifdef CONFIG_IIO_TRIGGER
337static const struct iio_trigger_ops st_gyro_trigger_ops = { 363static const struct iio_trigger_ops st_gyro_trigger_ops = {
338 .owner = THIS_MODULE,
339 .set_trigger_state = ST_GYRO_TRIGGER_SET_STATE, 364 .set_trigger_state = ST_GYRO_TRIGGER_SET_STATE,
340 .validate_device = st_sensors_validate_device, 365 .validate_device = st_sensors_validate_device,
341}; 366};
diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index 6bb23a49e81e..a739fff01c6b 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -309,7 +309,6 @@ static const struct iio_info afe4403_iio_info = {
309 .attrs = &afe440x_attribute_group, 309 .attrs = &afe440x_attribute_group,
310 .read_raw = afe4403_read_raw, 310 .read_raw = afe4403_read_raw,
311 .write_raw = afe4403_write_raw, 311 .write_raw = afe4403_write_raw,
312 .driver_module = THIS_MODULE,
313}; 312};
314 313
315static irqreturn_t afe4403_trigger_handler(int irq, void *private) 314static irqreturn_t afe4403_trigger_handler(int irq, void *private)
@@ -354,7 +353,6 @@ err:
354} 353}
355 354
356static const struct iio_trigger_ops afe4403_trigger_ops = { 355static const struct iio_trigger_ops afe4403_trigger_ops = {
357 .owner = THIS_MODULE,
358}; 356};
359 357
360#define AFE4403_TIMING_PAIRS \ 358#define AFE4403_TIMING_PAIRS \
diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
index 964f5231a831..11910922e655 100644
--- a/drivers/iio/health/afe4404.c
+++ b/drivers/iio/health/afe4404.c
@@ -328,7 +328,6 @@ static const struct iio_info afe4404_iio_info = {
328 .attrs = &afe440x_attribute_group, 328 .attrs = &afe440x_attribute_group,
329 .read_raw = afe4404_read_raw, 329 .read_raw = afe4404_read_raw,
330 .write_raw = afe4404_write_raw, 330 .write_raw = afe4404_write_raw,
331 .driver_module = THIS_MODULE,
332}; 331};
333 332
334static irqreturn_t afe4404_trigger_handler(int irq, void *private) 333static irqreturn_t afe4404_trigger_handler(int irq, void *private)
@@ -355,7 +354,6 @@ err:
355} 354}
356 355
357static const struct iio_trigger_ops afe4404_trigger_ops = { 356static const struct iio_trigger_ops afe4404_trigger_ops = {
358 .owner = THIS_MODULE,
359}; 357};
360 358
361/* Default timings from data-sheet */ 359/* Default timings from data-sheet */
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 849d71747f9f..91aef5df24a1 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -420,7 +420,6 @@ static int max30100_read_raw(struct iio_dev *indio_dev,
420} 420}
421 421
422static const struct iio_info max30100_info = { 422static const struct iio_info max30100_info = {
423 .driver_module = THIS_MODULE,
424 .read_raw = max30100_read_raw, 423 .read_raw = max30100_read_raw,
425}; 424};
426 425
diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
index 839b875c29b9..203ffb9cad6a 100644
--- a/drivers/iio/health/max30102.c
+++ b/drivers/iio/health/max30102.c
@@ -381,7 +381,6 @@ static int max30102_read_raw(struct iio_dev *indio_dev,
381} 381}
382 382
383static const struct iio_info max30102_info = { 383static const struct iio_info max30102_info = {
384 .driver_module = THIS_MODULE,
385 .read_raw = max30102_read_raw, 384 .read_raw = max30102_read_raw,
386}; 385};
387 386
diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
index ff96b6d0fdae..7d8669dc6547 100644
--- a/drivers/iio/humidity/am2315.c
+++ b/drivers/iio/humidity/am2315.c
@@ -215,7 +215,6 @@ static int am2315_read_raw(struct iio_dev *indio_dev,
215} 215}
216 216
217static const struct iio_info am2315_info = { 217static const struct iio_info am2315_info = {
218 .driver_module = THIS_MODULE,
219 .read_raw = am2315_read_raw, 218 .read_raw = am2315_read_raw,
220}; 219};
221 220
diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c
index 2a22ad920333..df6bab40d6fa 100644
--- a/drivers/iio/humidity/dht11.c
+++ b/drivers/iio/humidity/dht11.c
@@ -284,7 +284,6 @@ err:
284} 284}
285 285
286static const struct iio_info dht11_iio_info = { 286static const struct iio_info dht11_iio_info = {
287 .driver_module = THIS_MODULE,
288 .read_raw = dht11_read_raw, 287 .read_raw = dht11_read_raw,
289}; 288};
290 289
diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index 7851bd90ef64..d8438310b6d4 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -357,7 +357,6 @@ static const struct iio_info hdc100x_info = {
357 .read_raw = hdc100x_read_raw, 357 .read_raw = hdc100x_read_raw,
358 .write_raw = hdc100x_write_raw, 358 .write_raw = hdc100x_write_raw,
359 .attrs = &hdc100x_attribute_group, 359 .attrs = &hdc100x_attribute_group,
360 .driver_module = THIS_MODULE,
361}; 360};
362 361
363static int hdc100x_probe(struct i2c_client *client, 362static int hdc100x_probe(struct i2c_client *client,
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index 6e09c1acfe51..beab6d6fd6e1 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -125,7 +125,6 @@ static int humidity_write_raw(struct iio_dev *indio_dev,
125} 125}
126 126
127static const struct iio_info humidity_info = { 127static const struct iio_info humidity_info = {
128 .driver_module = THIS_MODULE,
129 .read_raw = &humidity_read_raw, 128 .read_raw = &humidity_read_raw,
130 .write_raw = &humidity_write_raw, 129 .write_raw = &humidity_write_raw,
131}; 130};
diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index 9690dfe9a844..e971ea425268 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -47,7 +47,6 @@ static int hts221_trig_set_state(struct iio_trigger *trig, bool state)
47} 47}
48 48
49static const struct iio_trigger_ops hts221_trigger_ops = { 49static const struct iio_trigger_ops hts221_trigger_ops = {
50 .owner = THIS_MODULE,
51 .set_trigger_state = hts221_trig_set_state, 50 .set_trigger_state = hts221_trig_set_state,
52}; 51};
53 52
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 32524a8dc66f..daef177219b6 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -573,7 +573,6 @@ static const struct attribute_group hts221_attribute_group = {
573}; 573};
574 574
575static const struct iio_info hts221_info = { 575static const struct iio_info hts221_info = {
576 .driver_module = THIS_MODULE,
577 .attrs = &hts221_attribute_group, 576 .attrs = &hts221_attribute_group,
578 .read_raw = hts221_read_raw, 577 .read_raw = hts221_read_raw,
579 .write_raw = hts221_write_raw, 578 .write_raw = hts221_write_raw,
diff --git a/drivers/iio/humidity/htu21.c b/drivers/iio/humidity/htu21.c
index 2c4b9be85a05..f5a2701ba6dd 100644
--- a/drivers/iio/humidity/htu21.c
+++ b/drivers/iio/humidity/htu21.c
@@ -175,7 +175,6 @@ static const struct iio_info htu21_info = {
175 .read_raw = htu21_read_raw, 175 .read_raw = htu21_read_raw,
176 .write_raw = htu21_write_raw, 176 .write_raw = htu21_write_raw,
177 .attrs = &htu21_attribute_group, 177 .attrs = &htu21_attribute_group,
178 .driver_module = THIS_MODULE,
179}; 178};
180 179
181static int htu21_probe(struct i2c_client *client, 180static int htu21_probe(struct i2c_client *client,
diff --git a/drivers/iio/humidity/si7005.c b/drivers/iio/humidity/si7005.c
index 6297766e93d0..1fd19f035a5d 100644
--- a/drivers/iio/humidity/si7005.c
+++ b/drivers/iio/humidity/si7005.c
@@ -124,7 +124,6 @@ static const struct iio_chan_spec si7005_channels[] = {
124 124
125static const struct iio_info si7005_info = { 125static const struct iio_info si7005_info = {
126 .read_raw = si7005_read_raw, 126 .read_raw = si7005_read_raw,
127 .driver_module = THIS_MODULE,
128}; 127};
129 128
130static int si7005_probe(struct i2c_client *client, 129static int si7005_probe(struct i2c_client *client,
diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c
index 345a7656c5ef..1b2ec8df1a72 100644
--- a/drivers/iio/humidity/si7020.c
+++ b/drivers/iio/humidity/si7020.c
@@ -108,7 +108,6 @@ static const struct iio_chan_spec si7020_channels[] = {
108 108
109static const struct iio_info si7020_info = { 109static const struct iio_info si7020_info = {
110 .read_raw = si7020_read_raw, 110 .read_raw = si7020_read_raw,
111 .driver_module = THIS_MODULE,
112}; 111};
113 112
114static int si7020_probe(struct i2c_client *client, 113static int si7020_probe(struct i2c_client *client,
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index 9b697d35dbef..46a569005a13 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -833,7 +833,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
833}; 833};
834 834
835static const struct iio_info adis16400_info = { 835static const struct iio_info adis16400_info = {
836 .driver_module = THIS_MODULE,
837 .read_raw = &adis16400_read_raw, 836 .read_raw = &adis16400_read_raw,
838 .write_raw = &adis16400_write_raw, 837 .write_raw = &adis16400_write_raw,
839 .update_scan_mode = adis16400_update_scan_mode, 838 .update_scan_mode = adis16400_update_scan_mode,
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 12898424d838..7a33d6bd60e0 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -720,7 +720,6 @@ static const struct iio_info adis16480_info = {
720 .read_raw = &adis16480_read_raw, 720 .read_raw = &adis16480_read_raw,
721 .write_raw = &adis16480_write_raw, 721 .write_raw = &adis16480_write_raw,
722 .update_scan_mode = adis_update_scan_mode, 722 .update_scan_mode = adis_update_scan_mode,
723 .driver_module = THIS_MODULE,
724}; 723};
725 724
726static int adis16480_stop_device(struct iio_dev *indio_dev) 725static int adis16480_stop_device(struct iio_dev *indio_dev)
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
index f53e9a803a0e..0dd5a381be64 100644
--- a/drivers/iio/imu/adis_trigger.c
+++ b/drivers/iio/imu/adis_trigger.c
@@ -25,7 +25,6 @@ static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig,
25} 25}
26 26
27static const struct iio_trigger_ops adis_trigger_ops = { 27static const struct iio_trigger_ops adis_trigger_ops = {
28 .owner = THIS_MODULE,
29 .set_trigger_state = &adis_data_rdy_trigger_set_state, 28 .set_trigger_state = &adis_data_rdy_trigger_set_state,
30}; 29};
31 30
diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index cfd225ed1c8d..c85659ca9507 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -482,7 +482,6 @@ static const struct attribute_group bmi160_attrs_group = {
482}; 482};
483 483
484static const struct iio_info bmi160_info = { 484static const struct iio_info bmi160_info = {
485 .driver_module = THIS_MODULE,
486 .read_raw = bmi160_read_raw, 485 .read_raw = bmi160_read_raw,
487 .write_raw = bmi160_write_raw, 486 .write_raw = bmi160_write_raw,
488 .attrs = &bmi160_attrs_group, 487 .attrs = &bmi160_attrs_group,
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 44830bce13df..7d64be353403 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -542,7 +542,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
542 break; 542 break;
543 default: 543 default:
544 result = -EINVAL; 544 result = -EINVAL;
545 break;
545 } 546 }
547 break;
546 default: 548 default:
547 result = -EINVAL; 549 result = -EINVAL;
548 break; 550 break;
@@ -570,10 +572,12 @@ error_write_raw_unlock:
570 */ 572 */
571static int inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate) 573static int inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate)
572{ 574{
573 const int hz[] = {188, 98, 42, 20, 10, 5}; 575 static const int hz[] = {188, 98, 42, 20, 10, 5};
574 const int d[] = {INV_MPU6050_FILTER_188HZ, INV_MPU6050_FILTER_98HZ, 576 static const int d[] = {
575 INV_MPU6050_FILTER_42HZ, INV_MPU6050_FILTER_20HZ, 577 INV_MPU6050_FILTER_188HZ, INV_MPU6050_FILTER_98HZ,
576 INV_MPU6050_FILTER_10HZ, INV_MPU6050_FILTER_5HZ}; 578 INV_MPU6050_FILTER_42HZ, INV_MPU6050_FILTER_20HZ,
579 INV_MPU6050_FILTER_10HZ, INV_MPU6050_FILTER_5HZ
580 };
577 int i, h, result; 581 int i, h, result;
578 u8 data; 582 u8 data;
579 583
@@ -795,7 +799,6 @@ static const struct attribute_group inv_attribute_group = {
795}; 799};
796 800
797static const struct iio_info mpu_info = { 801static const struct iio_info mpu_info = {
798 .driver_module = THIS_MODULE,
799 .read_raw = &inv_mpu6050_read_raw, 802 .read_raw = &inv_mpu6050_read_raw,
800 .write_raw = &inv_mpu6050_write_raw, 803 .write_raw = &inv_mpu6050_write_raw,
801 .write_raw_get_fmt = &inv_write_raw_get_fmt, 804 .write_raw_get_fmt = &inv_write_raw_get_fmt,
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
index 540070f0a230..f963f9fc98c0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
@@ -114,7 +114,6 @@ static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig,
114} 114}
115 115
116static const struct iio_trigger_ops inv_mpu_trigger_ops = { 116static const struct iio_trigger_ops inv_mpu_trigger_ops = {
117 .owner = THIS_MODULE,
118 .set_trigger_state = &inv_mpu_data_rdy_trigger_set_state, 117 .set_trigger_state = &inv_mpu_data_rdy_trigger_set_state,
119}; 118};
120 119
diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index 2e7dd5754a56..44b3f5397343 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -1003,7 +1003,6 @@ static int kmx61_mag_validate_trigger(struct iio_dev *indio_dev,
1003} 1003}
1004 1004
1005static const struct iio_info kmx61_acc_info = { 1005static const struct iio_info kmx61_acc_info = {
1006 .driver_module = THIS_MODULE,
1007 .read_raw = kmx61_read_raw, 1006 .read_raw = kmx61_read_raw,
1008 .write_raw = kmx61_write_raw, 1007 .write_raw = kmx61_write_raw,
1009 .attrs = &kmx61_acc_attribute_group, 1008 .attrs = &kmx61_acc_attribute_group,
@@ -1015,7 +1014,6 @@ static const struct iio_info kmx61_acc_info = {
1015}; 1014};
1016 1015
1017static const struct iio_info kmx61_mag_info = { 1016static const struct iio_info kmx61_mag_info = {
1018 .driver_module = THIS_MODULE,
1019 .read_raw = kmx61_read_raw, 1017 .read_raw = kmx61_read_raw,
1020 .write_raw = kmx61_write_raw, 1018 .write_raw = kmx61_write_raw,
1021 .attrs = &kmx61_mag_attribute_group, 1019 .attrs = &kmx61_mag_attribute_group,
@@ -1087,7 +1085,6 @@ static int kmx61_trig_try_reenable(struct iio_trigger *trig)
1087static const struct iio_trigger_ops kmx61_trigger_ops = { 1085static const struct iio_trigger_ops kmx61_trigger_ops = {
1088 .set_trigger_state = kmx61_data_rdy_trigger_set_state, 1086 .set_trigger_state = kmx61_data_rdy_trigger_set_state,
1089 .try_reenable = kmx61_trig_try_reenable, 1087 .try_reenable = kmx61_trig_try_reenable,
1090 .owner = THIS_MODULE,
1091}; 1088};
1092 1089
1093static irqreturn_t kmx61_event_handler(int irq, void *private) 1090static irqreturn_t kmx61_event_handler(int irq, void *private)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 46352c7bff43..4fdb7fcc3ea8 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -29,8 +29,6 @@ enum st_lsm6dsx_hw_id {
29 29
30#define ST_LSM6DSX_CHAN_SIZE 2 30#define ST_LSM6DSX_CHAN_SIZE 2
31#define ST_LSM6DSX_SAMPLE_SIZE 6 31#define ST_LSM6DSX_SAMPLE_SIZE 6
32#define ST_LSM6DSX_SAMPLE_DEPTH (ST_LSM6DSX_SAMPLE_SIZE / \
33 ST_LSM6DSX_CHAN_SIZE)
34 32
35#if defined(CONFIG_SPI_MASTER) 33#if defined(CONFIG_SPI_MASTER)
36#define ST_LSM6DSX_RX_MAX_LENGTH 256 34#define ST_LSM6DSX_RX_MAX_LENGTH 256
@@ -52,10 +50,38 @@ struct st_lsm6dsx_reg {
52 u8 mask; 50 u8 mask;
53}; 51};
54 52
53/**
54 * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings
55 * @fifo_th: FIFO threshold register info (addr + mask).
56 * @fifo_diff: FIFO diff status register info (addr + mask).
57 * @th_wl: FIFO threshold word length.
58 */
59struct st_lsm6dsx_fifo_ops {
60 struct {
61 u8 addr;
62 u16 mask;
63 } fifo_th;
64 struct {
65 u8 addr;
66 u16 mask;
67 } fifo_diff;
68 u8 th_wl;
69};
70
71/**
72 * struct st_lsm6dsx_settings - ST IMU sensor settings
73 * @wai: Sensor WhoAmI default value.
74 * @max_fifo_size: Sensor max fifo length in FIFO words.
75 * @id: List of hw id supported by the driver configuration.
76 * @decimator: List of decimator register info (addr + mask).
77 * @fifo_ops: Sensor hw FIFO parameters.
78 */
55struct st_lsm6dsx_settings { 79struct st_lsm6dsx_settings {
56 u8 wai; 80 u8 wai;
57 u16 max_fifo_size; 81 u16 max_fifo_size;
58 enum st_lsm6dsx_hw_id id[ST_LSM6DSX_MAX_ID]; 82 enum st_lsm6dsx_hw_id id[ST_LSM6DSX_MAX_ID];
83 struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
84 struct st_lsm6dsx_fifo_ops fifo_ops;
59}; 85};
60 86
61enum st_lsm6dsx_sensor_id { 87enum st_lsm6dsx_sensor_id {
@@ -79,7 +105,6 @@ enum st_lsm6dsx_fifo_mode {
79 * @watermark: Sensor watermark level. 105 * @watermark: Sensor watermark level.
80 * @sip: Number of samples in a given pattern. 106 * @sip: Number of samples in a given pattern.
81 * @decimator: FIFO decimation factor. 107 * @decimator: FIFO decimation factor.
82 * @decimator_mask: Sensor mask for decimation register.
83 * @delta_ts: Delta time between two consecutive interrupts. 108 * @delta_ts: Delta time between two consecutive interrupts.
84 * @ts: Latest timestamp from the interrupt handler. 109 * @ts: Latest timestamp from the interrupt handler.
85 */ 110 */
@@ -94,7 +119,6 @@ struct st_lsm6dsx_sensor {
94 u16 watermark; 119 u16 watermark;
95 u8 sip; 120 u8 sip;
96 u8 decimator; 121 u8 decimator;
97 u8 decimator_mask;
98 122
99 s64 delta_ts; 123 s64 delta_ts;
100 s64 ts; 124 s64 ts;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index e2737dc71b67..755c472e8a05 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -35,10 +35,6 @@
35 35
36#include "st_lsm6dsx.h" 36#include "st_lsm6dsx.h"
37 37
38#define ST_LSM6DSX_REG_FIFO_THL_ADDR 0x06
39#define ST_LSM6DSX_REG_FIFO_THH_ADDR 0x07
40#define ST_LSM6DSX_FIFO_TH_MASK GENMASK(11, 0)
41#define ST_LSM6DSX_REG_FIFO_DEC_GXL_ADDR 0x08
42#define ST_LSM6DSX_REG_HLACTIVE_ADDR 0x12 38#define ST_LSM6DSX_REG_HLACTIVE_ADDR 0x12
43#define ST_LSM6DSX_REG_HLACTIVE_MASK BIT(5) 39#define ST_LSM6DSX_REG_HLACTIVE_MASK BIT(5)
44#define ST_LSM6DSX_REG_PP_OD_ADDR 0x12 40#define ST_LSM6DSX_REG_PP_OD_ADDR 0x12
@@ -46,8 +42,6 @@
46#define ST_LSM6DSX_REG_FIFO_MODE_ADDR 0x0a 42#define ST_LSM6DSX_REG_FIFO_MODE_ADDR 0x0a
47#define ST_LSM6DSX_FIFO_MODE_MASK GENMASK(2, 0) 43#define ST_LSM6DSX_FIFO_MODE_MASK GENMASK(2, 0)
48#define ST_LSM6DSX_FIFO_ODR_MASK GENMASK(6, 3) 44#define ST_LSM6DSX_FIFO_ODR_MASK GENMASK(6, 3)
49#define ST_LSM6DSX_REG_FIFO_DIFFL_ADDR 0x3a
50#define ST_LSM6DSX_FIFO_DIFF_MASK GENMASK(11, 0)
51#define ST_LSM6DSX_FIFO_EMPTY_MASK BIT(12) 45#define ST_LSM6DSX_FIFO_EMPTY_MASK BIT(12)
52#define ST_LSM6DSX_REG_FIFO_OUTL_ADDR 0x3e 46#define ST_LSM6DSX_REG_FIFO_OUTL_ADDR 0x3e
53 47
@@ -110,8 +104,9 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
110 st_lsm6dsx_get_max_min_odr(hw, &max_odr, &min_odr); 104 st_lsm6dsx_get_max_min_odr(hw, &max_odr, &min_odr);
111 105
112 for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { 106 for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
113 sensor = iio_priv(hw->iio_devs[i]); 107 const struct st_lsm6dsx_reg *dec_reg;
114 108
109 sensor = iio_priv(hw->iio_devs[i]);
115 /* update fifo decimators and sample in pattern */ 110 /* update fifo decimators and sample in pattern */
116 if (hw->enable_mask & BIT(sensor->id)) { 111 if (hw->enable_mask & BIT(sensor->id)) {
117 sensor->sip = sensor->odr / min_odr; 112 sensor->sip = sensor->odr / min_odr;
@@ -123,12 +118,13 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
123 data = 0; 118 data = 0;
124 } 119 }
125 120
126 err = st_lsm6dsx_write_with_mask(hw, 121 dec_reg = &hw->settings->decimator[sensor->id];
127 ST_LSM6DSX_REG_FIFO_DEC_GXL_ADDR, 122 if (dec_reg->addr) {
128 sensor->decimator_mask, data); 123 err = st_lsm6dsx_write_with_mask(hw, dec_reg->addr,
129 if (err < 0) 124 dec_reg->mask, data);
130 return err; 125 if (err < 0)
131 126 return err;
127 }
132 sip += sensor->sip; 128 sip += sensor->sip;
133 } 129 }
134 hw->sip = sip; 130 hw->sip = sip;
@@ -139,23 +135,10 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
139int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, 135int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
140 enum st_lsm6dsx_fifo_mode fifo_mode) 136 enum st_lsm6dsx_fifo_mode fifo_mode)
141{ 137{
142 u8 data;
143 int err; 138 int err;
144 139
145 switch (fifo_mode) { 140 err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_FIFO_MODE_ADDR,
146 case ST_LSM6DSX_FIFO_BYPASS: 141 ST_LSM6DSX_FIFO_MODE_MASK, fifo_mode);
147 data = fifo_mode;
148 break;
149 case ST_LSM6DSX_FIFO_CONT:
150 data = (ST_LSM6DSX_MAX_FIFO_ODR_VAL <<
151 __ffs(ST_LSM6DSX_FIFO_ODR_MASK)) | fifo_mode;
152 break;
153 default:
154 return -EINVAL;
155 }
156
157 err = hw->tf->write(hw->dev, ST_LSM6DSX_REG_FIFO_MODE_ADDR,
158 sizeof(data), &data);
159 if (err < 0) 142 if (err < 0)
160 return err; 143 return err;
161 144
@@ -164,9 +147,20 @@ int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
164 return 0; 147 return 0;
165} 148}
166 149
150static int st_lsm6dsx_set_fifo_odr(struct st_lsm6dsx_sensor *sensor,
151 bool enable)
152{
153 struct st_lsm6dsx_hw *hw = sensor->hw;
154 u8 data;
155
156 data = hw->enable_mask ? ST_LSM6DSX_MAX_FIFO_ODR_VAL : 0;
157 return st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_FIFO_MODE_ADDR,
158 ST_LSM6DSX_FIFO_ODR_MASK, data);
159}
160
167int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) 161int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark)
168{ 162{
169 u16 fifo_watermark = ~0, cur_watermark, sip = 0; 163 u16 fifo_watermark = ~0, cur_watermark, sip = 0, fifo_th_mask;
170 struct st_lsm6dsx_hw *hw = sensor->hw; 164 struct st_lsm6dsx_hw *hw = sensor->hw;
171 struct st_lsm6dsx_sensor *cur_sensor; 165 struct st_lsm6dsx_sensor *cur_sensor;
172 __le16 wdata; 166 __le16 wdata;
@@ -191,20 +185,21 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark)
191 185
192 fifo_watermark = max_t(u16, fifo_watermark, sip); 186 fifo_watermark = max_t(u16, fifo_watermark, sip);
193 fifo_watermark = (fifo_watermark / sip) * sip; 187 fifo_watermark = (fifo_watermark / sip) * sip;
194 fifo_watermark = fifo_watermark * ST_LSM6DSX_SAMPLE_DEPTH; 188 fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl;
195 189
196 mutex_lock(&hw->lock); 190 mutex_lock(&hw->lock);
197 191
198 err = hw->tf->read(hw->dev, ST_LSM6DSX_REG_FIFO_THH_ADDR, 192 err = hw->tf->read(hw->dev, hw->settings->fifo_ops.fifo_th.addr + 1,
199 sizeof(data), &data); 193 sizeof(data), &data);
200 if (err < 0) 194 if (err < 0)
201 goto out; 195 goto out;
202 196
203 fifo_watermark = ((data << 8) & ~ST_LSM6DSX_FIFO_TH_MASK) | 197 fifo_th_mask = hw->settings->fifo_ops.fifo_th.mask;
204 (fifo_watermark & ST_LSM6DSX_FIFO_TH_MASK); 198 fifo_watermark = ((data << 8) & ~fifo_th_mask) |
199 (fifo_watermark & fifo_th_mask);
205 200
206 wdata = cpu_to_le16(fifo_watermark); 201 wdata = cpu_to_le16(fifo_watermark);
207 err = hw->tf->write(hw->dev, ST_LSM6DSX_REG_FIFO_THL_ADDR, 202 err = hw->tf->write(hw->dev, hw->settings->fifo_ops.fifo_th.addr,
208 sizeof(wdata), (u8 *)&wdata); 203 sizeof(wdata), (u8 *)&wdata);
209out: 204out:
210 mutex_unlock(&hw->lock); 205 mutex_unlock(&hw->lock);
@@ -223,6 +218,7 @@ out:
223static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) 218static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
224{ 219{
225 u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE; 220 u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE;
221 u16 fifo_diff_mask = hw->settings->fifo_ops.fifo_diff.mask;
226 int err, acc_sip, gyro_sip, read_len, samples, offset; 222 int err, acc_sip, gyro_sip, read_len, samples, offset;
227 struct st_lsm6dsx_sensor *acc_sensor, *gyro_sensor; 223 struct st_lsm6dsx_sensor *acc_sensor, *gyro_sensor;
228 s64 acc_ts, acc_delta_ts, gyro_ts, gyro_delta_ts; 224 s64 acc_ts, acc_delta_ts, gyro_ts, gyro_delta_ts;
@@ -230,7 +226,7 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
230 u8 buff[pattern_len]; 226 u8 buff[pattern_len];
231 __le16 fifo_status; 227 __le16 fifo_status;
232 228
233 err = hw->tf->read(hw->dev, ST_LSM6DSX_REG_FIFO_DIFFL_ADDR, 229 err = hw->tf->read(hw->dev, hw->settings->fifo_ops.fifo_diff.addr,
234 sizeof(fifo_status), (u8 *)&fifo_status); 230 sizeof(fifo_status), (u8 *)&fifo_status);
235 if (err < 0) 231 if (err < 0)
236 return err; 232 return err;
@@ -238,7 +234,7 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
238 if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK)) 234 if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK))
239 return 0; 235 return 0;
240 236
241 fifo_len = (le16_to_cpu(fifo_status) & ST_LSM6DSX_FIFO_DIFF_MASK) * 237 fifo_len = (le16_to_cpu(fifo_status) & fifo_diff_mask) *
242 ST_LSM6DSX_CHAN_SIZE; 238 ST_LSM6DSX_CHAN_SIZE;
243 samples = fifo_len / ST_LSM6DSX_SAMPLE_SIZE; 239 samples = fifo_len / ST_LSM6DSX_SAMPLE_SIZE;
244 fifo_len = (fifo_len / pattern_len) * pattern_len; 240 fifo_len = (fifo_len / pattern_len) * pattern_len;
@@ -345,6 +341,10 @@ static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable)
345 return err; 341 return err;
346 } 342 }
347 343
344 err = st_lsm6dsx_set_fifo_odr(sensor, enable);
345 if (err < 0)
346 return err;
347
348 err = st_lsm6dsx_update_decimators(hw); 348 err = st_lsm6dsx_update_decimators(hw);
349 if (err < 0) 349 if (err < 0)
350 return err; 350 return err;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index b485540da89e..239c735242be 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -42,8 +42,6 @@
42 42
43#include "st_lsm6dsx.h" 43#include "st_lsm6dsx.h"
44 44
45#define ST_LSM6DSX_REG_ACC_DEC_MASK GENMASK(2, 0)
46#define ST_LSM6DSX_REG_GYRO_DEC_MASK GENMASK(5, 3)
47#define ST_LSM6DSX_REG_INT1_ADDR 0x0d 45#define ST_LSM6DSX_REG_INT1_ADDR 0x0d
48#define ST_LSM6DSX_REG_INT2_ADDR 0x0e 46#define ST_LSM6DSX_REG_INT2_ADDR 0x0e
49#define ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK BIT(3) 47#define ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK BIT(3)
@@ -54,10 +52,6 @@
54#define ST_LSM6DSX_REG_BDU_MASK BIT(6) 52#define ST_LSM6DSX_REG_BDU_MASK BIT(6)
55#define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13 53#define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13
56#define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5) 54#define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5)
57#define ST_LSM6DSX_REG_ROUNDING_ADDR 0x16
58#define ST_LSM6DSX_REG_ROUNDING_MASK BIT(2)
59#define ST_LSM6DSX_REG_LIR_ADDR 0x58
60#define ST_LSM6DSX_REG_LIR_MASK BIT(0)
61 55
62#define ST_LSM6DSX_REG_ACC_ODR_ADDR 0x10 56#define ST_LSM6DSX_REG_ACC_ODR_ADDR 0x10
63#define ST_LSM6DSX_REG_ACC_ODR_MASK GENMASK(7, 4) 57#define ST_LSM6DSX_REG_ACC_ODR_MASK GENMASK(7, 4)
@@ -160,25 +154,88 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
160static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { 154static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
161 { 155 {
162 .wai = 0x69, 156 .wai = 0x69,
163 .max_fifo_size = 8192, 157 .max_fifo_size = 1365,
164 .id = { 158 .id = {
165 [0] = ST_LSM6DS3_ID, 159 [0] = ST_LSM6DS3_ID,
166 }, 160 },
161 .decimator = {
162 [ST_LSM6DSX_ID_ACC] = {
163 .addr = 0x08,
164 .mask = GENMASK(2, 0),
165 },
166 [ST_LSM6DSX_ID_GYRO] = {
167 .addr = 0x08,
168 .mask = GENMASK(5, 3),
169 },
170 },
171 .fifo_ops = {
172 .fifo_th = {
173 .addr = 0x06,
174 .mask = GENMASK(11, 0),
175 },
176 .fifo_diff = {
177 .addr = 0x3a,
178 .mask = GENMASK(11, 0),
179 },
180 .th_wl = 3, /* 1LSB = 2B */
181 },
167 }, 182 },
168 { 183 {
169 .wai = 0x69, 184 .wai = 0x69,
170 .max_fifo_size = 4096, 185 .max_fifo_size = 682,
171 .id = { 186 .id = {
172 [0] = ST_LSM6DS3H_ID, 187 [0] = ST_LSM6DS3H_ID,
173 }, 188 },
189 .decimator = {
190 [ST_LSM6DSX_ID_ACC] = {
191 .addr = 0x08,
192 .mask = GENMASK(2, 0),
193 },
194 [ST_LSM6DSX_ID_GYRO] = {
195 .addr = 0x08,
196 .mask = GENMASK(5, 3),
197 },
198 },
199 .fifo_ops = {
200 .fifo_th = {
201 .addr = 0x06,
202 .mask = GENMASK(11, 0),
203 },
204 .fifo_diff = {
205 .addr = 0x3a,
206 .mask = GENMASK(11, 0),
207 },
208 .th_wl = 3, /* 1LSB = 2B */
209 },
174 }, 210 },
175 { 211 {
176 .wai = 0x6a, 212 .wai = 0x6a,
177 .max_fifo_size = 4096, 213 .max_fifo_size = 682,
178 .id = { 214 .id = {
179 [0] = ST_LSM6DSL_ID, 215 [0] = ST_LSM6DSL_ID,
180 [1] = ST_LSM6DSM_ID, 216 [1] = ST_LSM6DSM_ID,
181 }, 217 },
218 .decimator = {
219 [ST_LSM6DSX_ID_ACC] = {
220 .addr = 0x08,
221 .mask = GENMASK(2, 0),
222 },
223 [ST_LSM6DSX_ID_GYRO] = {
224 .addr = 0x08,
225 .mask = GENMASK(5, 3),
226 },
227 },
228 .fifo_ops = {
229 .fifo_th = {
230 .addr = 0x06,
231 .mask = GENMASK(11, 0),
232 },
233 .fifo_diff = {
234 .addr = 0x3a,
235 .mask = GENMASK(11, 0),
236 },
237 .th_wl = 3, /* 1LSB = 2B */
238 },
182 }, 239 },
183}; 240};
184 241
@@ -322,7 +379,6 @@ static int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr,
322 return -EINVAL; 379 return -EINVAL;
323 380
324 *val = st_lsm6dsx_odr_table[sensor->id].odr_avl[i].val; 381 *val = st_lsm6dsx_odr_table[sensor->id].odr_avl[i].val;
325 sensor->odr = odr;
326 382
327 return 0; 383 return 0;
328} 384}
@@ -449,6 +505,8 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
449 u8 data; 505 u8 data;
450 506
451 err = st_lsm6dsx_check_odr(sensor, val, &data); 507 err = st_lsm6dsx_check_odr(sensor, val, &data);
508 if (!err)
509 sensor->odr = val;
452 break; 510 break;
453 } 511 }
454 default: 512 default:
@@ -465,10 +523,9 @@ static int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
465{ 523{
466 struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); 524 struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
467 struct st_lsm6dsx_hw *hw = sensor->hw; 525 struct st_lsm6dsx_hw *hw = sensor->hw;
468 int err, max_fifo_len; 526 int err;
469 527
470 max_fifo_len = hw->settings->max_fifo_size / ST_LSM6DSX_SAMPLE_SIZE; 528 if (val < 1 || val > hw->settings->max_fifo_size)
471 if (val < 1 || val > max_fifo_len)
472 return -EINVAL; 529 return -EINVAL;
473 530
474 err = st_lsm6dsx_update_watermark(sensor, val); 531 err = st_lsm6dsx_update_watermark(sensor, val);
@@ -530,7 +587,6 @@ static const struct attribute_group st_lsm6dsx_acc_attribute_group = {
530}; 587};
531 588
532static const struct iio_info st_lsm6dsx_acc_info = { 589static const struct iio_info st_lsm6dsx_acc_info = {
533 .driver_module = THIS_MODULE,
534 .attrs = &st_lsm6dsx_acc_attribute_group, 590 .attrs = &st_lsm6dsx_acc_attribute_group,
535 .read_raw = st_lsm6dsx_read_raw, 591 .read_raw = st_lsm6dsx_read_raw,
536 .write_raw = st_lsm6dsx_write_raw, 592 .write_raw = st_lsm6dsx_write_raw,
@@ -548,7 +604,6 @@ static const struct attribute_group st_lsm6dsx_gyro_attribute_group = {
548}; 604};
549 605
550static const struct iio_info st_lsm6dsx_gyro_info = { 606static const struct iio_info st_lsm6dsx_gyro_info = {
551 .driver_module = THIS_MODULE,
552 .attrs = &st_lsm6dsx_gyro_attribute_group, 607 .attrs = &st_lsm6dsx_gyro_attribute_group,
553 .read_raw = st_lsm6dsx_read_raw, 608 .read_raw = st_lsm6dsx_read_raw,
554 .write_raw = st_lsm6dsx_write_raw, 609 .write_raw = st_lsm6dsx_write_raw,
@@ -608,23 +663,12 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
608 663
609 msleep(200); 664 msleep(200);
610 665
611 /* latch interrupts */
612 err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_LIR_ADDR,
613 ST_LSM6DSX_REG_LIR_MASK, 1);
614 if (err < 0)
615 return err;
616
617 /* enable Block Data Update */ 666 /* enable Block Data Update */
618 err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_BDU_ADDR, 667 err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_BDU_ADDR,
619 ST_LSM6DSX_REG_BDU_MASK, 1); 668 ST_LSM6DSX_REG_BDU_MASK, 1);
620 if (err < 0) 669 if (err < 0)
621 return err; 670 return err;
622 671
623 err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_ROUNDING_ADDR,
624 ST_LSM6DSX_REG_ROUNDING_MASK, 1);
625 if (err < 0)
626 return err;
627
628 /* enable FIFO watermak interrupt */ 672 /* enable FIFO watermak interrupt */
629 err = st_lsm6dsx_get_drdy_reg(hw, &drdy_int_reg); 673 err = st_lsm6dsx_get_drdy_reg(hw, &drdy_int_reg);
630 if (err < 0) 674 if (err < 0)
@@ -662,7 +706,6 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
662 iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_acc_channels); 706 iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_acc_channels);
663 iio_dev->info = &st_lsm6dsx_acc_info; 707 iio_dev->info = &st_lsm6dsx_acc_info;
664 708
665 sensor->decimator_mask = ST_LSM6DSX_REG_ACC_DEC_MASK;
666 scnprintf(sensor->name, sizeof(sensor->name), "%s_accel", 709 scnprintf(sensor->name, sizeof(sensor->name), "%s_accel",
667 name); 710 name);
668 break; 711 break;
@@ -671,7 +714,6 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
671 iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_gyro_channels); 714 iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_gyro_channels);
672 iio_dev->info = &st_lsm6dsx_gyro_info; 715 iio_dev->info = &st_lsm6dsx_gyro_info;
673 716
674 sensor->decimator_mask = ST_LSM6DSX_REG_GYRO_DEC_MASK;
675 scnprintf(sensor->name, sizeof(sensor->name), "%s_gyro", 717 scnprintf(sensor->name, sizeof(sensor->name), "%s_gyro",
676 name); 718 name);
677 break; 719 break;
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a47428b4d31b..9c4cfd19b739 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1662,14 +1662,11 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
1662 1662
1663static const struct iio_buffer_setup_ops noop_ring_setup_ops; 1663static const struct iio_buffer_setup_ops noop_ring_setup_ops;
1664 1664
1665/** 1665int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
1666 * iio_device_register() - register a device with the IIO subsystem
1667 * @indio_dev: Device structure filled by the device driver
1668 **/
1669int iio_device_register(struct iio_dev *indio_dev)
1670{ 1666{
1671 int ret; 1667 int ret;
1672 1668
1669 indio_dev->driver_module = this_mod;
1673 /* If the calling driver did not initialize of_node, do it here */ 1670 /* If the calling driver did not initialize of_node, do it here */
1674 if (!indio_dev->dev.of_node && indio_dev->dev.parent) 1671 if (!indio_dev->dev.of_node && indio_dev->dev.parent)
1675 indio_dev->dev.of_node = indio_dev->dev.parent->of_node; 1672 indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
@@ -1715,7 +1712,8 @@ int iio_device_register(struct iio_dev *indio_dev)
1715 indio_dev->setup_ops = &noop_ring_setup_ops; 1712 indio_dev->setup_ops = &noop_ring_setup_ops;
1716 1713
1717 cdev_init(&indio_dev->chrdev, &iio_buffer_fileops); 1714 cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
1718 indio_dev->chrdev.owner = indio_dev->info->driver_module; 1715
1716 indio_dev->chrdev.owner = this_mod;
1719 1717
1720 ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev); 1718 ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
1721 if (ret < 0) 1719 if (ret < 0)
@@ -1733,7 +1731,7 @@ error_unreg_debugfs:
1733 iio_device_unregister_debugfs(indio_dev); 1731 iio_device_unregister_debugfs(indio_dev);
1734 return ret; 1732 return ret;
1735} 1733}
1736EXPORT_SYMBOL(iio_device_register); 1734EXPORT_SYMBOL(__iio_device_register);
1737 1735
1738/** 1736/**
1739 * iio_device_unregister() - unregister a device from the IIO subsystem 1737 * iio_device_unregister() - unregister a device from the IIO subsystem
@@ -1765,23 +1763,8 @@ static void devm_iio_device_unreg(struct device *dev, void *res)
1765 iio_device_unregister(*(struct iio_dev **)res); 1763 iio_device_unregister(*(struct iio_dev **)res);
1766} 1764}
1767 1765
1768/** 1766int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev,
1769 * devm_iio_device_register - Resource-managed iio_device_register() 1767 struct module *this_mod)
1770 * @dev: Device to allocate iio_dev for
1771 * @indio_dev: Device structure filled by the device driver
1772 *
1773 * Managed iio_device_register. The IIO device registered with this
1774 * function is automatically unregistered on driver detach. This function
1775 * calls iio_device_register() internally. Refer to that function for more
1776 * information.
1777 *
1778 * If an iio_dev registered with this function needs to be unregistered
1779 * separately, devm_iio_device_unregister() must be used.
1780 *
1781 * RETURNS:
1782 * 0 on success, negative error number on failure.
1783 */
1784int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev)
1785{ 1768{
1786 struct iio_dev **ptr; 1769 struct iio_dev **ptr;
1787 int ret; 1770 int ret;
@@ -1791,7 +1774,7 @@ int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev)
1791 return -ENOMEM; 1774 return -ENOMEM;
1792 1775
1793 *ptr = indio_dev; 1776 *ptr = indio_dev;
1794 ret = iio_device_register(indio_dev); 1777 ret = __iio_device_register(indio_dev, this_mod);
1795 if (!ret) 1778 if (!ret)
1796 devres_add(dev, ptr); 1779 devres_add(dev, ptr);
1797 else 1780 else
@@ -1799,7 +1782,7 @@ int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev)
1799 1782
1800 return ret; 1783 return ret;
1801} 1784}
1802EXPORT_SYMBOL_GPL(devm_iio_device_register); 1785EXPORT_SYMBOL_GPL(__devm_iio_device_register);
1803 1786
1804/** 1787/**
1805 * devm_iio_device_unregister - Resource-managed iio_device_unregister() 1788 * devm_iio_device_unregister - Resource-managed iio_device_unregister()
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 4061fed93f1f..ce66699c7fcc 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -66,13 +66,12 @@ ATTRIBUTE_GROUPS(iio_trig_dev);
66 66
67static struct iio_trigger *__iio_trigger_find_by_name(const char *name); 67static struct iio_trigger *__iio_trigger_find_by_name(const char *name);
68 68
69int iio_trigger_register(struct iio_trigger *trig_info) 69int __iio_trigger_register(struct iio_trigger *trig_info,
70 struct module *this_mod)
70{ 71{
71 int ret; 72 int ret;
72 73
73 /* trig_info->ops is required for the module member */ 74 trig_info->owner = this_mod;
74 if (!trig_info->ops)
75 return -EINVAL;
76 75
77 trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); 76 trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
78 if (trig_info->id < 0) 77 if (trig_info->id < 0)
@@ -105,7 +104,7 @@ error_unregister_id:
105 ida_simple_remove(&iio_trigger_ida, trig_info->id); 104 ida_simple_remove(&iio_trigger_ida, trig_info->id);
106 return ret; 105 return ret;
107} 106}
108EXPORT_SYMBOL(iio_trigger_register); 107EXPORT_SYMBOL(__iio_trigger_register);
109 108
110void iio_trigger_unregister(struct iio_trigger *trig_info) 109void iio_trigger_unregister(struct iio_trigger *trig_info)
111{ 110{
@@ -206,7 +205,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained);
206 205
207void iio_trigger_notify_done(struct iio_trigger *trig) 206void iio_trigger_notify_done(struct iio_trigger *trig)
208{ 207{
209 if (atomic_dec_and_test(&trig->use_count) && trig->ops->try_reenable) 208 if (atomic_dec_and_test(&trig->use_count) && trig->ops &&
209 trig->ops->try_reenable)
210 if (trig->ops->try_reenable(trig)) 210 if (trig->ops->try_reenable(trig))
211 /* Missed an interrupt so launch new poll now */ 211 /* Missed an interrupt so launch new poll now */
212 iio_trigger_poll(trig); 212 iio_trigger_poll(trig);
@@ -250,7 +250,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
250 = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 250 = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
251 251
252 /* Prevent the module from being removed whilst attached to a trigger */ 252 /* Prevent the module from being removed whilst attached to a trigger */
253 __module_get(pf->indio_dev->info->driver_module); 253 __module_get(pf->indio_dev->driver_module);
254 254
255 /* Get irq number */ 255 /* Get irq number */
256 pf->irq = iio_trigger_get_irq(trig); 256 pf->irq = iio_trigger_get_irq(trig);
@@ -265,7 +265,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
265 goto out_put_irq; 265 goto out_put_irq;
266 266
267 /* Enable trigger in driver */ 267 /* Enable trigger in driver */
268 if (trig->ops->set_trigger_state && notinuse) { 268 if (trig->ops && trig->ops->set_trigger_state && notinuse) {
269 ret = trig->ops->set_trigger_state(trig, true); 269 ret = trig->ops->set_trigger_state(trig, true);
270 if (ret < 0) 270 if (ret < 0)
271 goto out_free_irq; 271 goto out_free_irq;
@@ -286,7 +286,7 @@ out_free_irq:
286out_put_irq: 286out_put_irq:
287 iio_trigger_put_irq(trig, pf->irq); 287 iio_trigger_put_irq(trig, pf->irq);
288out_put_module: 288out_put_module:
289 module_put(pf->indio_dev->info->driver_module); 289 module_put(pf->indio_dev->driver_module);
290 return ret; 290 return ret;
291} 291}
292 292
@@ -298,7 +298,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
298 = (bitmap_weight(trig->pool, 298 = (bitmap_weight(trig->pool,
299 CONFIG_IIO_CONSUMERS_PER_TRIGGER) 299 CONFIG_IIO_CONSUMERS_PER_TRIGGER)
300 == 1); 300 == 1);
301 if (trig->ops->set_trigger_state && no_other_users) { 301 if (trig->ops && trig->ops->set_trigger_state && no_other_users) {
302 ret = trig->ops->set_trigger_state(trig, false); 302 ret = trig->ops->set_trigger_state(trig, false);
303 if (ret) 303 if (ret)
304 return ret; 304 return ret;
@@ -307,7 +307,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
307 trig->attached_own_device = false; 307 trig->attached_own_device = false;
308 iio_trigger_put_irq(trig, pf->irq); 308 iio_trigger_put_irq(trig, pf->irq);
309 free_irq(pf->irq, pf); 309 free_irq(pf->irq, pf);
310 module_put(pf->indio_dev->info->driver_module); 310 module_put(pf->indio_dev->driver_module);
311 311
312 return ret; 312 return ret;
313} 313}
@@ -428,7 +428,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
428 goto out_trigger_put; 428 goto out_trigger_put;
429 } 429 }
430 430
431 if (trig && trig->ops->validate_device) { 431 if (trig && trig->ops && trig->ops->validate_device) {
432 ret = trig->ops->validate_device(trig, indio_dev); 432 ret = trig->ops->validate_device(trig, indio_dev);
433 if (ret) 433 if (ret)
434 goto out_trigger_put; 434 goto out_trigger_put;
@@ -663,9 +663,10 @@ static void devm_iio_trigger_unreg(struct device *dev, void *res)
663} 663}
664 664
665/** 665/**
666 * devm_iio_trigger_register - Resource-managed iio_trigger_register() 666 * __devm_iio_trigger_register - Resource-managed iio_trigger_register()
667 * @dev: device this trigger was allocated for 667 * @dev: device this trigger was allocated for
668 * @trig_info: trigger to register 668 * @trig_info: trigger to register
669 * @this_mod: module registering the trigger
669 * 670 *
670 * Managed iio_trigger_register(). The IIO trigger registered with this 671 * Managed iio_trigger_register(). The IIO trigger registered with this
671 * function is automatically unregistered on driver detach. This function 672 * function is automatically unregistered on driver detach. This function
@@ -678,7 +679,9 @@ static void devm_iio_trigger_unreg(struct device *dev, void *res)
678 * RETURNS: 679 * RETURNS:
679 * 0 on success, negative error number on failure. 680 * 0 on success, negative error number on failure.
680 */ 681 */
681int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info) 682int __devm_iio_trigger_register(struct device *dev,
683 struct iio_trigger *trig_info,
684 struct module *this_mod)
682{ 685{
683 struct iio_trigger **ptr; 686 struct iio_trigger **ptr;
684 int ret; 687 int ret;
@@ -688,7 +691,7 @@ int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info)
688 return -ENOMEM; 691 return -ENOMEM;
689 692
690 *ptr = trig_info; 693 *ptr = trig_info;
691 ret = iio_trigger_register(trig_info); 694 ret = __iio_trigger_register(trig_info, this_mod);
692 if (!ret) 695 if (!ret)
693 devres_add(dev, ptr); 696 devres_add(dev, ptr);
694 else 697 else
@@ -696,7 +699,7 @@ int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info)
696 699
697 return ret; 700 return ret;
698} 701}
699EXPORT_SYMBOL_GPL(devm_iio_trigger_register); 702EXPORT_SYMBOL_GPL(__devm_iio_trigger_register);
700 703
701/** 704/**
702 * devm_iio_trigger_unregister - Resource-managed iio_trigger_unregister() 705 * devm_iio_trigger_unregister - Resource-managed iio_trigger_unregister()
diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
index f0b47c501f4e..c35e2f8df339 100644
--- a/drivers/iio/light/acpi-als.c
+++ b/drivers/iio/light/acpi-als.c
@@ -171,7 +171,6 @@ static int acpi_als_read_raw(struct iio_dev *indio_dev,
171} 171}
172 172
173static const struct iio_info acpi_als_info = { 173static const struct iio_info acpi_als_info = {
174 .driver_module = THIS_MODULE,
175 .read_raw = acpi_als_read_raw, 174 .read_raw = acpi_als_read_raw,
176}; 175};
177 176
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
index 0113fc843a81..e45bb6a277c2 100644
--- a/drivers/iio/light/adjd_s311.c
+++ b/drivers/iio/light/adjd_s311.c
@@ -245,7 +245,6 @@ static const struct iio_info adjd_s311_info = {
245 .read_raw = adjd_s311_read_raw, 245 .read_raw = adjd_s311_read_raw,
246 .write_raw = adjd_s311_write_raw, 246 .write_raw = adjd_s311_write_raw,
247 .update_scan_mode = adjd_s311_update_scan_mode, 247 .update_scan_mode = adjd_s311_update_scan_mode,
248 .driver_module = THIS_MODULE,
249}; 248};
250 249
251static int adjd_s311_probe(struct i2c_client *client, 250static int adjd_s311_probe(struct i2c_client *client,
diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c
index 6aac6513fd41..66623facea9a 100644
--- a/drivers/iio/light/al3320a.c
+++ b/drivers/iio/light/al3320a.c
@@ -168,7 +168,6 @@ static int al3320a_write_raw(struct iio_dev *indio_dev,
168} 168}
169 169
170static const struct iio_info al3320a_info = { 170static const struct iio_info al3320a_info = {
171 .driver_module = THIS_MODULE,
172 .read_raw = al3320a_read_raw, 171 .read_raw = al3320a_read_raw,
173 .write_raw = al3320a_write_raw, 172 .write_raw = al3320a_write_raw,
174 .attrs = &al3320a_attribute_group, 173 .attrs = &al3320a_attribute_group,
diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c
index 05eacd1ee40f..5c15736fb93e 100644
--- a/drivers/iio/light/apds9300.c
+++ b/drivers/iio/light/apds9300.c
@@ -337,12 +337,10 @@ static int apds9300_write_interrupt_config(struct iio_dev *indio_dev,
337} 337}
338 338
339static const struct iio_info apds9300_info_no_irq = { 339static const struct iio_info apds9300_info_no_irq = {
340 .driver_module = THIS_MODULE,
341 .read_raw = apds9300_read_raw, 340 .read_raw = apds9300_read_raw,
342}; 341};
343 342
344static const struct iio_info apds9300_info = { 343static const struct iio_info apds9300_info = {
345 .driver_module = THIS_MODULE,
346 .read_raw = apds9300_read_raw, 344 .read_raw = apds9300_read_raw,
347 .read_event_value = apds9300_read_thresh, 345 .read_event_value = apds9300_read_thresh,
348 .write_event_value = apds9300_write_thresh, 346 .write_event_value = apds9300_write_thresh,
diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index 518a47e9377b..a8fa00e31c39 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -744,7 +744,6 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,
744} 744}
745 745
746static const struct iio_info apds9960_info = { 746static const struct iio_info apds9960_info = {
747 .driver_module = THIS_MODULE,
748 .attrs = &apds9960_attribute_group, 747 .attrs = &apds9960_attribute_group,
749 .read_raw = apds9960_read_raw, 748 .read_raw = apds9960_read_raw,
750 .write_raw = apds9960_write_raw, 749 .write_raw = apds9960_write_raw,
diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
index 6c61187e630f..a814828e69f5 100644
--- a/drivers/iio/light/bh1750.c
+++ b/drivers/iio/light/bh1750.c
@@ -217,7 +217,6 @@ static const struct attribute_group bh1750_attribute_group = {
217}; 217};
218 218
219static const struct iio_info bh1750_info = { 219static const struct iio_info bh1750_info = {
220 .driver_module = THIS_MODULE,
221 .attrs = &bh1750_attribute_group, 220 .attrs = &bh1750_attribute_group,
222 .read_raw = bh1750_read_raw, 221 .read_raw = bh1750_read_raw,
223 .write_raw = bh1750_write_raw, 222 .write_raw = bh1750_write_raw,
diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
index b54dcba05a82..036f3bbe323c 100644
--- a/drivers/iio/light/bh1780.c
+++ b/drivers/iio/light/bh1780.c
@@ -128,7 +128,6 @@ static int bh1780_read_raw(struct iio_dev *indio_dev,
128} 128}
129 129
130static const struct iio_info bh1780_info = { 130static const struct iio_info bh1780_info = {
131 .driver_module = THIS_MODULE,
132 .read_raw = bh1780_read_raw, 131 .read_raw = bh1780_read_raw,
133 .debugfs_reg_access = bh1780_debugfs_reg_access, 132 .debugfs_reg_access = bh1780_debugfs_reg_access,
134}; 133};
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index d6fd0dace74f..aebf7dd071af 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -292,7 +292,6 @@ static const struct attribute_group cm32181_attribute_group = {
292}; 292};
293 293
294static const struct iio_info cm32181_info = { 294static const struct iio_info cm32181_info = {
295 .driver_module = THIS_MODULE,
296 .read_raw = &cm32181_read_raw, 295 .read_raw = &cm32181_read_raw,
297 .write_raw = &cm32181_write_raw, 296 .write_raw = &cm32181_write_raw,
298 .attrs = &cm32181_attribute_group, 297 .attrs = &cm32181_attribute_group,
diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index 263e97235ea0..c639cf276ee6 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -322,7 +322,6 @@ static const struct attribute_group cm3232_attribute_group = {
322}; 322};
323 323
324static const struct iio_info cm3232_info = { 324static const struct iio_info cm3232_info = {
325 .driver_module = THIS_MODULE,
326 .read_raw = &cm3232_read_raw, 325 .read_raw = &cm3232_read_raw,
327 .write_raw = &cm3232_write_raw, 326 .write_raw = &cm3232_write_raw,
328 .attrs = &cm3232_attribute_group, 327 .attrs = &cm3232_attribute_group,
diff --git a/drivers/iio/light/cm3323.c b/drivers/iio/light/cm3323.c
index d823c112d54b..83b08b6dc60f 100644
--- a/drivers/iio/light/cm3323.c
+++ b/drivers/iio/light/cm3323.c
@@ -211,7 +211,6 @@ static int cm3323_write_raw(struct iio_dev *indio_dev,
211} 211}
212 212
213static const struct iio_info cm3323_info = { 213static const struct iio_info cm3323_info = {
214 .driver_module = THIS_MODULE,
215 .read_raw = cm3323_read_raw, 214 .read_raw = cm3323_read_raw,
216 .write_raw = cm3323_write_raw, 215 .write_raw = cm3323_write_raw,
217 .attrs = &cm3323_attribute_group, 216 .attrs = &cm3323_attribute_group,
diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c
index 980624e9ffb5..e454bc6a33c6 100644
--- a/drivers/iio/light/cm3605.c
+++ b/drivers/iio/light/cm3605.c
@@ -126,7 +126,6 @@ static int cm3605_read_raw(struct iio_dev *indio_dev,
126} 126}
127 127
128static const struct iio_info cm3605_info = { 128static const struct iio_info cm3605_info = {
129 .driver_module = THIS_MODULE,
130 .read_raw = cm3605_read_raw, 129 .read_raw = cm3605_read_raw,
131}; 130};
132 131
diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c
index 9d66e89c57ef..1dd8ed0121b3 100644
--- a/drivers/iio/light/cm36651.c
+++ b/drivers/iio/light/cm36651.c
@@ -612,7 +612,6 @@ static const struct attribute_group cm36651_attribute_group = {
612}; 612};
613 613
614static const struct iio_info cm36651_info = { 614static const struct iio_info cm36651_info = {
615 .driver_module = THIS_MODULE,
616 .read_raw = &cm36651_read_raw, 615 .read_raw = &cm36651_read_raw,
617 .write_raw = &cm36651_write_raw, 616 .write_raw = &cm36651_write_raw,
618 .read_event_value = &cm36651_read_prox_thresh, 617 .read_event_value = &cm36651_read_prox_thresh,
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 721722376fd0..b2a46b390d5c 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -175,7 +175,6 @@ static int cros_ec_light_prox_write(struct iio_dev *indio_dev,
175static const struct iio_info cros_ec_light_prox_info = { 175static const struct iio_info cros_ec_light_prox_info = {
176 .read_raw = &cros_ec_light_prox_read, 176 .read_raw = &cros_ec_light_prox_read,
177 .write_raw = &cros_ec_light_prox_write, 177 .write_raw = &cros_ec_light_prox_write,
178 .driver_module = THIS_MODULE,
179}; 178};
180 179
181static int cros_ec_light_prox_probe(struct platform_device *pdev) 180static int cros_ec_light_prox_probe(struct platform_device *pdev)
diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
index 6ada9149f142..44b13fbcd093 100644
--- a/drivers/iio/light/gp2ap020a00f.c
+++ b/drivers/iio/light/gp2ap020a00f.c
@@ -1384,7 +1384,6 @@ static const struct iio_info gp2ap020a00f_info = {
1384 .read_event_config = &gp2ap020a00f_read_event_config, 1384 .read_event_config = &gp2ap020a00f_read_event_config,
1385 .write_event_value = &gp2ap020a00f_write_event_val, 1385 .write_event_value = &gp2ap020a00f_write_event_val,
1386 .write_event_config = &gp2ap020a00f_write_event_config, 1386 .write_event_config = &gp2ap020a00f_write_event_config,
1387 .driver_module = THIS_MODULE,
1388}; 1387};
1389 1388
1390static int gp2ap020a00f_buffer_postenable(struct iio_dev *indio_dev) 1389static int gp2ap020a00f_buffer_postenable(struct iio_dev *indio_dev)
@@ -1481,7 +1480,6 @@ static const struct iio_buffer_setup_ops gp2ap020a00f_buffer_setup_ops = {
1481}; 1480};
1482 1481
1483static const struct iio_trigger_ops gp2ap020a00f_trigger_ops = { 1482static const struct iio_trigger_ops gp2ap020a00f_trigger_ops = {
1484 .owner = THIS_MODULE,
1485}; 1483};
1486 1484
1487static int gp2ap020a00f_probe(struct i2c_client *client, 1485static int gp2ap020a00f_probe(struct i2c_client *client,
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 059d964772c7..befd693a4a31 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -177,7 +177,6 @@ static int als_write_raw(struct iio_dev *indio_dev,
177} 177}
178 178
179static const struct iio_info als_info = { 179static const struct iio_info als_info = {
180 .driver_module = THIS_MODULE,
181 .read_raw = &als_read_raw, 180 .read_raw = &als_read_raw,
182 .write_raw = &als_write_raw, 181 .write_raw = &als_write_raw,
183}; 182};
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index 73fced8a63b7..45107f7537b5 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -156,7 +156,6 @@ static int prox_write_raw(struct iio_dev *indio_dev,
156} 156}
157 157
158static const struct iio_info prox_info = { 158static const struct iio_info prox_info = {
159 .driver_module = THIS_MODULE,
160 .read_raw = &prox_read_raw, 159 .read_raw = &prox_read_raw,
161 .write_raw = &prox_write_raw, 160 .write_raw = &prox_write_raw,
162}; 161};
diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index 61f5924b472d..b45400f8fef4 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -624,14 +624,12 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
624 624
625static const struct iio_info isl29018_info = { 625static const struct iio_info isl29018_info = {
626 .attrs = &isl29018_group, 626 .attrs = &isl29018_group,
627 .driver_module = THIS_MODULE,
628 .read_raw = isl29018_read_raw, 627 .read_raw = isl29018_read_raw,
629 .write_raw = isl29018_write_raw, 628 .write_raw = isl29018_write_raw,
630}; 629};
631 630
632static const struct iio_info isl29023_info = { 631static const struct iio_info isl29023_info = {
633 .attrs = &isl29023_group, 632 .attrs = &isl29023_group,
634 .driver_module = THIS_MODULE,
635 .read_raw = isl29018_read_raw, 633 .read_raw = isl29018_read_raw,
636 .write_raw = isl29018_write_raw, 634 .write_raw = isl29018_write_raw,
637}; 635};
diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c
index 3d09c1fc4dad..f9912ab4f65c 100644
--- a/drivers/iio/light/isl29028.c
+++ b/drivers/iio/light/isl29028.c
@@ -536,7 +536,6 @@ static const struct iio_chan_spec isl29028_channels[] = {
536 536
537static const struct iio_info isl29028_info = { 537static const struct iio_info isl29028_info = {
538 .attrs = &isl29108_group, 538 .attrs = &isl29108_group,
539 .driver_module = THIS_MODULE,
540 .read_raw = isl29028_read_raw, 539 .read_raw = isl29028_read_raw,
541 .write_raw = isl29028_write_raw, 540 .write_raw = isl29028_write_raw,
542}; 541};
diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index 1d2c0c8a1d4f..ed38edcd5efe 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -214,7 +214,6 @@ static const struct iio_info isl29125_info = {
214 .read_raw = isl29125_read_raw, 214 .read_raw = isl29125_read_raw,
215 .write_raw = isl29125_write_raw, 215 .write_raw = isl29125_write_raw,
216 .attrs = &isl29125_attribute_group, 216 .attrs = &isl29125_attribute_group,
217 .driver_module = THIS_MODULE,
218}; 217};
219 218
220static int isl29125_buffer_preenable(struct iio_dev *indio_dev) 219static int isl29125_buffer_preenable(struct iio_dev *indio_dev)
diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c
index e8a8931b4f50..811505d925b3 100644
--- a/drivers/iio/light/jsa1212.c
+++ b/drivers/iio/light/jsa1212.c
@@ -271,7 +271,6 @@ static const struct iio_chan_spec jsa1212_channels[] = {
271}; 271};
272 272
273static const struct iio_info jsa1212_info = { 273static const struct iio_info jsa1212_info = {
274 .driver_module = THIS_MODULE,
275 .read_raw = &jsa1212_read_raw, 274 .read_raw = &jsa1212_read_raw,
276}; 275};
277 276
diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
index 0443fd2e8757..36208a3652e9 100644
--- a/drivers/iio/light/lm3533-als.c
+++ b/drivers/iio/light/lm3533-als.c
@@ -827,7 +827,6 @@ static int lm3533_als_disable(struct lm3533_als *als)
827static const struct iio_info lm3533_als_info = { 827static const struct iio_info lm3533_als_info = {
828 .attrs = &lm3533_als_attribute_group, 828 .attrs = &lm3533_als_attribute_group,
829 .event_attrs = &lm3533_als_event_attribute_group, 829 .event_attrs = &lm3533_als_event_attribute_group,
830 .driver_module = THIS_MODULE,
831 .read_raw = &lm3533_als_read_raw, 830 .read_raw = &lm3533_als_read_raw,
832}; 831};
833 832
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 67838edd8b37..830a2d45aa4d 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -1158,7 +1158,6 @@ static const struct iio_info ltr501_info_no_irq = {
1158 .read_raw = ltr501_read_raw, 1158 .read_raw = ltr501_read_raw,
1159 .write_raw = ltr501_write_raw, 1159 .write_raw = ltr501_write_raw,
1160 .attrs = &ltr501_attribute_group, 1160 .attrs = &ltr501_attribute_group,
1161 .driver_module = THIS_MODULE,
1162}; 1161};
1163 1162
1164static const struct iio_info ltr501_info = { 1163static const struct iio_info ltr501_info = {
@@ -1169,14 +1168,12 @@ static const struct iio_info ltr501_info = {
1169 .write_event_value = &ltr501_write_event, 1168 .write_event_value = &ltr501_write_event,
1170 .read_event_config = &ltr501_read_event_config, 1169 .read_event_config = &ltr501_read_event_config,
1171 .write_event_config = &ltr501_write_event_config, 1170 .write_event_config = &ltr501_write_event_config,
1172 .driver_module = THIS_MODULE,
1173}; 1171};
1174 1172
1175static const struct iio_info ltr301_info_no_irq = { 1173static const struct iio_info ltr301_info_no_irq = {
1176 .read_raw = ltr501_read_raw, 1174 .read_raw = ltr501_read_raw,
1177 .write_raw = ltr501_write_raw, 1175 .write_raw = ltr501_write_raw,
1178 .attrs = &ltr301_attribute_group, 1176 .attrs = &ltr301_attribute_group,
1179 .driver_module = THIS_MODULE,
1180}; 1177};
1181 1178
1182static const struct iio_info ltr301_info = { 1179static const struct iio_info ltr301_info = {
@@ -1187,7 +1184,6 @@ static const struct iio_info ltr301_info = {
1187 .write_event_value = &ltr501_write_event, 1184 .write_event_value = &ltr501_write_event,
1188 .read_event_config = &ltr501_read_event_config, 1185 .read_event_config = &ltr501_read_event_config,
1189 .write_event_config = &ltr501_write_event_config, 1186 .write_event_config = &ltr501_write_event_config,
1190 .driver_module = THIS_MODULE,
1191}; 1187};
1192 1188
1193static struct ltr501_chip_info ltr501_chip_info_tbl[] = { 1189static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index 81bd8e8da4a6..bcdb0eb9e537 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -402,7 +402,6 @@ static const struct attribute_group max44000_attribute_group = {
402}; 402};
403 403
404static const struct iio_info max44000_info = { 404static const struct iio_info max44000_info = {
405 .driver_module = THIS_MODULE,
406 .read_raw = max44000_read_raw, 405 .read_raw = max44000_read_raw,
407 .write_raw = max44000_write_raw, 406 .write_raw = max44000_write_raw,
408 .write_raw_get_fmt = max44000_write_raw_get_fmt, 407 .write_raw_get_fmt = max44000_write_raw_get_fmt,
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index b91ebc3483ce..54d88b60e303 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -585,7 +585,6 @@ err:
585} 585}
586 586
587static const struct iio_info opt3001_info = { 587static const struct iio_info opt3001_info = {
588 .driver_module = THIS_MODULE,
589 .attrs = &opt3001_attribute_group, 588 .attrs = &opt3001_attribute_group,
590 .read_raw = opt3001_read_raw, 589 .read_raw = opt3001_read_raw,
591 .write_raw = opt3001_write_raw, 590 .write_raw = opt3001_write_raw,
diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
index 76a9e12b46bc..30ea1a088dd9 100644
--- a/drivers/iio/light/pa12203001.c
+++ b/drivers/iio/light/pa12203001.c
@@ -306,7 +306,6 @@ static int pa12203001_write_raw(struct iio_dev *indio_dev,
306} 306}
307 307
308static const struct iio_info pa12203001_info = { 308static const struct iio_info pa12203001_info = {
309 .driver_module = THIS_MODULE,
310 .read_raw = pa12203001_read_raw, 309 .read_raw = pa12203001_read_raw,
311 .write_raw = pa12203001_write_raw, 310 .write_raw = pa12203001_write_raw,
312 .attrs = &pa12203001_attr_group, 311 .attrs = &pa12203001_attr_group,
diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
index a6efa12613a2..ffe9ce798ea2 100644
--- a/drivers/iio/light/rpr0521.c
+++ b/drivers/iio/light/rpr0521.c
@@ -538,7 +538,6 @@ static int rpr0521_pxs_drdy_set_state(struct iio_trigger *trigger,
538 538
539static const struct iio_trigger_ops rpr0521_trigger_ops = { 539static const struct iio_trigger_ops rpr0521_trigger_ops = {
540 .set_trigger_state = rpr0521_pxs_drdy_set_state, 540 .set_trigger_state = rpr0521_pxs_drdy_set_state,
541 .owner = THIS_MODULE,
542 }; 541 };
543 542
544 543
@@ -830,7 +829,6 @@ static int rpr0521_write_raw(struct iio_dev *indio_dev,
830} 829}
831 830
832static const struct iio_info rpr0521_info = { 831static const struct iio_info rpr0521_info = {
833 .driver_module = THIS_MODULE,
834 .read_raw = rpr0521_read_raw, 832 .read_raw = rpr0521_read_raw,
835 .write_raw = rpr0521_write_raw, 833 .write_raw = rpr0521_write_raw,
836 .attrs = &rpr0521_attribute_group, 834 .attrs = &rpr0521_attribute_group,
diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
index 096034c126a4..76f16f9c7616 100644
--- a/drivers/iio/light/si1145.c
+++ b/drivers/iio/light/si1145.c
@@ -989,14 +989,12 @@ static const struct attribute_group si114x_attribute_group = {
989static const struct iio_info si1132_info = { 989static const struct iio_info si1132_info = {
990 .read_raw = si1145_read_raw, 990 .read_raw = si1145_read_raw,
991 .write_raw = si1145_write_raw, 991 .write_raw = si1145_write_raw,
992 .driver_module = THIS_MODULE,
993 .attrs = &si1132_attribute_group, 992 .attrs = &si1132_attribute_group,
994}; 993};
995 994
996static const struct iio_info si114x_info = { 995static const struct iio_info si114x_info = {
997 .read_raw = si1145_read_raw, 996 .read_raw = si1145_read_raw,
998 .write_raw = si1145_write_raw, 997 .write_raw = si1145_write_raw,
999 .driver_module = THIS_MODULE,
1000 .attrs = &si114x_attribute_group, 998 .attrs = &si114x_attribute_group,
1001}; 999};
1002 1000
@@ -1237,7 +1235,6 @@ disable:
1237} 1235}
1238 1236
1239static const struct iio_trigger_ops si1145_trigger_ops = { 1237static const struct iio_trigger_ops si1145_trigger_ops = {
1240 .owner = THIS_MODULE,
1241 .set_trigger_state = si1145_trigger_set_state, 1238 .set_trigger_state = si1145_trigger_set_state,
1242}; 1239};
1243 1240
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 45cf8b0a4363..6e2a169da950 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -409,7 +409,6 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
409} 409}
410 410
411static const struct iio_info stk3310_info = { 411static const struct iio_info stk3310_info = {
412 .driver_module = THIS_MODULE,
413 .read_raw = stk3310_read_raw, 412 .read_raw = stk3310_read_raw,
414 .write_raw = stk3310_write_raw, 413 .write_raw = stk3310_write_raw,
415 .attrs = &stk3310_attribute_group, 414 .attrs = &stk3310_attribute_group,
diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
index a795afb7667b..205e5659ce6b 100644
--- a/drivers/iio/light/tcs3414.c
+++ b/drivers/iio/light/tcs3414.c
@@ -241,7 +241,6 @@ static const struct iio_info tcs3414_info = {
241 .read_raw = tcs3414_read_raw, 241 .read_raw = tcs3414_read_raw,
242 .write_raw = tcs3414_write_raw, 242 .write_raw = tcs3414_write_raw,
243 .attrs = &tcs3414_attribute_group, 243 .attrs = &tcs3414_attribute_group,
244 .driver_module = THIS_MODULE,
245}; 244};
246 245
247static int tcs3414_buffer_preenable(struct iio_dev *indio_dev) 246static int tcs3414_buffer_preenable(struct iio_dev *indio_dev)
diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index 09e6ca5e332e..e7923b514d7a 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -13,7 +13,7 @@
13 * 13 *
14 * Datasheet: http://ams.com/eng/content/download/319364/1117183/file/TCS3472_Datasheet_EN_v2.pdf 14 * Datasheet: http://ams.com/eng/content/download/319364/1117183/file/TCS3472_Datasheet_EN_v2.pdf
15 * 15 *
16 * TODO: interrupt support, thresholds, wait time 16 * TODO: wait time
17 */ 17 */
18 18
19#include <linux/module.h> 19#include <linux/module.h>
@@ -23,6 +23,7 @@
23 23
24#include <linux/iio/iio.h> 24#include <linux/iio/iio.h>
25#include <linux/iio/sysfs.h> 25#include <linux/iio/sysfs.h>
26#include <linux/iio/events.h>
26#include <linux/iio/trigger_consumer.h> 27#include <linux/iio/trigger_consumer.h>
27#include <linux/iio/buffer.h> 28#include <linux/iio/buffer.h>
28#include <linux/iio/triggered_buffer.h> 29#include <linux/iio/triggered_buffer.h>
@@ -31,12 +32,15 @@
31 32
32#define TCS3472_COMMAND BIT(7) 33#define TCS3472_COMMAND BIT(7)
33#define TCS3472_AUTO_INCR BIT(5) 34#define TCS3472_AUTO_INCR BIT(5)
35#define TCS3472_SPECIAL_FUNC (BIT(5) | BIT(6))
36
37#define TCS3472_INTR_CLEAR (TCS3472_COMMAND | TCS3472_SPECIAL_FUNC | 0x06)
34 38
35#define TCS3472_ENABLE (TCS3472_COMMAND | 0x00) 39#define TCS3472_ENABLE (TCS3472_COMMAND | 0x00)
36#define TCS3472_ATIME (TCS3472_COMMAND | 0x01) 40#define TCS3472_ATIME (TCS3472_COMMAND | 0x01)
37#define TCS3472_WTIME (TCS3472_COMMAND | 0x03) 41#define TCS3472_WTIME (TCS3472_COMMAND | 0x03)
38#define TCS3472_AILT (TCS3472_COMMAND | 0x04) 42#define TCS3472_AILT (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x04)
39#define TCS3472_AIHT (TCS3472_COMMAND | 0x06) 43#define TCS3472_AIHT (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x06)
40#define TCS3472_PERS (TCS3472_COMMAND | 0x0c) 44#define TCS3472_PERS (TCS3472_COMMAND | 0x0c)
41#define TCS3472_CONFIG (TCS3472_COMMAND | 0x0d) 45#define TCS3472_CONFIG (TCS3472_COMMAND | 0x0d)
42#define TCS3472_CONTROL (TCS3472_COMMAND | 0x0f) 46#define TCS3472_CONTROL (TCS3472_COMMAND | 0x0f)
@@ -47,19 +51,42 @@
47#define TCS3472_GDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x18) 51#define TCS3472_GDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x18)
48#define TCS3472_BDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x1a) 52#define TCS3472_BDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x1a)
49 53
54#define TCS3472_STATUS_AINT BIT(4)
50#define TCS3472_STATUS_AVALID BIT(0) 55#define TCS3472_STATUS_AVALID BIT(0)
56#define TCS3472_ENABLE_AIEN BIT(4)
51#define TCS3472_ENABLE_AEN BIT(1) 57#define TCS3472_ENABLE_AEN BIT(1)
52#define TCS3472_ENABLE_PON BIT(0) 58#define TCS3472_ENABLE_PON BIT(0)
53#define TCS3472_CONTROL_AGAIN_MASK (BIT(0) | BIT(1)) 59#define TCS3472_CONTROL_AGAIN_MASK (BIT(0) | BIT(1))
54 60
55struct tcs3472_data { 61struct tcs3472_data {
56 struct i2c_client *client; 62 struct i2c_client *client;
63 struct mutex lock;
64 u16 low_thresh;
65 u16 high_thresh;
57 u8 enable; 66 u8 enable;
58 u8 control; 67 u8 control;
59 u8 atime; 68 u8 atime;
69 u8 apers;
60 u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */ 70 u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */
61}; 71};
62 72
73static const struct iio_event_spec tcs3472_events[] = {
74 {
75 .type = IIO_EV_TYPE_THRESH,
76 .dir = IIO_EV_DIR_RISING,
77 .mask_separate = BIT(IIO_EV_INFO_VALUE),
78 }, {
79 .type = IIO_EV_TYPE_THRESH,
80 .dir = IIO_EV_DIR_FALLING,
81 .mask_separate = BIT(IIO_EV_INFO_VALUE),
82 }, {
83 .type = IIO_EV_TYPE_THRESH,
84 .dir = IIO_EV_DIR_EITHER,
85 .mask_separate = BIT(IIO_EV_INFO_ENABLE) |
86 BIT(IIO_EV_INFO_PERIOD),
87 },
88};
89
63#define TCS3472_CHANNEL(_color, _si, _addr) { \ 90#define TCS3472_CHANNEL(_color, _si, _addr) { \
64 .type = IIO_INTENSITY, \ 91 .type = IIO_INTENSITY, \
65 .modified = 1, \ 92 .modified = 1, \
@@ -75,6 +102,8 @@ struct tcs3472_data {
75 .storagebits = 16, \ 102 .storagebits = 16, \
76 .endianness = IIO_CPU, \ 103 .endianness = IIO_CPU, \
77 }, \ 104 }, \
105 .event_spec = _si ? NULL : tcs3472_events, \
106 .num_event_specs = _si ? 0 : ARRAY_SIZE(tcs3472_events), \
78} 107}
79 108
80static const int tcs3472_agains[] = { 1, 4, 16, 60 }; 109static const int tcs3472_agains[] = { 1, 4, 16, 60 };
@@ -182,6 +211,166 @@ static int tcs3472_write_raw(struct iio_dev *indio_dev,
182 return -EINVAL; 211 return -EINVAL;
183} 212}
184 213
214/*
215 * Translation from APERS field value to the number of consecutive out-of-range
216 * clear channel values before an interrupt is generated
217 */
218static const int tcs3472_intr_pers[] = {
219 0, 1, 2, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
220};
221
222static int tcs3472_read_event(struct iio_dev *indio_dev,
223 const struct iio_chan_spec *chan, enum iio_event_type type,
224 enum iio_event_direction dir, enum iio_event_info info, int *val,
225 int *val2)
226{
227 struct tcs3472_data *data = iio_priv(indio_dev);
228 int ret;
229 unsigned int period;
230
231 mutex_lock(&data->lock);
232
233 switch (info) {
234 case IIO_EV_INFO_VALUE:
235 *val = (dir == IIO_EV_DIR_RISING) ?
236 data->high_thresh : data->low_thresh;
237 ret = IIO_VAL_INT;
238 break;
239 case IIO_EV_INFO_PERIOD:
240 period = (256 - data->atime) * 2400 *
241 tcs3472_intr_pers[data->apers];
242 *val = period / USEC_PER_SEC;
243 *val2 = period % USEC_PER_SEC;
244 ret = IIO_VAL_INT_PLUS_MICRO;
245 break;
246 default:
247 ret = -EINVAL;
248 break;
249 }
250
251 mutex_unlock(&data->lock);
252
253 return ret;
254}
255
256static int tcs3472_write_event(struct iio_dev *indio_dev,
257 const struct iio_chan_spec *chan, enum iio_event_type type,
258 enum iio_event_direction dir, enum iio_event_info info, int val,
259 int val2)
260{
261 struct tcs3472_data *data = iio_priv(indio_dev);
262 int ret;
263 u8 command;
264 int period;
265 int i;
266
267 mutex_lock(&data->lock);
268 switch (info) {
269 case IIO_EV_INFO_VALUE:
270 switch (dir) {
271 case IIO_EV_DIR_RISING:
272 command = TCS3472_AIHT;
273 break;
274 case IIO_EV_DIR_FALLING:
275 command = TCS3472_AILT;
276 break;
277 default:
278 ret = -EINVAL;
279 goto error;
280 }
281 ret = i2c_smbus_write_word_data(data->client, command, val);
282 if (ret)
283 goto error;
284
285 if (dir == IIO_EV_DIR_RISING)
286 data->high_thresh = val;
287 else
288 data->low_thresh = val;
289 break;
290 case IIO_EV_INFO_PERIOD:
291 period = val * USEC_PER_SEC + val2;
292 for (i = 1; i < ARRAY_SIZE(tcs3472_intr_pers) - 1; i++) {
293 if (period <= (256 - data->atime) * 2400 *
294 tcs3472_intr_pers[i])
295 break;
296 }
297 ret = i2c_smbus_write_byte_data(data->client, TCS3472_PERS, i);
298 if (ret)
299 goto error;
300
301 data->apers = i;
302 break;
303 default:
304 ret = -EINVAL;
305 break;
306 }
307error:
308 mutex_unlock(&data->lock);
309
310 return ret;
311}
312
313static int tcs3472_read_event_config(struct iio_dev *indio_dev,
314 const struct iio_chan_spec *chan, enum iio_event_type type,
315 enum iio_event_direction dir)
316{
317 struct tcs3472_data *data = iio_priv(indio_dev);
318 int ret;
319
320 mutex_lock(&data->lock);
321 ret = !!(data->enable & TCS3472_ENABLE_AIEN);
322 mutex_unlock(&data->lock);
323
324 return ret;
325}
326
327static int tcs3472_write_event_config(struct iio_dev *indio_dev,
328 const struct iio_chan_spec *chan, enum iio_event_type type,
329 enum iio_event_direction dir, int state)
330{
331 struct tcs3472_data *data = iio_priv(indio_dev);
332 int ret = 0;
333 u8 enable_old;
334
335 mutex_lock(&data->lock);
336
337 enable_old = data->enable;
338
339 if (state)
340 data->enable |= TCS3472_ENABLE_AIEN;
341 else
342 data->enable &= ~TCS3472_ENABLE_AIEN;
343
344 if (enable_old != data->enable) {
345 ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
346 data->enable);
347 if (ret)
348 data->enable = enable_old;
349 }
350 mutex_unlock(&data->lock);
351
352 return ret;
353}
354
355static irqreturn_t tcs3472_event_handler(int irq, void *priv)
356{
357 struct iio_dev *indio_dev = priv;
358 struct tcs3472_data *data = iio_priv(indio_dev);
359 int ret;
360
361 ret = i2c_smbus_read_byte_data(data->client, TCS3472_STATUS);
362 if (ret >= 0 && (ret & TCS3472_STATUS_AINT)) {
363 iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0,
364 IIO_EV_TYPE_THRESH,
365 IIO_EV_DIR_EITHER),
366 iio_get_time_ns(indio_dev));
367
368 i2c_smbus_read_byte_data(data->client, TCS3472_INTR_CLEAR);
369 }
370
371 return IRQ_HANDLED;
372}
373
185static irqreturn_t tcs3472_trigger_handler(int irq, void *p) 374static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
186{ 375{
187 struct iio_poll_func *pf = p; 376 struct iio_poll_func *pf = p;
@@ -245,8 +434,11 @@ static const struct attribute_group tcs3472_attribute_group = {
245static const struct iio_info tcs3472_info = { 434static const struct iio_info tcs3472_info = {
246 .read_raw = tcs3472_read_raw, 435 .read_raw = tcs3472_read_raw,
247 .write_raw = tcs3472_write_raw, 436 .write_raw = tcs3472_write_raw,
437 .read_event_value = tcs3472_read_event,
438 .write_event_value = tcs3472_write_event,
439 .read_event_config = tcs3472_read_event_config,
440 .write_event_config = tcs3472_write_event_config,
248 .attrs = &tcs3472_attribute_group, 441 .attrs = &tcs3472_attribute_group,
249 .driver_module = THIS_MODULE,
250}; 442};
251 443
252static int tcs3472_probe(struct i2c_client *client, 444static int tcs3472_probe(struct i2c_client *client,
@@ -263,6 +455,7 @@ static int tcs3472_probe(struct i2c_client *client,
263 data = iio_priv(indio_dev); 455 data = iio_priv(indio_dev);
264 i2c_set_clientdata(client, indio_dev); 456 i2c_set_clientdata(client, indio_dev);
265 data->client = client; 457 data->client = client;
458 mutex_init(&data->lock);
266 459
267 indio_dev->dev.parent = &client->dev; 460 indio_dev->dev.parent = &client->dev;
268 indio_dev->info = &tcs3472_info; 461 indio_dev->info = &tcs3472_info;
@@ -292,12 +485,29 @@ static int tcs3472_probe(struct i2c_client *client,
292 return ret; 485 return ret;
293 data->atime = ret; 486 data->atime = ret;
294 487
488 ret = i2c_smbus_read_word_data(data->client, TCS3472_AILT);
489 if (ret < 0)
490 return ret;
491 data->low_thresh = ret;
492
493 ret = i2c_smbus_read_word_data(data->client, TCS3472_AIHT);
494 if (ret < 0)
495 return ret;
496 data->high_thresh = ret;
497
498 data->apers = 1;
499 ret = i2c_smbus_write_byte_data(data->client, TCS3472_PERS,
500 data->apers);
501 if (ret < 0)
502 return ret;
503
295 ret = i2c_smbus_read_byte_data(data->client, TCS3472_ENABLE); 504 ret = i2c_smbus_read_byte_data(data->client, TCS3472_ENABLE);
296 if (ret < 0) 505 if (ret < 0)
297 return ret; 506 return ret;
298 507
299 /* enable device */ 508 /* enable device */
300 data->enable = ret | TCS3472_ENABLE_PON | TCS3472_ENABLE_AEN; 509 data->enable = ret | TCS3472_ENABLE_PON | TCS3472_ENABLE_AEN;
510 data->enable &= ~TCS3472_ENABLE_AIEN;
301 ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, 511 ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
302 data->enable); 512 data->enable);
303 if (ret < 0) 513 if (ret < 0)
@@ -308,12 +518,24 @@ static int tcs3472_probe(struct i2c_client *client,
308 if (ret < 0) 518 if (ret < 0)
309 return ret; 519 return ret;
310 520
521 if (client->irq) {
522 ret = request_threaded_irq(client->irq, NULL,
523 tcs3472_event_handler,
524 IRQF_TRIGGER_FALLING | IRQF_SHARED |
525 IRQF_ONESHOT,
526 client->name, indio_dev);
527 if (ret)
528 goto buffer_cleanup;
529 }
530
311 ret = iio_device_register(indio_dev); 531 ret = iio_device_register(indio_dev);
312 if (ret < 0) 532 if (ret < 0)
313 goto buffer_cleanup; 533 goto free_irq;
314 534
315 return 0; 535 return 0;
316 536
537free_irq:
538 free_irq(client->irq, indio_dev);
317buffer_cleanup: 539buffer_cleanup:
318 iio_triggered_buffer_cleanup(indio_dev); 540 iio_triggered_buffer_cleanup(indio_dev);
319 return ret; 541 return ret;
@@ -321,8 +543,19 @@ buffer_cleanup:
321 543
322static int tcs3472_powerdown(struct tcs3472_data *data) 544static int tcs3472_powerdown(struct tcs3472_data *data)
323{ 545{
324 return i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, 546 int ret;
325 data->enable & ~(TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON)); 547 u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON;
548
549 mutex_lock(&data->lock);
550
551 ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
552 data->enable & ~enable_mask);
553 if (!ret)
554 data->enable &= ~enable_mask;
555
556 mutex_unlock(&data->lock);
557
558 return ret;
326} 559}
327 560
328static int tcs3472_remove(struct i2c_client *client) 561static int tcs3472_remove(struct i2c_client *client)
@@ -330,6 +563,7 @@ static int tcs3472_remove(struct i2c_client *client)
330 struct iio_dev *indio_dev = i2c_get_clientdata(client); 563 struct iio_dev *indio_dev = i2c_get_clientdata(client);
331 564
332 iio_device_unregister(indio_dev); 565 iio_device_unregister(indio_dev);
566 free_irq(client->irq, indio_dev);
333 iio_triggered_buffer_cleanup(indio_dev); 567 iio_triggered_buffer_cleanup(indio_dev);
334 tcs3472_powerdown(iio_priv(indio_dev)); 568 tcs3472_powerdown(iio_priv(indio_dev));
335 569
@@ -348,8 +582,19 @@ static int tcs3472_resume(struct device *dev)
348{ 582{
349 struct tcs3472_data *data = iio_priv(i2c_get_clientdata( 583 struct tcs3472_data *data = iio_priv(i2c_get_clientdata(
350 to_i2c_client(dev))); 584 to_i2c_client(dev)));
351 return i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, 585 int ret;
352 data->enable | (TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON)); 586 u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON;
587
588 mutex_lock(&data->lock);
589
590 ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
591 data->enable | enable_mask);
592 if (!ret)
593 data->enable |= enable_mask;
594
595 mutex_unlock(&data->lock);
596
597 return ret;
353} 598}
354#endif 599#endif
355 600
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 7599693f7fe9..6bbb0b1e6032 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -697,13 +697,11 @@ static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev,
697} 697}
698 698
699static const struct iio_info tsl2563_info_no_irq = { 699static const struct iio_info tsl2563_info_no_irq = {
700 .driver_module = THIS_MODULE,
701 .read_raw = &tsl2563_read_raw, 700 .read_raw = &tsl2563_read_raw,
702 .write_raw = &tsl2563_write_raw, 701 .write_raw = &tsl2563_write_raw,
703}; 702};
704 703
705static const struct iio_info tsl2563_info = { 704static const struct iio_info tsl2563_info = {
706 .driver_module = THIS_MODULE,
707 .read_raw = &tsl2563_read_raw, 705 .read_raw = &tsl2563_read_raw,
708 .write_raw = &tsl2563_write_raw, 706 .write_raw = &tsl2563_write_raw,
709 .read_event_value = &tsl2563_read_thresh, 707 .read_event_value = &tsl2563_read_thresh,
diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
index fb711ed4862e..f2e50edaa242 100644
--- a/drivers/iio/light/tsl2583.c
+++ b/drivers/iio/light/tsl2583.c
@@ -804,7 +804,6 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
804 804
805static const struct iio_info tsl2583_info = { 805static const struct iio_info tsl2583_info = {
806 .attrs = &tsl2583_attribute_group, 806 .attrs = &tsl2583_attribute_group,
807 .driver_module = THIS_MODULE,
808 .read_raw = tsl2583_read_raw, 807 .read_raw = tsl2583_read_raw,
809 .write_raw = tsl2583_write_raw, 808 .write_raw = tsl2583_write_raw,
810}; 809};
diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
index cf94ec72b181..06171cb76e23 100644
--- a/drivers/iio/light/tsl4531.c
+++ b/drivers/iio/light/tsl4531.c
@@ -144,7 +144,6 @@ static const struct iio_info tsl4531_info = {
144 .read_raw = tsl4531_read_raw, 144 .read_raw = tsl4531_read_raw,
145 .write_raw = tsl4531_write_raw, 145 .write_raw = tsl4531_write_raw,
146 .attrs = &tsl4531_attribute_group, 146 .attrs = &tsl4531_attribute_group,
147 .driver_module = THIS_MODULE,
148}; 147};
149 148
150static int tsl4531_check_id(struct i2c_client *client) 149static int tsl4531_check_id(struct i2c_client *client)
diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index d571ad7291ed..68e52943879a 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -714,7 +714,6 @@ err:
714} 714}
715 715
716static const struct iio_info us5182d_info = { 716static const struct iio_info us5182d_info = {
717 .driver_module = THIS_MODULE,
718 .read_raw = us5182d_read_raw, 717 .read_raw = us5182d_read_raw,
719 .write_raw = us5182d_write_raw, 718 .write_raw = us5182d_write_raw,
720 .attrs = &us5182d_attr_group, 719 .attrs = &us5182d_attr_group,
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 360b6e98137a..c599a90506ad 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -155,7 +155,6 @@ static int vcnl4000_read_raw(struct iio_dev *indio_dev,
155 155
156static const struct iio_info vcnl4000_info = { 156static const struct iio_info vcnl4000_info = {
157 .read_raw = vcnl4000_read_raw, 157 .read_raw = vcnl4000_read_raw,
158 .driver_module = THIS_MODULE,
159}; 158};
160 159
161static int vcnl4000_probe(struct i2c_client *client, 160static int vcnl4000_probe(struct i2c_client *client,
diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index bc1c4cb782cd..f4bf3c5b5eda 100644
--- a/drivers/iio/light/veml6070.c
+++ b/drivers/iio/light/veml6070.c
@@ -136,7 +136,6 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
136 136
137static const struct iio_info veml6070_info = { 137static const struct iio_info veml6070_info = {
138 .read_raw = veml6070_read_raw, 138 .read_raw = veml6070_read_raw,
139 .driver_module = THIS_MODULE,
140}; 139};
141 140
142static int veml6070_probe(struct i2c_client *client, 141static int veml6070_probe(struct i2c_client *client,
diff --git a/drivers/iio/light/vl6180.c b/drivers/iio/light/vl6180.c
index 6e25b724d941..192c77ef3608 100644
--- a/drivers/iio/light/vl6180.c
+++ b/drivers/iio/light/vl6180.c
@@ -24,6 +24,7 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/of.h> 25#include <linux/of.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/util_macros.h>
27 28
28#include <linux/iio/iio.h> 29#include <linux/iio/iio.h>
29#include <linux/iio/sysfs.h> 30#include <linux/iio/sysfs.h>
@@ -86,6 +87,8 @@
86struct vl6180_data { 87struct vl6180_data {
87 struct i2c_client *client; 88 struct i2c_client *client;
88 struct mutex lock; 89 struct mutex lock;
90 unsigned int als_gain_milli;
91 unsigned int als_it_ms;
89}; 92};
90 93
91enum { VL6180_ALS, VL6180_RANGE, VL6180_PROX }; 94enum { VL6180_ALS, VL6180_RANGE, VL6180_PROX };
@@ -275,19 +278,17 @@ static const struct iio_chan_spec vl6180_channels[] = {
275}; 278};
276 279
277/* 280/*
278 * Columns 3 & 4 represent the same value in decimal and hex notations. 281 * Available Ambient Light Sensor gain settings, 1/1000th, and
279 * Kept in order to avoid the datatype conversion while reading the 282 * corresponding setting for the VL6180_ALS_GAIN register
280 * hardware_gain.
281 */ 283 */
282static const int vl6180_als_gain[8][4] = { 284static const int vl6180_als_gain_tab[8] = {
283 { 1, 0, 70, VL6180_ALS_GAIN_1 }, 285 1000, 1250, 1670, 2500, 5000, 10000, 20000, 40000
284 { 1, 250000, 69, VL6180_ALS_GAIN_1_25 }, 286};
285 { 1, 670000, 68, VL6180_ALS_GAIN_1_67 }, 287static const u8 vl6180_als_gain_tab_bits[8] = {
286 { 2, 500000, 67, VL6180_ALS_GAIN_2_5 }, 288 VL6180_ALS_GAIN_1, VL6180_ALS_GAIN_1_25,
287 { 5, 0, 66, VL6180_ALS_GAIN_5 }, 289 VL6180_ALS_GAIN_1_67, VL6180_ALS_GAIN_2_5,
288 { 10, 0, 65, VL6180_ALS_GAIN_10 }, 290 VL6180_ALS_GAIN_5, VL6180_ALS_GAIN_10,
289 { 20, 0, 64, VL6180_ALS_GAIN_20 }, 291 VL6180_ALS_GAIN_20, VL6180_ALS_GAIN_40
290 { 40, 0, 71, VL6180_ALS_GAIN_40 }
291}; 292};
292 293
293static int vl6180_read_raw(struct iio_dev *indio_dev, 294static int vl6180_read_raw(struct iio_dev *indio_dev,
@@ -295,7 +296,7 @@ static int vl6180_read_raw(struct iio_dev *indio_dev,
295 int *val, int *val2, long mask) 296 int *val, int *val2, long mask)
296{ 297{
297 struct vl6180_data *data = iio_priv(indio_dev); 298 struct vl6180_data *data = iio_priv(indio_dev);
298 int ret, i; 299 int ret;
299 300
300 switch (mask) { 301 switch (mask) {
301 case IIO_CHAN_INFO_RAW: 302 case IIO_CHAN_INFO_RAW:
@@ -306,19 +307,20 @@ static int vl6180_read_raw(struct iio_dev *indio_dev,
306 307
307 return IIO_VAL_INT; 308 return IIO_VAL_INT;
308 case IIO_CHAN_INFO_INT_TIME: 309 case IIO_CHAN_INFO_INT_TIME:
309 ret = vl6180_read_word(data->client, VL6180_ALS_IT); 310 *val = data->als_it_ms;
310 if (ret < 0) 311 *val2 = 1000;
311 return ret; 312
312 *val = 0; /* 1 count = 1ms (0 = 1ms) */ 313 return IIO_VAL_FRACTIONAL;
313 *val2 = (ret + 1) * 1000; /* convert to seconds */
314 314
315 return IIO_VAL_INT_PLUS_MICRO;
316 case IIO_CHAN_INFO_SCALE: 315 case IIO_CHAN_INFO_SCALE:
317 switch (chan->type) { 316 switch (chan->type) {
318 case IIO_LIGHT: 317 case IIO_LIGHT:
319 *val = 0; /* one ALS count is 0.32 Lux */ 318 /* one ALS count is 0.32 Lux @ gain 1, IT 100 ms */
320 *val2 = 320000; 319 *val = 32000; /* 0.32 * 1000 * 100 */
321 break; 320 *val2 = data->als_gain_milli * data->als_it_ms;
321
322 return IIO_VAL_FRACTIONAL;
323
322 case IIO_DISTANCE: 324 case IIO_DISTANCE:
323 *val = 0; /* sensor reports mm, scale to meter */ 325 *val = 0; /* sensor reports mm, scale to meter */
324 *val2 = 1000; 326 *val2 = 1000;
@@ -329,17 +331,11 @@ static int vl6180_read_raw(struct iio_dev *indio_dev,
329 331
330 return IIO_VAL_INT_PLUS_MICRO; 332 return IIO_VAL_INT_PLUS_MICRO;
331 case IIO_CHAN_INFO_HARDWAREGAIN: 333 case IIO_CHAN_INFO_HARDWAREGAIN:
332 ret = vl6180_read_byte(data->client, VL6180_ALS_GAIN); 334 *val = data->als_gain_milli;
333 if (ret < 0) 335 *val2 = 1000;
334 return -EINVAL; 336
335 for (i = 0; i < ARRAY_SIZE(vl6180_als_gain); i++) { 337 return IIO_VAL_FRACTIONAL;
336 if (ret == vl6180_als_gain[i][2]) {
337 *val = vl6180_als_gain[i][0];
338 *val2 = vl6180_als_gain[i][1];
339 }
340 }
341 338
342 return IIO_VAL_INT_PLUS_MICRO;
343 default: 339 default:
344 return -EINVAL; 340 return -EINVAL;
345 } 341 }
@@ -365,37 +361,53 @@ static int vl6180_hold(struct vl6180_data *data, bool hold)
365 361
366static int vl6180_set_als_gain(struct vl6180_data *data, int val, int val2) 362static int vl6180_set_als_gain(struct vl6180_data *data, int val, int val2)
367{ 363{
368 int i, ret; 364 int i, ret, gain;
369
370 for (i = 0; i < ARRAY_SIZE(vl6180_als_gain); i++) {
371 if (val == vl6180_als_gain[i][0] &&
372 val2 == vl6180_als_gain[i][1]) {
373 mutex_lock(&data->lock);
374 ret = vl6180_hold(data, true);
375 if (ret < 0)
376 goto fail;
377 ret = vl6180_write_byte(data->client, VL6180_ALS_GAIN,
378 vl6180_als_gain[i][3]);
379fail:
380 vl6180_hold(data, false);
381 mutex_unlock(&data->lock);
382 return ret;
383 }
384 }
385 365
386 return -EINVAL; 366 if (val < 1 || val > 40)
367 return -EINVAL;
368
369 gain = (val * 1000000 + val2) / 1000;
370 if (gain < 1 || gain > 40000)
371 return -EINVAL;
372
373 i = find_closest(gain, vl6180_als_gain_tab,
374 ARRAY_SIZE(vl6180_als_gain_tab));
375
376 mutex_lock(&data->lock);
377 ret = vl6180_hold(data, true);
378 if (ret < 0)
379 goto fail;
380
381 ret = vl6180_write_byte(data->client, VL6180_ALS_GAIN,
382 vl6180_als_gain_tab_bits[i]);
383
384 if (ret >= 0)
385 data->als_gain_milli = vl6180_als_gain_tab[i];
386
387fail:
388 vl6180_hold(data, false);
389 mutex_unlock(&data->lock);
390 return ret;
387} 391}
388 392
389static int vl6180_set_it(struct vl6180_data *data, int val2) 393static int vl6180_set_it(struct vl6180_data *data, int val, int val2)
390{ 394{
391 int ret; 395 int ret, it_ms;
396
397 it_ms = (val2 + 500) / 1000; /* round to ms */
398 if (val != 0 || it_ms < 1 || it_ms > 512)
399 return -EINVAL;
392 400
393 mutex_lock(&data->lock); 401 mutex_lock(&data->lock);
394 ret = vl6180_hold(data, true); 402 ret = vl6180_hold(data, true);
395 if (ret < 0) 403 if (ret < 0)
396 goto fail; 404 goto fail;
397 ret = vl6180_write_word(data->client, VL6180_ALS_IT, 405
398 (val2 - 500) / 1000); /* write value in ms */ 406 ret = vl6180_write_word(data->client, VL6180_ALS_IT, it_ms - 1);
407
408 if (ret >= 0)
409 data->als_it_ms = it_ms;
410
399fail: 411fail:
400 vl6180_hold(data, false); 412 vl6180_hold(data, false);
401 mutex_unlock(&data->lock); 413 mutex_unlock(&data->lock);
@@ -411,10 +423,8 @@ static int vl6180_write_raw(struct iio_dev *indio_dev,
411 423
412 switch (mask) { 424 switch (mask) {
413 case IIO_CHAN_INFO_INT_TIME: 425 case IIO_CHAN_INFO_INT_TIME:
414 if (val != 0 || val2 < 500 || val2 >= 512500) 426 return vl6180_set_it(data, val, val2);
415 return -EINVAL;
416 427
417 return vl6180_set_it(data, val2);
418 case IIO_CHAN_INFO_HARDWAREGAIN: 428 case IIO_CHAN_INFO_HARDWAREGAIN:
419 if (chan->type != IIO_LIGHT) 429 if (chan->type != IIO_LIGHT)
420 return -EINVAL; 430 return -EINVAL;
@@ -429,7 +439,6 @@ static const struct iio_info vl6180_info = {
429 .read_raw = vl6180_read_raw, 439 .read_raw = vl6180_read_raw,
430 .write_raw = vl6180_write_raw, 440 .write_raw = vl6180_write_raw,
431 .attrs = &vl6180_attribute_group, 441 .attrs = &vl6180_attribute_group,
432 .driver_module = THIS_MODULE,
433}; 442};
434 443
435static int vl6180_init(struct vl6180_data *data) 444static int vl6180_init(struct vl6180_data *data)
@@ -468,11 +477,13 @@ static int vl6180_init(struct vl6180_data *data)
468 return ret; 477 return ret;
469 478
470 /* ALS integration time: 100ms */ 479 /* ALS integration time: 100ms */
480 data->als_it_ms = 100;
471 ret = vl6180_write_word(client, VL6180_ALS_IT, VL6180_ALS_IT_100); 481 ret = vl6180_write_word(client, VL6180_ALS_IT, VL6180_ALS_IT_100);
472 if (ret < 0) 482 if (ret < 0)
473 return ret; 483 return ret;
474 484
475 /* ALS gain: 1 */ 485 /* ALS gain: 1 */
486 data->als_gain_milli = 1000;
476 ret = vl6180_write_byte(client, VL6180_ALS_GAIN, VL6180_ALS_GAIN_1); 487 ret = vl6180_write_byte(client, VL6180_ALS_GAIN, VL6180_ALS_GAIN_1);
477 if (ret < 0) 488 if (ret < 0)
478 return ret; 489 return ret;
diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
index 0bff76e96950..93be1f4c0f27 100644
--- a/drivers/iio/magnetometer/ak8974.c
+++ b/drivers/iio/magnetometer/ak8974.c
@@ -658,7 +658,6 @@ static const unsigned long ak8974_scan_masks[] = { 0x7, 0 };
658 658
659static const struct iio_info ak8974_info = { 659static const struct iio_info ak8974_info = {
660 .read_raw = &ak8974_read_raw, 660 .read_raw = &ak8974_read_raw,
661 .driver_module = THIS_MODULE,
662}; 661};
663 662
664static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) 663static bool ak8974_writeable_reg(struct device *dev, unsigned int reg)
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 4ff883942f7b..c09329069d0a 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -781,7 +781,6 @@ static const unsigned long ak8975_scan_masks[] = { 0x7, 0 };
781 781
782static const struct iio_info ak8975_info = { 782static const struct iio_info ak8975_info = {
783 .read_raw = &ak8975_read_raw, 783 .read_raw = &ak8975_read_raw,
784 .driver_module = THIS_MODULE,
785}; 784};
786 785
787#ifdef CONFIG_ACPI 786#ifdef CONFIG_ACPI
diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
index d104fb8d9379..d91cb845e3d6 100644
--- a/drivers/iio/magnetometer/bmc150_magn.c
+++ b/drivers/iio/magnetometer/bmc150_magn.c
@@ -651,7 +651,6 @@ static const struct iio_info bmc150_magn_info = {
651 .attrs = &bmc150_magn_attrs_group, 651 .attrs = &bmc150_magn_attrs_group,
652 .read_raw = bmc150_magn_read_raw, 652 .read_raw = bmc150_magn_read_raw,
653 .write_raw = bmc150_magn_write_raw, 653 .write_raw = bmc150_magn_write_raw,
654 .driver_module = THIS_MODULE,
655}; 654};
656 655
657static const unsigned long bmc150_magn_scan_masks[] = { 656static const unsigned long bmc150_magn_scan_masks[] = {
@@ -811,7 +810,6 @@ err_unlock:
811static const struct iio_trigger_ops bmc150_magn_trigger_ops = { 810static const struct iio_trigger_ops bmc150_magn_trigger_ops = {
812 .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state, 811 .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state,
813 .try_reenable = bmc150_magn_trig_try_reen, 812 .try_reenable = bmc150_magn_trig_try_reen,
814 .owner = THIS_MODULE,
815}; 813};
816 814
817static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev) 815static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 0e791b02ed4a..a1fd9d591818 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -282,7 +282,6 @@ static int magn_3d_write_raw(struct iio_dev *indio_dev,
282} 282}
283 283
284static const struct iio_info magn_3d_info = { 284static const struct iio_info magn_3d_info = {
285 .driver_module = THIS_MODULE,
286 .read_raw = &magn_3d_read_raw, 285 .read_raw = &magn_3d_read_raw,
287 .write_raw = &magn_3d_write_raw, 286 .write_raw = &magn_3d_write_raw,
288}; 287};
diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c
index ba3e2a374ee5..ada142fb7aa3 100644
--- a/drivers/iio/magnetometer/hmc5843_core.c
+++ b/drivers/iio/magnetometer/hmc5843_core.c
@@ -597,7 +597,6 @@ static const struct iio_info hmc5843_info = {
597 .read_raw = &hmc5843_read_raw, 597 .read_raw = &hmc5843_read_raw,
598 .write_raw = &hmc5843_write_raw, 598 .write_raw = &hmc5843_write_raw,
599 .write_raw_get_fmt = &hmc5843_write_raw_get_fmt, 599 .write_raw_get_fmt = &hmc5843_write_raw_get_fmt,
600 .driver_module = THIS_MODULE,
601}; 600};
602 601
603static const unsigned long hmc5843_scan_masks[] = {0x7, 0}; 602static const unsigned long hmc5843_scan_masks[] = {0x7, 0};
diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index dad8d57f7402..b34ace76d31b 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -333,7 +333,6 @@ static const struct iio_info mag3110_info = {
333 .attrs = &mag3110_group, 333 .attrs = &mag3110_group,
334 .read_raw = &mag3110_read_raw, 334 .read_raw = &mag3110_read_raw,
335 .write_raw = &mag3110_write_raw, 335 .write_raw = &mag3110_write_raw,
336 .driver_module = THIS_MODULE,
337}; 336};
338 337
339static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0}; 338static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0};
diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index 176e14a61558..6b640c6338c9 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -418,7 +418,6 @@ static int mmc35240_write_raw(struct iio_dev *indio_dev,
418} 418}
419 419
420static const struct iio_info mmc35240_info = { 420static const struct iio_info mmc35240_info = {
421 .driver_module = THIS_MODULE,
422 .read_raw = mmc35240_read_raw, 421 .read_raw = mmc35240_read_raw,
423 .write_raw = mmc35240_write_raw, 422 .write_raw = mmc35240_write_raw,
424 .attrs = &mmc35240_attribute_group, 423 .attrs = &mmc35240_attribute_group,
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 08aafba4481c..72f6d1335a04 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -317,7 +317,14 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
317 }, 317 },
318 .drdy_irq = { 318 .drdy_irq = {
319 /* drdy line is routed drdy pin */ 319 /* drdy line is routed drdy pin */
320 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 320 .stat_drdy = {
321 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
322 .mask = 0x07,
323 },
324 },
325 .sim = {
326 .addr = 0x22,
327 .value = BIT(2),
321 }, 328 },
322 .multi_read_bit = true, 329 .multi_read_bit = true,
323 .bootime = 2, 330 .bootime = 2,
@@ -359,9 +366,14 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
359 .mask = 0x10, 366 .mask = 0x10,
360 }, 367 },
361 .drdy_irq = { 368 .drdy_irq = {
362 .addr = 0x62, 369 .int1 = {
363 .mask_int1 = 0x01, 370 .addr = 0x62,
364 .addr_stat_drdy = 0x67, 371 .mask = 0x01,
372 },
373 .stat_drdy = {
374 .addr = 0x67,
375 .mask = 0x07,
376 },
365 }, 377 },
366 .multi_read_bit = false, 378 .multi_read_bit = false,
367 .bootime = 2, 379 .bootime = 2,
@@ -438,7 +450,6 @@ static const struct attribute_group st_magn_attribute_group = {
438}; 450};
439 451
440static const struct iio_info magn_info = { 452static const struct iio_info magn_info = {
441 .driver_module = THIS_MODULE,
442 .attrs = &st_magn_attribute_group, 453 .attrs = &st_magn_attribute_group,
443 .read_raw = &st_magn_read_raw, 454 .read_raw = &st_magn_read_raw,
444 .write_raw = &st_magn_write_raw, 455 .write_raw = &st_magn_write_raw,
@@ -447,7 +458,6 @@ static const struct iio_info magn_info = {
447 458
448#ifdef CONFIG_IIO_TRIGGER 459#ifdef CONFIG_IIO_TRIGGER
449static const struct iio_trigger_ops st_magn_trigger_ops = { 460static const struct iio_trigger_ops st_magn_trigger_ops = {
450 .owner = THIS_MODULE,
451 .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE, 461 .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE,
452 .validate_device = st_sensors_validate_device, 462 .validate_device = st_sensors_validate_device,
453}; 463};
diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
index 37ba007f8dca..60621ccd67e4 100644
--- a/drivers/iio/multiplexer/iio-mux.c
+++ b/drivers/iio/multiplexer/iio-mux.c
@@ -173,7 +173,6 @@ static const struct iio_info mux_info = {
173 .read_raw = mux_read_raw, 173 .read_raw = mux_read_raw,
174 .read_avail = mux_read_avail, 174 .read_avail = mux_read_avail,
175 .write_raw = mux_write_raw, 175 .write_raw = mux_write_raw,
176 .driver_module = THIS_MODULE,
177}; 176};
178 177
179static ssize_t mux_read_ext_info(struct iio_dev *indio_dev, uintptr_t private, 178static ssize_t mux_read_ext_info(struct iio_dev *indio_dev, uintptr_t private,
@@ -285,6 +284,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
285 child->ext_info_cache = devm_kzalloc(dev, 284 child->ext_info_cache = devm_kzalloc(dev,
286 sizeof(*child->ext_info_cache) * 285 sizeof(*child->ext_info_cache) *
287 num_ext_info, GFP_KERNEL); 286 num_ext_info, GFP_KERNEL);
287 if (!child->ext_info_cache)
288 return -ENOMEM;
289
288 for (i = 0; i < num_ext_info; ++i) { 290 for (i = 0; i < num_ext_info; ++i) {
289 child->ext_info_cache[i].size = -1; 291 child->ext_info_cache[i].size = -1;
290 292
@@ -309,6 +311,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
309 311
310 child->ext_info_cache[i].data = devm_kmemdup(dev, page, ret + 1, 312 child->ext_info_cache[i].data = devm_kmemdup(dev, page, ret + 1,
311 GFP_KERNEL); 313 GFP_KERNEL);
314 if (!child->ext_info_cache[i].data)
315 return -ENOMEM;
316
312 child->ext_info_cache[i].data[ret] = 0; 317 child->ext_info_cache[i].data[ret] = 0;
313 child->ext_info_cache[i].size = ret; 318 child->ext_info_cache[i].size = ret;
314 } 319 }
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index fd1b3696ee42..1e5451d1ff88 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -186,7 +186,6 @@ static int incl_3d_write_raw(struct iio_dev *indio_dev,
186} 186}
187 187
188static const struct iio_info incl_3d_info = { 188static const struct iio_info incl_3d_info = {
189 .driver_module = THIS_MODULE,
190 .read_raw = &incl_3d_read_raw, 189 .read_raw = &incl_3d_read_raw,
191 .write_raw = &incl_3d_write_raw, 190 .write_raw = &incl_3d_write_raw,
192}; 191};
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 98fe0c5df380..a69db2002414 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -138,7 +138,6 @@ static int dev_rot_write_raw(struct iio_dev *indio_dev,
138} 138}
139 139
140static const struct iio_info dev_rot_info = { 140static const struct iio_info dev_rot_info = {
141 .driver_module = THIS_MODULE,
142 .read_raw_multi = &dev_rot_read_raw, 141 .read_raw_multi = &dev_rot_read_raw,
143 .write_raw = &dev_rot_write_raw, 142 .write_raw = &dev_rot_write_raw,
144}; 143};
diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c
index fb9e2a337dc2..9b0ff4ab2f9c 100644
--- a/drivers/iio/potentiometer/ds1803.c
+++ b/drivers/iio/potentiometer/ds1803.c
@@ -110,7 +110,6 @@ static int ds1803_write_raw(struct iio_dev *indio_dev,
110static const struct iio_info ds1803_info = { 110static const struct iio_info ds1803_info = {
111 .read_raw = ds1803_read_raw, 111 .read_raw = ds1803_read_raw,
112 .write_raw = ds1803_write_raw, 112 .write_raw = ds1803_write_raw,
113 .driver_module = THIS_MODULE,
114}; 113};
115 114
116static int ds1803_probe(struct i2c_client *client, 115static int ds1803_probe(struct i2c_client *client,
diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c
index 926554991244..ffe2761333a2 100644
--- a/drivers/iio/potentiometer/max5481.c
+++ b/drivers/iio/potentiometer/max5481.c
@@ -119,7 +119,6 @@ static int max5481_write_raw(struct iio_dev *indio_dev,
119static const struct iio_info max5481_info = { 119static const struct iio_info max5481_info = {
120 .read_raw = max5481_read_raw, 120 .read_raw = max5481_read_raw,
121 .write_raw = max5481_write_raw, 121 .write_raw = max5481_write_raw,
122 .driver_module = THIS_MODULE,
123}; 122};
124 123
125#if defined(CONFIG_OF) 124#if defined(CONFIG_OF)
@@ -207,7 +206,6 @@ MODULE_DEVICE_TABLE(acpi, max5481_acpi_match);
207static struct spi_driver max5481_driver = { 206static struct spi_driver max5481_driver = {
208 .driver = { 207 .driver = {
209 .name = "max5481", 208 .name = "max5481",
210 .owner = THIS_MODULE,
211 .of_match_table = of_match_ptr(max5481_match), 209 .of_match_table = of_match_ptr(max5481_match),
212 .acpi_match_table = ACPI_PTR(max5481_acpi_match), 210 .acpi_match_table = ACPI_PTR(max5481_acpi_match),
213 }, 211 },
diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c
index 6c50939a2e83..5042d3e09b12 100644
--- a/drivers/iio/potentiometer/max5487.c
+++ b/drivers/iio/potentiometer/max5487.c
@@ -83,7 +83,6 @@ static int max5487_write_raw(struct iio_dev *indio_dev,
83static const struct iio_info max5487_info = { 83static const struct iio_info max5487_info = {
84 .read_raw = max5487_read_raw, 84 .read_raw = max5487_read_raw,
85 .write_raw = max5487_write_raw, 85 .write_raw = max5487_write_raw,
86 .driver_module = THIS_MODULE,
87}; 86};
88 87
89static int max5487_spi_probe(struct spi_device *spi) 88static int max5487_spi_probe(struct spi_device *spi)
@@ -147,7 +146,6 @@ MODULE_DEVICE_TABLE(acpi, max5487_acpi_match);
147static struct spi_driver max5487_driver = { 146static struct spi_driver max5487_driver = {
148 .driver = { 147 .driver = {
149 .name = "max5487", 148 .name = "max5487",
150 .owner = THIS_MODULE,
151 .acpi_match_table = ACPI_PTR(max5487_acpi_match), 149 .acpi_match_table = ACPI_PTR(max5487_acpi_match),
152 }, 150 },
153 .id_table = max5487_id, 151 .id_table = max5487_id,
diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c
index 4e7e2c6c522c..b3e30db246cc 100644
--- a/drivers/iio/potentiometer/mcp4131.c
+++ b/drivers/iio/potentiometer/mcp4131.c
@@ -237,7 +237,6 @@ static int mcp4131_write_raw(struct iio_dev *indio_dev,
237static const struct iio_info mcp4131_info = { 237static const struct iio_info mcp4131_info = {
238 .read_raw = mcp4131_read_raw, 238 .read_raw = mcp4131_read_raw,
239 .write_raw = mcp4131_write_raw, 239 .write_raw = mcp4131_write_raw,
240 .driver_module = THIS_MODULE,
241}; 240};
242 241
243static int mcp4131_probe(struct spi_device *spi) 242static int mcp4131_probe(struct spi_device *spi)
diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c
index 314353d7ab59..114ab876fcc6 100644
--- a/drivers/iio/potentiometer/mcp4531.c
+++ b/drivers/iio/potentiometer/mcp4531.c
@@ -207,7 +207,6 @@ static const struct iio_info mcp4531_info = {
207 .read_raw = mcp4531_read_raw, 207 .read_raw = mcp4531_read_raw,
208 .read_avail = mcp4531_read_avail, 208 .read_avail = mcp4531_read_avail,
209 .write_raw = mcp4531_write_raw, 209 .write_raw = mcp4531_write_raw,
210 .driver_module = THIS_MODULE,
211}; 210};
212 211
213#ifdef CONFIG_OF 212#ifdef CONFIG_OF
diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c
index 7b6b54531ea2..93f9d4a8c9aa 100644
--- a/drivers/iio/potentiometer/tpl0102.c
+++ b/drivers/iio/potentiometer/tpl0102.c
@@ -106,7 +106,6 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev,
106static const struct iio_info tpl0102_info = { 106static const struct iio_info tpl0102_info = {
107 .read_raw = tpl0102_read_raw, 107 .read_raw = tpl0102_read_raw,
108 .write_raw = tpl0102_write_raw, 108 .write_raw = tpl0102_write_raw,
109 .driver_module = THIS_MODULE,
110}; 109};
111 110
112static int tpl0102_probe(struct i2c_client *client, 111static int tpl0102_probe(struct i2c_client *client,
diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
index afa8de3418d0..007710991f15 100644
--- a/drivers/iio/potentiostat/lmp91000.c
+++ b/drivers/iio/potentiostat/lmp91000.c
@@ -207,7 +207,6 @@ static int lmp91000_read_raw(struct iio_dev *indio_dev,
207} 207}
208 208
209static const struct iio_info lmp91000_info = { 209static const struct iio_info lmp91000_info = {
210 .driver_module = THIS_MODULE,
211 .read_raw = lmp91000_read_raw, 210 .read_raw = lmp91000_read_raw,
212}; 211};
213 212
@@ -283,7 +282,6 @@ static int lmp91000_buffer_cb(const void *val, void *private)
283} 282}
284 283
285static const struct iio_trigger_ops lmp91000_trigger_ops = { 284static const struct iio_trigger_ops lmp91000_trigger_ops = {
286 .owner = THIS_MODULE,
287}; 285};
288 286
289 287
diff --git a/drivers/iio/pressure/abp060mg.c b/drivers/iio/pressure/abp060mg.c
index 43bdd0b9155f..46a220c70d6a 100644
--- a/drivers/iio/pressure/abp060mg.c
+++ b/drivers/iio/pressure/abp060mg.c
@@ -168,7 +168,6 @@ static int abp060mg_read_raw(struct iio_dev *indio_dev,
168} 168}
169 169
170static const struct iio_info abp060mg_info = { 170static const struct iio_info abp060mg_info = {
171 .driver_module = THIS_MODULE,
172 .read_raw = abp060mg_read_raw, 171 .read_raw = abp060mg_read_raw,
173}; 172};
174 173
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 8f26428804a2..fd1da26a62e4 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -561,7 +561,6 @@ static const struct attribute_group bmp280_attrs_group = {
561}; 561};
562 562
563static const struct iio_info bmp280_info = { 563static const struct iio_info bmp280_info = {
564 .driver_module = THIS_MODULE,
565 .read_raw = &bmp280_read_raw, 564 .read_raw = &bmp280_read_raw,
566 .write_raw = &bmp280_write_raw, 565 .write_raw = &bmp280_write_raw,
567 .attrs = &bmp280_attrs_group, 566 .attrs = &bmp280_attrs_group,
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 48b2a30f57ae..4599fde4dd25 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -120,14 +120,12 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev,
120static const struct iio_info cros_ec_baro_info = { 120static const struct iio_info cros_ec_baro_info = {
121 .read_raw = &cros_ec_baro_read, 121 .read_raw = &cros_ec_baro_read,
122 .write_raw = &cros_ec_baro_write, 122 .write_raw = &cros_ec_baro_write,
123 .driver_module = THIS_MODULE,
124}; 123};
125 124
126static int cros_ec_baro_probe(struct platform_device *pdev) 125static int cros_ec_baro_probe(struct platform_device *pdev)
127{ 126{
128 struct device *dev = &pdev->dev; 127 struct device *dev = &pdev->dev;
129 struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent); 128 struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
130 struct cros_ec_device *ec_device;
131 struct iio_dev *indio_dev; 129 struct iio_dev *indio_dev;
132 struct cros_ec_baro_state *state; 130 struct cros_ec_baro_state *state;
133 struct iio_chan_spec *channel; 131 struct iio_chan_spec *channel;
@@ -137,7 +135,6 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
137 dev_warn(dev, "No CROS EC device found.\n"); 135 dev_warn(dev, "No CROS EC device found.\n");
138 return -EINVAL; 136 return -EINVAL;
139 } 137 }
140 ec_device = ec_dev->ec_dev;
141 138
142 indio_dev = devm_iio_device_alloc(dev, sizeof(*state)); 139 indio_dev = devm_iio_device_alloc(dev, sizeof(*state));
143 if (!indio_dev) 140 if (!indio_dev)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 6848d8c80eff..4c437918f1d2 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -160,7 +160,6 @@ static int press_write_raw(struct iio_dev *indio_dev,
160} 160}
161 161
162static const struct iio_info press_info = { 162static const struct iio_info press_info = {
163 .driver_module = THIS_MODULE,
164 .read_raw = &press_read_raw, 163 .read_raw = &press_read_raw,
165 .write_raw = &press_write_raw, 164 .write_raw = &press_write_raw,
166}; 165};
diff --git a/drivers/iio/pressure/hp03.c b/drivers/iio/pressure/hp03.c
index 8c7b3ec3d84a..406934ea6228 100644
--- a/drivers/iio/pressure/hp03.c
+++ b/drivers/iio/pressure/hp03.c
@@ -208,7 +208,6 @@ static int hp03_read_raw(struct iio_dev *indio_dev,
208} 208}
209 209
210static const struct iio_info hp03_info = { 210static const struct iio_info hp03_info = {
211 .driver_module = THIS_MODULE,
212 .read_raw = &hp03_read_raw, 211 .read_raw = &hp03_read_raw,
213}; 212};
214 213
diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c
index 12f769e86355..c38c19678cf6 100644
--- a/drivers/iio/pressure/hp206c.c
+++ b/drivers/iio/pressure/hp206c.c
@@ -351,7 +351,6 @@ static const struct iio_info hp206c_info = {
351 .attrs = &hp206c_attribute_group, 351 .attrs = &hp206c_attribute_group,
352 .read_raw = hp206c_read_raw, 352 .read_raw = hp206c_read_raw,
353 .write_raw = hp206c_write_raw, 353 .write_raw = hp206c_write_raw,
354 .driver_module = THIS_MODULE,
355}; 354};
356 355
357static int hp206c_probe(struct i2c_client *client, 356static int hp206c_probe(struct i2c_client *client,
diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
index 8f2bce213248..ab4786d0102b 100644
--- a/drivers/iio/pressure/mpl115.c
+++ b/drivers/iio/pressure/mpl115.c
@@ -144,7 +144,6 @@ static const struct iio_chan_spec mpl115_channels[] = {
144 144
145static const struct iio_info mpl115_info = { 145static const struct iio_info mpl115_info = {
146 .read_raw = &mpl115_read_raw, 146 .read_raw = &mpl115_read_raw,
147 .driver_module = THIS_MODULE,
148}; 147};
149 148
150int mpl115_probe(struct device *dev, const char *name, 149int mpl115_probe(struct device *dev, const char *name,
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index 619b963714c7..7537547fb7ee 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -218,7 +218,6 @@ static const struct iio_chan_spec mpl3115_channels[] = {
218 218
219static const struct iio_info mpl3115_info = { 219static const struct iio_info mpl3115_info = {
220 .read_raw = &mpl3115_read_raw, 220 .read_raw = &mpl3115_read_raw,
221 .driver_module = THIS_MODULE,
222}; 221};
223 222
224static int mpl3115_probe(struct i2c_client *client, 223static int mpl3115_probe(struct i2c_client *client,
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
index 2a77a2f15752..f950cfde5db9 100644
--- a/drivers/iio/pressure/ms5611_core.c
+++ b/drivers/iio/pressure/ms5611_core.c
@@ -384,7 +384,6 @@ static const struct iio_info ms5611_info = {
384 .read_raw = &ms5611_read_raw, 384 .read_raw = &ms5611_read_raw,
385 .write_raw = &ms5611_write_raw, 385 .write_raw = &ms5611_write_raw,
386 .attrs = &ms5611_attribute_group, 386 .attrs = &ms5611_attribute_group,
387 .driver_module = THIS_MODULE,
388}; 387};
389 388
390static int ms5611_init(struct iio_dev *indio_dev) 389static int ms5611_init(struct iio_dev *indio_dev)
diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c
index c413f8a84a63..e2f73e6dc58f 100644
--- a/drivers/iio/pressure/ms5637.c
+++ b/drivers/iio/pressure/ms5637.c
@@ -124,7 +124,6 @@ static const struct iio_info ms5637_info = {
124 .read_raw = ms5637_read_raw, 124 .read_raw = ms5637_read_raw,
125 .write_raw = ms5637_write_raw, 125 .write_raw = ms5637_write_raw,
126 .attrs = &ms5637_attribute_group, 126 .attrs = &ms5637_attribute_group,
127 .driver_module = THIS_MODULE,
128}; 127};
129 128
130static int ms5637_probe(struct i2c_client *client, 129static int ms5637_probe(struct i2c_client *client,
diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index 7d995937adba..e67eb0d971bf 100644
--- a/drivers/iio/pressure/st_pressure.h
+++ b/drivers/iio/pressure/st_pressure.h
@@ -19,6 +19,8 @@ enum st_press_type {
19 LPS25H, 19 LPS25H,
20 LPS331AP, 20 LPS331AP,
21 LPS22HB, 21 LPS22HB,
22 LPS33HW,
23 LPS35HW,
22 ST_PRESS_MAX, 24 ST_PRESS_MAX,
23}; 25};
24 26
@@ -26,6 +28,8 @@ enum st_press_type {
26#define LPS25H_PRESS_DEV_NAME "lps25h" 28#define LPS25H_PRESS_DEV_NAME "lps25h"
27#define LPS331AP_PRESS_DEV_NAME "lps331ap" 29#define LPS331AP_PRESS_DEV_NAME "lps331ap"
28#define LPS22HB_PRESS_DEV_NAME "lps22hb" 30#define LPS22HB_PRESS_DEV_NAME "lps22hb"
31#define LPS33HW_PRESS_DEV_NAME "lps33hw"
32#define LPS35HW_PRESS_DEV_NAME "lps35hw"
29 33
30/** 34/**
31 * struct st_sensors_platform_data - default press platform data 35 * struct st_sensors_platform_data - default press platform data
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 34611a8ea2ce..349e5c713c03 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -280,14 +280,28 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
280 .mask = 0x04, 280 .mask = 0x04,
281 }, 281 },
282 .drdy_irq = { 282 .drdy_irq = {
283 .addr = 0x22, 283 .int1 = {
284 .mask_int1 = 0x04, 284 .addr = 0x22,
285 .mask_int2 = 0x20, 285 .mask = 0x04,
286 .addr_od = 0x22,
287 .mask_od = 0x40,
288 },
289 .int2 = {
290 .addr = 0x22,
291 .mask = 0x20,
292 .addr_od = 0x22,
293 .mask_od = 0x40,
294 },
286 .addr_ihl = 0x22, 295 .addr_ihl = 0x22,
287 .mask_ihl = 0x80, 296 .mask_ihl = 0x80,
288 .addr_od = 0x22, 297 .stat_drdy = {
289 .mask_od = 0x40, 298 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
290 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 299 .mask = 0x03,
300 },
301 },
302 .sim = {
303 .addr = 0x20,
304 .value = BIT(0),
291 }, 305 },
292 .multi_read_bit = true, 306 .multi_read_bit = true,
293 .bootime = 2, 307 .bootime = 2,
@@ -335,8 +349,9 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
335 .addr = 0x20, 349 .addr = 0x20,
336 .mask = 0x04, 350 .mask = 0x04,
337 }, 351 },
338 .drdy_irq = { 352 .sim = {
339 .addr = 0, 353 .addr = 0x20,
354 .value = BIT(0),
340 }, 355 },
341 .multi_read_bit = true, 356 .multi_read_bit = true,
342 .bootime = 2, 357 .bootime = 2,
@@ -388,14 +403,22 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
388 .mask = 0x04, 403 .mask = 0x04,
389 }, 404 },
390 .drdy_irq = { 405 .drdy_irq = {
391 .addr = 0x23, 406 .int1 = {
392 .mask_int1 = 0x01, 407 .addr = 0x23,
393 .mask_int2 = 0x00, 408 .mask = 0x01,
409 .addr_od = 0x22,
410 .mask_od = 0x40,
411 },
394 .addr_ihl = 0x22, 412 .addr_ihl = 0x22,
395 .mask_ihl = 0x80, 413 .mask_ihl = 0x80,
396 .addr_od = 0x22, 414 .stat_drdy = {
397 .mask_od = 0x40, 415 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
398 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 416 .mask = 0x03,
417 },
418 },
419 .sim = {
420 .addr = 0x20,
421 .value = BIT(0),
399 }, 422 },
400 .multi_read_bit = true, 423 .multi_read_bit = true,
401 .bootime = 2, 424 .bootime = 2,
@@ -410,6 +433,8 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
410 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, 433 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
411 .sensors_supported = { 434 .sensors_supported = {
412 [0] = LPS22HB_PRESS_DEV_NAME, 435 [0] = LPS22HB_PRESS_DEV_NAME,
436 [1] = LPS33HW_PRESS_DEV_NAME,
437 [2] = LPS35HW_PRESS_DEV_NAME,
413 }, 438 },
414 .ch = (struct iio_chan_spec *)st_press_lps22hb_channels, 439 .ch = (struct iio_chan_spec *)st_press_lps22hb_channels,
415 .num_ch = ARRAY_SIZE(st_press_lps22hb_channels), 440 .num_ch = ARRAY_SIZE(st_press_lps22hb_channels),
@@ -447,14 +472,22 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
447 .mask = 0x02, 472 .mask = 0x02,
448 }, 473 },
449 .drdy_irq = { 474 .drdy_irq = {
450 .addr = 0x12, 475 .int1 = {
451 .mask_int1 = 0x04, 476 .addr = 0x12,
452 .mask_int2 = 0x00, 477 .mask = 0x04,
478 .addr_od = 0x12,
479 .mask_od = 0x40,
480 },
453 .addr_ihl = 0x12, 481 .addr_ihl = 0x12,
454 .mask_ihl = 0x80, 482 .mask_ihl = 0x80,
455 .addr_od = 0x12, 483 .stat_drdy = {
456 .mask_od = 0x40, 484 .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
457 .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, 485 .mask = 0x03,
486 },
487 },
488 .sim = {
489 .addr = 0x10,
490 .value = BIT(0),
458 }, 491 },
459 .multi_read_bit = false, 492 .multi_read_bit = false,
460 .bootime = 2, 493 .bootime = 2,
@@ -547,7 +580,6 @@ static const struct attribute_group st_press_attribute_group = {
547}; 580};
548 581
549static const struct iio_info press_info = { 582static const struct iio_info press_info = {
550 .driver_module = THIS_MODULE,
551 .attrs = &st_press_attribute_group, 583 .attrs = &st_press_attribute_group,
552 .read_raw = &st_press_read_raw, 584 .read_raw = &st_press_read_raw,
553 .write_raw = &st_press_write_raw, 585 .write_raw = &st_press_write_raw,
@@ -556,7 +588,6 @@ static const struct iio_info press_info = {
556 588
557#ifdef CONFIG_IIO_TRIGGER 589#ifdef CONFIG_IIO_TRIGGER
558static const struct iio_trigger_ops st_press_trigger_ops = { 590static const struct iio_trigger_ops st_press_trigger_ops = {
559 .owner = THIS_MODULE,
560 .set_trigger_state = ST_PRESS_TRIGGER_SET_STATE, 591 .set_trigger_state = ST_PRESS_TRIGGER_SET_STATE,
561 .validate_device = st_sensors_validate_device, 592 .validate_device = st_sensors_validate_device,
562}; 593};
@@ -605,7 +636,8 @@ int st_press_common_probe(struct iio_dev *indio_dev)
605 press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; 636 press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz;
606 637
607 /* Some devices don't support a data ready pin. */ 638 /* Some devices don't support a data ready pin. */
608 if (!pdata && press_data->sensor_settings->drdy_irq.addr) 639 if (!pdata && (press_data->sensor_settings->drdy_irq.int1.addr ||
640 press_data->sensor_settings->drdy_irq.int2.addr))
609 pdata = (struct st_sensors_platform_data *)&default_press_pdata; 641 pdata = (struct st_sensors_platform_data *)&default_press_pdata;
610 642
611 err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); 643 err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data);
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 7f15e927fa2b..fbb59059e942 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -37,6 +37,14 @@ static const struct of_device_id st_press_of_match[] = {
37 .compatible = "st,lps22hb-press", 37 .compatible = "st,lps22hb-press",
38 .data = LPS22HB_PRESS_DEV_NAME, 38 .data = LPS22HB_PRESS_DEV_NAME,
39 }, 39 },
40 {
41 .compatible = "st,lps33hw",
42 .data = LPS33HW_PRESS_DEV_NAME,
43 },
44 {
45 .compatible = "st,lps35hw",
46 .data = LPS35HW_PRESS_DEV_NAME,
47 },
40 {}, 48 {},
41}; 49};
42MODULE_DEVICE_TABLE(of, st_press_of_match); 50MODULE_DEVICE_TABLE(of, st_press_of_match);
@@ -59,6 +67,8 @@ static const struct i2c_device_id st_press_id_table[] = {
59 { LPS25H_PRESS_DEV_NAME, LPS25H }, 67 { LPS25H_PRESS_DEV_NAME, LPS25H },
60 { LPS331AP_PRESS_DEV_NAME, LPS331AP }, 68 { LPS331AP_PRESS_DEV_NAME, LPS331AP },
61 { LPS22HB_PRESS_DEV_NAME, LPS22HB }, 69 { LPS22HB_PRESS_DEV_NAME, LPS22HB },
70 { LPS33HW_PRESS_DEV_NAME, LPS33HW },
71 { LPS35HW_PRESS_DEV_NAME, LPS35HW },
62 {}, 72 {},
63}; 73};
64MODULE_DEVICE_TABLE(i2c, st_press_id_table); 74MODULE_DEVICE_TABLE(i2c, st_press_id_table);
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index f5ebd36bb4bf..9a3441b128e7 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -41,6 +41,14 @@ static const struct of_device_id st_press_of_match[] = {
41 .compatible = "st,lps22hb-press", 41 .compatible = "st,lps22hb-press",
42 .data = LPS22HB_PRESS_DEV_NAME, 42 .data = LPS22HB_PRESS_DEV_NAME,
43 }, 43 },
44 {
45 .compatible = "st,lps33hw",
46 .data = LPS33HW_PRESS_DEV_NAME,
47 },
48 {
49 .compatible = "st,lps35hw",
50 .data = LPS35HW_PRESS_DEV_NAME,
51 },
44 {}, 52 {},
45}; 53};
46MODULE_DEVICE_TABLE(of, st_press_of_match); 54MODULE_DEVICE_TABLE(of, st_press_of_match);
@@ -83,6 +91,8 @@ static const struct spi_device_id st_press_id_table[] = {
83 { LPS25H_PRESS_DEV_NAME }, 91 { LPS25H_PRESS_DEV_NAME },
84 { LPS331AP_PRESS_DEV_NAME }, 92 { LPS331AP_PRESS_DEV_NAME },
85 { LPS22HB_PRESS_DEV_NAME }, 93 { LPS22HB_PRESS_DEV_NAME },
94 { LPS33HW_PRESS_DEV_NAME },
95 { LPS35HW_PRESS_DEV_NAME },
86 {}, 96 {},
87}; 97};
88MODULE_DEVICE_TABLE(spi, st_press_id_table); 98MODULE_DEVICE_TABLE(spi, st_press_id_table);
diff --git a/drivers/iio/pressure/t5403.c b/drivers/iio/pressure/t5403.c
index 2667e71721f5..92c00f603b1d 100644
--- a/drivers/iio/pressure/t5403.c
+++ b/drivers/iio/pressure/t5403.c
@@ -209,7 +209,6 @@ static const struct iio_info t5403_info = {
209 .read_raw = &t5403_read_raw, 209 .read_raw = &t5403_read_raw,
210 .write_raw = &t5403_write_raw, 210 .write_raw = &t5403_write_raw,
211 .attrs = &t5403_attribute_group, 211 .attrs = &t5403_attribute_group,
212 .driver_module = THIS_MODULE,
213}; 212};
214 213
215static int t5403_probe(struct i2c_client *client, 214static int t5403_probe(struct i2c_client *client,
diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index ebfb1de7377f..81d8f24eaeb4 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -865,7 +865,6 @@ complete:
865static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev, 865static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
866 struct zpa2326_private *private) 866 struct zpa2326_private *private)
867{ 867{
868 int ret;
869 unsigned int val; 868 unsigned int val;
870 long timeout; 869 long timeout;
871 870
@@ -887,14 +886,11 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
887 /* Timed out. */ 886 /* Timed out. */
888 zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)", 887 zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
889 timeout); 888 timeout);
890 ret = -ETIME; 889 return -ETIME;
891 } else if (timeout < 0) {
892 zpa2326_warn(indio_dev,
893 "wait for one shot interrupt cancelled");
894 ret = -ERESTARTSYS;
895 } 890 }
896 891
897 return ret; 892 zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled");
893 return -ERESTARTSYS;
898} 894}
899 895
900static int zpa2326_init_managed_irq(struct device *parent, 896static int zpa2326_init_managed_irq(struct device *parent,
@@ -1394,7 +1390,6 @@ static int zpa2326_set_trigger_state(struct iio_trigger *trig, bool state)
1394} 1390}
1395 1391
1396static const struct iio_trigger_ops zpa2326_trigger_ops = { 1392static const struct iio_trigger_ops zpa2326_trigger_ops = {
1397 .owner = THIS_MODULE,
1398 .set_trigger_state = zpa2326_set_trigger_state, 1393 .set_trigger_state = zpa2326_set_trigger_state,
1399}; 1394};
1400 1395
@@ -1594,7 +1589,6 @@ static const struct iio_chan_spec zpa2326_channels[] = {
1594}; 1589};
1595 1590
1596static const struct iio_info zpa2326_info = { 1591static const struct iio_info zpa2326_info = {
1597 .driver_module = THIS_MODULE,
1598 .attrs = &zpa2326_attribute_group, 1592 .attrs = &zpa2326_attribute_group,
1599 .read_raw = zpa2326_read_raw, 1593 .read_raw = zpa2326_read_raw,
1600 .write_raw = zpa2326_write_raw, 1594 .write_raw = zpa2326_write_raw,
diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
index ae070950f920..fcb1c4ba5e41 100644
--- a/drivers/iio/proximity/Kconfig
+++ b/drivers/iio/proximity/Kconfig
@@ -32,6 +32,16 @@ config LIDAR_LITE_V2
32 To compile this driver as a module, choose M here: the 32 To compile this driver as a module, choose M here: the
33 module will be called pulsedlight-lite-v2 33 module will be called pulsedlight-lite-v2
34 34
35config RFD77402
36 tristate "RFD77402 ToF sensor"
37 depends on I2C
38 help
39 Say Y to build a driver for the RFD77420 Time-of-Flight (distance)
40 sensor module with I2C interface.
41
42 To compile this driver as a module, choose M here: the
43 module will be called rfd77402.
44
35config SRF04 45config SRF04
36 tristate "Devantech SRF04 ultrasonic ranger sensor" 46 tristate "Devantech SRF04 ultrasonic ranger sensor"
37 depends on GPIOLIB 47 depends on GPIOLIB
diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
index ed1b6f4cc209..1b195d84c611 100644
--- a/drivers/iio/proximity/Makefile
+++ b/drivers/iio/proximity/Makefile
@@ -5,6 +5,7 @@
5# When adding new entries keep the list in alphabetical order 5# When adding new entries keep the list in alphabetical order
6obj-$(CONFIG_AS3935) += as3935.o 6obj-$(CONFIG_AS3935) += as3935.o
7obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o 7obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o
8obj-$(CONFIG_RFD77402) += rfd77402.o
8obj-$(CONFIG_SRF04) += srf04.o 9obj-$(CONFIG_SRF04) += srf04.o
9obj-$(CONFIG_SRF08) += srf08.o 10obj-$(CONFIG_SRF08) += srf08.o
10obj-$(CONFIG_SX9500) += sx9500.o 11obj-$(CONFIG_SX9500) += sx9500.o
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index 0eeff29b61be..b6249af48014 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -39,8 +39,12 @@
39#define AS3935_AFE_GAIN_MAX 0x1F 39#define AS3935_AFE_GAIN_MAX 0x1F
40#define AS3935_AFE_PWR_BIT BIT(0) 40#define AS3935_AFE_PWR_BIT BIT(0)
41 41
42#define AS3935_NFLWDTH 0x01
43#define AS3935_NFLWDTH_MASK 0x7f
44
42#define AS3935_INT 0x03 45#define AS3935_INT 0x03
43#define AS3935_INT_MASK 0x0f 46#define AS3935_INT_MASK 0x0f
47#define AS3935_DISTURB_INT BIT(2)
44#define AS3935_EVENT_INT BIT(3) 48#define AS3935_EVENT_INT BIT(3)
45#define AS3935_NOISE_INT BIT(0) 49#define AS3935_NOISE_INT BIT(0)
46 50
@@ -48,6 +52,7 @@
48#define AS3935_DATA_MASK 0x3F 52#define AS3935_DATA_MASK 0x3F
49 53
50#define AS3935_TUNE_CAP 0x08 54#define AS3935_TUNE_CAP 0x08
55#define AS3935_DEFAULTS 0x3C
51#define AS3935_CALIBRATE 0x3D 56#define AS3935_CALIBRATE 0x3D
52 57
53#define AS3935_READ_DATA BIT(14) 58#define AS3935_READ_DATA BIT(14)
@@ -62,7 +67,9 @@ struct as3935_state {
62 struct mutex lock; 67 struct mutex lock;
63 struct delayed_work work; 68 struct delayed_work work;
64 69
70 unsigned long noise_tripped;
65 u32 tune_cap; 71 u32 tune_cap;
72 u32 nflwdth_reg;
66 u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */ 73 u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */
67 u8 buf[2] ____cacheline_aligned; 74 u8 buf[2] ____cacheline_aligned;
68}; 75};
@@ -145,12 +152,29 @@ static ssize_t as3935_sensor_sensitivity_store(struct device *dev,
145 return len; 152 return len;
146} 153}
147 154
155static ssize_t as3935_noise_level_tripped_show(struct device *dev,
156 struct device_attribute *attr,
157 char *buf)
158{
159 struct as3935_state *st = iio_priv(dev_to_iio_dev(dev));
160 int ret;
161
162 mutex_lock(&st->lock);
163 ret = sprintf(buf, "%d\n", !time_after(jiffies, st->noise_tripped + HZ));
164 mutex_unlock(&st->lock);
165
166 return ret;
167}
168
148static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR, 169static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR,
149 as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0); 170 as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0);
150 171
172static IIO_DEVICE_ATTR(noise_level_tripped, S_IRUGO,
173 as3935_noise_level_tripped_show, NULL, 0);
151 174
152static struct attribute *as3935_attributes[] = { 175static struct attribute *as3935_attributes[] = {
153 &iio_dev_attr_sensor_sensitivity.dev_attr.attr, 176 &iio_dev_attr_sensor_sensitivity.dev_attr.attr,
177 &iio_dev_attr_noise_level_tripped.dev_attr.attr,
154 NULL, 178 NULL,
155}; 179};
156 180
@@ -197,7 +221,6 @@ static int as3935_read_raw(struct iio_dev *indio_dev,
197} 221}
198 222
199static const struct iio_info as3935_info = { 223static const struct iio_info as3935_info = {
200 .driver_module = THIS_MODULE,
201 .attrs = &as3935_attribute_group, 224 .attrs = &as3935_attribute_group,
202 .read_raw = &as3935_read_raw, 225 .read_raw = &as3935_read_raw,
203}; 226};
@@ -223,7 +246,6 @@ err_read:
223} 246}
224 247
225static const struct iio_trigger_ops iio_interrupt_trigger_ops = { 248static const struct iio_trigger_ops iio_interrupt_trigger_ops = {
226 .owner = THIS_MODULE,
227}; 249};
228 250
229static void as3935_event_work(struct work_struct *work) 251static void as3935_event_work(struct work_struct *work)
@@ -246,7 +268,11 @@ static void as3935_event_work(struct work_struct *work)
246 case AS3935_EVENT_INT: 268 case AS3935_EVENT_INT:
247 iio_trigger_poll_chained(st->trig); 269 iio_trigger_poll_chained(st->trig);
248 break; 270 break;
271 case AS3935_DISTURB_INT:
249 case AS3935_NOISE_INT: 272 case AS3935_NOISE_INT:
273 mutex_lock(&st->lock);
274 st->noise_tripped = jiffies;
275 mutex_unlock(&st->lock);
250 dev_warn(&st->spi->dev, "noise level is too high\n"); 276 dev_warn(&st->spi->dev, "noise level is too high\n");
251 break; 277 break;
252 } 278 }
@@ -269,15 +295,14 @@ static irqreturn_t as3935_interrupt_handler(int irq, void *private)
269 295
270static void calibrate_as3935(struct as3935_state *st) 296static void calibrate_as3935(struct as3935_state *st)
271{ 297{
272 /* mask disturber interrupt bit */ 298 as3935_write(st, AS3935_DEFAULTS, 0x96);
273 as3935_write(st, AS3935_INT, BIT(5));
274
275 as3935_write(st, AS3935_CALIBRATE, 0x96); 299 as3935_write(st, AS3935_CALIBRATE, 0x96);
276 as3935_write(st, AS3935_TUNE_CAP, 300 as3935_write(st, AS3935_TUNE_CAP,
277 BIT(5) | (st->tune_cap / TUNE_CAP_DIV)); 301 BIT(5) | (st->tune_cap / TUNE_CAP_DIV));
278 302
279 mdelay(2); 303 mdelay(2);
280 as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); 304 as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV));
305 as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg);
281} 306}
282 307
283#ifdef CONFIG_PM_SLEEP 308#ifdef CONFIG_PM_SLEEP
@@ -370,6 +395,15 @@ static int as3935_probe(struct spi_device *spi)
370 return -EINVAL; 395 return -EINVAL;
371 } 396 }
372 397
398 ret = of_property_read_u32(np,
399 "ams,nflwdth", &st->nflwdth_reg);
400 if (!ret && st->nflwdth_reg > AS3935_NFLWDTH_MASK) {
401 dev_err(&spi->dev,
402 "invalid nflwdth setting of %d\n",
403 st->nflwdth_reg);
404 return -EINVAL;
405 }
406
373 indio_dev->dev.parent = &spi->dev; 407 indio_dev->dev.parent = &spi->dev;
374 indio_dev->name = spi_get_device_id(spi)->name; 408 indio_dev->name = spi_get_device_id(spi)->name;
375 indio_dev->channels = as3935_channels; 409 indio_dev->channels = as3935_channels;
@@ -384,6 +418,7 @@ static int as3935_probe(struct spi_device *spi)
384 return -ENOMEM; 418 return -ENOMEM;
385 419
386 st->trig = trig; 420 st->trig = trig;
421 st->noise_tripped = jiffies - HZ;
387 trig->dev.parent = indio_dev->dev.parent; 422 trig->dev.parent = indio_dev->dev.parent;
388 iio_trigger_set_drvdata(trig, indio_dev); 423 iio_trigger_set_drvdata(trig, indio_dev);
389 trig->ops = &iio_interrupt_trigger_ops; 424 trig->ops = &iio_interrupt_trigger_ops;
diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 36c1ddc251aa..4d56f67b24c6 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -249,7 +249,6 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
249} 249}
250 250
251static const struct iio_info lidar_info = { 251static const struct iio_info lidar_info = {
252 .driver_module = THIS_MODULE,
253 .read_raw = lidar_read_raw, 252 .read_raw = lidar_read_raw,
254}; 253};
255 254
diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77402.c
new file mode 100644
index 000000000000..fe29fb1a19a6
--- /dev/null
+++ b/drivers/iio/proximity/rfd77402.c
@@ -0,0 +1,352 @@
1/*
2 * rfd77402.c - Support for RF Digital RFD77402 Time-of-Flight (distance) sensor
3 *
4 * Copyright 2017 Peter Meerwald-Stadler <pmeerw@pmeerw.net>
5 *
6 * This file is subject to the terms and conditions of version 2 of
7 * the GNU General Public License. See the file COPYING in the main
8 * directory of this archive for more details.
9 *
10 * 7-bit I2C slave address 0x4c
11 *
12 * TODO: interrupt
13 * https://media.digikey.com/pdf/Data%20Sheets/RF%20Digital%20PDFs/RFD77402.pdf
14 */
15
16#include <linux/module.h>
17#include <linux/i2c.h>
18#include <linux/delay.h>
19
20#include <linux/iio/iio.h>
21
22#define RFD77402_DRV_NAME "rfd77402"
23
24#define RFD77402_ICSR 0x00 /* Interrupt Control Status Register */
25#define RFD77402_ICSR_INT_MODE BIT(2)
26#define RFD77402_ICSR_INT_POL BIT(3)
27#define RFD77402_ICSR_RESULT BIT(4)
28#define RFD77402_ICSR_M2H_MSG BIT(5)
29#define RFD77402_ICSR_H2M_MSG BIT(6)
30#define RFD77402_ICSR_RESET BIT(7)
31
32#define RFD77402_CMD_R 0x04
33#define RFD77402_CMD_SINGLE 0x01
34#define RFD77402_CMD_STANDBY 0x10
35#define RFD77402_CMD_MCPU_OFF 0x11
36#define RFD77402_CMD_MCPU_ON 0x12
37#define RFD77402_CMD_RESET BIT(6)
38#define RFD77402_CMD_VALID BIT(7)
39
40#define RFD77402_STATUS_R 0x06
41#define RFD77402_STATUS_PM_MASK GENMASK(4, 0)
42#define RFD77402_STATUS_STANDBY 0x00
43#define RFD77402_STATUS_MCPU_OFF 0x10
44#define RFD77402_STATUS_MCPU_ON 0x18
45
46#define RFD77402_RESULT_R 0x08
47#define RFD77402_RESULT_DIST_MASK GENMASK(12, 2)
48#define RFD77402_RESULT_ERR_MASK GENMASK(14, 13)
49#define RFD77402_RESULT_VALID BIT(15)
50
51#define RFD77402_PMU_CFG 0x14
52#define RFD77402_PMU_MCPU_INIT BIT(9)
53
54#define RFD77402_I2C_INIT_CFG 0x1c
55#define RFD77402_I2C_ADDR_INCR BIT(0)
56#define RFD77402_I2C_DATA_INCR BIT(2)
57#define RFD77402_I2C_HOST_DEBUG BIT(5)
58#define RFD77402_I2C_MCPU_DEBUG BIT(6)
59
60#define RFD77402_CMD_CFGR_A 0x0c
61#define RFD77402_CMD_CFGR_B 0x0e
62#define RFD77402_HFCFG_0 0x20
63#define RFD77402_HFCFG_1 0x22
64#define RFD77402_HFCFG_2 0x24
65#define RFD77402_HFCFG_3 0x26
66
67#define RFD77402_MOD_CHIP_ID 0x28
68
69/* magic configuration values from datasheet */
70static const struct {
71 u8 reg;
72 u16 val;
73} rf77402_tof_config[] = {
74 {RFD77402_CMD_CFGR_A, 0xe100},
75 {RFD77402_CMD_CFGR_B, 0x10ff},
76 {RFD77402_HFCFG_0, 0x07d0},
77 {RFD77402_HFCFG_1, 0x5008},
78 {RFD77402_HFCFG_2, 0xa041},
79 {RFD77402_HFCFG_3, 0x45d4},
80};
81
82struct rfd77402_data {
83 struct i2c_client *client;
84 /* Serialize reads from the sensor */
85 struct mutex lock;
86};
87
88static const struct iio_chan_spec rfd77402_channels[] = {
89 {
90 .type = IIO_DISTANCE,
91 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
92 BIT(IIO_CHAN_INFO_SCALE),
93 },
94};
95
96static int rfd77402_set_state(struct rfd77402_data *data, u8 state, u16 check)
97{
98 int ret;
99
100 ret = i2c_smbus_write_byte_data(data->client, RFD77402_CMD_R,
101 state | RFD77402_CMD_VALID);
102 if (ret < 0)
103 return ret;
104
105 usleep_range(10000, 20000);
106
107 ret = i2c_smbus_read_word_data(data->client, RFD77402_STATUS_R);
108 if (ret < 0)
109 return ret;
110 if ((ret & RFD77402_STATUS_PM_MASK) != check)
111 return -ENODEV;
112
113 return 0;
114}
115
116static int rfd77402_measure(struct rfd77402_data *data)
117{
118 int ret;
119 int tries = 10;
120
121 ret = rfd77402_set_state(data, RFD77402_CMD_MCPU_ON,
122 RFD77402_STATUS_MCPU_ON);
123 if (ret < 0)
124 return ret;
125
126 ret = i2c_smbus_write_byte_data(data->client, RFD77402_CMD_R,
127 RFD77402_CMD_SINGLE |
128 RFD77402_CMD_VALID);
129 if (ret < 0)
130 goto err;
131
132 while (tries-- > 0) {
133 ret = i2c_smbus_read_byte_data(data->client, RFD77402_ICSR);
134 if (ret < 0)
135 goto err;
136 if (ret & RFD77402_ICSR_RESULT)
137 break;
138 msleep(20);
139 }
140
141 if (tries < 0) {
142 ret = -ETIMEDOUT;
143 goto err;
144 }
145
146 ret = i2c_smbus_read_word_data(data->client, RFD77402_RESULT_R);
147 if (ret < 0)
148 goto err;
149
150 if ((ret & RFD77402_RESULT_ERR_MASK) ||
151 !(ret & RFD77402_RESULT_VALID)) {
152 ret = -EIO;
153 goto err;
154 }
155
156 return (ret & RFD77402_RESULT_DIST_MASK) >> 2;
157
158err:
159 rfd77402_set_state(data, RFD77402_CMD_MCPU_OFF,
160 RFD77402_STATUS_MCPU_OFF);
161 return ret;
162}
163
164static int rfd77402_read_raw(struct iio_dev *indio_dev,
165 struct iio_chan_spec const *chan,
166 int *val, int *val2, long mask)
167{
168 struct rfd77402_data *data = iio_priv(indio_dev);
169 int ret;
170
171 switch (mask) {
172 case IIO_CHAN_INFO_RAW:
173 mutex_lock(&data->lock);
174 ret = rfd77402_measure(data);
175 mutex_unlock(&data->lock);
176 if (ret < 0)
177 return ret;
178 *val = ret;
179 return IIO_VAL_INT;
180 case IIO_CHAN_INFO_SCALE:
181 /* 1 LSB is 1 mm */
182 *val = 0;
183 *val2 = 1000;
184 return IIO_VAL_INT_PLUS_MICRO;
185 default:
186 return -EINVAL;
187 }
188}
189
190static const struct iio_info rfd77402_info = {
191 .read_raw = rfd77402_read_raw,
192};
193
194static int rfd77402_init(struct rfd77402_data *data)
195{
196 int ret, i;
197
198 ret = rfd77402_set_state(data, RFD77402_CMD_STANDBY,
199 RFD77402_STATUS_STANDBY);
200 if (ret < 0)
201 return ret;
202
203 /* configure INT pad as push-pull, active low */
204 ret = i2c_smbus_write_byte_data(data->client, RFD77402_ICSR,
205 RFD77402_ICSR_INT_MODE);
206 if (ret < 0)
207 return ret;
208
209 /* I2C configuration */
210 ret = i2c_smbus_write_word_data(data->client, RFD77402_I2C_INIT_CFG,
211 RFD77402_I2C_ADDR_INCR |
212 RFD77402_I2C_DATA_INCR |
213 RFD77402_I2C_HOST_DEBUG |
214 RFD77402_I2C_MCPU_DEBUG);
215 if (ret < 0)
216 return ret;
217
218 /* set initialization */
219 ret = i2c_smbus_write_word_data(data->client, RFD77402_PMU_CFG, 0x0500);
220 if (ret < 0)
221 return ret;
222
223 ret = rfd77402_set_state(data, RFD77402_CMD_MCPU_OFF,
224 RFD77402_STATUS_MCPU_OFF);
225 if (ret < 0)
226 return ret;
227
228 /* set initialization */
229 ret = i2c_smbus_write_word_data(data->client, RFD77402_PMU_CFG, 0x0600);
230 if (ret < 0)
231 return ret;
232
233 ret = rfd77402_set_state(data, RFD77402_CMD_MCPU_ON,
234 RFD77402_STATUS_MCPU_ON);
235 if (ret < 0)
236 return ret;
237
238 for (i = 0; i < ARRAY_SIZE(rf77402_tof_config); i++) {
239 ret = i2c_smbus_write_word_data(data->client,
240 rf77402_tof_config[i].reg,
241 rf77402_tof_config[i].val);
242 if (ret < 0)
243 return ret;
244 }
245
246 ret = rfd77402_set_state(data, RFD77402_CMD_STANDBY,
247 RFD77402_STATUS_STANDBY);
248
249 return ret;
250}
251
252static int rfd77402_powerdown(struct rfd77402_data *data)
253{
254 return rfd77402_set_state(data, RFD77402_CMD_STANDBY,
255 RFD77402_STATUS_STANDBY);
256}
257
258static int rfd77402_probe(struct i2c_client *client,
259 const struct i2c_device_id *id)
260{
261 struct rfd77402_data *data;
262 struct iio_dev *indio_dev;
263 int ret;
264
265 ret = i2c_smbus_read_word_data(client, RFD77402_MOD_CHIP_ID);
266 if (ret < 0)
267 return ret;
268 if (ret != 0xad01 && ret != 0xad02) /* known chip ids */
269 return -ENODEV;
270
271 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
272 if (!indio_dev)
273 return -ENOMEM;
274
275 data = iio_priv(indio_dev);
276 i2c_set_clientdata(client, indio_dev);
277 data->client = client;
278 mutex_init(&data->lock);
279
280 indio_dev->dev.parent = &client->dev;
281 indio_dev->info = &rfd77402_info;
282 indio_dev->channels = rfd77402_channels;
283 indio_dev->num_channels = ARRAY_SIZE(rfd77402_channels);
284 indio_dev->name = RFD77402_DRV_NAME;
285 indio_dev->modes = INDIO_DIRECT_MODE;
286
287 ret = rfd77402_init(data);
288 if (ret < 0)
289 return ret;
290
291 ret = iio_device_register(indio_dev);
292 if (ret)
293 goto err_powerdown;
294
295 return 0;
296
297err_powerdown:
298 rfd77402_powerdown(data);
299 return ret;
300}
301
302static int rfd77402_remove(struct i2c_client *client)
303{
304 struct iio_dev *indio_dev = i2c_get_clientdata(client);
305
306 iio_device_unregister(indio_dev);
307 rfd77402_powerdown(iio_priv(indio_dev));
308
309 return 0;
310}
311
312#ifdef CONFIG_PM_SLEEP
313static int rfd77402_suspend(struct device *dev)
314{
315 struct rfd77402_data *data = iio_priv(i2c_get_clientdata(
316 to_i2c_client(dev)));
317
318 return rfd77402_powerdown(data);
319}
320
321static int rfd77402_resume(struct device *dev)
322{
323 struct rfd77402_data *data = iio_priv(i2c_get_clientdata(
324 to_i2c_client(dev)));
325
326 return rfd77402_init(data);
327}
328#endif
329
330static SIMPLE_DEV_PM_OPS(rfd77402_pm_ops, rfd77402_suspend, rfd77402_resume);
331
332static const struct i2c_device_id rfd77402_id[] = {
333 { "rfd77402", 0},
334 { }
335};
336MODULE_DEVICE_TABLE(i2c, rfd77402_id);
337
338static struct i2c_driver rfd77402_driver = {
339 .driver = {
340 .name = RFD77402_DRV_NAME,
341 .pm = &rfd77402_pm_ops,
342 },
343 .probe = rfd77402_probe,
344 .remove = rfd77402_remove,
345 .id_table = rfd77402_id,
346};
347
348module_i2c_driver(rfd77402_driver);
349
350MODULE_AUTHOR("Peter Meerwald-Stadler <pmeerw@pmeerw.net>");
351MODULE_DESCRIPTION("RFD77402 Time-of-Flight sensor driver");
352MODULE_LICENSE("GPL");
diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c
index e37667f933b3..09c7b9c095b0 100644
--- a/drivers/iio/proximity/srf04.c
+++ b/drivers/iio/proximity/srf04.c
@@ -203,7 +203,6 @@ static int srf04_read_raw(struct iio_dev *indio_dev,
203} 203}
204 204
205static const struct iio_info srf04_iio_info = { 205static const struct iio_info srf04_iio_info = {
206 .driver_module = THIS_MODULE,
207 .read_raw = srf04_read_raw, 206 .read_raw = srf04_read_raw,
208}; 207};
209 208
diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
index 9380d545aab1..f2bf783f829a 100644
--- a/drivers/iio/proximity/srf08.c
+++ b/drivers/iio/proximity/srf08.c
@@ -436,7 +436,6 @@ static const struct iio_chan_spec srf08_channels[] = {
436static const struct iio_info srf08_info = { 436static const struct iio_info srf08_info = {
437 .read_raw = srf08_read_raw, 437 .read_raw = srf08_read_raw,
438 .attrs = &srf08_attribute_group, 438 .attrs = &srf08_attribute_group,
439 .driver_module = THIS_MODULE,
440}; 439};
441 440
442/* 441/*
@@ -445,7 +444,6 @@ static const struct iio_info srf08_info = {
445 */ 444 */
446static const struct iio_info srf02_info = { 445static const struct iio_info srf02_info = {
447 .read_raw = srf08_read_raw, 446 .read_raw = srf08_read_raw,
448 .driver_module = THIS_MODULE,
449}; 447};
450 448
451static int srf08_probe(struct i2c_client *client, 449static int srf08_probe(struct i2c_client *client,
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index f42b3a1c75ff..53c5d653e780 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -615,7 +615,6 @@ static const struct attribute_group sx9500_attribute_group = {
615}; 615};
616 616
617static const struct iio_info sx9500_info = { 617static const struct iio_info sx9500_info = {
618 .driver_module = THIS_MODULE,
619 .attrs = &sx9500_attribute_group, 618 .attrs = &sx9500_attribute_group,
620 .read_raw = &sx9500_read_raw, 619 .read_raw = &sx9500_read_raw,
621 .write_raw = &sx9500_write_raw, 620 .write_raw = &sx9500_write_raw,
@@ -650,7 +649,6 @@ out:
650 649
651static const struct iio_trigger_ops sx9500_trigger_ops = { 650static const struct iio_trigger_ops sx9500_trigger_ops = {
652 .set_trigger_state = sx9500_set_trigger_state, 651 .set_trigger_state = sx9500_set_trigger_state,
653 .owner = THIS_MODULE,
654}; 652};
655 653
656static irqreturn_t sx9500_trigger_handler(int irq, void *private) 654static irqreturn_t sx9500_trigger_handler(int irq, void *private)
diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
index c01efeca4002..beaf6fd3e337 100644
--- a/drivers/iio/temperature/hid-sensor-temperature.c
+++ b/drivers/iio/temperature/hid-sensor-temperature.c
@@ -123,7 +123,6 @@ static int temperature_write_raw(struct iio_dev *indio_dev,
123} 123}
124 124
125static const struct iio_info temperature_info = { 125static const struct iio_info temperature_info = {
126 .driver_module = THIS_MODULE,
127 .read_raw = &temperature_read_raw, 126 .read_raw = &temperature_read_raw,
128 .write_raw = &temperature_write_raw, 127 .write_raw = &temperature_write_raw,
129}; 128};
diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c
index d70e2e53d6a7..e8b7e0b6c8ad 100644
--- a/drivers/iio/temperature/maxim_thermocouple.c
+++ b/drivers/iio/temperature/maxim_thermocouple.c
@@ -208,7 +208,6 @@ static int maxim_thermocouple_read_raw(struct iio_dev *indio_dev,
208} 208}
209 209
210static const struct iio_info maxim_thermocouple_info = { 210static const struct iio_info maxim_thermocouple_info = {
211 .driver_module = THIS_MODULE,
212 .read_raw = maxim_thermocouple_read_raw, 211 .read_raw = maxim_thermocouple_read_raw,
213}; 212};
214 213
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index 2077eef4095c..d619e8634a00 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -400,7 +400,6 @@ static const struct iio_info mlx90614_info = {
400 .write_raw = mlx90614_write_raw, 400 .write_raw = mlx90614_write_raw,
401 .write_raw_get_fmt = mlx90614_write_raw_get_fmt, 401 .write_raw_get_fmt = mlx90614_write_raw_get_fmt,
402 .attrs = &mlx90614_attr_group, 402 .attrs = &mlx90614_attr_group,
403 .driver_module = THIS_MODULE,
404}; 403};
405 404
406#ifdef CONFIG_PM 405#ifdef CONFIG_PM
diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index 18c9b43c02cb..a9b5b7cc7836 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -179,7 +179,6 @@ static const struct iio_info tmp006_info = {
179 .read_raw = tmp006_read_raw, 179 .read_raw = tmp006_read_raw,
180 .write_raw = tmp006_write_raw, 180 .write_raw = tmp006_write_raw,
181 .attrs = &tmp006_attribute_group, 181 .attrs = &tmp006_attribute_group,
182 .driver_module = THIS_MODULE,
183}; 182};
184 183
185static bool tmp006_check_identification(struct i2c_client *client) 184static bool tmp006_check_identification(struct i2c_client *client)
diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
index 0615324d054c..0e3f2d432e10 100644
--- a/drivers/iio/temperature/tmp007.c
+++ b/drivers/iio/temperature/tmp007.c
@@ -426,7 +426,6 @@ static const struct iio_info tmp007_info = {
426 .read_event_value = tmp007_read_thresh, 426 .read_event_value = tmp007_read_thresh,
427 .write_event_value = tmp007_write_thresh, 427 .write_event_value = tmp007_write_thresh,
428 .attrs = &tmp007_attribute_group, 428 .attrs = &tmp007_attribute_group,
429 .driver_module = THIS_MODULE,
430}; 429};
431 430
432static bool tmp007_identify(struct i2c_client *client) 431static bool tmp007_identify(struct i2c_client *client)
diff --git a/drivers/iio/temperature/tsys01.c b/drivers/iio/temperature/tsys01.c
index d8aa211d76e4..3799d007c8e7 100644
--- a/drivers/iio/temperature/tsys01.c
+++ b/drivers/iio/temperature/tsys01.c
@@ -111,7 +111,6 @@ static const struct iio_chan_spec tsys01_channels[] = {
111 111
112static const struct iio_info tsys01_info = { 112static const struct iio_info tsys01_info = {
113 .read_raw = tsys01_read_raw, 113 .read_raw = tsys01_read_raw,
114 .driver_module = THIS_MODULE,
115}; 114};
116 115
117static bool tsys01_crc_valid(u16 *n_prom) 116static bool tsys01_crc_valid(u16 *n_prom)
diff --git a/drivers/iio/temperature/tsys02d.c b/drivers/iio/temperature/tsys02d.c
index c0a19a000387..9b2e56fa5fd5 100644
--- a/drivers/iio/temperature/tsys02d.c
+++ b/drivers/iio/temperature/tsys02d.c
@@ -120,7 +120,6 @@ static const struct iio_info tsys02d_info = {
120 .read_raw = tsys02d_read_raw, 120 .read_raw = tsys02d_read_raw,
121 .write_raw = tsys02d_write_raw, 121 .write_raw = tsys02d_write_raw,
122 .attrs = &tsys02d_attribute_group, 122 .attrs = &tsys02d_attribute_group,
123 .driver_module = THIS_MODULE,
124}; 123};
125 124
126static int tsys02d_probe(struct i2c_client *client, 125static int tsys02d_probe(struct i2c_client *client,
diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c
index a1cad6cc2e0f..3ee92160053f 100644
--- a/drivers/iio/trigger/iio-trig-hrtimer.c
+++ b/drivers/iio/trigger/iio-trig-hrtimer.c
@@ -114,7 +114,6 @@ static int iio_trig_hrtimer_set_state(struct iio_trigger *trig, bool state)
114} 114}
115 115
116static const struct iio_trigger_ops iio_hrtimer_trigger_ops = { 116static const struct iio_trigger_ops iio_hrtimer_trigger_ops = {
117 .owner = THIS_MODULE,
118 .set_trigger_state = iio_trig_hrtimer_set_state, 117 .set_trigger_state = iio_trig_hrtimer_set_state,
119}; 118};
120 119
diff --git a/drivers/iio/trigger/iio-trig-interrupt.c b/drivers/iio/trigger/iio-trig-interrupt.c
index e18f12b74610..171c4ed03543 100644
--- a/drivers/iio/trigger/iio-trig-interrupt.c
+++ b/drivers/iio/trigger/iio-trig-interrupt.c
@@ -29,7 +29,6 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private)
29} 29}
30 30
31static const struct iio_trigger_ops iio_interrupt_trigger_ops = { 31static const struct iio_trigger_ops iio_interrupt_trigger_ops = {
32 .owner = THIS_MODULE,
33}; 32};
34 33
35static int iio_interrupt_trigger_probe(struct platform_device *pdev) 34static int iio_interrupt_trigger_probe(struct platform_device *pdev)
diff --git a/drivers/iio/trigger/iio-trig-loop.c b/drivers/iio/trigger/iio-trig-loop.c
index dc6be28f96fe..b4b02dbd6e8a 100644
--- a/drivers/iio/trigger/iio-trig-loop.c
+++ b/drivers/iio/trigger/iio-trig-loop.c
@@ -74,7 +74,6 @@ static int iio_loop_trigger_set_state(struct iio_trigger *trig, bool state)
74 74
75static const struct iio_trigger_ops iio_loop_trigger_ops = { 75static const struct iio_trigger_ops iio_loop_trigger_ops = {
76 .set_trigger_state = iio_loop_trigger_set_state, 76 .set_trigger_state = iio_loop_trigger_set_state,
77 .owner = THIS_MODULE,
78}; 77};
79 78
80static struct iio_sw_trigger *iio_trig_loop_probe(const char *name) 79static struct iio_sw_trigger *iio_trig_loop_probe(const char *name)
diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c
index 202e8b89caf2..3f0dc9a1a514 100644
--- a/drivers/iio/trigger/iio-trig-sysfs.c
+++ b/drivers/iio/trigger/iio-trig-sysfs.c
@@ -127,7 +127,6 @@ static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = {
127}; 127};
128 128
129static const struct iio_trigger_ops iio_sysfs_trigger_ops = { 129static const struct iio_trigger_ops iio_sysfs_trigger_ops = {
130 .owner = THIS_MODULE,
131}; 130};
132 131
133static int iio_sysfs_trigger_probe(int id) 132static int iio_sysfs_trigger_probe(int id)
diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
index 241eae6a4306..de361d879929 100644
--- a/drivers/iio/trigger/stm32-lptimer-trigger.c
+++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
@@ -37,7 +37,6 @@ static int stm32_lptim_validate_device(struct iio_trigger *trig,
37} 37}
38 38
39static const struct iio_trigger_ops stm32_lptim_trigger_ops = { 39static const struct iio_trigger_ops stm32_lptim_trigger_ops = {
40 .owner = THIS_MODULE,
41 .validate_device = stm32_lptim_validate_device, 40 .validate_device = stm32_lptim_validate_device,
42}; 41};
43 42
diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
index eb212f8c8879..b542dc484969 100644
--- a/drivers/iio/trigger/stm32-timer-trigger.c
+++ b/drivers/iio/trigger/stm32-timer-trigger.c
@@ -355,7 +355,6 @@ static const struct attribute_group *stm32_trigger_attr_groups[] = {
355}; 355};
356 356
357static const struct iio_trigger_ops timer_trigger_ops = { 357static const struct iio_trigger_ops timer_trigger_ops = {
358 .owner = THIS_MODULE,
359}; 358};
360 359
361static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv) 360static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
@@ -493,7 +492,6 @@ static int stm32_counter_validate_trigger(struct iio_dev *indio_dev,
493} 492}
494 493
495static const struct iio_info stm32_trigger_info = { 494static const struct iio_info stm32_trigger_info = {
496 .driver_module = THIS_MODULE,
497 .validate_trigger = stm32_counter_validate_trigger, 495 .validate_trigger = stm32_counter_validate_trigger,
498 .read_raw = stm32_counter_read_raw, 496 .read_raw = stm32_counter_read_raw,
499 .write_raw = stm32_counter_write_raw 497 .write_raw = stm32_counter_write_raw
diff --git a/drivers/input/input.c b/drivers/input/input.c
index d268fdc23c64..762bfb9487dc 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -933,58 +933,52 @@ int input_set_keycode(struct input_dev *dev,
933} 933}
934EXPORT_SYMBOL(input_set_keycode); 934EXPORT_SYMBOL(input_set_keycode);
935 935
936bool input_match_device_id(const struct input_dev *dev,
937 const struct input_device_id *id)
938{
939 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
940 if (id->bustype != dev->id.bustype)
941 return false;
942
943 if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
944 if (id->vendor != dev->id.vendor)
945 return false;
946
947 if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
948 if (id->product != dev->id.product)
949 return false;
950
951 if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
952 if (id->version != dev->id.version)
953 return false;
954
955 if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX) ||
956 !bitmap_subset(id->keybit, dev->keybit, KEY_MAX) ||
957 !bitmap_subset(id->relbit, dev->relbit, REL_MAX) ||
958 !bitmap_subset(id->absbit, dev->absbit, ABS_MAX) ||
959 !bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX) ||
960 !bitmap_subset(id->ledbit, dev->ledbit, LED_MAX) ||
961 !bitmap_subset(id->sndbit, dev->sndbit, SND_MAX) ||
962 !bitmap_subset(id->ffbit, dev->ffbit, FF_MAX) ||
963 !bitmap_subset(id->swbit, dev->swbit, SW_MAX) ||
964 !bitmap_subset(id->propbit, dev->propbit, INPUT_PROP_MAX)) {
965 return false;
966 }
967
968 return true;
969}
970EXPORT_SYMBOL(input_match_device_id);
971
936static const struct input_device_id *input_match_device(struct input_handler *handler, 972static const struct input_device_id *input_match_device(struct input_handler *handler,
937 struct input_dev *dev) 973 struct input_dev *dev)
938{ 974{
939 const struct input_device_id *id; 975 const struct input_device_id *id;
940 976
941 for (id = handler->id_table; id->flags || id->driver_info; id++) { 977 for (id = handler->id_table; id->flags || id->driver_info; id++) {
942 978 if (input_match_device_id(dev, id) &&
943 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 979 (!handler->match || handler->match(handler, dev))) {
944 if (id->bustype != dev->id.bustype)
945 continue;
946
947 if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
948 if (id->vendor != dev->id.vendor)
949 continue;
950
951 if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
952 if (id->product != dev->id.product)
953 continue;
954
955 if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
956 if (id->version != dev->id.version)
957 continue;
958
959 if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX))
960 continue;
961
962 if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX))
963 continue;
964
965 if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX))
966 continue;
967
968 if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX))
969 continue;
970
971 if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX))
972 continue;
973
974 if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX))
975 continue;
976
977 if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX))
978 continue;
979
980 if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX))
981 continue;
982
983 if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX))
984 continue;
985
986 if (!handler->match || handler->match(handler, dev))
987 return id; 980 return id;
981 }
988 } 982 }
989 983
990 return NULL; 984 return NULL;
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 29d677c714d2..7b29a8944039 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -747,6 +747,68 @@ static void joydev_cleanup(struct joydev *joydev)
747 input_close_device(handle); 747 input_close_device(handle);
748} 748}
749 749
750/*
751 * These codes are copied from from hid-ids.h, unfortunately there is no common
752 * usb_ids/bt_ids.h header.
753 */
754#define USB_VENDOR_ID_SONY 0x054c
755#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
756#define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4
757#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 0x09cc
758#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE 0x0ba0
759
760#define USB_VENDOR_ID_THQ 0x20d6
761#define USB_DEVICE_ID_THQ_PS3_UDRAW 0xcb17
762
763#define ACCEL_DEV(vnd, prd) \
764 { \
765 .flags = INPUT_DEVICE_ID_MATCH_VENDOR | \
766 INPUT_DEVICE_ID_MATCH_PRODUCT | \
767 INPUT_DEVICE_ID_MATCH_PROPBIT, \
768 .vendor = (vnd), \
769 .product = (prd), \
770 .propbit = { BIT_MASK(INPUT_PROP_ACCELEROMETER) }, \
771 }
772
773static const struct input_device_id joydev_blacklist[] = {
774 /* Avoid touchpads and touchscreens */
775 {
776 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
777 INPUT_DEVICE_ID_MATCH_KEYBIT,
778 .evbit = { BIT_MASK(EV_KEY) },
779 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
780 },
781 /* Avoid tablets, digitisers and similar devices */
782 {
783 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
784 INPUT_DEVICE_ID_MATCH_KEYBIT,
785 .evbit = { BIT_MASK(EV_KEY) },
786 .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) },
787 },
788 /* Disable accelerometers on composite devices */
789 ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
790 ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
791 ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2),
792 ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE),
793 ACCEL_DEV(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW),
794 { /* sentinel */ }
795};
796
797static bool joydev_dev_is_blacklisted(struct input_dev *dev)
798{
799 const struct input_device_id *id;
800
801 for (id = joydev_blacklist; id->flags; id++) {
802 if (input_match_device_id(dev, id)) {
803 dev_dbg(&dev->dev,
804 "joydev: blacklisting '%s'\n", dev->name);
805 return true;
806 }
807 }
808
809 return false;
810}
811
750static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) 812static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
751{ 813{
752 DECLARE_BITMAP(jd_scratch, KEY_CNT); 814 DECLARE_BITMAP(jd_scratch, KEY_CNT);
@@ -807,12 +869,8 @@ static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
807 869
808static bool joydev_match(struct input_handler *handler, struct input_dev *dev) 870static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
809{ 871{
810 /* Avoid touchpads and touchscreens */ 872 /* Disable blacklisted devices */
811 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit)) 873 if (joydev_dev_is_blacklisted(dev))
812 return false;
813
814 /* Avoid tablets, digitisers and similar devices */
815 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit))
816 return false; 874 return false;
817 875
818 /* Avoid absolute mice */ 876 /* Avoid absolute mice */
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
index e37e335e406f..6da607d3b811 100644
--- a/drivers/input/keyboard/tca8418_keypad.c
+++ b/drivers/input/keyboard/tca8418_keypad.c
@@ -234,14 +234,7 @@ static irqreturn_t tca8418_irq_handler(int irq, void *dev_id)
234static int tca8418_configure(struct tca8418_keypad *keypad_data, 234static int tca8418_configure(struct tca8418_keypad *keypad_data,
235 u32 rows, u32 cols) 235 u32 rows, u32 cols)
236{ 236{
237 int reg, error; 237 int reg, error = 0;
238
239 /* Write config register, if this fails assume device not present */
240 error = tca8418_write_byte(keypad_data, REG_CFG,
241 CFG_INT_CFG | CFG_OVR_FLOW_IEN | CFG_KE_IEN);
242 if (error < 0)
243 return -ENODEV;
244
245 238
246 /* Assemble a mask for row and column registers */ 239 /* Assemble a mask for row and column registers */
247 reg = ~(~0 << rows); 240 reg = ~(~0 << rows);
@@ -257,6 +250,12 @@ static int tca8418_configure(struct tca8418_keypad *keypad_data,
257 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS2, reg >> 8); 250 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS2, reg >> 8);
258 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS3, reg >> 16); 251 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS3, reg >> 16);
259 252
253 if (error)
254 return error;
255
256 error = tca8418_write_byte(keypad_data, REG_CFG,
257 CFG_INT_CFG | CFG_OVR_FLOW_IEN | CFG_KE_IEN);
258
260 return error; 259 return error;
261} 260}
262 261
@@ -268,6 +267,7 @@ static int tca8418_keypad_probe(struct i2c_client *client,
268 struct input_dev *input; 267 struct input_dev *input;
269 u32 rows = 0, cols = 0; 268 u32 rows = 0, cols = 0;
270 int error, row_shift, max_keys; 269 int error, row_shift, max_keys;
270 u8 reg;
271 271
272 /* Check i2c driver capabilities */ 272 /* Check i2c driver capabilities */
273 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 273 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
@@ -301,10 +301,10 @@ static int tca8418_keypad_probe(struct i2c_client *client,
301 keypad_data->client = client; 301 keypad_data->client = client;
302 keypad_data->row_shift = row_shift; 302 keypad_data->row_shift = row_shift;
303 303
304 /* Initialize the chip or fail if chip isn't present */ 304 /* Read key lock register, if this fails assume device not present */
305 error = tca8418_configure(keypad_data, rows, cols); 305 error = tca8418_read_byte(keypad_data, REG_KEY_LCK_EC, &reg);
306 if (error < 0) 306 if (error)
307 return error; 307 return -ENODEV;
308 308
309 /* Configure input device */ 309 /* Configure input device */
310 input = devm_input_allocate_device(dev); 310 input = devm_input_allocate_device(dev);
@@ -340,6 +340,11 @@ static int tca8418_keypad_probe(struct i2c_client *client,
340 return error; 340 return error;
341 } 341 }
342 342
343 /* Initialize the chip */
344 error = tca8418_configure(keypad_data, rows, cols);
345 if (error < 0)
346 return error;
347
343 error = input_register_device(input); 348 error = input_register_device(input);
344 if (error) { 349 if (error) {
345 dev_err(dev, "Unable to register input device, error: %d\n", 350 dev_err(dev, "Unable to register input device, error: %d\n",
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 6cee5adc3b5c..debeeaeb8812 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -403,6 +403,7 @@ static const struct platform_device_id axp_pek_id_match[] = {
403 }, 403 },
404 { /* sentinel */ } 404 { /* sentinel */ }
405}; 405};
406MODULE_DEVICE_TABLE(platform, axp_pek_id_match);
406 407
407static struct platform_driver axp20x_pek_driver = { 408static struct platform_driver axp20x_pek_driver = {
408 .probe = axp20x_pek_probe, 409 .probe = axp20x_pek_probe,
@@ -417,4 +418,3 @@ module_platform_driver(axp20x_pek_driver);
417MODULE_DESCRIPTION("axp20x Power Button"); 418MODULE_DESCRIPTION("axp20x Power Button");
418MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); 419MODULE_AUTHOR("Carlo Caione <carlo@caione.org>");
419MODULE_LICENSE("GPL"); 420MODULE_LICENSE("GPL");
420MODULE_ALIAS("platform:axp20x-pek");
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 6bf82ea8c918..ae473123583b 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1635,13 +1635,25 @@ ims_pcu_get_cdc_union_desc(struct usb_interface *intf)
1635 return NULL; 1635 return NULL;
1636 } 1636 }
1637 1637
1638 while (buflen > 0) { 1638 while (buflen >= sizeof(*union_desc)) {
1639 union_desc = (struct usb_cdc_union_desc *)buf; 1639 union_desc = (struct usb_cdc_union_desc *)buf;
1640 1640
1641 if (union_desc->bLength > buflen) {
1642 dev_err(&intf->dev, "Too large descriptor\n");
1643 return NULL;
1644 }
1645
1641 if (union_desc->bDescriptorType == USB_DT_CS_INTERFACE && 1646 if (union_desc->bDescriptorType == USB_DT_CS_INTERFACE &&
1642 union_desc->bDescriptorSubType == USB_CDC_UNION_TYPE) { 1647 union_desc->bDescriptorSubType == USB_CDC_UNION_TYPE) {
1643 dev_dbg(&intf->dev, "Found union header\n"); 1648 dev_dbg(&intf->dev, "Found union header\n");
1644 return union_desc; 1649
1650 if (union_desc->bLength >= sizeof(*union_desc))
1651 return union_desc;
1652
1653 dev_err(&intf->dev,
1654 "Union descriptor to short (%d vs %zd\n)",
1655 union_desc->bLength, sizeof(*union_desc));
1656 return NULL;
1645 } 1657 }
1646 1658
1647 buflen -= union_desc->bLength; 1659 buflen -= union_desc->bLength;
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 5af0b7d200bc..ee5466a374bf 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -1709,8 +1709,7 @@ static int synaptics_create_intertouch(struct psmouse *psmouse,
1709 .sensor_pdata = { 1709 .sensor_pdata = {
1710 .sensor_type = rmi_sensor_touchpad, 1710 .sensor_type = rmi_sensor_touchpad,
1711 .axis_align.flip_y = true, 1711 .axis_align.flip_y = true,
1712 /* to prevent cursors jumps: */ 1712 .kernel_tracking = false,
1713 .kernel_tracking = true,
1714 .topbuttonpad = topbuttonpad, 1713 .topbuttonpad = topbuttonpad,
1715 }, 1714 },
1716 .f30_data = { 1715 .f30_data = {
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 32d2762448aa..b3bbad7d2282 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -72,6 +72,9 @@ struct goodix_ts_data {
72#define GOODIX_REG_CONFIG_DATA 0x8047 72#define GOODIX_REG_CONFIG_DATA 0x8047
73#define GOODIX_REG_ID 0x8140 73#define GOODIX_REG_ID 0x8140
74 74
75#define GOODIX_BUFFER_STATUS_READY BIT(7)
76#define GOODIX_BUFFER_STATUS_TIMEOUT 20
77
75#define RESOLUTION_LOC 1 78#define RESOLUTION_LOC 1
76#define MAX_CONTACTS_LOC 5 79#define MAX_CONTACTS_LOC 5
77#define TRIGGER_LOC 6 80#define TRIGGER_LOC 6
@@ -195,35 +198,53 @@ static int goodix_get_cfg_len(u16 id)
195 198
196static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) 199static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
197{ 200{
201 unsigned long max_timeout;
198 int touch_num; 202 int touch_num;
199 int error; 203 int error;
200 204
201 error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR, data, 205 /*
202 GOODIX_CONTACT_SIZE + 1); 206 * The 'buffer status' bit, which indicates that the data is valid, is
203 if (error) { 207 * not set as soon as the interrupt is raised, but slightly after.
204 dev_err(&ts->client->dev, "I2C transfer error: %d\n", error); 208 * This takes around 10 ms to happen, so we poll for 20 ms.
205 return error; 209 */
206 } 210 max_timeout = jiffies + msecs_to_jiffies(GOODIX_BUFFER_STATUS_TIMEOUT);
211 do {
212 error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR,
213 data, GOODIX_CONTACT_SIZE + 1);
214 if (error) {
215 dev_err(&ts->client->dev, "I2C transfer error: %d\n",
216 error);
217 return error;
218 }
207 219
208 if (!(data[0] & 0x80)) 220 if (data[0] & GOODIX_BUFFER_STATUS_READY) {
209 return -EAGAIN; 221 touch_num = data[0] & 0x0f;
222 if (touch_num > ts->max_touch_num)
223 return -EPROTO;
224
225 if (touch_num > 1) {
226 data += 1 + GOODIX_CONTACT_SIZE;
227 error = goodix_i2c_read(ts->client,
228 GOODIX_READ_COOR_ADDR +
229 1 + GOODIX_CONTACT_SIZE,
230 data,
231 GOODIX_CONTACT_SIZE *
232 (touch_num - 1));
233 if (error)
234 return error;
235 }
236
237 return touch_num;
238 }
210 239
211 touch_num = data[0] & 0x0f; 240 usleep_range(1000, 2000); /* Poll every 1 - 2 ms */
212 if (touch_num > ts->max_touch_num) 241 } while (time_before(jiffies, max_timeout));
213 return -EPROTO;
214
215 if (touch_num > 1) {
216 data += 1 + GOODIX_CONTACT_SIZE;
217 error = goodix_i2c_read(ts->client,
218 GOODIX_READ_COOR_ADDR +
219 1 + GOODIX_CONTACT_SIZE,
220 data,
221 GOODIX_CONTACT_SIZE * (touch_num - 1));
222 if (error)
223 return error;
224 }
225 242
226 return touch_num; 243 /*
244 * The Goodix panel will send spurious interrupts after a
245 * 'finger up' event, which will always cause a timeout.
246 */
247 return 0;
227} 248}
228 249
229static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) 250static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index 157fdb4bb2e8..8c6c6178ec12 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -663,12 +663,10 @@ static int stmfts_probe(struct i2c_client *client,
663 sdata->input->open = stmfts_input_open; 663 sdata->input->open = stmfts_input_open;
664 sdata->input->close = stmfts_input_close; 664 sdata->input->close = stmfts_input_close;
665 665
666 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_X);
667 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_Y);
666 touchscreen_parse_properties(sdata->input, true, &sdata->prop); 668 touchscreen_parse_properties(sdata->input, true, &sdata->prop);
667 669
668 input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0,
669 sdata->prop.max_x, 0, 0);
670 input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0,
671 sdata->prop.max_y, 0, 0);
672 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 670 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
673 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); 671 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0);
674 input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0); 672 input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0);
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 7953381d939a..f1043ae71dcc 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -161,7 +161,7 @@ static void titsc_step_config(struct titsc *ts_dev)
161 break; 161 break;
162 case 5: 162 case 5:
163 config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 | 163 config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 |
164 ts_dev->bit_xn | ts_dev->bit_yp; 164 STEPCONFIG_XNP | STEPCONFIG_YPN;
165 break; 165 break;
166 case 8: 166 case 8:
167 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp); 167 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp);
diff --git a/drivers/input/touchscreen/tsc2007_iio.c b/drivers/input/touchscreen/tsc2007_iio.c
index 27b25a9fce83..e27a956f5f2b 100644
--- a/drivers/input/touchscreen/tsc2007_iio.c
+++ b/drivers/input/touchscreen/tsc2007_iio.c
@@ -104,7 +104,6 @@ static int tsc2007_read_raw(struct iio_dev *indio_dev,
104 104
105static const struct iio_info tsc2007_iio_info = { 105static const struct iio_info tsc2007_iio_info = {
106 .read_raw = tsc2007_read_raw, 106 .read_raw = tsc2007_read_raw,
107 .driver_module = THIS_MODULE,
108}; 107};
109 108
110int tsc2007_iio_configure(struct tsc2007 *ts) 109int tsc2007_iio_configure(struct tsc2007 *ts)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index e8d89343d613..e88395605e32 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -107,6 +107,10 @@ struct its_node {
107 107
108#define ITS_ITT_ALIGN SZ_256 108#define ITS_ITT_ALIGN SZ_256
109 109
110/* The maximum number of VPEID bits supported by VLPI commands */
111#define ITS_MAX_VPEID_BITS (16)
112#define ITS_MAX_VPEID (1 << (ITS_MAX_VPEID_BITS))
113
110/* Convert page order to size in bytes */ 114/* Convert page order to size in bytes */
111#define PAGE_ORDER_TO_SIZE(o) (PAGE_SIZE << (o)) 115#define PAGE_ORDER_TO_SIZE(o) (PAGE_SIZE << (o))
112 116
@@ -308,7 +312,7 @@ static void its_encode_size(struct its_cmd_block *cmd, u8 size)
308 312
309static void its_encode_itt(struct its_cmd_block *cmd, u64 itt_addr) 313static void its_encode_itt(struct its_cmd_block *cmd, u64 itt_addr)
310{ 314{
311 its_mask_encode(&cmd->raw_cmd[2], itt_addr >> 8, 50, 8); 315 its_mask_encode(&cmd->raw_cmd[2], itt_addr >> 8, 51, 8);
312} 316}
313 317
314static void its_encode_valid(struct its_cmd_block *cmd, int valid) 318static void its_encode_valid(struct its_cmd_block *cmd, int valid)
@@ -318,7 +322,7 @@ static void its_encode_valid(struct its_cmd_block *cmd, int valid)
318 322
319static void its_encode_target(struct its_cmd_block *cmd, u64 target_addr) 323static void its_encode_target(struct its_cmd_block *cmd, u64 target_addr)
320{ 324{
321 its_mask_encode(&cmd->raw_cmd[2], target_addr >> 16, 50, 16); 325 its_mask_encode(&cmd->raw_cmd[2], target_addr >> 16, 51, 16);
322} 326}
323 327
324static void its_encode_collection(struct its_cmd_block *cmd, u16 col) 328static void its_encode_collection(struct its_cmd_block *cmd, u16 col)
@@ -358,7 +362,7 @@ static void its_encode_its_list(struct its_cmd_block *cmd, u16 its_list)
358 362
359static void its_encode_vpt_addr(struct its_cmd_block *cmd, u64 vpt_pa) 363static void its_encode_vpt_addr(struct its_cmd_block *cmd, u64 vpt_pa)
360{ 364{
361 its_mask_encode(&cmd->raw_cmd[3], vpt_pa >> 16, 50, 16); 365 its_mask_encode(&cmd->raw_cmd[3], vpt_pa >> 16, 51, 16);
362} 366}
363 367
364static void its_encode_vpt_size(struct its_cmd_block *cmd, u8 vpt_size) 368static void its_encode_vpt_size(struct its_cmd_block *cmd, u8 vpt_size)
@@ -1478,9 +1482,9 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
1478 u64 val = its_read_baser(its, baser); 1482 u64 val = its_read_baser(its, baser);
1479 u64 esz = GITS_BASER_ENTRY_SIZE(val); 1483 u64 esz = GITS_BASER_ENTRY_SIZE(val);
1480 u64 type = GITS_BASER_TYPE(val); 1484 u64 type = GITS_BASER_TYPE(val);
1485 u64 baser_phys, tmp;
1481 u32 alloc_pages; 1486 u32 alloc_pages;
1482 void *base; 1487 void *base;
1483 u64 tmp;
1484 1488
1485retry_alloc_baser: 1489retry_alloc_baser:
1486 alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz); 1490 alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
@@ -1496,8 +1500,24 @@ retry_alloc_baser:
1496 if (!base) 1500 if (!base)
1497 return -ENOMEM; 1501 return -ENOMEM;
1498 1502
1503 baser_phys = virt_to_phys(base);
1504
1505 /* Check if the physical address of the memory is above 48bits */
1506 if (IS_ENABLED(CONFIG_ARM64_64K_PAGES) && (baser_phys >> 48)) {
1507
1508 /* 52bit PA is supported only when PageSize=64K */
1509 if (psz != SZ_64K) {
1510 pr_err("ITS: no 52bit PA support when psz=%d\n", psz);
1511 free_pages((unsigned long)base, order);
1512 return -ENXIO;
1513 }
1514
1515 /* Convert 52bit PA to 48bit field */
1516 baser_phys = GITS_BASER_PHYS_52_to_48(baser_phys);
1517 }
1518
1499retry_baser: 1519retry_baser:
1500 val = (virt_to_phys(base) | 1520 val = (baser_phys |
1501 (type << GITS_BASER_TYPE_SHIFT) | 1521 (type << GITS_BASER_TYPE_SHIFT) |
1502 ((esz - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) | 1522 ((esz - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) |
1503 ((alloc_pages - 1) << GITS_BASER_PAGES_SHIFT) | 1523 ((alloc_pages - 1) << GITS_BASER_PAGES_SHIFT) |
@@ -1582,13 +1602,12 @@ retry_baser:
1582 1602
1583static bool its_parse_indirect_baser(struct its_node *its, 1603static bool its_parse_indirect_baser(struct its_node *its,
1584 struct its_baser *baser, 1604 struct its_baser *baser,
1585 u32 psz, u32 *order) 1605 u32 psz, u32 *order, u32 ids)
1586{ 1606{
1587 u64 tmp = its_read_baser(its, baser); 1607 u64 tmp = its_read_baser(its, baser);
1588 u64 type = GITS_BASER_TYPE(tmp); 1608 u64 type = GITS_BASER_TYPE(tmp);
1589 u64 esz = GITS_BASER_ENTRY_SIZE(tmp); 1609 u64 esz = GITS_BASER_ENTRY_SIZE(tmp);
1590 u64 val = GITS_BASER_InnerShareable | GITS_BASER_RaWaWb; 1610 u64 val = GITS_BASER_InnerShareable | GITS_BASER_RaWaWb;
1591 u32 ids = its->device_ids;
1592 u32 new_order = *order; 1611 u32 new_order = *order;
1593 bool indirect = false; 1612 bool indirect = false;
1594 1613
@@ -1680,9 +1699,13 @@ static int its_alloc_tables(struct its_node *its)
1680 continue; 1699 continue;
1681 1700
1682 case GITS_BASER_TYPE_DEVICE: 1701 case GITS_BASER_TYPE_DEVICE:
1702 indirect = its_parse_indirect_baser(its, baser,
1703 psz, &order,
1704 its->device_ids);
1683 case GITS_BASER_TYPE_VCPU: 1705 case GITS_BASER_TYPE_VCPU:
1684 indirect = its_parse_indirect_baser(its, baser, 1706 indirect = its_parse_indirect_baser(its, baser,
1685 psz, &order); 1707 psz, &order,
1708 ITS_MAX_VPEID_BITS);
1686 break; 1709 break;
1687 } 1710 }
1688 1711
@@ -2551,7 +2574,7 @@ static struct irq_chip its_vpe_irq_chip = {
2551 2574
2552static int its_vpe_id_alloc(void) 2575static int its_vpe_id_alloc(void)
2553{ 2576{
2554 return ida_simple_get(&its_vpeid_ida, 0, 1 << 16, GFP_KERNEL); 2577 return ida_simple_get(&its_vpeid_ida, 0, ITS_MAX_VPEID, GFP_KERNEL);
2555} 2578}
2556 2579
2557static void its_vpe_id_free(u16 id) 2580static void its_vpe_id_free(u16 id)
@@ -2851,7 +2874,7 @@ static int its_init_vpe_domain(void)
2851 return -ENOMEM; 2874 return -ENOMEM;
2852 } 2875 }
2853 2876
2854 BUG_ON(entries != vpe_proxy.dev->nr_ites); 2877 BUG_ON(entries > vpe_proxy.dev->nr_ites);
2855 2878
2856 raw_spin_lock_init(&vpe_proxy.lock); 2879 raw_spin_lock_init(&vpe_proxy.lock);
2857 vpe_proxy.next_victim = 0; 2880 vpe_proxy.next_victim = 0;
diff --git a/drivers/irqchip/irq-tango.c b/drivers/irqchip/irq-tango.c
index bdbb5c0ff7fe..0c085303a583 100644
--- a/drivers/irqchip/irq-tango.c
+++ b/drivers/irqchip/irq-tango.c
@@ -141,7 +141,7 @@ static void __init tangox_irq_init_chip(struct irq_chip_generic *gc,
141 for (i = 0; i < 2; i++) { 141 for (i = 0; i < 2; i++) {
142 ct[i].chip.irq_ack = irq_gc_ack_set_bit; 142 ct[i].chip.irq_ack = irq_gc_ack_set_bit;
143 ct[i].chip.irq_mask = irq_gc_mask_disable_reg; 143 ct[i].chip.irq_mask = irq_gc_mask_disable_reg;
144 ct[i].chip.irq_mask_ack = irq_gc_mask_disable_reg_and_ack; 144 ct[i].chip.irq_mask_ack = irq_gc_mask_disable_and_ack_set;
145 ct[i].chip.irq_unmask = irq_gc_unmask_enable_reg; 145 ct[i].chip.irq_unmask = irq_gc_unmask_enable_reg;
146 ct[i].chip.irq_set_type = tangox_irq_set_type; 146 ct[i].chip.irq_set_type = tangox_irq_set_type;
147 ct[i].chip.name = gc->domain->name; 147 ct[i].chip.name = gc->domain->name;
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8136dc7e863d..f1a5c2357b14 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -393,16 +393,6 @@ config SPEAR13XX_PCIE_GADGET
393 entry will be created for that controller. User can use these 393 entry will be created for that controller. User can use these
394 sysfs node to configure PCIe EP as per his requirements. 394 sysfs node to configure PCIe EP as per his requirements.
395 395
396config TI_DAC7512
397 tristate "Texas Instruments DAC7512"
398 depends on SPI && SYSFS
399 help
400 If you say yes here you get support for the Texas Instruments
401 DAC7512 16-bit digital-to-analog converter.
402
403 This driver can also be built as a module. If so, the module
404 will be called ti_dac7512.
405
406config VMWARE_BALLOON 396config VMWARE_BALLOON
407 tristate "VMware Balloon Driver" 397 tristate "VMware Balloon Driver"
408 depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST 398 depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index d84819dc2468..9f80b1e9bae1 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -30,7 +30,6 @@ obj-$(CONFIG_ISL29003) += isl29003.o
30obj-$(CONFIG_ISL29020) += isl29020.o 30obj-$(CONFIG_ISL29020) += isl29020.o
31obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o 31obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
32obj-$(CONFIG_DS1682) += ds1682.o 32obj-$(CONFIG_DS1682) += ds1682.o
33obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o
34obj-$(CONFIG_C2PORT) += c2port/ 33obj-$(CONFIG_C2PORT) += c2port/
35obj-$(CONFIG_HMC6352) += hmc6352.o 34obj-$(CONFIG_HMC6352) += hmc6352.o
36obj-y += eeprom/ 35obj-y += eeprom/
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c
deleted file mode 100644
index f5456fb7d773..000000000000
--- a/drivers/misc/ti_dac7512.c
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * dac7512.c - Linux kernel module for
3 * Texas Instruments DAC7512
4 *
5 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/spi/spi.h>
24#include <linux/of.h>
25
26static ssize_t dac7512_store_val(struct device *dev,
27 struct device_attribute *attr,
28 const char *buf, size_t count)
29{
30 struct spi_device *spi = to_spi_device(dev);
31 unsigned char tmp[2];
32 unsigned long val;
33 int ret;
34
35 ret = kstrtoul(buf, 10, &val);
36 if (ret)
37 return ret;
38
39 tmp[0] = val >> 8;
40 tmp[1] = val & 0xff;
41 spi_write(spi, tmp, sizeof(tmp));
42 return count;
43}
44
45static DEVICE_ATTR(value, S_IWUSR, NULL, dac7512_store_val);
46
47static struct attribute *dac7512_attributes[] = {
48 &dev_attr_value.attr,
49 NULL
50};
51
52static const struct attribute_group dac7512_attr_group = {
53 .attrs = dac7512_attributes,
54};
55
56static int dac7512_probe(struct spi_device *spi)
57{
58 int ret;
59
60 spi->bits_per_word = 8;
61 spi->mode = SPI_MODE_0;
62 ret = spi_setup(spi);
63 if (ret < 0)
64 return ret;
65
66 return sysfs_create_group(&spi->dev.kobj, &dac7512_attr_group);
67}
68
69static int dac7512_remove(struct spi_device *spi)
70{
71 sysfs_remove_group(&spi->dev.kobj, &dac7512_attr_group);
72 return 0;
73}
74
75static const struct spi_device_id dac7512_id_table[] = {
76 { "dac7512", 0 },
77 { }
78};
79MODULE_DEVICE_TABLE(spi, dac7512_id_table);
80
81#ifdef CONFIG_OF
82static const struct of_device_id dac7512_of_match[] = {
83 { .compatible = "ti,dac7512", },
84 { }
85};
86MODULE_DEVICE_TABLE(of, dac7512_of_match);
87#endif
88
89static struct spi_driver dac7512_driver = {
90 .driver = {
91 .name = "dac7512",
92 .of_match_table = of_match_ptr(dac7512_of_match),
93 },
94 .probe = dac7512_probe,
95 .remove = dac7512_remove,
96 .id_table = dac7512_id_table,
97};
98
99module_spi_driver(dac7512_driver);
100
101MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
102MODULE_DESCRIPTION("DAC7512 16-bit DAC");
103MODULE_LICENSE("GPL v2");
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index d0ccc6729fd2..67d787fa3306 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -448,6 +448,8 @@ static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
448 int err; 448 int err;
449 u32 val; 449 u32 val;
450 450
451 intel_host->d3_retune = true;
452
451 err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns); 453 err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns);
452 if (err) { 454 if (err) {
453 pr_debug("%s: DSM not supported, error %d\n", 455 pr_debug("%s: DSM not supported, error %d\n",
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 13f0f219d8aa..a13a4896a8bd 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -182,22 +182,23 @@
182/* FLEXCAN hardware feature flags 182/* FLEXCAN hardware feature flags
183 * 183 *
184 * Below is some version info we got: 184 * Below is some version info we got:
185 * SOC Version IP-Version Glitch- [TR]WRN_INT Memory err RTR re- 185 * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re-
186 * Filter? connected? detection ception in MB 186 * Filter? connected? Passive detection ception in MB
187 * MX25 FlexCAN2 03.00.00.00 no no no no 187 * MX25 FlexCAN2 03.00.00.00 no no ? no no
188 * MX28 FlexCAN2 03.00.04.00 yes yes no no 188 * MX28 FlexCAN2 03.00.04.00 yes yes no no no
189 * MX35 FlexCAN2 03.00.00.00 no no no no 189 * MX35 FlexCAN2 03.00.00.00 no no ? no no
190 * MX53 FlexCAN2 03.00.00.00 yes no no no 190 * MX53 FlexCAN2 03.00.00.00 yes no no no no
191 * MX6s FlexCAN3 10.00.12.00 yes yes no yes 191 * MX6s FlexCAN3 10.00.12.00 yes yes no no yes
192 * VF610 FlexCAN3 ? no yes yes yes? 192 * VF610 FlexCAN3 ? no yes ? yes yes?
193 * 193 *
194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected. 194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
195 */ 195 */
196#define FLEXCAN_QUIRK_BROKEN_ERR_STATE BIT(1) /* [TR]WRN_INT not connected */ 196#define FLEXCAN_QUIRK_BROKEN_WERR_STATE BIT(1) /* [TR]WRN_INT not connected */
197#define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */ 197#define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */
198#define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */ 198#define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */
199#define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */ 199#define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */
200#define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based offloading */ 200#define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based offloading */
201#define FLEXCAN_QUIRK_BROKEN_PERR_STATE BIT(6) /* No interrupt for error passive */
201 202
202/* Structure of the message buffer */ 203/* Structure of the message buffer */
203struct flexcan_mb { 204struct flexcan_mb {
@@ -281,14 +282,17 @@ struct flexcan_priv {
281}; 282};
282 283
283static const struct flexcan_devtype_data fsl_p1010_devtype_data = { 284static const struct flexcan_devtype_data fsl_p1010_devtype_data = {
284 .quirks = FLEXCAN_QUIRK_BROKEN_ERR_STATE, 285 .quirks = FLEXCAN_QUIRK_BROKEN_WERR_STATE |
286 FLEXCAN_QUIRK_BROKEN_PERR_STATE,
285}; 287};
286 288
287static const struct flexcan_devtype_data fsl_imx28_devtype_data; 289static const struct flexcan_devtype_data fsl_imx28_devtype_data = {
290 .quirks = FLEXCAN_QUIRK_BROKEN_PERR_STATE,
291};
288 292
289static const struct flexcan_devtype_data fsl_imx6q_devtype_data = { 293static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {
290 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | 294 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
291 FLEXCAN_QUIRK_USE_OFF_TIMESTAMP, 295 FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_BROKEN_PERR_STATE,
292}; 296};
293 297
294static const struct flexcan_devtype_data fsl_vf610_devtype_data = { 298static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
@@ -335,6 +339,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr)
335} 339}
336#endif 340#endif
337 341
342static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
343{
344 struct flexcan_regs __iomem *regs = priv->regs;
345 u32 reg_ctrl = (priv->reg_ctrl_default | FLEXCAN_CTRL_ERR_MSK);
346
347 flexcan_write(reg_ctrl, &regs->ctrl);
348}
349
350static inline void flexcan_error_irq_disable(const struct flexcan_priv *priv)
351{
352 struct flexcan_regs __iomem *regs = priv->regs;
353 u32 reg_ctrl = (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_MSK);
354
355 flexcan_write(reg_ctrl, &regs->ctrl);
356}
357
338static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv) 358static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
339{ 359{
340 if (!priv->reg_xceiver) 360 if (!priv->reg_xceiver)
@@ -713,6 +733,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
713 struct flexcan_regs __iomem *regs = priv->regs; 733 struct flexcan_regs __iomem *regs = priv->regs;
714 irqreturn_t handled = IRQ_NONE; 734 irqreturn_t handled = IRQ_NONE;
715 u32 reg_iflag1, reg_esr; 735 u32 reg_iflag1, reg_esr;
736 enum can_state last_state = priv->can.state;
716 737
717 reg_iflag1 = flexcan_read(&regs->iflag1); 738 reg_iflag1 = flexcan_read(&regs->iflag1);
718 739
@@ -765,8 +786,10 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
765 flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr); 786 flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);
766 } 787 }
767 788
768 /* state change interrupt */ 789 /* state change interrupt or broken error state quirk fix is enabled */
769 if (reg_esr & FLEXCAN_ESR_ERR_STATE) 790 if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
791 (priv->devtype_data->quirks & (FLEXCAN_QUIRK_BROKEN_WERR_STATE |
792 FLEXCAN_QUIRK_BROKEN_PERR_STATE)))
770 flexcan_irq_state(dev, reg_esr); 793 flexcan_irq_state(dev, reg_esr);
771 794
772 /* bus error IRQ - handle if bus error reporting is activated */ 795 /* bus error IRQ - handle if bus error reporting is activated */
@@ -774,6 +797,44 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
774 (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) 797 (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
775 flexcan_irq_bus_err(dev, reg_esr); 798 flexcan_irq_bus_err(dev, reg_esr);
776 799
800 /* availability of error interrupt among state transitions in case
801 * bus error reporting is de-activated and
802 * FLEXCAN_QUIRK_BROKEN_PERR_STATE is enabled:
803 * +--------------------------------------------------------------+
804 * | +----------------------------------------------+ [stopped / |
805 * | | | sleeping] -+
806 * +-+-> active <-> warning <-> passive -> bus off -+
807 * ___________^^^^^^^^^^^^_______________________________
808 * disabled(1) enabled disabled
809 *
810 * (1): enabled if FLEXCAN_QUIRK_BROKEN_WERR_STATE is enabled
811 */
812 if ((last_state != priv->can.state) &&
813 (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_PERR_STATE) &&
814 !(priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) {
815 switch (priv->can.state) {
816 case CAN_STATE_ERROR_ACTIVE:
817 if (priv->devtype_data->quirks &
818 FLEXCAN_QUIRK_BROKEN_WERR_STATE)
819 flexcan_error_irq_enable(priv);
820 else
821 flexcan_error_irq_disable(priv);
822 break;
823
824 case CAN_STATE_ERROR_WARNING:
825 flexcan_error_irq_enable(priv);
826 break;
827
828 case CAN_STATE_ERROR_PASSIVE:
829 case CAN_STATE_BUS_OFF:
830 flexcan_error_irq_disable(priv);
831 break;
832
833 default:
834 break;
835 }
836 }
837
777 return handled; 838 return handled;
778} 839}
779 840
@@ -887,7 +948,7 @@ static int flexcan_chip_start(struct net_device *dev)
887 * on most Flexcan cores, too. Otherwise we don't get 948 * on most Flexcan cores, too. Otherwise we don't get
888 * any error warning or passive interrupts. 949 * any error warning or passive interrupts.
889 */ 950 */
890 if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_ERR_STATE || 951 if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_WERR_STATE ||
891 priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) 952 priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
892 reg_ctrl |= FLEXCAN_CTRL_ERR_MSK; 953 reg_ctrl |= FLEXCAN_CTRL_ERR_MSK;
893 else 954 else
diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index be928ce62d32..9fdb0f0bfa06 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -333,7 +333,7 @@ static void esd_usb2_rx_can_msg(struct esd_usb2_net_priv *priv,
333 } 333 }
334 334
335 cf->can_id = id & ESD_IDMASK; 335 cf->can_id = id & ESD_IDMASK;
336 cf->can_dlc = get_can_dlc(msg->msg.rx.dlc); 336 cf->can_dlc = get_can_dlc(msg->msg.rx.dlc & ~ESD_RTR);
337 337
338 if (id & ESD_EXTID) 338 if (id & ESD_EXTID)
339 cf->can_id |= CAN_EFF_FLAG; 339 cf->can_id |= CAN_EFF_FLAG;
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index afcc1312dbaf..68ac3e88a8ce 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -375,6 +375,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
375 375
376 gs_free_tx_context(txc); 376 gs_free_tx_context(txc);
377 377
378 atomic_dec(&dev->active_tx_urbs);
379
378 netif_wake_queue(netdev); 380 netif_wake_queue(netdev);
379 } 381 }
380 382
@@ -463,14 +465,6 @@ static void gs_usb_xmit_callback(struct urb *urb)
463 urb->transfer_buffer_length, 465 urb->transfer_buffer_length,
464 urb->transfer_buffer, 466 urb->transfer_buffer,
465 urb->transfer_dma); 467 urb->transfer_dma);
466
467 atomic_dec(&dev->active_tx_urbs);
468
469 if (!netif_device_present(netdev))
470 return;
471
472 if (netif_queue_stopped(netdev))
473 netif_wake_queue(netdev);
474} 468}
475 469
476static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb, 470static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index dce7fa57eb55..f123ed57630d 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -214,8 +214,14 @@ static int mv88e6060_setup(struct dsa_switch *ds)
214 214
215static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr) 215static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr)
216{ 216{
217 /* Use the same MAC Address as FD Pause frames for all ports */ 217 u16 val = addr[0] << 8 | addr[1];
218 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_01, (addr[0] << 9) | addr[1]); 218
219 /* The multicast bit is always transmitted as a zero, so the switch uses
220 * bit 8 for "DiffAddr", where 0 means all ports transmit the same SA.
221 */
222 val &= 0xfeff;
223
224 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_01, val);
219 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_23, (addr[2] << 8) | addr[3]); 225 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_23, (addr[2] << 8) | addr[3]);
220 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_45, (addr[4] << 8) | addr[5]); 226 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_45, (addr[4] << 8) | addr[5]);
221 227
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index b1212debc2e1..967020fb26ee 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -742,8 +742,8 @@ static void ena_get_channels(struct net_device *netdev,
742{ 742{
743 struct ena_adapter *adapter = netdev_priv(netdev); 743 struct ena_adapter *adapter = netdev_priv(netdev);
744 744
745 channels->max_rx = ENA_MAX_NUM_IO_QUEUES; 745 channels->max_rx = adapter->num_queues;
746 channels->max_tx = ENA_MAX_NUM_IO_QUEUES; 746 channels->max_tx = adapter->num_queues;
747 channels->max_other = 0; 747 channels->max_other = 0;
748 channels->max_combined = 0; 748 channels->max_combined = 0;
749 channels->rx_count = adapter->num_queues; 749 channels->rx_count = adapter->num_queues;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index f7dc22f65d9f..c6bd5e24005d 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -966,7 +966,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring,
966 u64_stats_update_begin(&rx_ring->syncp); 966 u64_stats_update_begin(&rx_ring->syncp);
967 rx_ring->rx_stats.bad_csum++; 967 rx_ring->rx_stats.bad_csum++;
968 u64_stats_update_end(&rx_ring->syncp); 968 u64_stats_update_end(&rx_ring->syncp);
969 netif_err(rx_ring->adapter, rx_err, rx_ring->netdev, 969 netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
970 "RX IPv4 header checksum error\n"); 970 "RX IPv4 header checksum error\n");
971 return; 971 return;
972 } 972 }
@@ -979,7 +979,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring,
979 u64_stats_update_begin(&rx_ring->syncp); 979 u64_stats_update_begin(&rx_ring->syncp);
980 rx_ring->rx_stats.bad_csum++; 980 rx_ring->rx_stats.bad_csum++;
981 u64_stats_update_end(&rx_ring->syncp); 981 u64_stats_update_end(&rx_ring->syncp);
982 netif_err(rx_ring->adapter, rx_err, rx_ring->netdev, 982 netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
983 "RX L4 checksum error\n"); 983 "RX L4 checksum error\n");
984 skb->ip_summed = CHECKSUM_NONE; 984 skb->ip_summed = CHECKSUM_NONE;
985 return; 985 return;
@@ -3064,7 +3064,8 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev)
3064 if (ena_dev->mem_bar) 3064 if (ena_dev->mem_bar)
3065 devm_iounmap(&pdev->dev, ena_dev->mem_bar); 3065 devm_iounmap(&pdev->dev, ena_dev->mem_bar);
3066 3066
3067 devm_iounmap(&pdev->dev, ena_dev->reg_bar); 3067 if (ena_dev->reg_bar)
3068 devm_iounmap(&pdev->dev, ena_dev->reg_bar);
3068 3069
3069 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK; 3070 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
3070 pci_release_selected_regions(pdev, release_bars); 3071 pci_release_selected_regions(pdev, release_bars);
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
index 0fdaaa643073..57e796870595 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
@@ -22,8 +22,12 @@
22 22
23#define AQ_CFG_FORCE_LEGACY_INT 0U 23#define AQ_CFG_FORCE_LEGACY_INT 0U
24 24
25#define AQ_CFG_IS_INTERRUPT_MODERATION_DEF 1U 25#define AQ_CFG_INTERRUPT_MODERATION_OFF 0
26#define AQ_CFG_INTERRUPT_MODERATION_RATE_DEF 0xFFFFU 26#define AQ_CFG_INTERRUPT_MODERATION_ON 1
27#define AQ_CFG_INTERRUPT_MODERATION_AUTO 0xFFFFU
28
29#define AQ_CFG_INTERRUPT_MODERATION_USEC_MAX (0x1FF * 2)
30
27#define AQ_CFG_IRQ_MASK 0x1FFU 31#define AQ_CFG_IRQ_MASK 0x1FFU
28 32
29#define AQ_CFG_VECS_MAX 8U 33#define AQ_CFG_VECS_MAX 8U
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
index a761e91471df..d5e99b468870 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
@@ -56,10 +56,6 @@ aq_ethtool_set_link_ksettings(struct net_device *ndev,
56 return aq_nic_set_link_ksettings(aq_nic, cmd); 56 return aq_nic_set_link_ksettings(aq_nic, cmd);
57} 57}
58 58
59/* there "5U" is number of queue[#] stats lines (InPackets+...+InErrors) */
60static const unsigned int aq_ethtool_stat_queue_lines = 5U;
61static const unsigned int aq_ethtool_stat_queue_chars =
62 5U * ETH_GSTRING_LEN;
63static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = { 59static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
64 "InPackets", 60 "InPackets",
65 "InUCast", 61 "InUCast",
@@ -83,56 +79,26 @@ static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
83 "InOctetsDma", 79 "InOctetsDma",
84 "OutOctetsDma", 80 "OutOctetsDma",
85 "InDroppedDma", 81 "InDroppedDma",
86 "Queue[0] InPackets", 82};
87 "Queue[0] OutPackets", 83
88 "Queue[0] InJumboPackets", 84static const char aq_ethtool_queue_stat_names[][ETH_GSTRING_LEN] = {
89 "Queue[0] InLroPackets", 85 "Queue[%d] InPackets",
90 "Queue[0] InErrors", 86 "Queue[%d] OutPackets",
91 "Queue[1] InPackets", 87 "Queue[%d] Restarts",
92 "Queue[1] OutPackets", 88 "Queue[%d] InJumboPackets",
93 "Queue[1] InJumboPackets", 89 "Queue[%d] InLroPackets",
94 "Queue[1] InLroPackets", 90 "Queue[%d] InErrors",
95 "Queue[1] InErrors",
96 "Queue[2] InPackets",
97 "Queue[2] OutPackets",
98 "Queue[2] InJumboPackets",
99 "Queue[2] InLroPackets",
100 "Queue[2] InErrors",
101 "Queue[3] InPackets",
102 "Queue[3] OutPackets",
103 "Queue[3] InJumboPackets",
104 "Queue[3] InLroPackets",
105 "Queue[3] InErrors",
106 "Queue[4] InPackets",
107 "Queue[4] OutPackets",
108 "Queue[4] InJumboPackets",
109 "Queue[4] InLroPackets",
110 "Queue[4] InErrors",
111 "Queue[5] InPackets",
112 "Queue[5] OutPackets",
113 "Queue[5] InJumboPackets",
114 "Queue[5] InLroPackets",
115 "Queue[5] InErrors",
116 "Queue[6] InPackets",
117 "Queue[6] OutPackets",
118 "Queue[6] InJumboPackets",
119 "Queue[6] InLroPackets",
120 "Queue[6] InErrors",
121 "Queue[7] InPackets",
122 "Queue[7] OutPackets",
123 "Queue[7] InJumboPackets",
124 "Queue[7] InLroPackets",
125 "Queue[7] InErrors",
126}; 91};
127 92
128static void aq_ethtool_stats(struct net_device *ndev, 93static void aq_ethtool_stats(struct net_device *ndev,
129 struct ethtool_stats *stats, u64 *data) 94 struct ethtool_stats *stats, u64 *data)
130{ 95{
131 struct aq_nic_s *aq_nic = netdev_priv(ndev); 96 struct aq_nic_s *aq_nic = netdev_priv(ndev);
97 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
132 98
133/* ASSERT: Need add lines to aq_ethtool_stat_names if AQ_CFG_VECS_MAX > 8 */ 99 memset(data, 0, (ARRAY_SIZE(aq_ethtool_stat_names) +
134 BUILD_BUG_ON(AQ_CFG_VECS_MAX > 8); 100 ARRAY_SIZE(aq_ethtool_queue_stat_names) *
135 memset(data, 0, ARRAY_SIZE(aq_ethtool_stat_names) * sizeof(u64)); 101 cfg->vecs) * sizeof(u64));
136 aq_nic_get_stats(aq_nic, data); 102 aq_nic_get_stats(aq_nic, data);
137} 103}
138 104
@@ -154,8 +120,8 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev,
154 120
155 strlcpy(drvinfo->bus_info, pdev ? pci_name(pdev) : "", 121 strlcpy(drvinfo->bus_info, pdev ? pci_name(pdev) : "",
156 sizeof(drvinfo->bus_info)); 122 sizeof(drvinfo->bus_info));
157 drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) - 123 drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) +
158 (AQ_CFG_VECS_MAX - cfg->vecs) * aq_ethtool_stat_queue_lines; 124 cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
159 drvinfo->testinfo_len = 0; 125 drvinfo->testinfo_len = 0;
160 drvinfo->regdump_len = regs_count; 126 drvinfo->regdump_len = regs_count;
161 drvinfo->eedump_len = 0; 127 drvinfo->eedump_len = 0;
@@ -164,14 +130,25 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev,
164static void aq_ethtool_get_strings(struct net_device *ndev, 130static void aq_ethtool_get_strings(struct net_device *ndev,
165 u32 stringset, u8 *data) 131 u32 stringset, u8 *data)
166{ 132{
133 int i, si;
167 struct aq_nic_s *aq_nic = netdev_priv(ndev); 134 struct aq_nic_s *aq_nic = netdev_priv(ndev);
168 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic); 135 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
169 136 u8 *p = data;
170 if (stringset == ETH_SS_STATS) 137
171 memcpy(data, *aq_ethtool_stat_names, 138 if (stringset == ETH_SS_STATS) {
172 sizeof(aq_ethtool_stat_names) - 139 memcpy(p, *aq_ethtool_stat_names,
173 (AQ_CFG_VECS_MAX - cfg->vecs) * 140 sizeof(aq_ethtool_stat_names));
174 aq_ethtool_stat_queue_chars); 141 p = p + sizeof(aq_ethtool_stat_names);
142 for (i = 0; i < cfg->vecs; i++) {
143 for (si = 0;
144 si < ARRAY_SIZE(aq_ethtool_queue_stat_names);
145 si++) {
146 snprintf(p, ETH_GSTRING_LEN,
147 aq_ethtool_queue_stat_names[si], i);
148 p += ETH_GSTRING_LEN;
149 }
150 }
151 }
175} 152}
176 153
177static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset) 154static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset)
@@ -182,9 +159,8 @@ static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset)
182 159
183 switch (stringset) { 160 switch (stringset) {
184 case ETH_SS_STATS: 161 case ETH_SS_STATS:
185 ret = ARRAY_SIZE(aq_ethtool_stat_names) - 162 ret = ARRAY_SIZE(aq_ethtool_stat_names) +
186 (AQ_CFG_VECS_MAX - cfg->vecs) * 163 cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
187 aq_ethtool_stat_queue_lines;
188 break; 164 break;
189 default: 165 default:
190 ret = -EOPNOTSUPP; 166 ret = -EOPNOTSUPP;
@@ -245,6 +221,69 @@ static int aq_ethtool_get_rxnfc(struct net_device *ndev,
245 return err; 221 return err;
246} 222}
247 223
224int aq_ethtool_get_coalesce(struct net_device *ndev,
225 struct ethtool_coalesce *coal)
226{
227 struct aq_nic_s *aq_nic = netdev_priv(ndev);
228 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
229
230 if (cfg->itr == AQ_CFG_INTERRUPT_MODERATION_ON ||
231 cfg->itr == AQ_CFG_INTERRUPT_MODERATION_AUTO) {
232 coal->rx_coalesce_usecs = cfg->rx_itr;
233 coal->tx_coalesce_usecs = cfg->tx_itr;
234 coal->rx_max_coalesced_frames = 0;
235 coal->tx_max_coalesced_frames = 0;
236 } else {
237 coal->rx_coalesce_usecs = 0;
238 coal->tx_coalesce_usecs = 0;
239 coal->rx_max_coalesced_frames = 1;
240 coal->tx_max_coalesced_frames = 1;
241 }
242 return 0;
243}
244
245int aq_ethtool_set_coalesce(struct net_device *ndev,
246 struct ethtool_coalesce *coal)
247{
248 struct aq_nic_s *aq_nic = netdev_priv(ndev);
249 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
250
251 /* This is not yet supported
252 */
253 if (coal->use_adaptive_rx_coalesce || coal->use_adaptive_tx_coalesce)
254 return -EOPNOTSUPP;
255
256 /* Atlantic only supports timing based coalescing
257 */
258 if (coal->rx_max_coalesced_frames > 1 ||
259 coal->rx_coalesce_usecs_irq ||
260 coal->rx_max_coalesced_frames_irq)
261 return -EOPNOTSUPP;
262
263 if (coal->tx_max_coalesced_frames > 1 ||
264 coal->tx_coalesce_usecs_irq ||
265 coal->tx_max_coalesced_frames_irq)
266 return -EOPNOTSUPP;
267
268 /* We do not support frame counting. Check this
269 */
270 if (!(coal->rx_max_coalesced_frames == !coal->rx_coalesce_usecs))
271 return -EOPNOTSUPP;
272 if (!(coal->tx_max_coalesced_frames == !coal->tx_coalesce_usecs))
273 return -EOPNOTSUPP;
274
275 if (coal->rx_coalesce_usecs > AQ_CFG_INTERRUPT_MODERATION_USEC_MAX ||
276 coal->tx_coalesce_usecs > AQ_CFG_INTERRUPT_MODERATION_USEC_MAX)
277 return -EINVAL;
278
279 cfg->itr = AQ_CFG_INTERRUPT_MODERATION_ON;
280
281 cfg->rx_itr = coal->rx_coalesce_usecs;
282 cfg->tx_itr = coal->tx_coalesce_usecs;
283
284 return aq_nic_update_interrupt_moderation_settings(aq_nic);
285}
286
248const struct ethtool_ops aq_ethtool_ops = { 287const struct ethtool_ops aq_ethtool_ops = {
249 .get_link = aq_ethtool_get_link, 288 .get_link = aq_ethtool_get_link,
250 .get_regs_len = aq_ethtool_get_regs_len, 289 .get_regs_len = aq_ethtool_get_regs_len,
@@ -259,4 +298,6 @@ const struct ethtool_ops aq_ethtool_ops = {
259 .get_ethtool_stats = aq_ethtool_stats, 298 .get_ethtool_stats = aq_ethtool_stats,
260 .get_link_ksettings = aq_ethtool_get_link_ksettings, 299 .get_link_ksettings = aq_ethtool_get_link_ksettings,
261 .set_link_ksettings = aq_ethtool_set_link_ksettings, 300 .set_link_ksettings = aq_ethtool_set_link_ksettings,
301 .get_coalesce = aq_ethtool_get_coalesce,
302 .set_coalesce = aq_ethtool_set_coalesce,
262}; 303};
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index bf9b3f020e10..0207927dc8a6 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -151,8 +151,7 @@ struct aq_hw_ops {
151 [ETH_ALEN], 151 [ETH_ALEN],
152 u32 count); 152 u32 count);
153 153
154 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self, 154 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self);
155 bool itr_enabled);
156 155
157 int (*hw_rss_set)(struct aq_hw_s *self, 156 int (*hw_rss_set)(struct aq_hw_s *self,
158 struct aq_rss_parameters *rss_params); 157 struct aq_rss_parameters *rss_params);
@@ -163,6 +162,8 @@ struct aq_hw_ops {
163 int (*hw_get_regs)(struct aq_hw_s *self, 162 int (*hw_get_regs)(struct aq_hw_s *self,
164 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff); 163 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);
165 164
165 int (*hw_update_stats)(struct aq_hw_s *self);
166
166 int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data, 167 int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,
167 unsigned int *p_count); 168 unsigned int *p_count);
168 169
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 0a5bb4114eb4..483e97691eea 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -16,6 +16,7 @@
16#include "aq_pci_func.h" 16#include "aq_pci_func.h"
17#include "aq_nic_internal.h" 17#include "aq_nic_internal.h"
18 18
19#include <linux/moduleparam.h>
19#include <linux/netdevice.h> 20#include <linux/netdevice.h>
20#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
21#include <linux/timer.h> 22#include <linux/timer.h>
@@ -24,6 +25,18 @@
24#include <linux/tcp.h> 25#include <linux/tcp.h>
25#include <net/ip.h> 26#include <net/ip.h>
26 27
28static unsigned int aq_itr = AQ_CFG_INTERRUPT_MODERATION_AUTO;
29module_param_named(aq_itr, aq_itr, uint, 0644);
30MODULE_PARM_DESC(aq_itr, "Interrupt throttling mode");
31
32static unsigned int aq_itr_tx;
33module_param_named(aq_itr_tx, aq_itr_tx, uint, 0644);
34MODULE_PARM_DESC(aq_itr_tx, "TX interrupt throttle rate");
35
36static unsigned int aq_itr_rx;
37module_param_named(aq_itr_rx, aq_itr_rx, uint, 0644);
38MODULE_PARM_DESC(aq_itr_rx, "RX interrupt throttle rate");
39
27static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues) 40static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues)
28{ 41{
29 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; 42 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
@@ -61,9 +74,9 @@ static void aq_nic_cfg_init_defaults(struct aq_nic_s *self)
61 74
62 cfg->is_polling = AQ_CFG_IS_POLLING_DEF; 75 cfg->is_polling = AQ_CFG_IS_POLLING_DEF;
63 76
64 cfg->is_interrupt_moderation = AQ_CFG_IS_INTERRUPT_MODERATION_DEF; 77 cfg->itr = aq_itr;
65 cfg->itr = cfg->is_interrupt_moderation ? 78 cfg->tx_itr = aq_itr_tx;
66 AQ_CFG_INTERRUPT_MODERATION_RATE_DEF : 0U; 79 cfg->rx_itr = aq_itr_rx;
67 80
68 cfg->is_rss = AQ_CFG_IS_RSS_DEF; 81 cfg->is_rss = AQ_CFG_IS_RSS_DEF;
69 cfg->num_rss_queues = AQ_CFG_NUM_RSS_QUEUES_DEF; 82 cfg->num_rss_queues = AQ_CFG_NUM_RSS_QUEUES_DEF;
@@ -126,10 +139,12 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)
126 if (err) 139 if (err)
127 return err; 140 return err;
128 141
129 if (self->link_status.mbps != self->aq_hw->aq_link_status.mbps) 142 if (self->link_status.mbps != self->aq_hw->aq_link_status.mbps) {
130 pr_info("%s: link change old %d new %d\n", 143 pr_info("%s: link change old %d new %d\n",
131 AQ_CFG_DRV_NAME, self->link_status.mbps, 144 AQ_CFG_DRV_NAME, self->link_status.mbps,
132 self->aq_hw->aq_link_status.mbps); 145 self->aq_hw->aq_link_status.mbps);
146 aq_nic_update_interrupt_moderation_settings(self);
147 }
133 148
134 self->link_status = self->aq_hw->aq_link_status; 149 self->link_status = self->aq_hw->aq_link_status;
135 if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) { 150 if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) {
@@ -164,8 +179,8 @@ static void aq_nic_service_timer_cb(unsigned long param)
164 if (err) 179 if (err)
165 goto err_exit; 180 goto err_exit;
166 181
167 self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw, 182 if (self->aq_hw_ops.hw_update_stats)
168 self->aq_nic_cfg.is_interrupt_moderation); 183 self->aq_hw_ops.hw_update_stats(self->aq_hw);
169 184
170 memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s)); 185 memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));
171 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s)); 186 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
@@ -334,6 +349,7 @@ struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev)
334 } 349 }
335 if (netif_running(ndev)) 350 if (netif_running(ndev))
336 netif_tx_disable(ndev); 351 netif_tx_disable(ndev);
352 netif_carrier_off(self->ndev);
337 353
338 for (self->aq_vecs = 0; self->aq_vecs < self->aq_nic_cfg.vecs; 354 for (self->aq_vecs = 0; self->aq_vecs < self->aq_nic_cfg.vecs;
339 self->aq_vecs++) { 355 self->aq_vecs++) {
@@ -421,9 +437,8 @@ int aq_nic_start(struct aq_nic_s *self)
421 if (err < 0) 437 if (err < 0)
422 goto err_exit; 438 goto err_exit;
423 439
424 err = self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw, 440 err = aq_nic_update_interrupt_moderation_settings(self);
425 self->aq_nic_cfg.is_interrupt_moderation); 441 if (err)
426 if (err < 0)
427 goto err_exit; 442 goto err_exit;
428 setup_timer(&self->service_timer, &aq_nic_service_timer_cb, 443 setup_timer(&self->service_timer, &aq_nic_service_timer_cb,
429 (unsigned long)self); 444 (unsigned long)self);
@@ -645,6 +660,11 @@ err_exit:
645 return err; 660 return err;
646} 661}
647 662
663int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self)
664{
665 return self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw);
666}
667
648int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags) 668int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags)
649{ 669{
650 int err = 0; 670 int err = 0;
@@ -899,6 +919,7 @@ int aq_nic_stop(struct aq_nic_s *self)
899 unsigned int i = 0U; 919 unsigned int i = 0U;
900 920
901 netif_tx_disable(self->ndev); 921 netif_tx_disable(self->ndev);
922 netif_carrier_off(self->ndev);
902 923
903 del_timer_sync(&self->service_timer); 924 del_timer_sync(&self->service_timer);
904 925
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index 0ddd556ff901..4309983acdd6 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -40,6 +40,8 @@ struct aq_nic_cfg_s {
40 u32 vecs; /* vecs==allocated irqs */ 40 u32 vecs; /* vecs==allocated irqs */
41 u32 irq_type; 41 u32 irq_type;
42 u32 itr; 42 u32 itr;
43 u16 rx_itr;
44 u16 tx_itr;
43 u32 num_rss_queues; 45 u32 num_rss_queues;
44 u32 mtu; 46 u32 mtu;
45 u32 ucp_0x364; 47 u32 ucp_0x364;
@@ -49,7 +51,6 @@ struct aq_nic_cfg_s {
49 u16 is_mc_list_enabled; 51 u16 is_mc_list_enabled;
50 u16 mc_list_count; 52 u16 mc_list_count;
51 bool is_autoneg; 53 bool is_autoneg;
52 bool is_interrupt_moderation;
53 bool is_polling; 54 bool is_polling;
54 bool is_rss; 55 bool is_rss;
55 bool is_lro; 56 bool is_lro;
@@ -104,5 +105,6 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self,
104struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self); 105struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
105u32 aq_nic_get_fw_version(struct aq_nic_s *self); 106u32 aq_nic_get_fw_version(struct aq_nic_s *self);
106int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg); 107int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
108int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
107 109
108#endif /* AQ_NIC_H */ 110#endif /* AQ_NIC_H */
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index 4c6c882c6a1c..cadaa646c89f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -85,6 +85,7 @@ int aq_pci_func_init(struct aq_pci_func_s *self)
85 int err = 0; 85 int err = 0;
86 unsigned int bar = 0U; 86 unsigned int bar = 0U;
87 unsigned int port = 0U; 87 unsigned int port = 0U;
88 unsigned int numvecs = 0U;
88 89
89 err = pci_enable_device(self->pdev); 90 err = pci_enable_device(self->pdev);
90 if (err < 0) 91 if (err < 0)
@@ -142,10 +143,12 @@ int aq_pci_func_init(struct aq_pci_func_s *self)
142 } 143 }
143 } 144 }
144 145
145 /*enable interrupts */ 146 numvecs = min((u8)AQ_CFG_VECS_DEF, self->aq_hw_caps.msix_irqs);
147 numvecs = min(numvecs, num_online_cpus());
148
149 /* enable interrupts */
146#if !AQ_CFG_FORCE_LEGACY_INT 150#if !AQ_CFG_FORCE_LEGACY_INT
147 err = pci_alloc_irq_vectors(self->pdev, self->aq_hw_caps.msix_irqs, 151 err = pci_alloc_irq_vectors(self->pdev, numvecs, numvecs, PCI_IRQ_MSIX);
148 self->aq_hw_caps.msix_irqs, PCI_IRQ_MSIX);
149 152
150 if (err < 0) { 153 if (err < 0) {
151 err = pci_alloc_irq_vectors(self->pdev, 1, 1, 154 err = pci_alloc_irq_vectors(self->pdev, 1, 1,
@@ -153,7 +156,7 @@ int aq_pci_func_init(struct aq_pci_func_s *self)
153 if (err < 0) 156 if (err < 0)
154 goto err_exit; 157 goto err_exit;
155 } 158 }
156#endif 159#endif /* AQ_CFG_FORCE_LEGACY_INT */
157 160
158 /* net device init */ 161 /* net device init */
159 for (port = 0; port < self->ports; ++port) { 162 for (port = 0; port < self->ports; ++port) {
@@ -265,6 +268,9 @@ void aq_pci_func_free(struct aq_pci_func_s *self)
265 aq_nic_ndev_free(self->port[port]); 268 aq_nic_ndev_free(self->port[port]);
266 } 269 }
267 270
271 if (self->mmio)
272 iounmap(self->mmio);
273
268 kfree(self); 274 kfree(self);
269 275
270err_exit:; 276err_exit:;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
index 305ff8ffac2c..5fecc9a099ef 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
@@ -373,8 +373,11 @@ int aq_vec_get_sw_stats(struct aq_vec_s *self, u64 *data, unsigned int *p_count)
373 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s)); 373 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
374 aq_vec_add_stats(self, &stats_rx, &stats_tx); 374 aq_vec_add_stats(self, &stats_rx, &stats_tx);
375 375
376 /* This data should mimic aq_ethtool_queue_stat_names structure
377 */
376 data[count] += stats_rx.packets; 378 data[count] += stats_rx.packets;
377 data[++count] += stats_tx.packets; 379 data[++count] += stats_tx.packets;
380 data[++count] += stats_tx.queue_restarts;
378 data[++count] += stats_rx.jumbo_packets; 381 data[++count] += stats_rx.jumbo_packets;
379 data[++count] += stats_rx.lro_packets; 382 data[++count] += stats_rx.lro_packets;
380 data[++count] += stats_rx.errors; 383 data[++count] += stats_rx.errors;
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
index c5a02df7a48b..07b3c49a16a4 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
@@ -765,24 +765,23 @@ err_exit:
765 return err; 765 return err;
766} 766}
767 767
768static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self, 768static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self)
769 bool itr_enabled)
770{ 769{
771 unsigned int i = 0U; 770 unsigned int i = 0U;
771 u32 itr_rx;
772 772
773 if (itr_enabled && self->aq_nic_cfg->itr) { 773 if (self->aq_nic_cfg->itr) {
774 if (self->aq_nic_cfg->itr != 0xFFFFU) { 774 if (self->aq_nic_cfg->itr != AQ_CFG_INTERRUPT_MODERATION_AUTO) {
775 u32 itr_ = (self->aq_nic_cfg->itr >> 1); 775 u32 itr_ = (self->aq_nic_cfg->itr >> 1);
776 776
777 itr_ = min(AQ_CFG_IRQ_MASK, itr_); 777 itr_ = min(AQ_CFG_IRQ_MASK, itr_);
778 778
779 PHAL_ATLANTIC_A0->itr_rx = 0x80000000U | 779 itr_rx = 0x80000000U | (itr_ << 0x10);
780 (itr_ << 0x10);
781 } else { 780 } else {
782 u32 n = 0xFFFFU & aq_hw_read_reg(self, 0x00002A00U); 781 u32 n = 0xFFFFU & aq_hw_read_reg(self, 0x00002A00U);
783 782
784 if (n < self->aq_link_status.mbps) { 783 if (n < self->aq_link_status.mbps) {
785 PHAL_ATLANTIC_A0->itr_rx = 0U; 784 itr_rx = 0U;
786 } else { 785 } else {
787 static unsigned int hw_timers_tbl_[] = { 786 static unsigned int hw_timers_tbl_[] = {
788 0x01CU, /* 10Gbit */ 787 0x01CU, /* 10Gbit */
@@ -797,8 +796,7 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self,
797 hw_atl_utils_mbps_2_speed_index( 796 hw_atl_utils_mbps_2_speed_index(
798 self->aq_link_status.mbps); 797 self->aq_link_status.mbps);
799 798
800 PHAL_ATLANTIC_A0->itr_rx = 799 itr_rx = 0x80000000U |
801 0x80000000U |
802 (hw_timers_tbl_[speed_index] << 0x10U); 800 (hw_timers_tbl_[speed_index] << 0x10U);
803 } 801 }
804 802
@@ -806,11 +804,11 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self,
806 aq_hw_write_reg(self, 0x00002A00U, 0x8D000000U); 804 aq_hw_write_reg(self, 0x00002A00U, 0x8D000000U);
807 } 805 }
808 } else { 806 } else {
809 PHAL_ATLANTIC_A0->itr_rx = 0U; 807 itr_rx = 0U;
810 } 808 }
811 809
812 for (i = HW_ATL_A0_RINGS_MAX; i--;) 810 for (i = HW_ATL_A0_RINGS_MAX; i--;)
813 reg_irq_thr_set(self, PHAL_ATLANTIC_A0->itr_rx, i); 811 reg_irq_thr_set(self, itr_rx, i);
814 812
815 return aq_hw_err_from_flags(self); 813 return aq_hw_err_from_flags(self);
816} 814}
@@ -885,6 +883,7 @@ static struct aq_hw_ops hw_atl_ops_ = {
885 .hw_rss_set = hw_atl_a0_hw_rss_set, 883 .hw_rss_set = hw_atl_a0_hw_rss_set,
886 .hw_rss_hash_set = hw_atl_a0_hw_rss_hash_set, 884 .hw_rss_hash_set = hw_atl_a0_hw_rss_hash_set,
887 .hw_get_regs = hw_atl_utils_hw_get_regs, 885 .hw_get_regs = hw_atl_utils_hw_get_regs,
886 .hw_update_stats = hw_atl_utils_update_stats,
888 .hw_get_hw_stats = hw_atl_utils_get_hw_stats, 887 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
889 .hw_get_fw_version = hw_atl_utils_get_fw_version, 888 .hw_get_fw_version = hw_atl_utils_get_fw_version,
890}; 889};
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
index 21784cc39dab..ec68c20efcbd 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
@@ -788,39 +788,45 @@ err_exit:
788 return err; 788 return err;
789} 789}
790 790
791static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self, 791static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self)
792 bool itr_enabled)
793{ 792{
794 unsigned int i = 0U; 793 unsigned int i = 0U;
794 u32 itr_tx = 2U;
795 u32 itr_rx = 2U;
795 796
796 if (itr_enabled && self->aq_nic_cfg->itr) { 797 switch (self->aq_nic_cfg->itr) {
798 case AQ_CFG_INTERRUPT_MODERATION_ON:
799 case AQ_CFG_INTERRUPT_MODERATION_AUTO:
797 tdm_tx_desc_wr_wb_irq_en_set(self, 0U); 800 tdm_tx_desc_wr_wb_irq_en_set(self, 0U);
798 tdm_tdm_intr_moder_en_set(self, 1U); 801 tdm_tdm_intr_moder_en_set(self, 1U);
799 rdm_rx_desc_wr_wb_irq_en_set(self, 0U); 802 rdm_rx_desc_wr_wb_irq_en_set(self, 0U);
800 rdm_rdm_intr_moder_en_set(self, 1U); 803 rdm_rdm_intr_moder_en_set(self, 1U);
801 804
802 PHAL_ATLANTIC_B0->itr_tx = 2U; 805 if (self->aq_nic_cfg->itr == AQ_CFG_INTERRUPT_MODERATION_ON) {
803 PHAL_ATLANTIC_B0->itr_rx = 2U; 806 /* HW timers are in 2us units */
807 int tx_max_timer = self->aq_nic_cfg->tx_itr / 2;
808 int tx_min_timer = tx_max_timer / 2;
804 809
805 if (self->aq_nic_cfg->itr != 0xFFFFU) { 810 int rx_max_timer = self->aq_nic_cfg->rx_itr / 2;
806 unsigned int max_timer = self->aq_nic_cfg->itr / 2U; 811 int rx_min_timer = rx_max_timer / 2;
807 unsigned int min_timer = self->aq_nic_cfg->itr / 32U;
808 812
809 max_timer = min(0x1FFU, max_timer); 813 tx_max_timer = min(HW_ATL_INTR_MODER_MAX, tx_max_timer);
810 min_timer = min(0xFFU, min_timer); 814 tx_min_timer = min(HW_ATL_INTR_MODER_MIN, tx_min_timer);
815 rx_max_timer = min(HW_ATL_INTR_MODER_MAX, rx_max_timer);
816 rx_min_timer = min(HW_ATL_INTR_MODER_MIN, rx_min_timer);
811 817
812 PHAL_ATLANTIC_B0->itr_tx |= min_timer << 0x8U; 818 itr_tx |= tx_min_timer << 0x8U;
813 PHAL_ATLANTIC_B0->itr_tx |= max_timer << 0x10U; 819 itr_tx |= tx_max_timer << 0x10U;
814 PHAL_ATLANTIC_B0->itr_rx |= min_timer << 0x8U; 820 itr_rx |= rx_min_timer << 0x8U;
815 PHAL_ATLANTIC_B0->itr_rx |= max_timer << 0x10U; 821 itr_rx |= rx_max_timer << 0x10U;
816 } else { 822 } else {
817 static unsigned int hw_atl_b0_timers_table_tx_[][2] = { 823 static unsigned int hw_atl_b0_timers_table_tx_[][2] = {
818 {0xffU, 0xffU}, /* 10Gbit */ 824 {0xfU, 0xffU}, /* 10Gbit */
819 {0xffU, 0x1ffU}, /* 5Gbit */ 825 {0xfU, 0x1ffU}, /* 5Gbit */
820 {0xffU, 0x1ffU}, /* 5Gbit 5GS */ 826 {0xfU, 0x1ffU}, /* 5Gbit 5GS */
821 {0xffU, 0x1ffU}, /* 2.5Gbit */ 827 {0xfU, 0x1ffU}, /* 2.5Gbit */
822 {0xffU, 0x1ffU}, /* 1Gbit */ 828 {0xfU, 0x1ffU}, /* 1Gbit */
823 {0xffU, 0x1ffU}, /* 100Mbit */ 829 {0xfU, 0x1ffU}, /* 100Mbit */
824 }; 830 };
825 831
826 static unsigned int hw_atl_b0_timers_table_rx_[][2] = { 832 static unsigned int hw_atl_b0_timers_table_rx_[][2] = {
@@ -836,34 +842,36 @@ static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self,
836 hw_atl_utils_mbps_2_speed_index( 842 hw_atl_utils_mbps_2_speed_index(
837 self->aq_link_status.mbps); 843 self->aq_link_status.mbps);
838 844
839 PHAL_ATLANTIC_B0->itr_tx |= 845 /* Update user visible ITR settings */
840 hw_atl_b0_timers_table_tx_[speed_index] 846 self->aq_nic_cfg->tx_itr = hw_atl_b0_timers_table_tx_
841 [0] << 0x8U; /* set min timer value */ 847 [speed_index][1] * 2;
842 PHAL_ATLANTIC_B0->itr_tx |= 848 self->aq_nic_cfg->rx_itr = hw_atl_b0_timers_table_rx_
843 hw_atl_b0_timers_table_tx_[speed_index] 849 [speed_index][1] * 2;
844 [1] << 0x10U; /* set max timer value */ 850
845 851 itr_tx |= hw_atl_b0_timers_table_tx_
846 PHAL_ATLANTIC_B0->itr_rx |= 852 [speed_index][0] << 0x8U;
847 hw_atl_b0_timers_table_rx_[speed_index] 853 itr_tx |= hw_atl_b0_timers_table_tx_
848 [0] << 0x8U; /* set min timer value */ 854 [speed_index][1] << 0x10U;
849 PHAL_ATLANTIC_B0->itr_rx |= 855
850 hw_atl_b0_timers_table_rx_[speed_index] 856 itr_rx |= hw_atl_b0_timers_table_rx_
851 [1] << 0x10U; /* set max timer value */ 857 [speed_index][0] << 0x8U;
858 itr_rx |= hw_atl_b0_timers_table_rx_
859 [speed_index][1] << 0x10U;
852 } 860 }
853 } else { 861 break;
862 case AQ_CFG_INTERRUPT_MODERATION_OFF:
854 tdm_tx_desc_wr_wb_irq_en_set(self, 1U); 863 tdm_tx_desc_wr_wb_irq_en_set(self, 1U);
855 tdm_tdm_intr_moder_en_set(self, 0U); 864 tdm_tdm_intr_moder_en_set(self, 0U);
856 rdm_rx_desc_wr_wb_irq_en_set(self, 1U); 865 rdm_rx_desc_wr_wb_irq_en_set(self, 1U);
857 rdm_rdm_intr_moder_en_set(self, 0U); 866 rdm_rdm_intr_moder_en_set(self, 0U);
858 PHAL_ATLANTIC_B0->itr_tx = 0U; 867 itr_tx = 0U;
859 PHAL_ATLANTIC_B0->itr_rx = 0U; 868 itr_rx = 0U;
869 break;
860 } 870 }
861 871
862 for (i = HW_ATL_B0_RINGS_MAX; i--;) { 872 for (i = HW_ATL_B0_RINGS_MAX; i--;) {
863 reg_tx_intr_moder_ctrl_set(self, 873 reg_tx_intr_moder_ctrl_set(self, itr_tx, i);
864 PHAL_ATLANTIC_B0->itr_tx, i); 874 reg_rx_intr_moder_ctrl_set(self, itr_rx, i);
865 reg_rx_intr_moder_ctrl_set(self,
866 PHAL_ATLANTIC_B0->itr_rx, i);
867 } 875 }
868 876
869 return aq_hw_err_from_flags(self); 877 return aq_hw_err_from_flags(self);
@@ -939,6 +947,7 @@ static struct aq_hw_ops hw_atl_ops_ = {
939 .hw_rss_set = hw_atl_b0_hw_rss_set, 947 .hw_rss_set = hw_atl_b0_hw_rss_set,
940 .hw_rss_hash_set = hw_atl_b0_hw_rss_hash_set, 948 .hw_rss_hash_set = hw_atl_b0_hw_rss_hash_set,
941 .hw_get_regs = hw_atl_utils_hw_get_regs, 949 .hw_get_regs = hw_atl_utils_hw_get_regs,
950 .hw_update_stats = hw_atl_utils_update_stats,
942 .hw_get_hw_stats = hw_atl_utils_get_hw_stats, 951 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
943 .hw_get_fw_version = hw_atl_utils_get_fw_version, 952 .hw_get_fw_version = hw_atl_utils_get_fw_version,
944}; 953};
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h
index fcf89e25a773..9aa2c6edfca2 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h
@@ -139,6 +139,9 @@
139 139
140#define HW_ATL_B0_FW_VER_EXPECTED 0x01050006U 140#define HW_ATL_B0_FW_VER_EXPECTED 0x01050006U
141 141
142#define HW_ATL_INTR_MODER_MAX 0x1FF
143#define HW_ATL_INTR_MODER_MIN 0xFF
144
142/* Hardware tx descriptor */ 145/* Hardware tx descriptor */
143struct __packed hw_atl_txd_s { 146struct __packed hw_atl_txd_s {
144 u64 buf_addr; 147 u64 buf_addr;
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index bf734b32e44b..1fe016fc4bc7 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -255,6 +255,15 @@ err_exit:
255 return err; 255 return err;
256} 256}
257 257
258int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
259 struct hw_aq_atl_utils_mbox_header *pmbox)
260{
261 return hw_atl_utils_fw_downld_dwords(self,
262 PHAL_ATLANTIC->mbox_addr,
263 (u32 *)(void *)pmbox,
264 sizeof(*pmbox) / sizeof(u32));
265}
266
258void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, 267void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
259 struct hw_aq_atl_utils_mbox *pmbox) 268 struct hw_aq_atl_utils_mbox *pmbox)
260{ 269{
@@ -267,9 +276,6 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
267 if (err < 0) 276 if (err < 0)
268 goto err_exit; 277 goto err_exit;
269 278
270 if (pmbox != &PHAL_ATLANTIC->mbox)
271 memcpy(pmbox, &PHAL_ATLANTIC->mbox, sizeof(*pmbox));
272
273 if (IS_CHIP_FEATURE(REVISION_A0)) { 279 if (IS_CHIP_FEATURE(REVISION_A0)) {
274 unsigned int mtu = self->aq_nic_cfg ? 280 unsigned int mtu = self->aq_nic_cfg ?
275 self->aq_nic_cfg->mtu : 1514U; 281 self->aq_nic_cfg->mtu : 1514U;
@@ -299,17 +305,17 @@ void hw_atl_utils_mpi_set(struct aq_hw_s *self,
299{ 305{
300 int err = 0; 306 int err = 0;
301 u32 transaction_id = 0; 307 u32 transaction_id = 0;
308 struct hw_aq_atl_utils_mbox_header mbox;
302 309
303 if (state == MPI_RESET) { 310 if (state == MPI_RESET) {
304 hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox); 311 hw_atl_utils_mpi_read_mbox(self, &mbox);
305 312
306 transaction_id = PHAL_ATLANTIC->mbox.transaction_id; 313 transaction_id = mbox.transaction_id;
307 314
308 AQ_HW_WAIT_FOR(transaction_id != 315 AQ_HW_WAIT_FOR(transaction_id !=
309 (hw_atl_utils_mpi_read_stats 316 (hw_atl_utils_mpi_read_mbox(self, &mbox),
310 (self, &PHAL_ATLANTIC->mbox), 317 mbox.transaction_id),
311 PHAL_ATLANTIC->mbox.transaction_id), 318 1000U, 100U);
312 1000U, 100U);
313 if (err < 0) 319 if (err < 0)
314 goto err_exit; 320 goto err_exit;
315 } 321 }
@@ -492,16 +498,51 @@ int hw_atl_utils_hw_set_power(struct aq_hw_s *self,
492 return 0; 498 return 0;
493} 499}
494 500
501int hw_atl_utils_update_stats(struct aq_hw_s *self)
502{
503 struct hw_atl_s *hw_self = PHAL_ATLANTIC;
504 struct hw_aq_atl_utils_mbox mbox;
505
506 if (!self->aq_link_status.mbps)
507 return 0;
508
509 hw_atl_utils_mpi_read_stats(self, &mbox);
510
511#define AQ_SDELTA(_N_) (hw_self->curr_stats._N_ += \
512 mbox.stats._N_ - hw_self->last_stats._N_)
513
514 AQ_SDELTA(uprc);
515 AQ_SDELTA(mprc);
516 AQ_SDELTA(bprc);
517 AQ_SDELTA(erpt);
518
519 AQ_SDELTA(uptc);
520 AQ_SDELTA(mptc);
521 AQ_SDELTA(bptc);
522 AQ_SDELTA(erpr);
523
524 AQ_SDELTA(ubrc);
525 AQ_SDELTA(ubtc);
526 AQ_SDELTA(mbrc);
527 AQ_SDELTA(mbtc);
528 AQ_SDELTA(bbrc);
529 AQ_SDELTA(bbtc);
530 AQ_SDELTA(dpc);
531
532#undef AQ_SDELTA
533
534 memcpy(&hw_self->last_stats, &mbox.stats, sizeof(mbox.stats));
535
536 return 0;
537}
538
495int hw_atl_utils_get_hw_stats(struct aq_hw_s *self, 539int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
496 u64 *data, unsigned int *p_count) 540 u64 *data, unsigned int *p_count)
497{ 541{
498 struct hw_atl_stats_s *stats = NULL; 542 struct hw_atl_s *hw_self = PHAL_ATLANTIC;
543 struct hw_atl_stats_s *stats = &hw_self->curr_stats;
499 int i = 0; 544 int i = 0;
500 545
501 hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox);
502
503 stats = &PHAL_ATLANTIC->mbox.stats;
504
505 data[i] = stats->uprc + stats->mprc + stats->bprc; 546 data[i] = stats->uprc + stats->mprc + stats->bprc;
506 data[++i] = stats->uprc; 547 data[++i] = stats->uprc;
507 data[++i] = stats->mprc; 548 data[++i] = stats->mprc;
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
index e0360a6b2202..c99cc690e425 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
@@ -115,19 +115,22 @@ struct __packed hw_aq_atl_utils_fw_rpc {
115 }; 115 };
116}; 116};
117 117
118struct __packed hw_aq_atl_utils_mbox { 118struct __packed hw_aq_atl_utils_mbox_header {
119 u32 version; 119 u32 version;
120 u32 transaction_id; 120 u32 transaction_id;
121 int error; 121 u32 error;
122};
123
124struct __packed hw_aq_atl_utils_mbox {
125 struct hw_aq_atl_utils_mbox_header header;
122 struct hw_atl_stats_s stats; 126 struct hw_atl_stats_s stats;
123}; 127};
124 128
125struct __packed hw_atl_s { 129struct __packed hw_atl_s {
126 struct aq_hw_s base; 130 struct aq_hw_s base;
127 struct hw_aq_atl_utils_mbox mbox; 131 struct hw_atl_stats_s last_stats;
132 struct hw_atl_stats_s curr_stats;
128 u64 speed; 133 u64 speed;
129 u32 itr_tx;
130 u32 itr_rx;
131 unsigned int chip_features; 134 unsigned int chip_features;
132 u32 fw_ver_actual; 135 u32 fw_ver_actual;
133 atomic_t dpc; 136 atomic_t dpc;
@@ -170,6 +173,9 @@ enum hal_atl_utils_fw_state_e {
170 173
171void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p); 174void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);
172 175
176int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
177 struct hw_aq_atl_utils_mbox_header *pmbox);
178
173void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, 179void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
174 struct hw_aq_atl_utils_mbox *pmbox); 180 struct hw_aq_atl_utils_mbox *pmbox);
175 181
@@ -199,6 +205,8 @@ int hw_atl_utils_hw_deinit(struct aq_hw_s *self);
199 205
200int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version); 206int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version);
201 207
208int hw_atl_utils_update_stats(struct aq_hw_s *self);
209
202int hw_atl_utils_get_hw_stats(struct aq_hw_s *self, 210int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
203 u64 *data, 211 u64 *data,
204 unsigned int *p_count); 212 unsigned int *p_count);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index aacec8bc19d5..dc5de275352a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -214,6 +214,8 @@ static const u16 bnxt_async_events_arr[] = {
214 ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE, 214 ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,
215}; 215};
216 216
217static struct workqueue_struct *bnxt_pf_wq;
218
217static bool bnxt_vf_pciid(enum board_idx idx) 219static bool bnxt_vf_pciid(enum board_idx idx)
218{ 220{
219 return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF); 221 return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF);
@@ -1024,12 +1026,28 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_napi *bnapi,
1024 return 0; 1026 return 0;
1025} 1027}
1026 1028
1029static void bnxt_queue_sp_work(struct bnxt *bp)
1030{
1031 if (BNXT_PF(bp))
1032 queue_work(bnxt_pf_wq, &bp->sp_task);
1033 else
1034 schedule_work(&bp->sp_task);
1035}
1036
1037static void bnxt_cancel_sp_work(struct bnxt *bp)
1038{
1039 if (BNXT_PF(bp))
1040 flush_workqueue(bnxt_pf_wq);
1041 else
1042 cancel_work_sync(&bp->sp_task);
1043}
1044
1027static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr) 1045static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
1028{ 1046{
1029 if (!rxr->bnapi->in_reset) { 1047 if (!rxr->bnapi->in_reset) {
1030 rxr->bnapi->in_reset = true; 1048 rxr->bnapi->in_reset = true;
1031 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); 1049 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
1032 schedule_work(&bp->sp_task); 1050 bnxt_queue_sp_work(bp);
1033 } 1051 }
1034 rxr->rx_next_cons = 0xffff; 1052 rxr->rx_next_cons = 0xffff;
1035} 1053}
@@ -1717,7 +1735,7 @@ static int bnxt_async_event_process(struct bnxt *bp,
1717 default: 1735 default:
1718 goto async_event_process_exit; 1736 goto async_event_process_exit;
1719 } 1737 }
1720 schedule_work(&bp->sp_task); 1738 bnxt_queue_sp_work(bp);
1721async_event_process_exit: 1739async_event_process_exit:
1722 bnxt_ulp_async_events(bp, cmpl); 1740 bnxt_ulp_async_events(bp, cmpl);
1723 return 0; 1741 return 0;
@@ -1751,7 +1769,7 @@ static int bnxt_hwrm_handler(struct bnxt *bp, struct tx_cmp *txcmp)
1751 1769
1752 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); 1770 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap);
1753 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event); 1771 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event);
1754 schedule_work(&bp->sp_task); 1772 bnxt_queue_sp_work(bp);
1755 break; 1773 break;
1756 1774
1757 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT: 1775 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
@@ -3448,6 +3466,12 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
3448 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false); 3466 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false);
3449} 3467}
3450 3468
3469int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len,
3470 int timeout)
3471{
3472 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, true);
3473}
3474
3451int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) 3475int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
3452{ 3476{
3453 int rc; 3477 int rc;
@@ -6327,7 +6351,9 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
6327 } 6351 }
6328 6352
6329 if (link_re_init) { 6353 if (link_re_init) {
6354 mutex_lock(&bp->link_lock);
6330 rc = bnxt_update_phy_setting(bp); 6355 rc = bnxt_update_phy_setting(bp);
6356 mutex_unlock(&bp->link_lock);
6331 if (rc) 6357 if (rc)
6332 netdev_warn(bp->dev, "failed to update phy settings\n"); 6358 netdev_warn(bp->dev, "failed to update phy settings\n");
6333 } 6359 }
@@ -6647,7 +6673,7 @@ static void bnxt_set_rx_mode(struct net_device *dev)
6647 vnic->rx_mask = mask; 6673 vnic->rx_mask = mask;
6648 6674
6649 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event); 6675 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event);
6650 schedule_work(&bp->sp_task); 6676 bnxt_queue_sp_work(bp);
6651 } 6677 }
6652} 6678}
6653 6679
@@ -6920,7 +6946,7 @@ static void bnxt_tx_timeout(struct net_device *dev)
6920 6946
6921 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); 6947 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n");
6922 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); 6948 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
6923 schedule_work(&bp->sp_task); 6949 bnxt_queue_sp_work(bp);
6924} 6950}
6925 6951
6926#ifdef CONFIG_NET_POLL_CONTROLLER 6952#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -6952,7 +6978,7 @@ static void bnxt_timer(unsigned long data)
6952 if (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) && 6978 if (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) &&
6953 bp->stats_coal_ticks) { 6979 bp->stats_coal_ticks) {
6954 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event); 6980 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);
6955 schedule_work(&bp->sp_task); 6981 bnxt_queue_sp_work(bp);
6956 } 6982 }
6957bnxt_restart_timer: 6983bnxt_restart_timer:
6958 mod_timer(&bp->timer, jiffies + bp->current_interval); 6984 mod_timer(&bp->timer, jiffies + bp->current_interval);
@@ -7025,30 +7051,28 @@ static void bnxt_sp_task(struct work_struct *work)
7025 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) 7051 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))
7026 bnxt_hwrm_port_qstats(bp); 7052 bnxt_hwrm_port_qstats(bp);
7027 7053
7028 /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7029 * must be the last functions to be called before exiting.
7030 */
7031 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { 7054 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
7032 int rc = 0; 7055 int rc;
7033 7056
7057 mutex_lock(&bp->link_lock);
7034 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, 7058 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
7035 &bp->sp_event)) 7059 &bp->sp_event))
7036 bnxt_hwrm_phy_qcaps(bp); 7060 bnxt_hwrm_phy_qcaps(bp);
7037 7061
7038 bnxt_rtnl_lock_sp(bp); 7062 rc = bnxt_update_link(bp, true);
7039 if (test_bit(BNXT_STATE_OPEN, &bp->state)) 7063 mutex_unlock(&bp->link_lock);
7040 rc = bnxt_update_link(bp, true);
7041 bnxt_rtnl_unlock_sp(bp);
7042 if (rc) 7064 if (rc)
7043 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", 7065 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
7044 rc); 7066 rc);
7045 } 7067 }
7046 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { 7068 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {
7047 bnxt_rtnl_lock_sp(bp); 7069 mutex_lock(&bp->link_lock);
7048 if (test_bit(BNXT_STATE_OPEN, &bp->state)) 7070 bnxt_get_port_module_status(bp);
7049 bnxt_get_port_module_status(bp); 7071 mutex_unlock(&bp->link_lock);
7050 bnxt_rtnl_unlock_sp(bp);
7051 } 7072 }
7073 /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7074 * must be the last functions to be called before exiting.
7075 */
7052 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) 7076 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
7053 bnxt_reset(bp, false); 7077 bnxt_reset(bp, false);
7054 7078
@@ -7433,7 +7457,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
7433 spin_unlock_bh(&bp->ntp_fltr_lock); 7457 spin_unlock_bh(&bp->ntp_fltr_lock);
7434 7458
7435 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event); 7459 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event);
7436 schedule_work(&bp->sp_task); 7460 bnxt_queue_sp_work(bp);
7437 7461
7438 return new_fltr->sw_id; 7462 return new_fltr->sw_id;
7439 7463
@@ -7516,7 +7540,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev,
7516 if (bp->vxlan_port_cnt == 1) { 7540 if (bp->vxlan_port_cnt == 1) {
7517 bp->vxlan_port = ti->port; 7541 bp->vxlan_port = ti->port;
7518 set_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event); 7542 set_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event);
7519 schedule_work(&bp->sp_task); 7543 bnxt_queue_sp_work(bp);
7520 } 7544 }
7521 break; 7545 break;
7522 case UDP_TUNNEL_TYPE_GENEVE: 7546 case UDP_TUNNEL_TYPE_GENEVE:
@@ -7533,7 +7557,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev,
7533 return; 7557 return;
7534 } 7558 }
7535 7559
7536 schedule_work(&bp->sp_task); 7560 bnxt_queue_sp_work(bp);
7537} 7561}
7538 7562
7539static void bnxt_udp_tunnel_del(struct net_device *dev, 7563static void bnxt_udp_tunnel_del(struct net_device *dev,
@@ -7572,7 +7596,7 @@ static void bnxt_udp_tunnel_del(struct net_device *dev,
7572 return; 7596 return;
7573 } 7597 }
7574 7598
7575 schedule_work(&bp->sp_task); 7599 bnxt_queue_sp_work(bp);
7576} 7600}
7577 7601
7578static int bnxt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, 7602static int bnxt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
@@ -7720,7 +7744,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
7720 pci_disable_pcie_error_reporting(pdev); 7744 pci_disable_pcie_error_reporting(pdev);
7721 unregister_netdev(dev); 7745 unregister_netdev(dev);
7722 bnxt_shutdown_tc(bp); 7746 bnxt_shutdown_tc(bp);
7723 cancel_work_sync(&bp->sp_task); 7747 bnxt_cancel_sp_work(bp);
7724 bp->sp_event = 0; 7748 bp->sp_event = 0;
7725 7749
7726 bnxt_clear_int_mode(bp); 7750 bnxt_clear_int_mode(bp);
@@ -7748,6 +7772,7 @@ static int bnxt_probe_phy(struct bnxt *bp)
7748 rc); 7772 rc);
7749 return rc; 7773 return rc;
7750 } 7774 }
7775 mutex_init(&bp->link_lock);
7751 7776
7752 rc = bnxt_update_link(bp, false); 7777 rc = bnxt_update_link(bp, false);
7753 if (rc) { 7778 if (rc) {
@@ -7946,7 +7971,7 @@ static void bnxt_parse_log_pcie_link(struct bnxt *bp)
7946 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN; 7971 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
7947 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN; 7972 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
7948 7973
7949 if (pcie_get_minimum_link(bp->pdev, &speed, &width) || 7974 if (pcie_get_minimum_link(pci_physfn(bp->pdev), &speed, &width) ||
7950 speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN) 7975 speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)
7951 netdev_info(bp->dev, "Failed to determine PCIe Link Info\n"); 7976 netdev_info(bp->dev, "Failed to determine PCIe Link Info\n");
7952 else 7977 else
@@ -8138,8 +8163,17 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8138 else 8163 else
8139 device_set_wakeup_capable(&pdev->dev, false); 8164 device_set_wakeup_capable(&pdev->dev, false);
8140 8165
8141 if (BNXT_PF(bp)) 8166 if (BNXT_PF(bp)) {
8167 if (!bnxt_pf_wq) {
8168 bnxt_pf_wq =
8169 create_singlethread_workqueue("bnxt_pf_wq");
8170 if (!bnxt_pf_wq) {
8171 dev_err(&pdev->dev, "Unable to create workqueue.\n");
8172 goto init_err_pci_clean;
8173 }
8174 }
8142 bnxt_init_tc(bp); 8175 bnxt_init_tc(bp);
8176 }
8143 8177
8144 rc = register_netdev(dev); 8178 rc = register_netdev(dev);
8145 if (rc) 8179 if (rc)
@@ -8375,4 +8409,17 @@ static struct pci_driver bnxt_pci_driver = {
8375#endif 8409#endif
8376}; 8410};
8377 8411
8378module_pci_driver(bnxt_pci_driver); 8412static int __init bnxt_init(void)
8413{
8414 return pci_register_driver(&bnxt_pci_driver);
8415}
8416
8417static void __exit bnxt_exit(void)
8418{
8419 pci_unregister_driver(&bnxt_pci_driver);
8420 if (bnxt_pf_wq)
8421 destroy_workqueue(bnxt_pf_wq);
8422}
8423
8424module_init(bnxt_init);
8425module_exit(bnxt_exit);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 7b888d4b2b55..c911e69ff25f 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1290,6 +1290,10 @@ struct bnxt {
1290 unsigned long *ntp_fltr_bmap; 1290 unsigned long *ntp_fltr_bmap;
1291 int ntp_fltr_count; 1291 int ntp_fltr_count;
1292 1292
1293 /* To protect link related settings during link changes and
1294 * ethtool settings changes.
1295 */
1296 struct mutex link_lock;
1293 struct bnxt_link_info link_info; 1297 struct bnxt_link_info link_info;
1294 struct ethtool_eee eee; 1298 struct ethtool_eee eee;
1295 u32 lpi_tmr_lo; 1299 u32 lpi_tmr_lo;
@@ -1358,6 +1362,7 @@ void bnxt_set_ring_params(struct bnxt *);
1358int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); 1362int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
1359void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16); 1363void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
1360int _hwrm_send_message(struct bnxt *, void *, u32, int); 1364int _hwrm_send_message(struct bnxt *, void *, u32, int);
1365int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
1361int hwrm_send_message(struct bnxt *, void *, u32, int); 1366int hwrm_send_message(struct bnxt *, void *, u32, int);
1362int hwrm_send_message_silent(struct bnxt *, void *, u32, int); 1367int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
1363int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap, 1368int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
index aa1f3a2c7a78..fed37cd9ae1d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
@@ -50,7 +50,9 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets)
50 50
51 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1); 51 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1);
52 req.flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); 52 req.flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN);
53 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); 53
54 mutex_lock(&bp->hwrm_cmd_lock);
55 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
54 if (!rc) { 56 if (!rc) {
55 u8 *pri2cos = &resp->pri0_cos_queue_id; 57 u8 *pri2cos = &resp->pri0_cos_queue_id;
56 int i, j; 58 int i, j;
@@ -66,6 +68,7 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets)
66 } 68 }
67 } 69 }
68 } 70 }
71 mutex_unlock(&bp->hwrm_cmd_lock);
69 return rc; 72 return rc;
70} 73}
71 74
@@ -119,9 +122,13 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets)
119 int rc, i; 122 int rc, i;
120 123
121 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_QCFG, -1, -1); 124 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_QCFG, -1, -1);
122 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); 125
123 if (rc) 126 mutex_lock(&bp->hwrm_cmd_lock);
127 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
128 if (rc) {
129 mutex_unlock(&bp->hwrm_cmd_lock);
124 return rc; 130 return rc;
131 }
125 132
126 data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id); 133 data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);
127 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) { 134 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) {
@@ -143,6 +150,7 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets)
143 } 150 }
144 } 151 }
145 } 152 }
153 mutex_unlock(&bp->hwrm_cmd_lock);
146 return 0; 154 return 0;
147} 155}
148 156
@@ -240,12 +248,17 @@ static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc)
240 int rc; 248 int rc;
241 249
242 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_QCFG, -1, -1); 250 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_QCFG, -1, -1);
243 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); 251
244 if (rc) 252 mutex_lock(&bp->hwrm_cmd_lock);
253 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
254 if (rc) {
255 mutex_unlock(&bp->hwrm_cmd_lock);
245 return rc; 256 return rc;
257 }
246 258
247 pri_mask = le32_to_cpu(resp->flags); 259 pri_mask = le32_to_cpu(resp->flags);
248 pfc->pfc_en = pri_mask; 260 pfc->pfc_en = pri_mask;
261 mutex_unlock(&bp->hwrm_cmd_lock);
249 return 0; 262 return 0;
250} 263}
251 264
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 8eff05a3e0e4..3cbe771b3352 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -1052,6 +1052,7 @@ static int bnxt_get_link_ksettings(struct net_device *dev,
1052 u32 ethtool_speed; 1052 u32 ethtool_speed;
1053 1053
1054 ethtool_link_ksettings_zero_link_mode(lk_ksettings, supported); 1054 ethtool_link_ksettings_zero_link_mode(lk_ksettings, supported);
1055 mutex_lock(&bp->link_lock);
1055 bnxt_fw_to_ethtool_support_spds(link_info, lk_ksettings); 1056 bnxt_fw_to_ethtool_support_spds(link_info, lk_ksettings);
1056 1057
1057 ethtool_link_ksettings_zero_link_mode(lk_ksettings, advertising); 1058 ethtool_link_ksettings_zero_link_mode(lk_ksettings, advertising);
@@ -1099,6 +1100,7 @@ static int bnxt_get_link_ksettings(struct net_device *dev,
1099 base->port = PORT_FIBRE; 1100 base->port = PORT_FIBRE;
1100 } 1101 }
1101 base->phy_address = link_info->phy_addr; 1102 base->phy_address = link_info->phy_addr;
1103 mutex_unlock(&bp->link_lock);
1102 1104
1103 return 0; 1105 return 0;
1104} 1106}
@@ -1190,6 +1192,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev,
1190 if (!BNXT_SINGLE_PF(bp)) 1192 if (!BNXT_SINGLE_PF(bp))
1191 return -EOPNOTSUPP; 1193 return -EOPNOTSUPP;
1192 1194
1195 mutex_lock(&bp->link_lock);
1193 if (base->autoneg == AUTONEG_ENABLE) { 1196 if (base->autoneg == AUTONEG_ENABLE) {
1194 BNXT_ETHTOOL_TO_FW_SPDS(fw_advertising, lk_ksettings, 1197 BNXT_ETHTOOL_TO_FW_SPDS(fw_advertising, lk_ksettings,
1195 advertising); 1198 advertising);
@@ -1234,6 +1237,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev,
1234 rc = bnxt_hwrm_set_link_setting(bp, set_pause, false); 1237 rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);
1235 1238
1236set_setting_exit: 1239set_setting_exit:
1240 mutex_unlock(&bp->link_lock);
1237 return rc; 1241 return rc;
1238} 1242}
1239 1243
@@ -1805,7 +1809,8 @@ static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
1805 req.dir_ordinal = cpu_to_le16(ordinal); 1809 req.dir_ordinal = cpu_to_le16(ordinal);
1806 req.dir_ext = cpu_to_le16(ext); 1810 req.dir_ext = cpu_to_le16(ext);
1807 req.opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ; 1811 req.opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ;
1808 rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); 1812 mutex_lock(&bp->hwrm_cmd_lock);
1813 rc = _hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
1809 if (rc == 0) { 1814 if (rc == 0) {
1810 if (index) 1815 if (index)
1811 *index = le16_to_cpu(output->dir_idx); 1816 *index = le16_to_cpu(output->dir_idx);
@@ -1814,6 +1819,7 @@ static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
1814 if (data_length) 1819 if (data_length)
1815 *data_length = le32_to_cpu(output->dir_data_length); 1820 *data_length = le32_to_cpu(output->dir_data_length);
1816 } 1821 }
1822 mutex_unlock(&bp->hwrm_cmd_lock);
1817 return rc; 1823 return rc;
1818} 1824}
1819 1825
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index d37925a8a65b..5ee18660bc33 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -502,6 +502,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
502 int rc = 0, vfs_supported; 502 int rc = 0, vfs_supported;
503 int min_rx_rings, min_tx_rings, min_rss_ctxs; 503 int min_rx_rings, min_tx_rings, min_rss_ctxs;
504 int tx_ok = 0, rx_ok = 0, rss_ok = 0; 504 int tx_ok = 0, rx_ok = 0, rss_ok = 0;
505 int avail_cp, avail_stat;
505 506
506 /* Check if we can enable requested num of vf's. At a mininum 507 /* Check if we can enable requested num of vf's. At a mininum
507 * we require 1 RX 1 TX rings for each VF. In this minimum conf 508 * we require 1 RX 1 TX rings for each VF. In this minimum conf
@@ -509,6 +510,10 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
509 */ 510 */
510 vfs_supported = *num_vfs; 511 vfs_supported = *num_vfs;
511 512
513 avail_cp = bp->pf.max_cp_rings - bp->cp_nr_rings;
514 avail_stat = bp->pf.max_stat_ctxs - bp->num_stat_ctxs;
515 avail_cp = min_t(int, avail_cp, avail_stat);
516
512 while (vfs_supported) { 517 while (vfs_supported) {
513 min_rx_rings = vfs_supported; 518 min_rx_rings = vfs_supported;
514 min_tx_rings = vfs_supported; 519 min_tx_rings = vfs_supported;
@@ -523,10 +528,12 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
523 min_rx_rings) 528 min_rx_rings)
524 rx_ok = 1; 529 rx_ok = 1;
525 } 530 }
526 if (bp->pf.max_vnics - bp->nr_vnics < min_rx_rings) 531 if (bp->pf.max_vnics - bp->nr_vnics < min_rx_rings ||
532 avail_cp < min_rx_rings)
527 rx_ok = 0; 533 rx_ok = 0;
528 534
529 if (bp->pf.max_tx_rings - bp->tx_nr_rings >= min_tx_rings) 535 if (bp->pf.max_tx_rings - bp->tx_nr_rings >= min_tx_rings &&
536 avail_cp >= min_tx_rings)
530 tx_ok = 1; 537 tx_ok = 1;
531 538
532 if (bp->pf.max_rsscos_ctxs - bp->rsscos_nr_ctxs >= min_rss_ctxs) 539 if (bp->pf.max_rsscos_ctxs - bp->rsscos_nr_ctxs >= min_rss_ctxs)
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index e7f54948173f..5b19826a7e16 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1847,7 +1847,7 @@ static int liquidio_ptp_settime(struct ptp_clock_info *ptp,
1847 struct lio *lio = container_of(ptp, struct lio, ptp_info); 1847 struct lio *lio = container_of(ptp, struct lio, ptp_info);
1848 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev; 1848 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;
1849 1849
1850 ns = timespec_to_ns(ts); 1850 ns = timespec64_to_ns(ts);
1851 1851
1852 spin_lock_irqsave(&lio->ptp_lock, flags); 1852 spin_lock_irqsave(&lio->ptp_lock, flags);
1853 lio_pci_writeq(oct, ns, CN6XXX_MIO_PTP_CLOCK_HI); 1853 lio_pci_writeq(oct, ns, CN6XXX_MIO_PTP_CLOCK_HI);
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index cb8182f4fdfa..c66abd476023 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1093,11 +1093,12 @@ static int build_hdr_data(u8 hdr_field, struct sk_buff *skb,
1093 * places them in a descriptor array, scrq_arr 1093 * places them in a descriptor array, scrq_arr
1094 */ 1094 */
1095 1095
1096static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len, 1096static int create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
1097 union sub_crq *scrq_arr) 1097 union sub_crq *scrq_arr)
1098{ 1098{
1099 union sub_crq hdr_desc; 1099 union sub_crq hdr_desc;
1100 int tmp_len = len; 1100 int tmp_len = len;
1101 int num_descs = 0;
1101 u8 *data, *cur; 1102 u8 *data, *cur;
1102 int tmp; 1103 int tmp;
1103 1104
@@ -1126,7 +1127,10 @@ static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
1126 tmp_len -= tmp; 1127 tmp_len -= tmp;
1127 *scrq_arr = hdr_desc; 1128 *scrq_arr = hdr_desc;
1128 scrq_arr++; 1129 scrq_arr++;
1130 num_descs++;
1129 } 1131 }
1132
1133 return num_descs;
1130} 1134}
1131 1135
1132/** 1136/**
@@ -1144,16 +1148,12 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff *txbuff,
1144 int *num_entries, u8 hdr_field) 1148 int *num_entries, u8 hdr_field)
1145{ 1149{
1146 int hdr_len[3] = {0, 0, 0}; 1150 int hdr_len[3] = {0, 0, 0};
1147 int tot_len, len; 1151 int tot_len;
1148 u8 *hdr_data = txbuff->hdr_data; 1152 u8 *hdr_data = txbuff->hdr_data;
1149 1153
1150 tot_len = build_hdr_data(hdr_field, txbuff->skb, hdr_len, 1154 tot_len = build_hdr_data(hdr_field, txbuff->skb, hdr_len,
1151 txbuff->hdr_data); 1155 txbuff->hdr_data);
1152 len = tot_len; 1156 *num_entries += create_hdr_descs(hdr_field, hdr_data, tot_len, hdr_len,
1153 len -= 24;
1154 if (len > 0)
1155 num_entries += len % 29 ? len / 29 + 1 : len / 29;
1156 create_hdr_descs(hdr_field, hdr_data, tot_len, hdr_len,
1157 txbuff->indir_arr + 1); 1157 txbuff->indir_arr + 1);
1158} 1158}
1159 1159
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 57505b1df98d..d591b3e6bd7c 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -298,7 +298,7 @@ static i40e_status i40e_read_nvm_word_aq(struct i40e_hw *hw, u16 offset,
298} 298}
299 299
300/** 300/**
301 * __i40e_read_nvm_word - Reads nvm word, assumes called does the locking 301 * __i40e_read_nvm_word - Reads nvm word, assumes caller does the locking
302 * @hw: pointer to the HW structure 302 * @hw: pointer to the HW structure
303 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF) 303 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
304 * @data: word read from the Shadow RAM 304 * @data: word read from the Shadow RAM
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 1519dfb851d0..2756131495f0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1038,6 +1038,32 @@ reset_latency:
1038} 1038}
1039 1039
1040/** 1040/**
1041 * i40e_reuse_rx_page - page flip buffer and store it back on the ring
1042 * @rx_ring: rx descriptor ring to store buffers on
1043 * @old_buff: donor buffer to have page reused
1044 *
1045 * Synchronizes page for reuse by the adapter
1046 **/
1047static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
1048 struct i40e_rx_buffer *old_buff)
1049{
1050 struct i40e_rx_buffer *new_buff;
1051 u16 nta = rx_ring->next_to_alloc;
1052
1053 new_buff = &rx_ring->rx_bi[nta];
1054
1055 /* update, and store next to alloc */
1056 nta++;
1057 rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
1058
1059 /* transfer page from old buffer to new buffer */
1060 new_buff->dma = old_buff->dma;
1061 new_buff->page = old_buff->page;
1062 new_buff->page_offset = old_buff->page_offset;
1063 new_buff->pagecnt_bias = old_buff->pagecnt_bias;
1064}
1065
1066/**
1041 * i40e_rx_is_programming_status - check for programming status descriptor 1067 * i40e_rx_is_programming_status - check for programming status descriptor
1042 * @qw: qword representing status_error_len in CPU ordering 1068 * @qw: qword representing status_error_len in CPU ordering
1043 * 1069 *
@@ -1071,15 +1097,24 @@ static void i40e_clean_programming_status(struct i40e_ring *rx_ring,
1071 union i40e_rx_desc *rx_desc, 1097 union i40e_rx_desc *rx_desc,
1072 u64 qw) 1098 u64 qw)
1073{ 1099{
1074 u32 ntc = rx_ring->next_to_clean + 1; 1100 struct i40e_rx_buffer *rx_buffer;
1101 u32 ntc = rx_ring->next_to_clean;
1075 u8 id; 1102 u8 id;
1076 1103
1077 /* fetch, update, and store next to clean */ 1104 /* fetch, update, and store next to clean */
1105 rx_buffer = &rx_ring->rx_bi[ntc++];
1078 ntc = (ntc < rx_ring->count) ? ntc : 0; 1106 ntc = (ntc < rx_ring->count) ? ntc : 0;
1079 rx_ring->next_to_clean = ntc; 1107 rx_ring->next_to_clean = ntc;
1080 1108
1081 prefetch(I40E_RX_DESC(rx_ring, ntc)); 1109 prefetch(I40E_RX_DESC(rx_ring, ntc));
1082 1110
1111 /* place unused page back on the ring */
1112 i40e_reuse_rx_page(rx_ring, rx_buffer);
1113 rx_ring->rx_stats.page_reuse_count++;
1114
1115 /* clear contents of buffer_info */
1116 rx_buffer->page = NULL;
1117
1083 id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >> 1118 id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >>
1084 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT; 1119 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
1085 1120
@@ -1639,32 +1674,6 @@ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb,
1639} 1674}
1640 1675
1641/** 1676/**
1642 * i40e_reuse_rx_page - page flip buffer and store it back on the ring
1643 * @rx_ring: rx descriptor ring to store buffers on
1644 * @old_buff: donor buffer to have page reused
1645 *
1646 * Synchronizes page for reuse by the adapter
1647 **/
1648static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
1649 struct i40e_rx_buffer *old_buff)
1650{
1651 struct i40e_rx_buffer *new_buff;
1652 u16 nta = rx_ring->next_to_alloc;
1653
1654 new_buff = &rx_ring->rx_bi[nta];
1655
1656 /* update, and store next to alloc */
1657 nta++;
1658 rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
1659
1660 /* transfer page from old buffer to new buffer */
1661 new_buff->dma = old_buff->dma;
1662 new_buff->page = old_buff->page;
1663 new_buff->page_offset = old_buff->page_offset;
1664 new_buff->pagecnt_bias = old_buff->pagecnt_bias;
1665}
1666
1667/**
1668 * i40e_page_is_reusable - check if any reuse is possible 1677 * i40e_page_is_reusable - check if any reuse is possible
1669 * @page: page struct to check 1678 * @page: page struct to check
1670 * 1679 *
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 9d5e7cf288be..f3315bc874ad 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -96,6 +96,7 @@ struct mlxsw_core {
96 const struct mlxsw_bus *bus; 96 const struct mlxsw_bus *bus;
97 void *bus_priv; 97 void *bus_priv;
98 const struct mlxsw_bus_info *bus_info; 98 const struct mlxsw_bus_info *bus_info;
99 struct workqueue_struct *emad_wq;
99 struct list_head rx_listener_list; 100 struct list_head rx_listener_list;
100 struct list_head event_listener_list; 101 struct list_head event_listener_list;
101 struct { 102 struct {
@@ -465,7 +466,7 @@ static void mlxsw_emad_trans_timeout_schedule(struct mlxsw_reg_trans *trans)
465{ 466{
466 unsigned long timeout = msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS); 467 unsigned long timeout = msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS);
467 468
468 mlxsw_core_schedule_dw(&trans->timeout_dw, timeout); 469 queue_delayed_work(trans->core->emad_wq, &trans->timeout_dw, timeout);
469} 470}
470 471
471static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core, 472static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,
@@ -587,12 +588,18 @@ static const struct mlxsw_listener mlxsw_emad_rx_listener =
587 588
588static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core) 589static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
589{ 590{
591 struct workqueue_struct *emad_wq;
590 u64 tid; 592 u64 tid;
591 int err; 593 int err;
592 594
593 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX)) 595 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
594 return 0; 596 return 0;
595 597
598 emad_wq = alloc_workqueue("mlxsw_core_emad", WQ_MEM_RECLAIM, 0);
599 if (!emad_wq)
600 return -ENOMEM;
601 mlxsw_core->emad_wq = emad_wq;
602
596 /* Set the upper 32 bits of the transaction ID field to a random 603 /* Set the upper 32 bits of the transaction ID field to a random
597 * number. This allows us to discard EMADs addressed to other 604 * number. This allows us to discard EMADs addressed to other
598 * devices. 605 * devices.
@@ -619,6 +626,7 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
619err_emad_trap_set: 626err_emad_trap_set:
620 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener, 627 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
621 mlxsw_core); 628 mlxsw_core);
629 destroy_workqueue(mlxsw_core->emad_wq);
622 return err; 630 return err;
623} 631}
624 632
@@ -631,6 +639,7 @@ static void mlxsw_emad_fini(struct mlxsw_core *mlxsw_core)
631 mlxsw_core->emad.use_emad = false; 639 mlxsw_core->emad.use_emad = false;
632 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener, 640 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
633 mlxsw_core); 641 mlxsw_core);
642 destroy_workqueue(mlxsw_core->emad_wq);
634} 643}
635 644
636static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core, 645static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index cc27c5de5a1d..4afc8486eb9a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -6401,6 +6401,36 @@ static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
6401 mlxsw_reg_mgpc_opcode_set(payload, opcode); 6401 mlxsw_reg_mgpc_opcode_set(payload, opcode);
6402} 6402}
6403 6403
6404/* TIGCR - Tunneling IPinIP General Configuration Register
6405 * -------------------------------------------------------
6406 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
6407 */
6408#define MLXSW_REG_TIGCR_ID 0xA801
6409#define MLXSW_REG_TIGCR_LEN 0x10
6410
6411MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
6412
6413/* reg_tigcr_ipip_ttlc
6414 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
6415 * header.
6416 * Access: RW
6417 */
6418MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
6419
6420/* reg_tigcr_ipip_ttl_uc
6421 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
6422 * reg_tigcr_ipip_ttlc is unset.
6423 * Access: RW
6424 */
6425MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
6426
6427static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
6428{
6429 MLXSW_REG_ZERO(tigcr, payload);
6430 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
6431 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
6432}
6433
6404/* SBPR - Shared Buffer Pools Register 6434/* SBPR - Shared Buffer Pools Register
6405 * ----------------------------------- 6435 * -----------------------------------
6406 * The SBPR configures and retrieves the shared buffer pools and configuration. 6436 * The SBPR configures and retrieves the shared buffer pools and configuration.
@@ -6881,6 +6911,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
6881 MLXSW_REG(mcc), 6911 MLXSW_REG(mcc),
6882 MLXSW_REG(mcda), 6912 MLXSW_REG(mcda),
6883 MLXSW_REG(mgpc), 6913 MLXSW_REG(mgpc),
6914 MLXSW_REG(tigcr),
6884 MLXSW_REG(sbpr), 6915 MLXSW_REG(sbpr),
6885 MLXSW_REG(sbcm), 6916 MLXSW_REG(sbcm),
6886 MLXSW_REG(sbpm), 6917 MLXSW_REG(sbpm),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index c16718d296d3..5189022a1c8c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -5896,11 +5896,20 @@ static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp)
5896 kfree(mlxsw_sp->router->rifs); 5896 kfree(mlxsw_sp->router->rifs);
5897} 5897}
5898 5898
5899static int
5900mlxsw_sp_ipip_config_tigcr(struct mlxsw_sp *mlxsw_sp)
5901{
5902 char tigcr_pl[MLXSW_REG_TIGCR_LEN];
5903
5904 mlxsw_reg_tigcr_pack(tigcr_pl, true, 0);
5905 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(tigcr), tigcr_pl);
5906}
5907
5899static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp) 5908static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)
5900{ 5909{
5901 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr; 5910 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;
5902 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list); 5911 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list);
5903 return 0; 5912 return mlxsw_sp_ipip_config_tigcr(mlxsw_sp);
5904} 5913}
5905 5914
5906static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp) 5915static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 1c0187f0af51..e118b5f23996 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -1180,10 +1180,14 @@ static void *nfp_net_rx_alloc_one(struct nfp_net_dp *dp, dma_addr_t *dma_addr)
1180{ 1180{
1181 void *frag; 1181 void *frag;
1182 1182
1183 if (!dp->xdp_prog) 1183 if (!dp->xdp_prog) {
1184 frag = netdev_alloc_frag(dp->fl_bufsz); 1184 frag = netdev_alloc_frag(dp->fl_bufsz);
1185 else 1185 } else {
1186 frag = page_address(alloc_page(GFP_KERNEL | __GFP_COLD)); 1186 struct page *page;
1187
1188 page = alloc_page(GFP_KERNEL | __GFP_COLD);
1189 frag = page ? page_address(page) : NULL;
1190 }
1187 if (!frag) { 1191 if (!frag) {
1188 nn_dp_warn(dp, "Failed to alloc receive page frag\n"); 1192 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
1189 return NULL; 1193 return NULL;
@@ -1203,10 +1207,14 @@ static void *nfp_net_napi_alloc_one(struct nfp_net_dp *dp, dma_addr_t *dma_addr)
1203{ 1207{
1204 void *frag; 1208 void *frag;
1205 1209
1206 if (!dp->xdp_prog) 1210 if (!dp->xdp_prog) {
1207 frag = napi_alloc_frag(dp->fl_bufsz); 1211 frag = napi_alloc_frag(dp->fl_bufsz);
1208 else 1212 } else {
1209 frag = page_address(alloc_page(GFP_ATOMIC | __GFP_COLD)); 1213 struct page *page;
1214
1215 page = alloc_page(GFP_ATOMIC | __GFP_COLD);
1216 frag = page ? page_address(page) : NULL;
1217 }
1210 if (!frag) { 1218 if (!frag) {
1211 nn_dp_warn(dp, "Failed to alloc receive page frag\n"); 1219 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
1212 return NULL; 1220 return NULL;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
index 07969f06df10..dc016dfec64d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
@@ -464,7 +464,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
464 464
465 do { 465 do {
466 start = u64_stats_fetch_begin(&nn->r_vecs[i].rx_sync); 466 start = u64_stats_fetch_begin(&nn->r_vecs[i].rx_sync);
467 *data++ = nn->r_vecs[i].rx_pkts; 467 data[0] = nn->r_vecs[i].rx_pkts;
468 tmp[0] = nn->r_vecs[i].hw_csum_rx_ok; 468 tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;
469 tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok; 469 tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;
470 tmp[2] = nn->r_vecs[i].hw_csum_rx_error; 470 tmp[2] = nn->r_vecs[i].hw_csum_rx_error;
@@ -472,14 +472,16 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
472 472
473 do { 473 do {
474 start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync); 474 start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);
475 *data++ = nn->r_vecs[i].tx_pkts; 475 data[1] = nn->r_vecs[i].tx_pkts;
476 *data++ = nn->r_vecs[i].tx_busy; 476 data[2] = nn->r_vecs[i].tx_busy;
477 tmp[3] = nn->r_vecs[i].hw_csum_tx; 477 tmp[3] = nn->r_vecs[i].hw_csum_tx;
478 tmp[4] = nn->r_vecs[i].hw_csum_tx_inner; 478 tmp[4] = nn->r_vecs[i].hw_csum_tx_inner;
479 tmp[5] = nn->r_vecs[i].tx_gather; 479 tmp[5] = nn->r_vecs[i].tx_gather;
480 tmp[6] = nn->r_vecs[i].tx_lso; 480 tmp[6] = nn->r_vecs[i].tx_lso;
481 } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start)); 481 } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));
482 482
483 data += 3;
484
483 for (j = 0; j < NN_ET_RVEC_GATHER_STATS; j++) 485 for (j = 0; j < NN_ET_RVEC_GATHER_STATS; j++)
484 gathered_stats[j] += tmp[j]; 486 gathered_stats[j] += tmp[j];
485 } 487 }
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index e03fcf914690..a3c949ea7d1a 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -8491,8 +8491,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8491 rtl8168_driver_start(tp); 8491 rtl8168_driver_start(tp);
8492 } 8492 }
8493 8493
8494 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
8495
8496 if (pci_dev_run_wake(pdev)) 8494 if (pci_dev_run_wake(pdev))
8497 pm_runtime_put_noidle(&pdev->dev); 8495 pm_runtime_put_noidle(&pdev->dev);
8498 8496
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index e0ef02f9503b..4b286e27c4ca 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -275,7 +275,7 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats)
275 goto exit; 275 goto exit;
276 i++; 276 i++;
277 277
278 } while ((ret == 1) || (i < 10)); 278 } while ((ret == 1) && (i < 10));
279 279
280 if (i == 10) 280 if (i == 10)
281 ret = -EBUSY; 281 ret = -EBUSY;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
index 67af0bdd7f10..7516ca210855 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
@@ -34,7 +34,7 @@ int dwmac_dma_reset(void __iomem *ioaddr)
34 34
35 err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value, 35 err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
36 !(value & DMA_BUS_MODE_SFT_RESET), 36 !(value & DMA_BUS_MODE_SFT_RESET),
37 100000, 10000); 37 10000, 100000);
38 if (err) 38 if (err)
39 return -EBUSY; 39 return -EBUSY;
40 40
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1763e48c84e2..16bd50929084 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -473,19 +473,18 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
473 struct dma_desc *np, struct sk_buff *skb) 473 struct dma_desc *np, struct sk_buff *skb)
474{ 474{
475 struct skb_shared_hwtstamps *shhwtstamp = NULL; 475 struct skb_shared_hwtstamps *shhwtstamp = NULL;
476 struct dma_desc *desc = p;
476 u64 ns; 477 u64 ns;
477 478
478 if (!priv->hwts_rx_en) 479 if (!priv->hwts_rx_en)
479 return; 480 return;
481 /* For GMAC4, the valid timestamp is from CTX next desc. */
482 if (priv->plat->has_gmac4)
483 desc = np;
480 484
481 /* Check if timestamp is available */ 485 /* Check if timestamp is available */
482 if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) { 486 if (priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) {
483 /* For GMAC4, the valid timestamp is from CTX next desc. */ 487 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
484 if (priv->plat->has_gmac4)
485 ns = priv->hw->desc->get_timestamp(np, priv->adv_ts);
486 else
487 ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
488
489 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns); 488 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
490 shhwtstamp = skb_hwtstamps(skb); 489 shhwtstamp = skb_hwtstamps(skb);
491 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); 490 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
@@ -1800,12 +1799,13 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue)
1800{ 1799{
1801 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; 1800 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];
1802 unsigned int bytes_compl = 0, pkts_compl = 0; 1801 unsigned int bytes_compl = 0, pkts_compl = 0;
1803 unsigned int entry = tx_q->dirty_tx; 1802 unsigned int entry;
1804 1803
1805 netif_tx_lock(priv->dev); 1804 netif_tx_lock(priv->dev);
1806 1805
1807 priv->xstats.tx_clean++; 1806 priv->xstats.tx_clean++;
1808 1807
1808 entry = tx_q->dirty_tx;
1809 while (entry != tx_q->cur_tx) { 1809 while (entry != tx_q->cur_tx) {
1810 struct sk_buff *skb = tx_q->tx_skbuff[entry]; 1810 struct sk_buff *skb = tx_q->tx_skbuff[entry];
1811 struct dma_desc *p; 1811 struct dma_desc *p;
@@ -3333,6 +3333,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
3333 * them in stmmac_rx_refill() function so that 3333 * them in stmmac_rx_refill() function so that
3334 * device can reuse it. 3334 * device can reuse it.
3335 */ 3335 */
3336 dev_kfree_skb_any(rx_q->rx_skbuff[entry]);
3336 rx_q->rx_skbuff[entry] = NULL; 3337 rx_q->rx_skbuff[entry] = NULL;
3337 dma_unmap_single(priv->device, 3338 dma_unmap_single(priv->device,
3338 rx_q->rx_skbuff_dma[entry], 3339 rx_q->rx_skbuff_dma[entry],
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index f6404074b7b0..ed51018a813e 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -113,13 +113,7 @@ static void tunnel_id_to_vni(__be64 tun_id, __u8 *vni)
113 113
114static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni) 114static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni)
115{ 115{
116#ifdef __BIG_ENDIAN
117 return (vni[0] == tun_id[2]) &&
118 (vni[1] == tun_id[1]) &&
119 (vni[2] == tun_id[0]);
120#else
121 return !memcmp(vni, &tun_id[5], 3); 116 return !memcmp(vni, &tun_id[5], 3);
122#endif
123} 117}
124 118
125static sa_family_t geneve_get_sk_family(struct geneve_sock *gs) 119static sa_family_t geneve_get_sk_family(struct geneve_sock *gs)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 98e4deaa3a6a..5ab1b8849c30 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -742,6 +742,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
742 sg_init_table(sg, ret); 742 sg_init_table(sg, ret);
743 ret = skb_to_sgvec(skb, sg, 0, skb->len); 743 ret = skb_to_sgvec(skb, sg, 0, skb->len);
744 if (unlikely(ret < 0)) { 744 if (unlikely(ret < 0)) {
745 aead_request_free(req);
745 macsec_txsa_put(tx_sa); 746 macsec_txsa_put(tx_sa);
746 kfree_skb(skb); 747 kfree_skb(skb);
747 return ERR_PTR(ret); 748 return ERR_PTR(ret);
@@ -954,6 +955,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
954 sg_init_table(sg, ret); 955 sg_init_table(sg, ret);
955 ret = skb_to_sgvec(skb, sg, 0, skb->len); 956 ret = skb_to_sgvec(skb, sg, 0, skb->len);
956 if (unlikely(ret < 0)) { 957 if (unlikely(ret < 0)) {
958 aead_request_free(req);
957 kfree_skb(skb); 959 kfree_skb(skb);
958 return ERR_PTR(ret); 960 return ERR_PTR(ret);
959 } 961 }
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5ce580f413b9..e21bf90b819f 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2027,6 +2027,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
2027 2027
2028 if (!dev) 2028 if (!dev)
2029 return -ENOMEM; 2029 return -ENOMEM;
2030 err = dev_get_valid_name(net, dev, name);
2031 if (err)
2032 goto err_free_dev;
2030 2033
2031 dev_net_set(dev, net); 2034 dev_net_set(dev, net);
2032 dev->rtnl_link_ops = &tun_link_ops; 2035 dev->rtnl_link_ops = &tun_link_ops;
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index c9c711dcd0e6..a89b5685e68b 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -652,7 +652,7 @@ static int i2400m_download_chunk(struct i2400m *i2400m, const void *chunk,
652 struct device *dev = i2400m_dev(i2400m); 652 struct device *dev = i2400m_dev(i2400m);
653 struct { 653 struct {
654 struct i2400m_bootrom_header cmd; 654 struct i2400m_bootrom_header cmd;
655 u8 cmd_payload[chunk_len]; 655 u8 cmd_payload[];
656 } __packed *buf; 656 } __packed *buf;
657 struct i2400m_bootrom_header ack; 657 struct i2400m_bootrom_header ack;
658 658
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
index 4eb1e1ce9ace..ef72baf6dd96 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
@@ -429,7 +429,8 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr,
429 if (code != BRCMF_E_IF && !fweh->evt_handler[code]) 429 if (code != BRCMF_E_IF && !fweh->evt_handler[code])
430 return; 430 return;
431 431
432 if (datalen > BRCMF_DCMD_MAXLEN) 432 if (datalen > BRCMF_DCMD_MAXLEN ||
433 datalen + sizeof(*event_packet) > packet_len)
433 return; 434 return;
434 435
435 if (in_interrupt()) 436 if (in_interrupt())
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index b3aab2fe96eb..ef685465f80a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -14764,8 +14764,8 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi)
14764} 14764}
14765 14765
14766static void 14766static void
14767wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, 14767wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events,
14768 u8 len) 14768 const u8 *dlys, u8 len)
14769{ 14769{
14770 u32 t1_offset, t2_offset; 14770 u32 t1_offset, t2_offset;
14771 u8 ctr; 14771 u8 ctr;
@@ -15240,16 +15240,16 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi)
15240static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) 15240static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
15241{ 15241{
15242 u16 currband; 15242 u16 currband;
15243 s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; 15243 static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
15244 s8 *lna1_gain_db = NULL; 15244 const s8 *lna1_gain_db = NULL;
15245 s8 *lna1_gain_db_2 = NULL; 15245 const s8 *lna1_gain_db_2 = NULL;
15246 s8 *lna2_gain_db = NULL; 15246 const s8 *lna2_gain_db = NULL;
15247 s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; 15247 static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };
15248 s8 *tia_gain_db; 15248 const s8 *tia_gain_db;
15249 s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; 15249 static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
15250 s8 *tia_gainbits; 15250 const s8 *tia_gainbits;
15251 u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; 15251 static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
15252 u16 *rfseq_init_gain; 15252 const u16 *rfseq_init_gain;
15253 u16 init_gaincode; 15253 u16 init_gaincode;
15254 u16 clip1hi_gaincode; 15254 u16 clip1hi_gaincode;
15255 u16 clip1md_gaincode = 0; 15255 u16 clip1md_gaincode = 0;
@@ -15310,10 +15310,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
15310 15310
15311 if ((freq <= 5080) || (freq == 5825)) { 15311 if ((freq <= 5080) || (freq == 5825)) {
15312 15312
15313 s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; 15313 static const s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };
15314 s8 lna1A_gain_db_2_rev7[] = { 15314 static const s8 lna1A_gain_db_2_rev7[] = { 11, 17, 22, 25};
15315 11, 17, 22, 25}; 15315 static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15316 s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15317 15316
15318 crsminu_th = 0x3e; 15317 crsminu_th = 0x3e;
15319 lna1_gain_db = lna1A_gain_db_rev7; 15318 lna1_gain_db = lna1A_gain_db_rev7;
@@ -15321,10 +15320,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
15321 lna2_gain_db = lna2A_gain_db_rev7; 15320 lna2_gain_db = lna2A_gain_db_rev7;
15322 } else if ((freq >= 5500) && (freq <= 5700)) { 15321 } else if ((freq >= 5500) && (freq <= 5700)) {
15323 15322
15324 s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; 15323 static const s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };
15325 s8 lna1A_gain_db_2_rev7[] = { 15324 static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15326 12, 18, 22, 26}; 15325 static const s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
15327 s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
15328 15326
15329 crsminu_th = 0x45; 15327 crsminu_th = 0x45;
15330 clip1md_gaincode_B = 0x14; 15328 clip1md_gaincode_B = 0x14;
@@ -15335,10 +15333,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
15335 lna2_gain_db = lna2A_gain_db_rev7; 15333 lna2_gain_db = lna2A_gain_db_rev7;
15336 } else { 15334 } else {
15337 15335
15338 s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; 15336 static const s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };
15339 s8 lna1A_gain_db_2_rev7[] = { 15337 static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15340 12, 18, 22, 26}; 15338 static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15341 s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15342 15339
15343 crsminu_th = 0x41; 15340 crsminu_th = 0x41;
15344 lna1_gain_db = lna1A_gain_db_rev7; 15341 lna1_gain_db = lna1A_gain_db_rev7;
@@ -15450,65 +15447,65 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi)
15450 NPHY_RFSEQ_CMD_CLR_HIQ_DIS, 15447 NPHY_RFSEQ_CMD_CLR_HIQ_DIS,
15451 NPHY_RFSEQ_CMD_SET_HPF_BW 15448 NPHY_RFSEQ_CMD_SET_HPF_BW
15452 }; 15449 };
15453 u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; 15450 static const u8 rfseq_updategainu_dlys[] = { 10, 30, 1 };
15454 s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; 15451 static const s8 lna1G_gain_db[] = { 7, 11, 16, 23 };
15455 s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; 15452 static const s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 };
15456 s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; 15453 static const s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 };
15457 s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; 15454 static const s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 };
15458 s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; 15455 static const s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 };
15459 s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; 15456 static const s8 lna1A_gain_db[] = { 7, 11, 17, 23 };
15460 s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; 15457 static const s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 };
15461 s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; 15458 static const s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 };
15462 s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; 15459 static const s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 };
15463 s8 *lna1_gain_db = NULL; 15460 const s8 *lna1_gain_db = NULL;
15464 s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; 15461 static const s8 lna2G_gain_db[] = { -5, 6, 10, 14 };
15465 s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; 15462 static const s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 };
15466 s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; 15463 static const s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 };
15467 s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; 15464 static const s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 };
15468 s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; 15465 static const s8 lna2A_gain_db[] = { -6, 2, 6, 10 };
15469 s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; 15466 static const s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 };
15470 s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; 15467 static const s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 };
15471 s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; 15468 static const s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 };
15472 s8 *lna2_gain_db = NULL; 15469 const s8 *lna2_gain_db = NULL;
15473 s8 tiaG_gain_db[] = { 15470 static const s8 tiaG_gain_db[] = {
15474 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; 15471 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };
15475 s8 tiaA_gain_db[] = { 15472 static const s8 tiaA_gain_db[] = {
15476 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; 15473 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 };
15477 s8 tiaA_gain_db_rev4[] = { 15474 static const s8 tiaA_gain_db_rev4[] = {
15478 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; 15475 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15479 s8 tiaA_gain_db_rev5[] = { 15476 static const s8 tiaA_gain_db_rev5[] = {
15480 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; 15477 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15481 s8 tiaA_gain_db_rev6[] = { 15478 static const s8 tiaA_gain_db_rev6[] = {
15482 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; 15479 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15483 s8 *tia_gain_db; 15480 const s8 *tia_gain_db;
15484 s8 tiaG_gainbits[] = { 15481 static const s8 tiaG_gainbits[] = {
15485 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; 15482 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
15486 s8 tiaA_gainbits[] = { 15483 static const s8 tiaA_gainbits[] = {
15487 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; 15484 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 };
15488 s8 tiaA_gainbits_rev4[] = { 15485 static const s8 tiaA_gainbits_rev4[] = {
15489 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; 15486 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15490 s8 tiaA_gainbits_rev5[] = { 15487 static const s8 tiaA_gainbits_rev5[] = {
15491 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; 15488 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15492 s8 tiaA_gainbits_rev6[] = { 15489 static const s8 tiaA_gainbits_rev6[] = {
15493 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; 15490 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15494 s8 *tia_gainbits; 15491 const s8 *tia_gainbits;
15495 s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; 15492 static const s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 };
15496 s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; 15493 static const s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 };
15497 u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; 15494 static const u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f };
15498 u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; 15495 static const u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f };
15499 u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; 15496 static const u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f };
15500 u16 rfseqG_init_gain_rev5_elna[] = { 15497 static const u16 rfseqG_init_gain_rev5_elna[] = {
15501 0x013f, 0x013f, 0x013f, 0x013f }; 15498 0x013f, 0x013f, 0x013f, 0x013f };
15502 u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; 15499 static const u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f };
15503 u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; 15500 static const u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f };
15504 u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; 15501 static const u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f };
15505 u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; 15502 static const u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f };
15506 u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; 15503 static const u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f };
15507 u16 rfseqA_init_gain_rev4_elna[] = { 15504 static const u16 rfseqA_init_gain_rev4_elna[] = {
15508 0x314f, 0x314f, 0x314f, 0x314f }; 15505 0x314f, 0x314f, 0x314f, 0x314f };
15509 u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; 15506 static const u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f };
15510 u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; 15507 static const u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f };
15511 u16 *rfseq_init_gain; 15508 const u16 *rfseq_init_gain;
15512 u16 initG_gaincode = 0x627e; 15509 u16 initG_gaincode = 0x627e;
15513 u16 initG_gaincode_rev4 = 0x527e; 15510 u16 initG_gaincode_rev4 = 0x527e;
15514 u16 initG_gaincode_rev5 = 0x427e; 15511 u16 initG_gaincode_rev5 = 0x427e;
@@ -15538,10 +15535,10 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi)
15538 u16 clip1mdA_gaincode_rev6 = 0x2084; 15535 u16 clip1mdA_gaincode_rev6 = 0x2084;
15539 u16 clip1md_gaincode = 0; 15536 u16 clip1md_gaincode = 0;
15540 u16 clip1loG_gaincode = 0x0074; 15537 u16 clip1loG_gaincode = 0x0074;
15541 u16 clip1loG_gaincode_rev5[] = { 15538 static const u16 clip1loG_gaincode_rev5[] = {
15542 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c 15539 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c
15543 }; 15540 };
15544 u16 clip1loG_gaincode_rev6[] = { 15541 static const u16 clip1loG_gaincode_rev6[] = {
15545 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e 15542 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e
15546 }; 15543 };
15547 u16 clip1loG_gaincode_rev6_224B0 = 0x1074; 15544 u16 clip1loG_gaincode_rev6_224B0 = 0x1074;
@@ -16066,7 +16063,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi)
16066 16063
16067static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) 16064static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16068{ 16065{
16069 u8 rfseq_rx2tx_events[] = { 16066 static const u8 rfseq_rx2tx_events[] = {
16070 NPHY_RFSEQ_CMD_NOP, 16067 NPHY_RFSEQ_CMD_NOP,
16071 NPHY_RFSEQ_CMD_RXG_FBW, 16068 NPHY_RFSEQ_CMD_RXG_FBW,
16072 NPHY_RFSEQ_CMD_TR_SWITCH, 16069 NPHY_RFSEQ_CMD_TR_SWITCH,
@@ -16076,7 +16073,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16076 NPHY_RFSEQ_CMD_EXT_PA 16073 NPHY_RFSEQ_CMD_EXT_PA
16077 }; 16074 };
16078 u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; 16075 u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 };
16079 u8 rfseq_tx2rx_events[] = { 16076 static const u8 rfseq_tx2rx_events[] = {
16080 NPHY_RFSEQ_CMD_NOP, 16077 NPHY_RFSEQ_CMD_NOP,
16081 NPHY_RFSEQ_CMD_EXT_PA, 16078 NPHY_RFSEQ_CMD_EXT_PA,
16082 NPHY_RFSEQ_CMD_TX_GAIN, 16079 NPHY_RFSEQ_CMD_TX_GAIN,
@@ -16085,8 +16082,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16085 NPHY_RFSEQ_CMD_RXG_FBW, 16082 NPHY_RFSEQ_CMD_RXG_FBW,
16086 NPHY_RFSEQ_CMD_CLR_HIQ_DIS 16083 NPHY_RFSEQ_CMD_CLR_HIQ_DIS
16087 }; 16084 };
16088 u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; 16085 static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };
16089 u8 rfseq_tx2rx_events_rev3[] = { 16086 static const u8 rfseq_tx2rx_events_rev3[] = {
16090 NPHY_REV3_RFSEQ_CMD_EXT_PA, 16087 NPHY_REV3_RFSEQ_CMD_EXT_PA,
16091 NPHY_REV3_RFSEQ_CMD_INT_PA_PU, 16088 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
16092 NPHY_REV3_RFSEQ_CMD_TX_GAIN, 16089 NPHY_REV3_RFSEQ_CMD_TX_GAIN,
@@ -16096,7 +16093,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16096 NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, 16093 NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,
16097 NPHY_REV3_RFSEQ_CMD_END 16094 NPHY_REV3_RFSEQ_CMD_END
16098 }; 16095 };
16099 u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; 16096 static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 };
16100 u8 rfseq_rx2tx_events_rev3[] = { 16097 u8 rfseq_rx2tx_events_rev3[] = {
16101 NPHY_REV3_RFSEQ_CMD_NOP, 16098 NPHY_REV3_RFSEQ_CMD_NOP,
16102 NPHY_REV3_RFSEQ_CMD_RXG_FBW, 16099 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
@@ -16110,7 +16107,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16110 }; 16107 };
16111 u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; 16108 u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 };
16112 16109
16113 u8 rfseq_rx2tx_events_rev3_ipa[] = { 16110 static const u8 rfseq_rx2tx_events_rev3_ipa[] = {
16114 NPHY_REV3_RFSEQ_CMD_NOP, 16111 NPHY_REV3_RFSEQ_CMD_NOP,
16115 NPHY_REV3_RFSEQ_CMD_RXG_FBW, 16112 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
16116 NPHY_REV3_RFSEQ_CMD_TR_SWITCH, 16113 NPHY_REV3_RFSEQ_CMD_TR_SWITCH,
@@ -16121,15 +16118,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16121 NPHY_REV3_RFSEQ_CMD_INT_PA_PU, 16118 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
16122 NPHY_REV3_RFSEQ_CMD_END 16119 NPHY_REV3_RFSEQ_CMD_END
16123 }; 16120 };
16124 u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; 16121 static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 };
16125 u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; 16122 static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };
16126 16123
16127 s16 alpha0, alpha1, alpha2; 16124 s16 alpha0, alpha1, alpha2;
16128 s16 beta0, beta1, beta2; 16125 s16 beta0, beta1, beta2;
16129 u32 leg_data_weights, ht_data_weights, nss1_data_weights, 16126 u32 leg_data_weights, ht_data_weights, nss1_data_weights,
16130 stbc_data_weights; 16127 stbc_data_weights;
16131 u8 chan_freq_range = 0; 16128 u8 chan_freq_range = 0;
16132 u16 dac_control = 0x0002; 16129 static const u16 dac_control = 0x0002;
16133 u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 }; 16130 u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 };
16134 u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 }; 16131 u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 };
16135 u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; 16132 u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 };
@@ -16139,8 +16136,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16139 u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; 16136 u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 };
16140 u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; 16137 u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 };
16141 u16 *aux_adc_gain; 16138 u16 *aux_adc_gain;
16142 u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; 16139 static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };
16143 u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; 16140 static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };
16144 s32 min_nvar_val = 0x18d; 16141 s32 min_nvar_val = 0x18d;
16145 s32 min_nvar_offset_6mbps = 20; 16142 s32 min_nvar_offset_6mbps = 20;
16146 u8 pdetrange; 16143 u8 pdetrange;
@@ -16151,9 +16148,9 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16151 u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77; 16148 u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77;
16152 u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77; 16149 u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77;
16153 u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77; 16150 u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77;
16154 u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; 16151 static const u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 };
16155 u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; 16152 static const u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16156 u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; 16153 static const u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16157 u16 ipalvlshift_3p3_war_en = 0; 16154 u16 ipalvlshift_3p3_war_en = 0;
16158 u16 rccal_bcap_val, rccal_scap_val; 16155 u16 rccal_bcap_val, rccal_scap_val;
16159 u16 rccal_tx20_11b_bcap = 0; 16156 u16 rccal_tx20_11b_bcap = 0;
@@ -24291,13 +24288,13 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core)
24291 u16 bbmult; 24288 u16 bbmult;
24292 u16 tblentry; 24289 u16 tblentry;
24293 24290
24294 struct nphy_txiqcal_ladder ladder_lo[] = { 24291 static const struct nphy_txiqcal_ladder ladder_lo[] = {
24295 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, 24292 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
24296 {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5}, 24293 {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5},
24297 {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7} 24294 {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7}
24298 }; 24295 };
24299 24296
24300 struct nphy_txiqcal_ladder ladder_iq[] = { 24297 static const struct nphy_txiqcal_ladder ladder_iq[] = {
24301 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, 24298 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
24302 {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1}, 24299 {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1},
24303 {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7} 24300 {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7}
@@ -25773,67 +25770,67 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,
25773 u16 cal_gain[2]; 25770 u16 cal_gain[2];
25774 struct nphy_iqcal_params cal_params[2]; 25771 struct nphy_iqcal_params cal_params[2];
25775 u32 tbl_len; 25772 u32 tbl_len;
25776 void *tbl_ptr; 25773 const void *tbl_ptr;
25777 bool ladder_updated[2]; 25774 bool ladder_updated[2];
25778 u8 mphase_cal_lastphase = 0; 25775 u8 mphase_cal_lastphase = 0;
25779 int bcmerror = 0; 25776 int bcmerror = 0;
25780 bool phyhang_avoid_state = false; 25777 bool phyhang_avoid_state = false;
25781 25778
25782 u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { 25779 static const u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
25783 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, 25780 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901,
25784 0x1902, 25781 0x1902,
25785 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, 25782 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607,
25786 0x6407 25783 0x6407
25787 }; 25784 };
25788 25785
25789 u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { 25786 static const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = {
25790 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, 25787 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400,
25791 0x3200, 25788 0x3200,
25792 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, 25789 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406,
25793 0x6407 25790 0x6407
25794 }; 25791 };
25795 25792
25796 u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { 25793 static const u16 tbl_tx_iqlo_cal_loft_ladder_40[] = {
25797 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, 25794 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201,
25798 0x1202, 25795 0x1202,
25799 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, 25796 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207,
25800 0x4707 25797 0x4707
25801 }; 25798 };
25802 25799
25803 u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { 25800 static const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = {
25804 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, 25801 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900,
25805 0x2300, 25802 0x2300,
25806 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, 25803 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706,
25807 0x4707 25804 0x4707
25808 }; 25805 };
25809 25806
25810 u16 tbl_tx_iqlo_cal_startcoefs[] = { 25807 static const u16 tbl_tx_iqlo_cal_startcoefs[] = {
25811 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 25808 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25812 0x0000 25809 0x0000
25813 }; 25810 };
25814 25811
25815 u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { 25812 static const u16 tbl_tx_iqlo_cal_cmds_fullcal[] = {
25816 0x8123, 0x8264, 0x8086, 0x8245, 0x8056, 25813 0x8123, 0x8264, 0x8086, 0x8245, 0x8056,
25817 0x9123, 0x9264, 0x9086, 0x9245, 0x9056 25814 0x9123, 0x9264, 0x9086, 0x9245, 0x9056
25818 }; 25815 };
25819 25816
25820 u16 tbl_tx_iqlo_cal_cmds_recal[] = { 25817 static const u16 tbl_tx_iqlo_cal_cmds_recal[] = {
25821 0x8101, 0x8253, 0x8053, 0x8234, 0x8034, 25818 0x8101, 0x8253, 0x8053, 0x8234, 0x8034,
25822 0x9101, 0x9253, 0x9053, 0x9234, 0x9034 25819 0x9101, 0x9253, 0x9053, 0x9234, 0x9034
25823 }; 25820 };
25824 25821
25825 u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { 25822 static const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = {
25826 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 25823 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25827 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 25824 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25828 0x0000 25825 0x0000
25829 }; 25826 };
25830 25827
25831 u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { 25828 static const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = {
25832 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234, 25829 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234,
25833 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234 25830 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234
25834 }; 25831 };
25835 25832
25836 u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { 25833 static const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = {
25837 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223, 25834 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223,
25838 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223 25835 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223
25839 }; 25836 };
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/7000.c b/drivers/net/wireless/intel/iwlwifi/cfg/7000.c
index 45e2efc70d19..ce741beec1fc 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/7000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/7000.c
@@ -309,6 +309,7 @@ const struct iwl_cfg iwl3168_2ac_cfg = {
309 .nvm_calib_ver = IWL3168_TX_POWER_VERSION, 309 .nvm_calib_ver = IWL3168_TX_POWER_VERSION,
310 .pwr_tx_backoffs = iwl7265_pwr_tx_backoffs, 310 .pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
311 .dccm_len = IWL7265_DCCM_LEN, 311 .dccm_len = IWL7265_DCCM_LEN,
312 .nvm_type = IWL_NVM_SDP,
312}; 313};
313 314
314const struct iwl_cfg iwl7265_2ac_cfg = { 315const struct iwl_cfg iwl7265_2ac_cfg = {
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/8000.c b/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
index 2e6c52664cee..c2a5936ccede 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
@@ -164,7 +164,7 @@ static const struct iwl_tt_params iwl8000_tt_params = {
164 .default_nvm_file_C_step = DEFAULT_NVM_FILE_FAMILY_8000C, \ 164 .default_nvm_file_C_step = DEFAULT_NVM_FILE_FAMILY_8000C, \
165 .thermal_params = &iwl8000_tt_params, \ 165 .thermal_params = &iwl8000_tt_params, \
166 .apmg_not_supported = true, \ 166 .apmg_not_supported = true, \
167 .ext_nvm = true, \ 167 .nvm_type = IWL_NVM_EXT, \
168 .dbgc_supported = true 168 .dbgc_supported = true
169 169
170#define IWL_DEVICE_8000 \ 170#define IWL_DEVICE_8000 \
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
index 2babe0a1f18b..e8b5ff42f5a8 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
@@ -148,7 +148,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
148 .vht_mu_mimo_supported = true, \ 148 .vht_mu_mimo_supported = true, \
149 .mac_addr_from_csr = true, \ 149 .mac_addr_from_csr = true, \
150 .rf_id = true, \ 150 .rf_id = true, \
151 .ext_nvm = true, \ 151 .nvm_type = IWL_NVM_EXT, \
152 .dbgc_supported = true 152 .dbgc_supported = true
153 153
154const struct iwl_cfg iwl9160_2ac_cfg = { 154const struct iwl_cfg iwl9160_2ac_cfg = {
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/a000.c b/drivers/net/wireless/intel/iwlwifi/cfg/a000.c
index 76ba1f8bc72f..a440140ed8dd 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/a000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/a000.c
@@ -133,7 +133,7 @@ static const struct iwl_ht_params iwl_a000_ht_params = {
133 .use_tfh = true, \ 133 .use_tfh = true, \
134 .rf_id = true, \ 134 .rf_id = true, \
135 .gen2 = true, \ 135 .gen2 = true, \
136 .ext_nvm = true, \ 136 .nvm_type = IWL_NVM_EXT, \
137 .dbgc_supported = true 137 .dbgc_supported = true
138 138
139const struct iwl_cfg iwla000_2ac_cfg_hr = { 139const struct iwl_cfg iwla000_2ac_cfg_hr = {
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h b/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
index 00bc7a25dece..3fd07bc80f54 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
@@ -108,6 +108,7 @@ enum iwl_nvm_access_target {
108 * @NVM_SECTION_TYPE_REGULATORY: regulatory section 108 * @NVM_SECTION_TYPE_REGULATORY: regulatory section
109 * @NVM_SECTION_TYPE_CALIBRATION: calibration section 109 * @NVM_SECTION_TYPE_CALIBRATION: calibration section
110 * @NVM_SECTION_TYPE_PRODUCTION: production section 110 * @NVM_SECTION_TYPE_PRODUCTION: production section
111 * @NVM_SECTION_TYPE_REGULATORY_SDP: regulatory section used by 3168 series
111 * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section 112 * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
112 * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section 113 * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
113 * @NVM_MAX_NUM_SECTIONS: number of sections 114 * @NVM_MAX_NUM_SECTIONS: number of sections
@@ -117,6 +118,7 @@ enum iwl_nvm_section_type {
117 NVM_SECTION_TYPE_REGULATORY = 3, 118 NVM_SECTION_TYPE_REGULATORY = 3,
118 NVM_SECTION_TYPE_CALIBRATION = 4, 119 NVM_SECTION_TYPE_CALIBRATION = 4,
119 NVM_SECTION_TYPE_PRODUCTION = 5, 120 NVM_SECTION_TYPE_PRODUCTION = 5,
121 NVM_SECTION_TYPE_REGULATORY_SDP = 8,
120 NVM_SECTION_TYPE_MAC_OVERRIDE = 11, 122 NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
121 NVM_SECTION_TYPE_PHY_SKU = 12, 123 NVM_SECTION_TYPE_PHY_SKU = 12,
122 NVM_MAX_NUM_SECTIONS = 13, 124 NVM_MAX_NUM_SECTIONS = 13,
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 6afc7a799892..f5dd7d83cd0a 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -1086,7 +1086,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work)
1086 1086
1087 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) { 1087 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
1088 /* stop recording */ 1088 /* stop recording */
1089 iwl_set_bits_prph(fwrt->trans, MON_BUFF_SAMPLE_CTL, 0x100); 1089 iwl_fw_dbg_stop_recording(fwrt);
1090 1090
1091 iwl_fw_error_dump(fwrt); 1091 iwl_fw_error_dump(fwrt);
1092 1092
@@ -1104,10 +1104,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work)
1104 u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE); 1104 u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE);
1105 u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL); 1105 u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL);
1106 1106
1107 /* stop recording */ 1107 iwl_fw_dbg_stop_recording(fwrt);
1108 iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, 0);
1109 udelay(100);
1110 iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, 0);
1111 /* wait before we collect the data till the DBGC stop */ 1108 /* wait before we collect the data till the DBGC stop */
1112 udelay(500); 1109 udelay(500);
1113 1110
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
index 0f810ea89d31..9c889a32fe24 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
@@ -68,6 +68,8 @@
68#include <linux/workqueue.h> 68#include <linux/workqueue.h>
69#include <net/cfg80211.h> 69#include <net/cfg80211.h>
70#include "runtime.h" 70#include "runtime.h"
71#include "iwl-prph.h"
72#include "iwl-io.h"
71#include "file.h" 73#include "file.h"
72#include "error-dump.h" 74#include "error-dump.h"
73 75
@@ -194,8 +196,21 @@ _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt,
194 iwl_fw_dbg_get_trigger((fwrt)->fw,\ 196 iwl_fw_dbg_get_trigger((fwrt)->fw,\
195 (trig))) 197 (trig)))
196 198
199static inline void iwl_fw_dbg_stop_recording(struct iwl_fw_runtime *fwrt)
200{
201 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
202 iwl_set_bits_prph(fwrt->trans, MON_BUFF_SAMPLE_CTL, 0x100);
203 } else {
204 iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, 0);
205 udelay(100);
206 iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, 0);
207 }
208}
209
197static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt) 210static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)
198{ 211{
212 iwl_fw_dbg_stop_recording(fwrt);
213
199 fwrt->dump.conf = FW_DBG_INVALID; 214 fwrt->dump.conf = FW_DBG_INVALID;
200} 215}
201 216
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index 3e057b539d5b..71cb1ecde0f7 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -108,6 +108,18 @@ enum iwl_led_mode {
108 IWL_LED_DISABLE, 108 IWL_LED_DISABLE,
109}; 109};
110 110
111/**
112 * enum iwl_nvm_type - nvm formats
113 * @IWL_NVM: the regular format
114 * @IWL_NVM_EXT: extended NVM format
115 * @IWL_NVM_SDP: NVM format used by 3168 series
116 */
117enum iwl_nvm_type {
118 IWL_NVM,
119 IWL_NVM_EXT,
120 IWL_NVM_SDP,
121};
122
111/* 123/*
112 * This is the threshold value of plcp error rate per 100mSecs. It is 124 * This is the threshold value of plcp error rate per 100mSecs. It is
113 * used to set and check for the validity of plcp_delta. 125 * used to set and check for the validity of plcp_delta.
@@ -320,7 +332,7 @@ struct iwl_pwr_tx_backoff {
320 * @integrated: discrete or integrated 332 * @integrated: discrete or integrated
321 * @gen2: a000 and on transport operation 333 * @gen2: a000 and on transport operation
322 * @cdb: CDB support 334 * @cdb: CDB support
323 * @ext_nvm: extended NVM format 335 * @nvm_type: see &enum iwl_nvm_type
324 * 336 *
325 * We enable the driver to be backward compatible wrt. hardware features. 337 * We enable the driver to be backward compatible wrt. hardware features.
326 * API differences in uCode shouldn't be handled here but through TLVs 338 * API differences in uCode shouldn't be handled here but through TLVs
@@ -342,6 +354,7 @@ struct iwl_cfg {
342 const struct iwl_tt_params *thermal_params; 354 const struct iwl_tt_params *thermal_params;
343 enum iwl_device_family device_family; 355 enum iwl_device_family device_family;
344 enum iwl_led_mode led_mode; 356 enum iwl_led_mode led_mode;
357 enum iwl_nvm_type nvm_type;
345 u32 max_data_size; 358 u32 max_data_size;
346 u32 max_inst_size; 359 u32 max_inst_size;
347 netdev_features_t features; 360 netdev_features_t features;
@@ -369,7 +382,6 @@ struct iwl_cfg {
369 use_tfh:1, 382 use_tfh:1,
370 gen2:1, 383 gen2:1,
371 cdb:1, 384 cdb:1,
372 ext_nvm:1,
373 dbgc_supported:1; 385 dbgc_supported:1;
374 u8 valid_tx_ant; 386 u8 valid_tx_ant;
375 u8 valid_rx_ant; 387 u8 valid_rx_ant;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 3014beef4873..c3a5d8ccc95e 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -77,7 +77,7 @@
77#include "iwl-csr.h" 77#include "iwl-csr.h"
78 78
79/* NVM offsets (in words) definitions */ 79/* NVM offsets (in words) definitions */
80enum wkp_nvm_offsets { 80enum nvm_offsets {
81 /* NVM HW-Section offset (in words) definitions */ 81 /* NVM HW-Section offset (in words) definitions */
82 SUBSYSTEM_ID = 0x0A, 82 SUBSYSTEM_ID = 0x0A,
83 HW_ADDR = 0x15, 83 HW_ADDR = 0x15,
@@ -92,7 +92,10 @@ enum wkp_nvm_offsets {
92 92
93 /* NVM calibration section offset (in words) definitions */ 93 /* NVM calibration section offset (in words) definitions */
94 NVM_CALIB_SECTION = 0x2B8, 94 NVM_CALIB_SECTION = 0x2B8,
95 XTAL_CALIB = 0x316 - NVM_CALIB_SECTION 95 XTAL_CALIB = 0x316 - NVM_CALIB_SECTION,
96
97 /* NVM REGULATORY -Section offset (in words) definitions */
98 NVM_CHANNELS_SDP = 0,
96}; 99};
97 100
98enum ext_nvm_offsets { 101enum ext_nvm_offsets {
@@ -206,8 +209,36 @@ enum iwl_nvm_channel_flags {
206 NVM_CHANNEL_DC_HIGH = BIT(12), 209 NVM_CHANNEL_DC_HIGH = BIT(12),
207}; 210};
208 211
212static inline void iwl_nvm_print_channel_flags(struct device *dev, u32 level,
213 int chan, u16 flags)
214{
209#define CHECK_AND_PRINT_I(x) \ 215#define CHECK_AND_PRINT_I(x) \
210 ((ch_flags & NVM_CHANNEL_##x) ? # x " " : "") 216 ((flags & NVM_CHANNEL_##x) ? " " #x : "")
217
218 if (!(flags & NVM_CHANNEL_VALID)) {
219 IWL_DEBUG_DEV(dev, level, "Ch. %d: 0x%x: No traffic\n",
220 chan, flags);
221 return;
222 }
223
224 /* Note: already can print up to 101 characters, 110 is the limit! */
225 IWL_DEBUG_DEV(dev, level,
226 "Ch. %d: 0x%x:%s%s%s%s%s%s%s%s%s%s%s%s\n",
227 chan, flags,
228 CHECK_AND_PRINT_I(VALID),
229 CHECK_AND_PRINT_I(IBSS),
230 CHECK_AND_PRINT_I(ACTIVE),
231 CHECK_AND_PRINT_I(RADAR),
232 CHECK_AND_PRINT_I(INDOOR_ONLY),
233 CHECK_AND_PRINT_I(GO_CONCURRENT),
234 CHECK_AND_PRINT_I(UNIFORM),
235 CHECK_AND_PRINT_I(20MHZ),
236 CHECK_AND_PRINT_I(40MHZ),
237 CHECK_AND_PRINT_I(80MHZ),
238 CHECK_AND_PRINT_I(160MHZ),
239 CHECK_AND_PRINT_I(DC_HIGH));
240#undef CHECK_AND_PRINT_I
241}
211 242
212static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz, 243static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,
213 u16 nvm_flags, const struct iwl_cfg *cfg) 244 u16 nvm_flags, const struct iwl_cfg *cfg)
@@ -215,7 +246,7 @@ static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,
215 u32 flags = IEEE80211_CHAN_NO_HT40; 246 u32 flags = IEEE80211_CHAN_NO_HT40;
216 u32 last_5ghz_ht = LAST_5GHZ_HT; 247 u32 last_5ghz_ht = LAST_5GHZ_HT;
217 248
218 if (cfg->ext_nvm) 249 if (cfg->nvm_type == IWL_NVM_EXT)
219 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; 250 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
220 251
221 if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) { 252 if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) {
@@ -268,7 +299,7 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
268 int num_of_ch, num_2ghz_channels; 299 int num_of_ch, num_2ghz_channels;
269 const u8 *nvm_chan; 300 const u8 *nvm_chan;
270 301
271 if (!cfg->ext_nvm) { 302 if (cfg->nvm_type != IWL_NVM_EXT) {
272 num_of_ch = IWL_NUM_CHANNELS; 303 num_of_ch = IWL_NUM_CHANNELS;
273 nvm_chan = &iwl_nvm_channels[0]; 304 nvm_chan = &iwl_nvm_channels[0];
274 num_2ghz_channels = NUM_2GHZ_CHANNELS; 305 num_2ghz_channels = NUM_2GHZ_CHANNELS;
@@ -302,12 +333,8 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
302 * supported, hence we still want to add them to 333 * supported, hence we still want to add them to
303 * the list of supported channels to cfg80211. 334 * the list of supported channels to cfg80211.
304 */ 335 */
305 IWL_DEBUG_EEPROM(dev, 336 iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
306 "Ch. %d Flags %x [%sGHz] - No traffic\n", 337 nvm_chan[ch_idx], ch_flags);
307 nvm_chan[ch_idx],
308 ch_flags,
309 (ch_idx >= num_2ghz_channels) ?
310 "5.2" : "2.4");
311 continue; 338 continue;
312 } 339 }
313 340
@@ -337,27 +364,10 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
337 else 364 else
338 channel->flags = 0; 365 channel->flags = 0;
339 366
340 IWL_DEBUG_EEPROM(dev, 367 iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
341 "Ch. %d [%sGHz] flags 0x%x %s%s%s%s%s%s%s%s%s%s%s%s(%ddBm): Ad-Hoc %ssupported\n", 368 channel->hw_value, ch_flags);
342 channel->hw_value, 369 IWL_DEBUG_EEPROM(dev, "Ch. %d: %ddBm\n",
343 is_5ghz ? "5.2" : "2.4", 370 channel->hw_value, channel->max_power);
344 ch_flags,
345 CHECK_AND_PRINT_I(VALID),
346 CHECK_AND_PRINT_I(IBSS),
347 CHECK_AND_PRINT_I(ACTIVE),
348 CHECK_AND_PRINT_I(RADAR),
349 CHECK_AND_PRINT_I(INDOOR_ONLY),
350 CHECK_AND_PRINT_I(GO_CONCURRENT),
351 CHECK_AND_PRINT_I(UNIFORM),
352 CHECK_AND_PRINT_I(20MHZ),
353 CHECK_AND_PRINT_I(40MHZ),
354 CHECK_AND_PRINT_I(80MHZ),
355 CHECK_AND_PRINT_I(160MHZ),
356 CHECK_AND_PRINT_I(DC_HIGH),
357 channel->max_power,
358 ((ch_flags & NVM_CHANNEL_IBSS) &&
359 !(ch_flags & NVM_CHANNEL_RADAR))
360 ? "" : "not ");
361 } 371 }
362 372
363 return n_channels; 373 return n_channels;
@@ -484,7 +494,7 @@ IWL_EXPORT_SYMBOL(iwl_init_sbands);
484static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw, 494static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
485 const __le16 *phy_sku) 495 const __le16 *phy_sku)
486{ 496{
487 if (!cfg->ext_nvm) 497 if (cfg->nvm_type != IWL_NVM_EXT)
488 return le16_to_cpup(nvm_sw + SKU); 498 return le16_to_cpup(nvm_sw + SKU);
489 499
490 return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000)); 500 return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000));
@@ -492,7 +502,7 @@ static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
492 502
493static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw) 503static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw)
494{ 504{
495 if (!cfg->ext_nvm) 505 if (cfg->nvm_type != IWL_NVM_EXT)
496 return le16_to_cpup(nvm_sw + NVM_VERSION); 506 return le16_to_cpup(nvm_sw + NVM_VERSION);
497 else 507 else
498 return le32_to_cpup((__le32 *)(nvm_sw + 508 return le32_to_cpup((__le32 *)(nvm_sw +
@@ -502,7 +512,7 @@ static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw)
502static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw, 512static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
503 const __le16 *phy_sku) 513 const __le16 *phy_sku)
504{ 514{
505 if (!cfg->ext_nvm) 515 if (cfg->nvm_type != IWL_NVM_EXT)
506 return le16_to_cpup(nvm_sw + RADIO_CFG); 516 return le16_to_cpup(nvm_sw + RADIO_CFG);
507 517
508 return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_EXT_NVM)); 518 return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_EXT_NVM));
@@ -513,7 +523,7 @@ static int iwl_get_n_hw_addrs(const struct iwl_cfg *cfg, const __le16 *nvm_sw)
513{ 523{
514 int n_hw_addr; 524 int n_hw_addr;
515 525
516 if (!cfg->ext_nvm) 526 if (cfg->nvm_type != IWL_NVM_EXT)
517 return le16_to_cpup(nvm_sw + N_HW_ADDRS); 527 return le16_to_cpup(nvm_sw + N_HW_ADDRS);
518 528
519 n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000)); 529 n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000));
@@ -525,7 +535,7 @@ static void iwl_set_radio_cfg(const struct iwl_cfg *cfg,
525 struct iwl_nvm_data *data, 535 struct iwl_nvm_data *data,
526 u32 radio_cfg) 536 u32 radio_cfg)
527{ 537{
528 if (!cfg->ext_nvm) { 538 if (cfg->nvm_type != IWL_NVM_EXT) {
529 data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg); 539 data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg);
530 data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg); 540 data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg);
531 data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg); 541 data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg);
@@ -634,7 +644,7 @@ static int iwl_set_hw_address(struct iwl_trans *trans,
634{ 644{
635 if (cfg->mac_addr_from_csr) { 645 if (cfg->mac_addr_from_csr) {
636 iwl_set_hw_address_from_csr(trans, data); 646 iwl_set_hw_address_from_csr(trans, data);
637 } else if (!cfg->ext_nvm) { 647 } else if (cfg->nvm_type != IWL_NVM_EXT) {
638 const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR); 648 const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR);
639 649
640 /* The byte order is little endian 16 bit, meaning 214365 */ 650 /* The byte order is little endian 16 bit, meaning 214365 */
@@ -706,7 +716,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
706 u16 lar_config; 716 u16 lar_config;
707 const __le16 *ch_section; 717 const __le16 *ch_section;
708 718
709 if (!cfg->ext_nvm) 719 if (cfg->nvm_type != IWL_NVM_EXT)
710 data = kzalloc(sizeof(*data) + 720 data = kzalloc(sizeof(*data) +
711 sizeof(struct ieee80211_channel) * 721 sizeof(struct ieee80211_channel) *
712 IWL_NUM_CHANNELS, 722 IWL_NUM_CHANNELS,
@@ -740,7 +750,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
740 750
741 data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw); 751 data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw);
742 752
743 if (!cfg->ext_nvm) { 753 if (cfg->nvm_type != IWL_NVM_EXT) {
744 /* Checking for required sections */ 754 /* Checking for required sections */
745 if (!nvm_calib) { 755 if (!nvm_calib) {
746 IWL_ERR(trans, 756 IWL_ERR(trans,
@@ -748,11 +758,15 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
748 kfree(data); 758 kfree(data);
749 return NULL; 759 return NULL;
750 } 760 }
761
762 ch_section = cfg->nvm_type == IWL_NVM_SDP ?
763 &regulatory[NVM_CHANNELS_SDP] :
764 &nvm_sw[NVM_CHANNELS];
765
751 /* in family 8000 Xtal calibration values moved to OTP */ 766 /* in family 8000 Xtal calibration values moved to OTP */
752 data->xtal_calib[0] = *(nvm_calib + XTAL_CALIB); 767 data->xtal_calib[0] = *(nvm_calib + XTAL_CALIB);
753 data->xtal_calib[1] = *(nvm_calib + XTAL_CALIB + 1); 768 data->xtal_calib[1] = *(nvm_calib + XTAL_CALIB + 1);
754 lar_enabled = true; 769 lar_enabled = true;
755 ch_section = &nvm_sw[NVM_CHANNELS];
756 } else { 770 } else {
757 u16 lar_offset = data->nvm_version < 0xE39 ? 771 u16 lar_offset = data->nvm_version < 0xE39 ?
758 NVM_LAR_OFFSET_OLD : 772 NVM_LAR_OFFSET_OLD :
@@ -786,7 +800,7 @@ static u32 iwl_nvm_get_regdom_bw_flags(const u8 *nvm_chan,
786 u32 flags = NL80211_RRF_NO_HT40; 800 u32 flags = NL80211_RRF_NO_HT40;
787 u32 last_5ghz_ht = LAST_5GHZ_HT; 801 u32 last_5ghz_ht = LAST_5GHZ_HT;
788 802
789 if (cfg->ext_nvm) 803 if (cfg->nvm_type == IWL_NVM_EXT)
790 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; 804 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
791 805
792 if (ch_idx < NUM_2GHZ_CHANNELS && 806 if (ch_idx < NUM_2GHZ_CHANNELS &&
@@ -834,7 +848,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
834 int ch_idx; 848 int ch_idx;
835 u16 ch_flags; 849 u16 ch_flags;
836 u32 reg_rule_flags, prev_reg_rule_flags = 0; 850 u32 reg_rule_flags, prev_reg_rule_flags = 0;
837 const u8 *nvm_chan = cfg->ext_nvm ? 851 const u8 *nvm_chan = cfg->nvm_type == IWL_NVM_EXT ?
838 iwl_ext_nvm_channels : iwl_nvm_channels; 852 iwl_ext_nvm_channels : iwl_nvm_channels;
839 struct ieee80211_regdomain *regd; 853 struct ieee80211_regdomain *regd;
840 int size_of_regd; 854 int size_of_regd;
@@ -843,7 +857,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
843 int center_freq, prev_center_freq = 0; 857 int center_freq, prev_center_freq = 0;
844 int valid_rules = 0; 858 int valid_rules = 0;
845 bool new_rule; 859 bool new_rule;
846 int max_num_ch = cfg->ext_nvm ? 860 int max_num_ch = cfg->nvm_type == IWL_NVM_EXT ?
847 IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS; 861 IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS;
848 862
849 if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES)) 863 if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES))
@@ -873,12 +887,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
873 new_rule = false; 887 new_rule = false;
874 888
875 if (!(ch_flags & NVM_CHANNEL_VALID)) { 889 if (!(ch_flags & NVM_CHANNEL_VALID)) {
876 IWL_DEBUG_DEV(dev, IWL_DL_LAR, 890 iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
877 "Ch. %d Flags %x [%sGHz] - No traffic\n", 891 nvm_chan[ch_idx], ch_flags);
878 nvm_chan[ch_idx],
879 ch_flags,
880 (ch_idx >= NUM_2GHZ_CHANNELS) ?
881 "5.2" : "2.4");
882 continue; 892 continue;
883 } 893 }
884 894
@@ -914,31 +924,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
914 prev_center_freq = center_freq; 924 prev_center_freq = center_freq;
915 prev_reg_rule_flags = reg_rule_flags; 925 prev_reg_rule_flags = reg_rule_flags;
916 926
917 IWL_DEBUG_DEV(dev, IWL_DL_LAR, 927 iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
918 "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s%s%s%s(0x%02x)\n", 928 nvm_chan[ch_idx], ch_flags);
919 center_freq,
920 band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
921 CHECK_AND_PRINT_I(VALID),
922 CHECK_AND_PRINT_I(IBSS),
923 CHECK_AND_PRINT_I(ACTIVE),
924 CHECK_AND_PRINT_I(RADAR),
925 CHECK_AND_PRINT_I(INDOOR_ONLY),
926 CHECK_AND_PRINT_I(GO_CONCURRENT),
927 CHECK_AND_PRINT_I(UNIFORM),
928 CHECK_AND_PRINT_I(20MHZ),
929 CHECK_AND_PRINT_I(40MHZ),
930 CHECK_AND_PRINT_I(80MHZ),
931 CHECK_AND_PRINT_I(160MHZ),
932 CHECK_AND_PRINT_I(DC_HIGH),
933 ch_flags);
934 IWL_DEBUG_DEV(dev, IWL_DL_LAR,
935 "Ch. %d [%sGHz] reg_flags 0x%x: %s\n",
936 center_freq,
937 band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
938 reg_rule_flags,
939 ((ch_flags & NVM_CHANNEL_ACTIVE) &&
940 !(ch_flags & NVM_CHANNEL_RADAR))
941 ? "Ad-Hoc" : "");
942 } 929 }
943 930
944 regd->n_reg_rules = valid_rules; 931 regd->n_reg_rules = valid_rules;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 3bcaa82f59b2..a9ac872226fd 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1077,6 +1077,7 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
1077 mvm->vif_count = 0; 1077 mvm->vif_count = 0;
1078 mvm->rx_ba_sessions = 0; 1078 mvm->rx_ba_sessions = 0;
1079 mvm->fwrt.dump.conf = FW_DBG_INVALID; 1079 mvm->fwrt.dump.conf = FW_DBG_INVALID;
1080 mvm->monitor_on = false;
1080 1081
1081 /* keep statistics ticking */ 1082 /* keep statistics ticking */
1082 iwl_mvm_accu_radio_stats(mvm); 1083 iwl_mvm_accu_radio_stats(mvm);
@@ -1437,6 +1438,9 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1437 mvm->p2p_device_vif = vif; 1438 mvm->p2p_device_vif = vif;
1438 } 1439 }
1439 1440
1441 if (vif->type == NL80211_IFTYPE_MONITOR)
1442 mvm->monitor_on = true;
1443
1440 iwl_mvm_vif_dbgfs_register(mvm, vif); 1444 iwl_mvm_vif_dbgfs_register(mvm, vif);
1441 goto out_unlock; 1445 goto out_unlock;
1442 1446
@@ -1526,6 +1530,9 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
1526 iwl_mvm_power_update_mac(mvm); 1530 iwl_mvm_power_update_mac(mvm);
1527 iwl_mvm_mac_ctxt_remove(mvm, vif); 1531 iwl_mvm_mac_ctxt_remove(mvm, vif);
1528 1532
1533 if (vif->type == NL80211_IFTYPE_MONITOR)
1534 mvm->monitor_on = false;
1535
1529out_release: 1536out_release:
1530 mutex_unlock(&mvm->mutex); 1537 mutex_unlock(&mvm->mutex);
1531} 1538}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 83303bac0e4b..949e63418299 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1015,6 +1015,9 @@ struct iwl_mvm {
1015 bool drop_bcn_ap_mode; 1015 bool drop_bcn_ap_mode;
1016 1016
1017 struct delayed_work cs_tx_unblock_dwork; 1017 struct delayed_work cs_tx_unblock_dwork;
1018
1019 /* does a monitor vif exist (only one can exist hence bool) */
1020 bool monitor_on;
1018#ifdef CONFIG_ACPI 1021#ifdef CONFIG_ACPI
1019 struct iwl_mvm_sar_profile sar_profiles[IWL_MVM_SAR_PROFILE_NUM]; 1022 struct iwl_mvm_sar_profile sar_profiles[IWL_MVM_SAR_PROFILE_NUM];
1020 struct iwl_mvm_geo_profile geo_profiles[IWL_NUM_GEO_PROFILES]; 1023 struct iwl_mvm_geo_profile geo_profiles[IWL_NUM_GEO_PROFILES];
@@ -1159,7 +1162,7 @@ static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm)
1159 * Enable LAR only if it is supported by the FW (TLV) && 1162 * Enable LAR only if it is supported by the FW (TLV) &&
1160 * enabled in the NVM 1163 * enabled in the NVM
1161 */ 1164 */
1162 if (mvm->cfg->ext_nvm) 1165 if (mvm->cfg->nvm_type == IWL_NVM_EXT)
1163 return nvm_lar && tlv_lar; 1166 return nvm_lar && tlv_lar;
1164 else 1167 else
1165 return tlv_lar; 1168 return tlv_lar;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 422aa6be9932..fb25b6f29323 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -295,18 +295,24 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm)
295 const __be16 *hw; 295 const __be16 *hw;
296 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku; 296 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;
297 bool lar_enabled; 297 bool lar_enabled;
298 int regulatory_type;
298 299
299 /* Checking for required sections */ 300 /* Checking for required sections */
300 if (!mvm->trans->cfg->ext_nvm) { 301 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
301 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data || 302 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||
302 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) { 303 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) {
303 IWL_ERR(mvm, "Can't parse empty OTP/NVM sections\n"); 304 IWL_ERR(mvm, "Can't parse empty OTP/NVM sections\n");
304 return NULL; 305 return NULL;
305 } 306 }
306 } else { 307 } else {
308 if (mvm->trans->cfg->nvm_type == IWL_NVM_SDP)
309 regulatory_type = NVM_SECTION_TYPE_REGULATORY_SDP;
310 else
311 regulatory_type = NVM_SECTION_TYPE_REGULATORY;
312
307 /* SW and REGULATORY sections are mandatory */ 313 /* SW and REGULATORY sections are mandatory */
308 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data || 314 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||
309 !mvm->nvm_sections[NVM_SECTION_TYPE_REGULATORY].data) { 315 !mvm->nvm_sections[regulatory_type].data) {
310 IWL_ERR(mvm, 316 IWL_ERR(mvm,
311 "Can't parse empty family 8000 OTP/NVM sections\n"); 317 "Can't parse empty family 8000 OTP/NVM sections\n");
312 return NULL; 318 return NULL;
@@ -330,11 +336,14 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm)
330 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data; 336 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data;
331 sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data; 337 sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data;
332 calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data; 338 calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data;
333 regulatory = (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
334 mac_override = 339 mac_override =
335 (const __le16 *)sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data; 340 (const __le16 *)sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data;
336 phy_sku = (const __le16 *)sections[NVM_SECTION_TYPE_PHY_SKU].data; 341 phy_sku = (const __le16 *)sections[NVM_SECTION_TYPE_PHY_SKU].data;
337 342
343 regulatory = mvm->trans->cfg->nvm_type == IWL_NVM_SDP ?
344 (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY_SDP].data :
345 (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
346
338 lar_enabled = !iwlwifi_mod_params.lar_disable && 347 lar_enabled = !iwlwifi_mod_params.lar_disable &&
339 fw_has_capa(&mvm->fw->ucode_capa, 348 fw_has_capa(&mvm->fw->ucode_capa,
340 IWL_UCODE_TLV_CAPA_LAR_SUPPORT); 349 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
@@ -394,7 +403,7 @@ int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm)
394 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n"); 403 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n");
395 404
396 /* Maximal size depends on NVM version */ 405 /* Maximal size depends on NVM version */
397 if (!mvm->trans->cfg->ext_nvm) 406 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT)
398 max_section_size = IWL_MAX_NVM_SECTION_SIZE; 407 max_section_size = IWL_MAX_NVM_SECTION_SIZE;
399 else 408 else
400 max_section_size = IWL_MAX_EXT_NVM_SECTION_SIZE; 409 max_section_size = IWL_MAX_EXT_NVM_SECTION_SIZE;
@@ -465,7 +474,7 @@ int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm)
465 break; 474 break;
466 } 475 }
467 476
468 if (!mvm->trans->cfg->ext_nvm) { 477 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
469 section_size = 478 section_size =
470 2 * NVM_WORD1_LEN(le16_to_cpu(file_sec->word1)); 479 2 * NVM_WORD1_LEN(le16_to_cpu(file_sec->word1));
471 section_id = NVM_WORD2_ID(le16_to_cpu(file_sec->word2)); 480 section_id = NVM_WORD2_ID(le16_to_cpu(file_sec->word2));
@@ -740,7 +749,7 @@ int iwl_mvm_init_mcc(struct iwl_mvm *mvm)
740 struct ieee80211_regdomain *regd; 749 struct ieee80211_regdomain *regd;
741 char mcc[3]; 750 char mcc[3];
742 751
743 if (mvm->cfg->ext_nvm) { 752 if (mvm->cfg->nvm_type == IWL_NVM_EXT) {
744 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa, 753 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
745 IWL_UCODE_TLV_CAPA_LAR_SUPPORT); 754 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
746 nvm_lar = mvm->nvm_data->lar_enabled; 755 nvm_lar = mvm->nvm_data->lar_enabled;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
index 184c749766f2..2d14a58cbdd7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
@@ -244,7 +244,9 @@ static u32 iwl_mvm_set_mac80211_rx_flag(struct iwl_mvm *mvm,
244 return 0; 244 return 0;
245 245
246 default: 246 default:
247 IWL_ERR(mvm, "Unhandled alg: 0x%x\n", rx_pkt_status); 247 /* Expected in monitor (not having the keys) */
248 if (!mvm->monitor_on)
249 IWL_ERR(mvm, "Unhandled alg: 0x%x\n", rx_pkt_status);
248 } 250 }
249 251
250 return 0; 252 return 0;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 77f77bc5d083..248699c2c4bf 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -277,7 +277,9 @@ static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
277 stats->flag |= RX_FLAG_DECRYPTED; 277 stats->flag |= RX_FLAG_DECRYPTED;
278 return 0; 278 return 0;
279 default: 279 default:
280 IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status); 280 /* Expected in monitor (not having the keys) */
281 if (!mvm->monitor_on)
282 IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status);
281 } 283 }
282 284
283 return 0; 285 return 0;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 4d907f60bce9..1232f63278eb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -631,7 +631,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
631 631
632 if (!iwl_mvm_firmware_running(mvm) || 632 if (!iwl_mvm_firmware_running(mvm) ||
633 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { 633 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
634 ret = -EIO; 634 ret = -ENODATA;
635 goto out; 635 goto out;
636 } 636 }
637 637
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 4f73012978e9..1d431d4bf6d2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -1122,7 +1122,7 @@ static u8 _rtl8821ae_dbi_read(struct rtl_priv *rtlpriv, u16 addr)
1122 } 1122 }
1123 if (0 == tmp) { 1123 if (0 == tmp) {
1124 read_addr = REG_DBI_RDATA + addr % 4; 1124 read_addr = REG_DBI_RDATA + addr % 4;
1125 ret = rtl_read_byte(rtlpriv, read_addr); 1125 ret = rtl_read_word(rtlpriv, read_addr);
1126 } 1126 }
1127 return ret; 1127 return ret;
1128} 1128}
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index ee8ed9da00ad..4491ca5aee90 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -486,7 +486,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
486 486
487 dev->tx_queue_len = XENVIF_QUEUE_LENGTH; 487 dev->tx_queue_len = XENVIF_QUEUE_LENGTH;
488 488
489 dev->min_mtu = 0; 489 dev->min_mtu = ETH_MIN_MTU;
490 dev->max_mtu = ETH_MAX_MTU - VLAN_ETH_HLEN; 490 dev->max_mtu = ETH_MAX_MTU - VLAN_ETH_HLEN;
491 491
492 /* 492 /*
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 523387e71a80..8b8689c6d887 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1316,7 +1316,7 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
1316 netdev->features |= netdev->hw_features; 1316 netdev->features |= netdev->hw_features;
1317 1317
1318 netdev->ethtool_ops = &xennet_ethtool_ops; 1318 netdev->ethtool_ops = &xennet_ethtool_ops;
1319 netdev->min_mtu = 0; 1319 netdev->min_mtu = ETH_MIN_MTU;
1320 netdev->max_mtu = XEN_NETIF_MAX_TX_SIZE; 1320 netdev->max_mtu = XEN_NETIF_MAX_TX_SIZE;
1321 SET_NETDEV_DEV(netdev, &dev->dev); 1321 SET_NETDEV_DEV(netdev, &dev->dev);
1322 1322
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index d94dd8b77abd..98258583abb0 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -44,7 +44,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
44 return -EINVAL; 44 return -EINVAL;
45} 45}
46 46
47static void of_mdiobus_register_phy(struct mii_bus *mdio, 47static int of_mdiobus_register_phy(struct mii_bus *mdio,
48 struct device_node *child, u32 addr) 48 struct device_node *child, u32 addr)
49{ 49{
50 struct phy_device *phy; 50 struct phy_device *phy;
@@ -60,9 +60,13 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio,
60 else 60 else
61 phy = get_phy_device(mdio, addr, is_c45); 61 phy = get_phy_device(mdio, addr, is_c45);
62 if (IS_ERR(phy)) 62 if (IS_ERR(phy))
63 return; 63 return PTR_ERR(phy);
64 64
65 rc = irq_of_parse_and_map(child, 0); 65 rc = of_irq_get(child, 0);
66 if (rc == -EPROBE_DEFER) {
67 phy_device_free(phy);
68 return rc;
69 }
66 if (rc > 0) { 70 if (rc > 0) {
67 phy->irq = rc; 71 phy->irq = rc;
68 mdio->irq[addr] = rc; 72 mdio->irq[addr] = rc;
@@ -84,22 +88,23 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio,
84 if (rc) { 88 if (rc) {
85 phy_device_free(phy); 89 phy_device_free(phy);
86 of_node_put(child); 90 of_node_put(child);
87 return; 91 return rc;
88 } 92 }
89 93
90 dev_dbg(&mdio->dev, "registered phy %s at address %i\n", 94 dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
91 child->name, addr); 95 child->name, addr);
96 return 0;
92} 97}
93 98
94static void of_mdiobus_register_device(struct mii_bus *mdio, 99static int of_mdiobus_register_device(struct mii_bus *mdio,
95 struct device_node *child, u32 addr) 100 struct device_node *child, u32 addr)
96{ 101{
97 struct mdio_device *mdiodev; 102 struct mdio_device *mdiodev;
98 int rc; 103 int rc;
99 104
100 mdiodev = mdio_device_create(mdio, addr); 105 mdiodev = mdio_device_create(mdio, addr);
101 if (IS_ERR(mdiodev)) 106 if (IS_ERR(mdiodev))
102 return; 107 return PTR_ERR(mdiodev);
103 108
104 /* Associate the OF node with the device structure so it 109 /* Associate the OF node with the device structure so it
105 * can be looked up later. 110 * can be looked up later.
@@ -112,11 +117,12 @@ static void of_mdiobus_register_device(struct mii_bus *mdio,
112 if (rc) { 117 if (rc) {
113 mdio_device_free(mdiodev); 118 mdio_device_free(mdiodev);
114 of_node_put(child); 119 of_node_put(child);
115 return; 120 return rc;
116 } 121 }
117 122
118 dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n", 123 dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n",
119 child->name, addr); 124 child->name, addr);
125 return 0;
120} 126}
121 127
122/* The following is a list of PHY compatible strings which appear in 128/* The following is a list of PHY compatible strings which appear in
@@ -219,9 +225,11 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
219 } 225 }
220 226
221 if (of_mdiobus_child_is_phy(child)) 227 if (of_mdiobus_child_is_phy(child))
222 of_mdiobus_register_phy(mdio, child, addr); 228 rc = of_mdiobus_register_phy(mdio, child, addr);
223 else 229 else
224 of_mdiobus_register_device(mdio, child, addr); 230 rc = of_mdiobus_register_device(mdio, child, addr);
231 if (rc)
232 goto unregister;
225 } 233 }
226 234
227 if (!scanphys) 235 if (!scanphys)
@@ -242,12 +250,19 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
242 dev_info(&mdio->dev, "scan phy %s at address %i\n", 250 dev_info(&mdio->dev, "scan phy %s at address %i\n",
243 child->name, addr); 251 child->name, addr);
244 252
245 if (of_mdiobus_child_is_phy(child)) 253 if (of_mdiobus_child_is_phy(child)) {
246 of_mdiobus_register_phy(mdio, child, addr); 254 rc = of_mdiobus_register_phy(mdio, child, addr);
255 if (rc)
256 goto unregister;
257 }
247 } 258 }
248 } 259 }
249 260
250 return 0; 261 return 0;
262
263unregister:
264 mdiobus_unregister(mdio);
265 return rc;
251} 266}
252EXPORT_SYMBOL(of_mdiobus_register); 267EXPORT_SYMBOL(of_mdiobus_register);
253 268
diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
index 73ebad6634a7..89c887ea5557 100644
--- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
+++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
@@ -111,6 +111,8 @@
111#define MVEBU_COMPHY_CONF6_40B BIT(18) 111#define MVEBU_COMPHY_CONF6_40B BIT(18)
112#define MVEBU_COMPHY_SELECTOR 0x1140 112#define MVEBU_COMPHY_SELECTOR 0x1140
113#define MVEBU_COMPHY_SELECTOR_PHY(n) ((n) * 0x4) 113#define MVEBU_COMPHY_SELECTOR_PHY(n) ((n) * 0x4)
114#define MVEBU_COMPHY_PIPE_SELECTOR 0x1144
115#define MVEBU_COMPHY_PIPE_SELECTOR_PIPE(n) ((n) * 0x4)
114 116
115#define MVEBU_COMPHY_LANES 6 117#define MVEBU_COMPHY_LANES 6
116#define MVEBU_COMPHY_PORTS 3 118#define MVEBU_COMPHY_PORTS 3
@@ -468,13 +470,17 @@ static int mvebu_comphy_power_on(struct phy *phy)
468{ 470{
469 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy); 471 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy);
470 struct mvebu_comphy_priv *priv = lane->priv; 472 struct mvebu_comphy_priv *priv = lane->priv;
471 int ret; 473 int ret, mux;
472 u32 mux, val; 474 u32 val;
473 475
474 mux = mvebu_comphy_get_mux(lane->id, lane->port, lane->mode); 476 mux = mvebu_comphy_get_mux(lane->id, lane->port, lane->mode);
475 if (mux < 0) 477 if (mux < 0)
476 return -ENOTSUPP; 478 return -ENOTSUPP;
477 479
480 regmap_read(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, &val);
481 val &= ~(0xf << MVEBU_COMPHY_PIPE_SELECTOR_PIPE(lane->id));
482 regmap_write(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, val);
483
478 regmap_read(priv->regmap, MVEBU_COMPHY_SELECTOR, &val); 484 regmap_read(priv->regmap, MVEBU_COMPHY_SELECTOR, &val);
479 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id)); 485 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id));
480 val |= mux << MVEBU_COMPHY_SELECTOR_PHY(lane->id); 486 val |= mux << MVEBU_COMPHY_SELECTOR_PHY(lane->id);
@@ -526,6 +532,10 @@ static int mvebu_comphy_power_off(struct phy *phy)
526 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id)); 532 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id));
527 regmap_write(priv->regmap, MVEBU_COMPHY_SELECTOR, val); 533 regmap_write(priv->regmap, MVEBU_COMPHY_SELECTOR, val);
528 534
535 regmap_read(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, &val);
536 val &= ~(0xf << MVEBU_COMPHY_PIPE_SELECTOR_PIPE(lane->id));
537 regmap_write(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, val);
538
529 return 0; 539 return 0;
530} 540}
531 541
@@ -576,8 +586,8 @@ static int mvebu_comphy_probe(struct platform_device *pdev)
576 return PTR_ERR(priv->regmap); 586 return PTR_ERR(priv->regmap);
577 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 587 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
578 priv->base = devm_ioremap_resource(&pdev->dev, res); 588 priv->base = devm_ioremap_resource(&pdev->dev, res);
579 if (!priv->base) 589 if (IS_ERR(priv->base))
580 return -ENOMEM; 590 return PTR_ERR(priv->base);
581 591
582 for_each_available_child_of_node(pdev->dev.of_node, child) { 592 for_each_available_child_of_node(pdev->dev.of_node, child) {
583 struct mvebu_comphy_lane *lane; 593 struct mvebu_comphy_lane *lane;
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index e3baad78521f..721a2a1c97ef 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -27,6 +27,7 @@
27/* banks shared by multiple phys */ 27/* banks shared by multiple phys */
28#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */ 28#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */
29#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */ 29#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */
30#define SSUSB_SIFSLV_V1_CHIP 0x300 /* shared by u3 phys */
30/* u2 phy bank */ 31/* u2 phy bank */
31#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000 32#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000
32/* u3/pcie/sata phy banks */ 33/* u3/pcie/sata phy banks */
@@ -762,7 +763,7 @@ static void phy_v1_banks_init(struct mtk_tphy *tphy,
762 case PHY_TYPE_USB3: 763 case PHY_TYPE_USB3:
763 case PHY_TYPE_PCIE: 764 case PHY_TYPE_PCIE:
764 u3_banks->spllc = tphy->sif_base + SSUSB_SIFSLV_V1_SPLLC; 765 u3_banks->spllc = tphy->sif_base + SSUSB_SIFSLV_V1_SPLLC;
765 u3_banks->chip = NULL; 766 u3_banks->chip = tphy->sif_base + SSUSB_SIFSLV_V1_CHIP;
766 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD; 767 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD;
767 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA; 768 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA;
768 break; 769 break;
diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index 4d2c57f21d76..a958c9bced01 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -443,14 +443,34 @@ static inline int property_enable(struct rockchip_typec_phy *tcphy,
443 return regmap_write(tcphy->grf_regs, reg->offset, val | mask); 443 return regmap_write(tcphy->grf_regs, reg->offset, val | mask);
444} 444}
445 445
446static void tcphy_dp_aux_set_flip(struct rockchip_typec_phy *tcphy)
447{
448 u16 tx_ana_ctrl_reg_1;
449
450 /*
451 * Select the polarity of the xcvr:
452 * 1, Reverses the polarity (If TYPEC, Pulls ups aux_p and pull
453 * down aux_m)
454 * 0, Normal polarity (if TYPEC, pulls up aux_m and pulls down
455 * aux_p)
456 */
457 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
458 if (!tcphy->flip)
459 tx_ana_ctrl_reg_1 |= BIT(12);
460 else
461 tx_ana_ctrl_reg_1 &= ~BIT(12);
462 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
463}
464
446static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy) 465static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
447{ 466{
467 u16 tx_ana_ctrl_reg_1;
448 u16 rdata, rdata2, val; 468 u16 rdata, rdata2, val;
449 469
450 /* disable txda_cal_latch_en for rewrite the calibration values */ 470 /* disable txda_cal_latch_en for rewrite the calibration values */
451 rdata = readl(tcphy->base + TX_ANA_CTRL_REG_1); 471 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
452 val = rdata & 0xdfff; 472 tx_ana_ctrl_reg_1 &= ~BIT(13);
453 writel(val, tcphy->base + TX_ANA_CTRL_REG_1); 473 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
454 474
455 /* 475 /*
456 * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and 476 * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and
@@ -472,9 +492,8 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
472 * Activate this signal for 1 clock cycle to sample new calibration 492 * Activate this signal for 1 clock cycle to sample new calibration
473 * values. 493 * values.
474 */ 494 */
475 rdata = readl(tcphy->base + TX_ANA_CTRL_REG_1); 495 tx_ana_ctrl_reg_1 |= BIT(13);
476 val = rdata | 0x2000; 496 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
477 writel(val, tcphy->base + TX_ANA_CTRL_REG_1);
478 usleep_range(150, 200); 497 usleep_range(150, 200);
479 498
480 /* set TX Voltage Level and TX Deemphasis to 0 */ 499 /* set TX Voltage Level and TX Deemphasis to 0 */
@@ -482,8 +501,10 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
482 /* re-enable decap */ 501 /* re-enable decap */
483 writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2); 502 writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2);
484 writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2); 503 writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2);
485 writel(0x2008, tcphy->base + TX_ANA_CTRL_REG_1); 504 tx_ana_ctrl_reg_1 |= BIT(3);
486 writel(0x2018, tcphy->base + TX_ANA_CTRL_REG_1); 505 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
506 tx_ana_ctrl_reg_1 |= BIT(4);
507 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
487 508
488 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 509 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
489 510
@@ -494,8 +515,10 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
494 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4); 515 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4);
495 516
496 /* re-enables Bandgap reference for LDO */ 517 /* re-enables Bandgap reference for LDO */
497 writel(0x2098, tcphy->base + TX_ANA_CTRL_REG_1); 518 tx_ana_ctrl_reg_1 |= BIT(7);
498 writel(0x2198, tcphy->base + TX_ANA_CTRL_REG_1); 519 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
520 tx_ana_ctrl_reg_1 |= BIT(8);
521 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
499 522
500 /* 523 /*
501 * re-enables the transmitter pre-driver, driver data selection MUX, 524 * re-enables the transmitter pre-driver, driver data selection MUX,
@@ -505,27 +528,26 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
505 writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2); 528 writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2);
506 529
507 /* 530 /*
508 * BIT 12: Controls auxda_polarity, which selects the polarity of the 531 * Do some magic undocumented stuff, some of which appears to
509 * xcvr: 532 * undo the "re-enables Bandgap reference for LDO" above.
510 * 1, Reverses the polarity (If TYPEC, Pulls ups aux_p and pull
511 * down aux_m)
512 * 0, Normal polarity (if TYPE_C, pulls up aux_m and pulls down
513 * aux_p)
514 */ 533 */
515 val = 0xa078; 534 tx_ana_ctrl_reg_1 |= BIT(15);
516 if (!tcphy->flip) 535 tx_ana_ctrl_reg_1 &= ~BIT(8);
517 val |= BIT(12); 536 tx_ana_ctrl_reg_1 &= ~BIT(7);
518 writel(val, tcphy->base + TX_ANA_CTRL_REG_1); 537 tx_ana_ctrl_reg_1 |= BIT(6);
538 tx_ana_ctrl_reg_1 |= BIT(5);
539 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
519 540
520 writel(0, tcphy->base + TX_ANA_CTRL_REG_3); 541 writel(0, tcphy->base + TX_ANA_CTRL_REG_3);
521 writel(0, tcphy->base + TX_ANA_CTRL_REG_4); 542 writel(0, tcphy->base + TX_ANA_CTRL_REG_4);
522 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 543 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
523 544
524 /* 545 /*
525 * Controls low_power_swing_en, set the voltage swing of the driver 546 * Controls low_power_swing_en, don't set the voltage swing of the
526 * to 400mv. The values below are peak to peak (differential) values. 547 * driver to 400mv. The values below are peak to peak (differential)
548 * values.
527 */ 549 */
528 writel(4, tcphy->base + TXDA_COEFF_CALC_CTRL); 550 writel(0, tcphy->base + TXDA_COEFF_CALC_CTRL);
529 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA); 551 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA);
530 552
531 /* Controls tx_high_z_tm_en */ 553 /* Controls tx_high_z_tm_en */
@@ -555,6 +577,7 @@ static int tcphy_phy_init(struct rockchip_typec_phy *tcphy, u8 mode)
555 reset_control_deassert(tcphy->tcphy_rst); 577 reset_control_deassert(tcphy->tcphy_rst);
556 578
557 property_enable(tcphy, &cfg->typec_conn_dir, tcphy->flip); 579 property_enable(tcphy, &cfg->typec_conn_dir, tcphy->flip);
580 tcphy_dp_aux_set_flip(tcphy);
558 581
559 tcphy_cfg_24m(tcphy); 582 tcphy_cfg_24m(tcphy);
560 583
@@ -685,8 +708,11 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
685 if (tcphy->mode == new_mode) 708 if (tcphy->mode == new_mode)
686 goto unlock_ret; 709 goto unlock_ret;
687 710
688 if (tcphy->mode == MODE_DISCONNECT) 711 if (tcphy->mode == MODE_DISCONNECT) {
689 tcphy_phy_init(tcphy, new_mode); 712 ret = tcphy_phy_init(tcphy, new_mode);
713 if (ret)
714 goto unlock_ret;
715 }
690 716
691 /* wait TCPHY for pipe ready */ 717 /* wait TCPHY for pipe ready */
692 for (timeout = 0; timeout < 100; timeout++) { 718 for (timeout = 0; timeout < 100; timeout++) {
@@ -760,10 +786,12 @@ static int rockchip_dp_phy_power_on(struct phy *phy)
760 */ 786 */
761 if (new_mode == MODE_DFP_DP && tcphy->mode != MODE_DISCONNECT) { 787 if (new_mode == MODE_DFP_DP && tcphy->mode != MODE_DISCONNECT) {
762 tcphy_phy_deinit(tcphy); 788 tcphy_phy_deinit(tcphy);
763 tcphy_phy_init(tcphy, new_mode); 789 ret = tcphy_phy_init(tcphy, new_mode);
764 } else if (tcphy->mode == MODE_DISCONNECT) { 790 } else if (tcphy->mode == MODE_DISCONNECT) {
765 tcphy_phy_init(tcphy, new_mode); 791 ret = tcphy_phy_init(tcphy, new_mode);
766 } 792 }
793 if (ret)
794 goto unlock_ret;
767 795
768 ret = readx_poll_timeout(readl, tcphy->base + DP_MODE_CTL, 796 ret = readx_poll_timeout(readl, tcphy->base + DP_MODE_CTL,
769 val, val & DP_MODE_A2, 1000, 797 val, val & DP_MODE_A2, 1000,
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 3cbcb2537657..4307bf0013e1 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -454,6 +454,8 @@ tegra_xusb_find_port_node(struct tegra_xusb_padctl *padctl, const char *type,
454 char *name; 454 char *name;
455 455
456 name = kasprintf(GFP_KERNEL, "%s-%u", type, index); 456 name = kasprintf(GFP_KERNEL, "%s-%u", type, index);
457 if (!name)
458 return ERR_PTR(-ENOMEM);
457 np = of_find_node_by_name(np, name); 459 np = of_find_node_by_name(np, name);
458 kfree(name); 460 kfree(name);
459 } 461 }
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index bb1dcd7fbdeb..e8d058c5ef21 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -2510,7 +2510,6 @@ static const struct iio_chan_spec toshiba_iio_accel_channels[] = {
2510}; 2510};
2511 2511
2512static const struct iio_info toshiba_iio_accel_info = { 2512static const struct iio_info toshiba_iio_accel_info = {
2513 .driver_module = THIS_MODULE,
2514 .read_raw = &toshiba_iio_accel_read_raw, 2513 .read_raw = &toshiba_iio_accel_read_raw,
2515}; 2514};
2516 2515
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index c60904ff40b8..3907bbc9c6cf 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -40,8 +40,9 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
40 struct socfpga_reset_data *data = container_of(rcdev, 40 struct socfpga_reset_data *data = container_of(rcdev,
41 struct socfpga_reset_data, 41 struct socfpga_reset_data,
42 rcdev); 42 rcdev);
43 int bank = id / BITS_PER_LONG; 43 int reg_width = sizeof(u32);
44 int offset = id % BITS_PER_LONG; 44 int bank = id / (reg_width * BITS_PER_BYTE);
45 int offset = id % (reg_width * BITS_PER_BYTE);
45 unsigned long flags; 46 unsigned long flags;
46 u32 reg; 47 u32 reg;
47 48
@@ -61,8 +62,9 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
61 struct socfpga_reset_data, 62 struct socfpga_reset_data,
62 rcdev); 63 rcdev);
63 64
64 int bank = id / BITS_PER_LONG; 65 int reg_width = sizeof(u32);
65 int offset = id % BITS_PER_LONG; 66 int bank = id / (reg_width * BITS_PER_BYTE);
67 int offset = id % (reg_width * BITS_PER_BYTE);
66 unsigned long flags; 68 unsigned long flags;
67 u32 reg; 69 u32 reg;
68 70
@@ -81,8 +83,9 @@ static int socfpga_reset_status(struct reset_controller_dev *rcdev,
81{ 83{
82 struct socfpga_reset_data *data = container_of(rcdev, 84 struct socfpga_reset_data *data = container_of(rcdev,
83 struct socfpga_reset_data, rcdev); 85 struct socfpga_reset_data, rcdev);
84 int bank = id / BITS_PER_LONG; 86 int reg_width = sizeof(u32);
85 int offset = id % BITS_PER_LONG; 87 int bank = id / (reg_width * BITS_PER_BYTE);
88 int offset = id % (reg_width * BITS_PER_BYTE);
86 u32 reg; 89 u32 reg;
87 90
88 reg = readl(data->membase + (bank * BANK_INCREMENT)); 91 reg = readl(data->membase + (bank * BANK_INCREMENT));
@@ -132,7 +135,7 @@ static int socfpga_reset_probe(struct platform_device *pdev)
132 spin_lock_init(&data->lock); 135 spin_lock_init(&data->lock);
133 136
134 data->rcdev.owner = THIS_MODULE; 137 data->rcdev.owner = THIS_MODULE;
135 data->rcdev.nr_resets = NR_BANKS * BITS_PER_LONG; 138 data->rcdev.nr_resets = NR_BANKS * (sizeof(u32) * BITS_PER_BYTE);
136 data->rcdev.ops = &socfpga_reset_ops; 139 data->rcdev.ops = &socfpga_reset_ops;
137 data->rcdev.of_node = pdev->dev.of_node; 140 data->rcdev.of_node = pdev->dev.of_node;
138 141
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 520325867e2b..31d31aad3de1 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -383,11 +383,11 @@ static void fc_rport_work(struct work_struct *work)
383 fc_rport_enter_flogi(rdata); 383 fc_rport_enter_flogi(rdata);
384 mutex_unlock(&rdata->rp_mutex); 384 mutex_unlock(&rdata->rp_mutex);
385 } else { 385 } else {
386 mutex_unlock(&rdata->rp_mutex);
386 FC_RPORT_DBG(rdata, "work delete\n"); 387 FC_RPORT_DBG(rdata, "work delete\n");
387 mutex_lock(&lport->disc.disc_mutex); 388 mutex_lock(&lport->disc.disc_mutex);
388 list_del_rcu(&rdata->peers); 389 list_del_rcu(&rdata->peers);
389 mutex_unlock(&lport->disc.disc_mutex); 390 mutex_unlock(&lport->disc.disc_mutex);
390 mutex_unlock(&rdata->rp_mutex);
391 kref_put(&rdata->kref, fc_rport_destroy); 391 kref_put(&rdata->kref, fc_rport_destroy);
392 } 392 }
393 } else { 393 } else {
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c62e8d111fd9..f8dc1601efd5 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1728,7 +1728,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
1728 1728
1729 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { 1729 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
1730 reason = FAILURE_SESSION_IN_RECOVERY; 1730 reason = FAILURE_SESSION_IN_RECOVERY;
1731 sc->result = DID_REQUEUE; 1731 sc->result = DID_REQUEUE << 16;
1732 goto fault; 1732 goto fault;
1733 } 1733 }
1734 1734
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5b2437a5ea44..937209805baf 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3175,6 +3175,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3175 host->can_queue, base_vha->req, 3175 host->can_queue, base_vha->req,
3176 base_vha->mgmt_svr_loop_id, host->sg_tablesize); 3176 base_vha->mgmt_svr_loop_id, host->sg_tablesize);
3177 3177
3178 INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn);
3179
3178 if (ha->mqenable) { 3180 if (ha->mqenable) {
3179 bool mq = false; 3181 bool mq = false;
3180 bool startit = false; 3182 bool startit = false;
@@ -3223,7 +3225,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3223 */ 3225 */
3224 qla2xxx_wake_dpc(base_vha); 3226 qla2xxx_wake_dpc(base_vha);
3225 3227
3226 INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn);
3227 INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); 3228 INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error);
3228 3229
3229 if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { 3230 if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) {
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index bf53356f41f0..f796bd61f3f0 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1376,13 +1376,19 @@ static void __scsi_remove_target(struct scsi_target *starget)
1376 spin_lock_irqsave(shost->host_lock, flags); 1376 spin_lock_irqsave(shost->host_lock, flags);
1377 restart: 1377 restart:
1378 list_for_each_entry(sdev, &shost->__devices, siblings) { 1378 list_for_each_entry(sdev, &shost->__devices, siblings) {
1379 /*
1380 * We cannot call scsi_device_get() here, as
1381 * we might've been called from rmmod() causing
1382 * scsi_device_get() to fail the module_is_live()
1383 * check.
1384 */
1379 if (sdev->channel != starget->channel || 1385 if (sdev->channel != starget->channel ||
1380 sdev->id != starget->id || 1386 sdev->id != starget->id ||
1381 scsi_device_get(sdev)) 1387 !get_device(&sdev->sdev_gendev))
1382 continue; 1388 continue;
1383 spin_unlock_irqrestore(shost->host_lock, flags); 1389 spin_unlock_irqrestore(shost->host_lock, flags);
1384 scsi_remove_device(sdev); 1390 scsi_remove_device(sdev);
1385 scsi_device_put(sdev); 1391 put_device(&sdev->sdev_gendev);
1386 spin_lock_irqsave(shost->host_lock, flags); 1392 spin_lock_irqsave(shost->host_lock, flags);
1387 goto restart; 1393 goto restart;
1388 } 1394 }
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index cbd4495d0ff9..8c46a6d536af 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -3320,6 +3320,9 @@ int fc_block_scsi_eh(struct scsi_cmnd *cmnd)
3320{ 3320{
3321 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); 3321 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
3322 3322
3323 if (WARN_ON_ONCE(!rport))
3324 return FAST_IO_FAIL;
3325
3323 return fc_block_rport(rport); 3326 return fc_block_rport(rport);
3324} 3327}
3325EXPORT_SYMBOL(fc_block_scsi_eh); 3328EXPORT_SYMBOL(fc_block_scsi_eh);
diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO
index 5f14247392bf..687e0eac85bf 100644
--- a/drivers/staging/android/TODO
+++ b/drivers/staging/android/TODO
@@ -1,5 +1,4 @@
1TODO: 1TODO:
2 - checkpatch.pl cleanups
3 - sparse fixes 2 - sparse fixes
4 - rename files to be not so "generic" 3 - rename files to be not so "generic"
5 - add proper arch dependencies as needed 4 - add proper arch dependencies as needed
diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
index d9f8b1424da1..c78989351f9c 100644
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ b/drivers/staging/android/ion/ion-ioctl.c
@@ -27,19 +27,18 @@ union ion_ioctl_arg {
27 27
28static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) 28static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
29{ 29{
30 int ret = 0;
31
32 switch (cmd) { 30 switch (cmd) {
33 case ION_IOC_HEAP_QUERY: 31 case ION_IOC_HEAP_QUERY:
34 ret = arg->query.reserved0 != 0; 32 if (arg->query.reserved0 ||
35 ret |= arg->query.reserved1 != 0; 33 arg->query.reserved1 ||
36 ret |= arg->query.reserved2 != 0; 34 arg->query.reserved2)
35 return -EINVAL;
37 break; 36 break;
38 default: 37 default:
39 break; 38 break;
40 } 39 }
41 40
42 return ret ? -EINVAL : 0; 41 return 0;
43} 42}
44 43
45/* fix up the cases where the ioctl direction bits are incorrect */ 44/* fix up the cases where the ioctl direction bits are incorrect */
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 93e2c90fa77d..a7d9b0e98572 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -81,7 +81,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
81 unsigned long flags) 81 unsigned long flags)
82{ 82{
83 struct ion_buffer *buffer; 83 struct ion_buffer *buffer;
84 struct sg_table *table;
85 int ret; 84 int ret;
86 85
87 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 86 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
@@ -109,7 +108,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
109 goto err1; 108 goto err1;
110 } 109 }
111 110
112 table = buffer->sg_table;
113 buffer->dev = dev; 111 buffer->dev = dev;
114 buffer->size = len; 112 buffer->size = len;
115 113
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index 621e5f7ceacb..f5f9cd63f8e9 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -86,6 +86,7 @@ struct ion_buffer {
86 struct sg_table *sg_table; 86 struct sg_table *sg_table;
87 struct list_head attachments; 87 struct list_head attachments;
88}; 88};
89
89void ion_buffer_destroy(struct ion_buffer *buffer); 90void ion_buffer_destroy(struct ion_buffer *buffer);
90 91
91/** 92/**
@@ -299,7 +300,6 @@ size_t ion_heap_freelist_shrink(struct ion_heap *heap,
299 */ 300 */
300size_t ion_heap_freelist_size(struct ion_heap *heap); 301size_t ion_heap_freelist_size(struct ion_heap *heap);
301 302
302
303/** 303/**
304 * functions for creating and destroying a heap pool -- allows you 304 * functions for creating and destroying a heap pool -- allows you
305 * to keep a pool of pre allocated memory to use from your heap. Keeping 305 * to keep a pool of pre allocated memory to use from your heap. Keeping
diff --git a/drivers/staging/ccree/cc_hal.h b/drivers/staging/ccree/cc_hal.h
deleted file mode 100644
index eecc866dfc74..000000000000
--- a/drivers/staging/ccree/cc_hal.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* pseudo cc_hal.h for cc7x_perf_test_driver (to be able to include code from
18 * CC drivers).
19 */
20
21#ifndef __CC_HAL_H__
22#define __CC_HAL_H__
23
24#include <linux/io.h>
25
26#define READ_REGISTER(_addr) ioread32((_addr))
27#define WRITE_REGISTER(_addr, _data) iowrite32((_data), (_addr))
28
29#define CC_HAL_WRITE_REGISTER(offset, val) \
30 WRITE_REGISTER(cc_base + (offset), val)
31#define CC_HAL_READ_REGISTER(offset) READ_REGISTER(cc_base + (offset))
32
33#endif
diff --git a/drivers/staging/ccree/cc_lli_defs.h b/drivers/staging/ccree/cc_lli_defs.h
index 851d3907167e..a9c417b07b04 100644
--- a/drivers/staging/ccree/cc_lli_defs.h
+++ b/drivers/staging/ccree/cc_lli_defs.h
@@ -59,7 +59,7 @@ static inline void cc_lli_set_addr(u32 *lli_p, dma_addr_t addr)
59 lli_p[LLI_WORD0_OFFSET] = (addr & U32_MAX); 59 lli_p[LLI_WORD0_OFFSET] = (addr & U32_MAX);
60#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT 60#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
61 lli_p[LLI_WORD1_OFFSET] &= ~LLI_HADDR_MASK; 61 lli_p[LLI_WORD1_OFFSET] &= ~LLI_HADDR_MASK;
62 lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_HADDR_MASK, (addr >> 16)); 62 lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_HADDR_MASK, (addr >> 32));
63#endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */ 63#endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */
64} 64}
65 65
diff --git a/drivers/staging/ccree/cc_regs.h b/drivers/staging/ccree/cc_regs.h
deleted file mode 100644
index 4a893a6ba6ef..000000000000
--- a/drivers/staging/ccree/cc_regs.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 */
16
17/*!
18 * @file
19 * @brief This file contains macro definitions for accessing ARM TrustZone
20 * CryptoCell register space.
21 */
22
23#ifndef _CC_REGS_H_
24#define _CC_REGS_H_
25
26#include <linux/bitfield.h>
27
28#define AXIM_MON_BASE_OFFSET CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_COMP)
29#define AXIM_MON_COMP_VALUE GENMASK(DX_AXIM_MON_COMP_VALUE_BIT_SIZE + \
30 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT, \
31 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT)
32
33#define AXIM_MON_BASE_OFFSET CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_COMP)
34#define AXIM_MON_COMP_VALUE GENMASK(DX_AXIM_MON_COMP_VALUE_BIT_SIZE + \
35 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT, \
36 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT)
37
38/* Register Offset macro */
39#define CC_REG_OFFSET(unit_name, reg_name) \
40 (DX_BASE_ ## unit_name + DX_ ## reg_name ## _REG_OFFSET)
41
42#endif /*_CC_REGS_H_*/
diff --git a/drivers/staging/ccree/dx_reg_base_host.h b/drivers/staging/ccree/dx_reg_base_host.h
deleted file mode 100644
index 47bbadbcd1df..000000000000
--- a/drivers/staging/ccree/dx_reg_base_host.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __DX_REG_BASE_HOST_H__
18#define __DX_REG_BASE_HOST_H__
19
20#define DX_BASE_CC 0x80000000
21#define DX_BASE_HOST_RGF 0x0UL
22#define DX_BASE_CRY_KERNEL 0x0UL
23#define DX_BASE_ROM 0x40000000
24
25#endif /*__DX_REG_BASE_HOST_H__*/
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 5abe6b24ff8c..ba0954e4d2e5 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -92,18 +92,17 @@ static inline bool valid_assoclen(struct aead_request *req)
92 92
93static void ssi_aead_exit(struct crypto_aead *tfm) 93static void ssi_aead_exit(struct crypto_aead *tfm)
94{ 94{
95 struct device *dev = NULL;
96 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 95 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
96 struct device *dev = drvdata_to_dev(ctx->drvdata);
97 97
98 SSI_LOG_DEBUG("Clearing context @%p for %s\n", 98 dev_dbg(dev, "Clearing context @%p for %s\n", crypto_aead_ctx(tfm),
99 crypto_aead_ctx(tfm), crypto_tfm_alg_name(&tfm->base)); 99 crypto_tfm_alg_name(&tfm->base));
100 100
101 dev = &ctx->drvdata->plat_dev->dev;
102 /* Unmap enckey buffer */ 101 /* Unmap enckey buffer */
103 if (ctx->enckey) { 102 if (ctx->enckey) {
104 dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, ctx->enckey_dma_addr); 103 dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, ctx->enckey_dma_addr);
105 SSI_LOG_DEBUG("Freed enckey DMA buffer enckey_dma_addr=%pad\n", 104 dev_dbg(dev, "Freed enckey DMA buffer enckey_dma_addr=%pad\n",
106 ctx->enckey_dma_addr); 105 &ctx->enckey_dma_addr);
107 ctx->enckey_dma_addr = 0; 106 ctx->enckey_dma_addr = 0;
108 ctx->enckey = NULL; 107 ctx->enckey = NULL;
109 } 108 }
@@ -116,8 +115,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
116 xcbc->xcbc_keys, 115 xcbc->xcbc_keys,
117 xcbc->xcbc_keys_dma_addr); 116 xcbc->xcbc_keys_dma_addr);
118 } 117 }
119 SSI_LOG_DEBUG("Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n", 118 dev_dbg(dev, "Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n",
120 xcbc->xcbc_keys_dma_addr); 119 &xcbc->xcbc_keys_dma_addr);
121 xcbc->xcbc_keys_dma_addr = 0; 120 xcbc->xcbc_keys_dma_addr = 0;
122 xcbc->xcbc_keys = NULL; 121 xcbc->xcbc_keys = NULL;
123 } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */ 122 } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */
@@ -127,8 +126,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
127 dma_free_coherent(dev, 2 * MAX_HMAC_DIGEST_SIZE, 126 dma_free_coherent(dev, 2 * MAX_HMAC_DIGEST_SIZE,
128 hmac->ipad_opad, 127 hmac->ipad_opad,
129 hmac->ipad_opad_dma_addr); 128 hmac->ipad_opad_dma_addr);
130 SSI_LOG_DEBUG("Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n", 129 dev_dbg(dev, "Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n",
131 hmac->ipad_opad_dma_addr); 130 &hmac->ipad_opad_dma_addr);
132 hmac->ipad_opad_dma_addr = 0; 131 hmac->ipad_opad_dma_addr = 0;
133 hmac->ipad_opad = NULL; 132 hmac->ipad_opad = NULL;
134 } 133 }
@@ -136,8 +135,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
136 dma_free_coherent(dev, MAX_HMAC_BLOCK_SIZE, 135 dma_free_coherent(dev, MAX_HMAC_BLOCK_SIZE,
137 hmac->padded_authkey, 136 hmac->padded_authkey,
138 hmac->padded_authkey_dma_addr); 137 hmac->padded_authkey_dma_addr);
139 SSI_LOG_DEBUG("Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n", 138 dev_dbg(dev, "Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n",
140 hmac->padded_authkey_dma_addr); 139 &hmac->padded_authkey_dma_addr);
141 hmac->padded_authkey_dma_addr = 0; 140 hmac->padded_authkey_dma_addr = 0;
142 hmac->padded_authkey = NULL; 141 hmac->padded_authkey = NULL;
143 } 142 }
@@ -146,29 +145,31 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
146 145
147static int ssi_aead_init(struct crypto_aead *tfm) 146static int ssi_aead_init(struct crypto_aead *tfm)
148{ 147{
149 struct device *dev;
150 struct aead_alg *alg = crypto_aead_alg(tfm); 148 struct aead_alg *alg = crypto_aead_alg(tfm);
151 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 149 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
152 struct ssi_crypto_alg *ssi_alg = 150 struct ssi_crypto_alg *ssi_alg =
153 container_of(alg, struct ssi_crypto_alg, aead_alg); 151 container_of(alg, struct ssi_crypto_alg, aead_alg);
154 SSI_LOG_DEBUG("Initializing context @%p for %s\n", ctx, crypto_tfm_alg_name(&tfm->base)); 152 struct device *dev = drvdata_to_dev(ssi_alg->drvdata);
153
154 dev_dbg(dev, "Initializing context @%p for %s\n", ctx,
155 crypto_tfm_alg_name(&tfm->base));
155 156
156 /* Initialize modes in instance */ 157 /* Initialize modes in instance */
157 ctx->cipher_mode = ssi_alg->cipher_mode; 158 ctx->cipher_mode = ssi_alg->cipher_mode;
158 ctx->flow_mode = ssi_alg->flow_mode; 159 ctx->flow_mode = ssi_alg->flow_mode;
159 ctx->auth_mode = ssi_alg->auth_mode; 160 ctx->auth_mode = ssi_alg->auth_mode;
160 ctx->drvdata = ssi_alg->drvdata; 161 ctx->drvdata = ssi_alg->drvdata;
161 dev = &ctx->drvdata->plat_dev->dev;
162 crypto_aead_set_reqsize(tfm, sizeof(struct aead_req_ctx)); 162 crypto_aead_set_reqsize(tfm, sizeof(struct aead_req_ctx));
163 163
164 /* Allocate key buffer, cache line aligned */ 164 /* Allocate key buffer, cache line aligned */
165 ctx->enckey = dma_alloc_coherent(dev, AES_MAX_KEY_SIZE, 165 ctx->enckey = dma_alloc_coherent(dev, AES_MAX_KEY_SIZE,
166 &ctx->enckey_dma_addr, GFP_KERNEL); 166 &ctx->enckey_dma_addr, GFP_KERNEL);
167 if (!ctx->enckey) { 167 if (!ctx->enckey) {
168 SSI_LOG_ERR("Failed allocating key buffer\n"); 168 dev_err(dev, "Failed allocating key buffer\n");
169 goto init_failed; 169 goto init_failed;
170 } 170 }
171 SSI_LOG_DEBUG("Allocated enckey buffer in context ctx->enckey=@%p\n", ctx->enckey); 171 dev_dbg(dev, "Allocated enckey buffer in context ctx->enckey=@%p\n",
172 ctx->enckey);
172 173
173 /* Set default authlen value */ 174 /* Set default authlen value */
174 175
@@ -182,7 +183,7 @@ static int ssi_aead_init(struct crypto_aead *tfm)
182 &xcbc->xcbc_keys_dma_addr, 183 &xcbc->xcbc_keys_dma_addr,
183 GFP_KERNEL); 184 GFP_KERNEL);
184 if (!xcbc->xcbc_keys) { 185 if (!xcbc->xcbc_keys) {
185 SSI_LOG_ERR("Failed allocating buffer for XCBC keys\n"); 186 dev_err(dev, "Failed allocating buffer for XCBC keys\n");
186 goto init_failed; 187 goto init_failed;
187 } 188 }
188 } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC authentication */ 189 } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC authentication */
@@ -196,12 +197,12 @@ static int ssi_aead_init(struct crypto_aead *tfm)
196 GFP_KERNEL); 197 GFP_KERNEL);
197 198
198 if (!hmac->ipad_opad) { 199 if (!hmac->ipad_opad) {
199 SSI_LOG_ERR("Failed allocating IPAD/OPAD buffer\n"); 200 dev_err(dev, "Failed allocating IPAD/OPAD buffer\n");
200 goto init_failed; 201 goto init_failed;
201 } 202 }
202 203
203 SSI_LOG_DEBUG("Allocated authkey buffer in context ctx->authkey=@%p\n", 204 dev_dbg(dev, "Allocated authkey buffer in context ctx->authkey=@%p\n",
204 hmac->ipad_opad); 205 hmac->ipad_opad);
205 206
206 hmac->padded_authkey = dma_alloc_coherent(dev, 207 hmac->padded_authkey = dma_alloc_coherent(dev,
207 MAX_HMAC_BLOCK_SIZE, 208 MAX_HMAC_BLOCK_SIZE,
@@ -209,7 +210,7 @@ static int ssi_aead_init(struct crypto_aead *tfm)
209 GFP_KERNEL); 210 GFP_KERNEL);
210 211
211 if (!hmac->padded_authkey) { 212 if (!hmac->padded_authkey) {
212 SSI_LOG_ERR("failed to allocate padded_authkey\n"); 213 dev_err(dev, "failed to allocate padded_authkey\n");
213 goto init_failed; 214 goto init_failed;
214 } 215 }
215 } else { 216 } else {
@@ -240,8 +241,7 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c
240 if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) { 241 if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
241 if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr, 242 if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr,
242 ctx->authsize) != 0) { 243 ctx->authsize) != 0) {
243 SSI_LOG_DEBUG("Payload authentication failure, " 244 dev_dbg(dev, "Payload authentication failure, (auth-size=%d, cipher=%d)\n",
244 "(auth-size=%d, cipher=%d).\n",
245 ctx->authsize, ctx->cipher_mode); 245 ctx->authsize, ctx->cipher_mode);
246 /* In case of payload authentication failure, MUST NOT 246 /* In case of payload authentication failure, MUST NOT
247 * revealed the decrypted message --> zero its memory. 247 * revealed the decrypted message --> zero its memory.
@@ -252,8 +252,11 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c
252 } else { /*ENCRYPT*/ 252 } else { /*ENCRYPT*/
253 if (unlikely(areq_ctx->is_icv_fragmented)) 253 if (unlikely(areq_ctx->is_icv_fragmented))
254 ssi_buffer_mgr_copy_scatterlist_portion( 254 ssi_buffer_mgr_copy_scatterlist_portion(
255 areq_ctx->mac_buf, areq_ctx->dst_sgl, areq->cryptlen + areq_ctx->dst_offset, 255 dev, areq_ctx->mac_buf, areq_ctx->dst_sgl,
256 areq->cryptlen + areq_ctx->dst_offset + ctx->authsize, SSI_SG_FROM_BUF); 256 areq->cryptlen + areq_ctx->dst_offset,
257 (areq->cryptlen + areq_ctx->dst_offset +
258 ctx->authsize),
259 SSI_SG_FROM_BUF);
257 260
258 /* If an IV was generated, copy it back to the user provided buffer. */ 261 /* If an IV was generated, copy it back to the user provided buffer. */
259 if (areq_ctx->backup_giv) { 262 if (areq_ctx->backup_giv) {
@@ -377,8 +380,10 @@ static int hmac_setkey(struct cc_hw_desc *desc, struct ssi_aead_ctx *ctx)
377 380
378static int validate_keys_sizes(struct ssi_aead_ctx *ctx) 381static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
379{ 382{
380 SSI_LOG_DEBUG("enc_keylen=%u authkeylen=%u\n", 383 struct device *dev = drvdata_to_dev(ctx->drvdata);
381 ctx->enc_keylen, ctx->auth_keylen); 384
385 dev_dbg(dev, "enc_keylen=%u authkeylen=%u\n",
386 ctx->enc_keylen, ctx->auth_keylen);
382 387
383 switch (ctx->auth_mode) { 388 switch (ctx->auth_mode) {
384 case DRV_HASH_SHA1: 389 case DRV_HASH_SHA1:
@@ -395,22 +400,22 @@ static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
395 return -EINVAL; 400 return -EINVAL;
396 break; 401 break;
397 default: 402 default:
398 SSI_LOG_ERR("Invalid auth_mode=%d\n", ctx->auth_mode); 403 dev_err(dev, "Invalid auth_mode=%d\n", ctx->auth_mode);
399 return -EINVAL; 404 return -EINVAL;
400 } 405 }
401 /* Check cipher key size */ 406 /* Check cipher key size */
402 if (unlikely(ctx->flow_mode == S_DIN_to_DES)) { 407 if (unlikely(ctx->flow_mode == S_DIN_to_DES)) {
403 if (ctx->enc_keylen != DES3_EDE_KEY_SIZE) { 408 if (ctx->enc_keylen != DES3_EDE_KEY_SIZE) {
404 SSI_LOG_ERR("Invalid cipher(3DES) key size: %u\n", 409 dev_err(dev, "Invalid cipher(3DES) key size: %u\n",
405 ctx->enc_keylen); 410 ctx->enc_keylen);
406 return -EINVAL; 411 return -EINVAL;
407 } 412 }
408 } else { /* Default assumed to be AES ciphers */ 413 } else { /* Default assumed to be AES ciphers */
409 if ((ctx->enc_keylen != AES_KEYSIZE_128) && 414 if ((ctx->enc_keylen != AES_KEYSIZE_128) &&
410 (ctx->enc_keylen != AES_KEYSIZE_192) && 415 (ctx->enc_keylen != AES_KEYSIZE_192) &&
411 (ctx->enc_keylen != AES_KEYSIZE_256)) { 416 (ctx->enc_keylen != AES_KEYSIZE_256)) {
412 SSI_LOG_ERR("Invalid cipher(AES) key size: %u\n", 417 dev_err(dev, "Invalid cipher(AES) key size: %u\n",
413 ctx->enc_keylen); 418 ctx->enc_keylen);
414 return -EINVAL; 419 return -EINVAL;
415 } 420 }
416 } 421 }
@@ -426,7 +431,7 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl
426{ 431{
427 dma_addr_t key_dma_addr = 0; 432 dma_addr_t key_dma_addr = 0;
428 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 433 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
429 struct device *dev = &ctx->drvdata->plat_dev->dev; 434 struct device *dev = drvdata_to_dev(ctx->drvdata);
430 u32 larval_addr = ssi_ahash_get_larval_digest_sram_addr( 435 u32 larval_addr = ssi_ahash_get_larval_digest_sram_addr(
431 ctx->drvdata, ctx->auth_mode); 436 ctx->drvdata, ctx->auth_mode);
432 struct ssi_crypto_req ssi_req = {}; 437 struct ssi_crypto_req ssi_req = {};
@@ -455,8 +460,8 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl
455 if (likely(keylen != 0)) { 460 if (likely(keylen != 0)) {
456 key_dma_addr = dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); 461 key_dma_addr = dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE);
457 if (unlikely(dma_mapping_error(dev, key_dma_addr))) { 462 if (unlikely(dma_mapping_error(dev, key_dma_addr))) {
458 SSI_LOG_ERR("Mapping key va=0x%p len=%u for" 463 dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n",
459 " DMA failed\n", key, keylen); 464 key, keylen);
460 return -ENOMEM; 465 return -ENOMEM;
461 } 466 }
462 if (keylen > blocksize) { 467 if (keylen > blocksize) {
@@ -534,7 +539,7 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl
534 539
535 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 540 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
536 if (unlikely(rc != 0)) 541 if (unlikely(rc != 0))
537 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 542 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
538 543
539 if (likely(key_dma_addr != 0)) 544 if (likely(key_dma_addr != 0))
540 dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE); 545 dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE);
@@ -551,10 +556,10 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
551 struct crypto_authenc_key_param *param; 556 struct crypto_authenc_key_param *param;
552 struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ]; 557 struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ];
553 int seq_len = 0, rc = -EINVAL; 558 int seq_len = 0, rc = -EINVAL;
559 struct device *dev = drvdata_to_dev(ctx->drvdata);
554 560
555 SSI_LOG_DEBUG("Setting key in context @%p for %s. key=%p keylen=%u\n", 561 dev_dbg(dev, "Setting key in context @%p for %s. key=%p keylen=%u\n",
556 ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), 562 ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), key, keylen);
557 key, keylen);
558 563
559 /* STAT_PHASE_0: Init and sanity checks */ 564 /* STAT_PHASE_0: Init and sanity checks */
560 565
@@ -622,7 +627,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
622 case DRV_HASH_NULL: /* non-authenc modes, e.g., CCM */ 627 case DRV_HASH_NULL: /* non-authenc modes, e.g., CCM */
623 break; /* No auth. key setup */ 628 break; /* No auth. key setup */
624 default: 629 default:
625 SSI_LOG_ERR("Unsupported authenc (%d)\n", ctx->auth_mode); 630 dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode);
626 rc = -ENOTSUPP; 631 rc = -ENOTSUPP;
627 goto badkey; 632 goto badkey;
628 } 633 }
@@ -632,7 +637,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
632 if (seq_len > 0) { /* For CCM there is no sequence to setup the key */ 637 if (seq_len > 0) { /* For CCM there is no sequence to setup the key */
633 rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 0); 638 rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 0);
634 if (unlikely(rc != 0)) { 639 if (unlikely(rc != 0)) {
635 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 640 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
636 goto setkey_error; 641 goto setkey_error;
637 } 642 }
638 } 643 }
@@ -651,7 +656,6 @@ setkey_error:
651static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) 656static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
652{ 657{
653 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 658 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
654 int rc = 0;
655 659
656 if (keylen < 3) 660 if (keylen < 3)
657 return -EINVAL; 661 return -EINVAL;
@@ -659,9 +663,7 @@ static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
659 keylen -= 3; 663 keylen -= 3;
660 memcpy(ctx->ctr_nonce, key + keylen, 3); 664 memcpy(ctx->ctr_nonce, key + keylen, 3);
661 665
662 rc = ssi_aead_setkey(tfm, key, keylen); 666 return ssi_aead_setkey(tfm, key, keylen);
663
664 return rc;
665} 667}
666#endif /*SSI_CC_HAS_AES_CCM*/ 668#endif /*SSI_CC_HAS_AES_CCM*/
667 669
@@ -670,6 +672,7 @@ static int ssi_aead_setauthsize(
670 unsigned int authsize) 672 unsigned int authsize)
671{ 673{
672 struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc); 674 struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc);
675 struct device *dev = drvdata_to_dev(ctx->drvdata);
673 676
674 /* Unsupported auth. sizes */ 677 /* Unsupported auth. sizes */
675 if ((authsize == 0) || 678 if ((authsize == 0) ||
@@ -678,7 +681,7 @@ static int ssi_aead_setauthsize(
678 } 681 }
679 682
680 ctx->authsize = authsize; 683 ctx->authsize = authsize;
681 SSI_LOG_DEBUG("authlen=%d\n", ctx->authsize); 684 dev_dbg(dev, "authlen=%d\n", ctx->authsize);
682 685
683 return 0; 686 return 0;
684} 687}
@@ -731,10 +734,11 @@ ssi_aead_create_assoc_desc(
731 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); 734 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq);
732 enum ssi_req_dma_buf_type assoc_dma_type = areq_ctx->assoc_buff_type; 735 enum ssi_req_dma_buf_type assoc_dma_type = areq_ctx->assoc_buff_type;
733 unsigned int idx = *seq_size; 736 unsigned int idx = *seq_size;
737 struct device *dev = drvdata_to_dev(ctx->drvdata);
734 738
735 switch (assoc_dma_type) { 739 switch (assoc_dma_type) {
736 case SSI_DMA_BUF_DLLI: 740 case SSI_DMA_BUF_DLLI:
737 SSI_LOG_DEBUG("ASSOC buffer type DLLI\n"); 741 dev_dbg(dev, "ASSOC buffer type DLLI\n");
738 hw_desc_init(&desc[idx]); 742 hw_desc_init(&desc[idx]);
739 set_din_type(&desc[idx], DMA_DLLI, sg_dma_address(areq->src), 743 set_din_type(&desc[idx], DMA_DLLI, sg_dma_address(areq->src),
740 areq->assoclen, NS_BIT); set_flow_mode(&desc[idx], 744 areq->assoclen, NS_BIT); set_flow_mode(&desc[idx],
@@ -744,7 +748,7 @@ ssi_aead_create_assoc_desc(
744 set_din_not_last_indication(&desc[idx]); 748 set_din_not_last_indication(&desc[idx]);
745 break; 749 break;
746 case SSI_DMA_BUF_MLLI: 750 case SSI_DMA_BUF_MLLI:
747 SSI_LOG_DEBUG("ASSOC buffer type MLLI\n"); 751 dev_dbg(dev, "ASSOC buffer type MLLI\n");
748 hw_desc_init(&desc[idx]); 752 hw_desc_init(&desc[idx]);
749 set_din_type(&desc[idx], DMA_MLLI, areq_ctx->assoc.sram_addr, 753 set_din_type(&desc[idx], DMA_MLLI, areq_ctx->assoc.sram_addr,
750 areq_ctx->assoc.mlli_nents, NS_BIT); 754 areq_ctx->assoc.mlli_nents, NS_BIT);
@@ -755,7 +759,7 @@ ssi_aead_create_assoc_desc(
755 break; 759 break;
756 case SSI_DMA_BUF_NULL: 760 case SSI_DMA_BUF_NULL:
757 default: 761 default:
758 SSI_LOG_ERR("Invalid ASSOC buffer type\n"); 762 dev_err(dev, "Invalid ASSOC buffer type\n");
759 } 763 }
760 764
761 *seq_size = (++idx); 765 *seq_size = (++idx);
@@ -772,6 +776,9 @@ ssi_aead_process_authenc_data_desc(
772 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); 776 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq);
773 enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type; 777 enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type;
774 unsigned int idx = *seq_size; 778 unsigned int idx = *seq_size;
779 struct crypto_aead *tfm = crypto_aead_reqtfm(areq);
780 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
781 struct device *dev = drvdata_to_dev(ctx->drvdata);
775 782
776 switch (data_dma_type) { 783 switch (data_dma_type) {
777 case SSI_DMA_BUF_DLLI: 784 case SSI_DMA_BUF_DLLI:
@@ -783,7 +790,7 @@ ssi_aead_process_authenc_data_desc(
783 unsigned int offset = 790 unsigned int offset =
784 (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? 791 (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ?
785 areq_ctx->dst_offset : areq_ctx->src_offset; 792 areq_ctx->dst_offset : areq_ctx->src_offset;
786 SSI_LOG_DEBUG("AUTHENC: SRC/DST buffer type DLLI\n"); 793 dev_dbg(dev, "AUTHENC: SRC/DST buffer type DLLI\n");
787 hw_desc_init(&desc[idx]); 794 hw_desc_init(&desc[idx]);
788 set_din_type(&desc[idx], DMA_DLLI, 795 set_din_type(&desc[idx], DMA_DLLI,
789 (sg_dma_address(cipher) + offset), 796 (sg_dma_address(cipher) + offset),
@@ -810,7 +817,7 @@ ssi_aead_process_authenc_data_desc(
810 } 817 }
811 } 818 }
812 819
813 SSI_LOG_DEBUG("AUTHENC: SRC/DST buffer type MLLI\n"); 820 dev_dbg(dev, "AUTHENC: SRC/DST buffer type MLLI\n");
814 hw_desc_init(&desc[idx]); 821 hw_desc_init(&desc[idx]);
815 set_din_type(&desc[idx], DMA_MLLI, mlli_addr, mlli_nents, 822 set_din_type(&desc[idx], DMA_MLLI, mlli_addr, mlli_nents,
816 NS_BIT); 823 NS_BIT);
@@ -819,7 +826,7 @@ ssi_aead_process_authenc_data_desc(
819 } 826 }
820 case SSI_DMA_BUF_NULL: 827 case SSI_DMA_BUF_NULL:
821 default: 828 default:
822 SSI_LOG_ERR("AUTHENC: Invalid SRC/DST buffer type\n"); 829 dev_err(dev, "AUTHENC: Invalid SRC/DST buffer type\n");
823 } 830 }
824 831
825 *seq_size = (++idx); 832 *seq_size = (++idx);
@@ -835,13 +842,16 @@ ssi_aead_process_cipher_data_desc(
835 unsigned int idx = *seq_size; 842 unsigned int idx = *seq_size;
836 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); 843 struct aead_req_ctx *areq_ctx = aead_request_ctx(areq);
837 enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type; 844 enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type;
845 struct crypto_aead *tfm = crypto_aead_reqtfm(areq);
846 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
847 struct device *dev = drvdata_to_dev(ctx->drvdata);
838 848
839 if (areq_ctx->cryptlen == 0) 849 if (areq_ctx->cryptlen == 0)
840 return; /*null processing*/ 850 return; /*null processing*/
841 851
842 switch (data_dma_type) { 852 switch (data_dma_type) {
843 case SSI_DMA_BUF_DLLI: 853 case SSI_DMA_BUF_DLLI:
844 SSI_LOG_DEBUG("CIPHER: SRC/DST buffer type DLLI\n"); 854 dev_dbg(dev, "CIPHER: SRC/DST buffer type DLLI\n");
845 hw_desc_init(&desc[idx]); 855 hw_desc_init(&desc[idx]);
846 set_din_type(&desc[idx], DMA_DLLI, 856 set_din_type(&desc[idx], DMA_DLLI,
847 (sg_dma_address(areq_ctx->src_sgl) + 857 (sg_dma_address(areq_ctx->src_sgl) +
@@ -853,7 +863,7 @@ ssi_aead_process_cipher_data_desc(
853 set_flow_mode(&desc[idx], flow_mode); 863 set_flow_mode(&desc[idx], flow_mode);
854 break; 864 break;
855 case SSI_DMA_BUF_MLLI: 865 case SSI_DMA_BUF_MLLI:
856 SSI_LOG_DEBUG("CIPHER: SRC/DST buffer type MLLI\n"); 866 dev_dbg(dev, "CIPHER: SRC/DST buffer type MLLI\n");
857 hw_desc_init(&desc[idx]); 867 hw_desc_init(&desc[idx]);
858 set_din_type(&desc[idx], DMA_MLLI, areq_ctx->src.sram_addr, 868 set_din_type(&desc[idx], DMA_MLLI, areq_ctx->src.sram_addr,
859 areq_ctx->src.mlli_nents, NS_BIT); 869 areq_ctx->src.mlli_nents, NS_BIT);
@@ -863,7 +873,7 @@ ssi_aead_process_cipher_data_desc(
863 break; 873 break;
864 case SSI_DMA_BUF_NULL: 874 case SSI_DMA_BUF_NULL:
865 default: 875 default:
866 SSI_LOG_ERR("CIPHER: Invalid SRC/DST buffer type\n"); 876 dev_err(dev, "CIPHER: Invalid SRC/DST buffer type\n");
867 } 877 }
868 878
869 *seq_size = (++idx); 879 *seq_size = (++idx);
@@ -1178,14 +1188,15 @@ static inline void ssi_aead_load_mlli_to_sram(
1178 struct aead_req_ctx *req_ctx = aead_request_ctx(req); 1188 struct aead_req_ctx *req_ctx = aead_request_ctx(req);
1179 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 1189 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
1180 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 1190 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
1191 struct device *dev = drvdata_to_dev(ctx->drvdata);
1181 1192
1182 if (unlikely( 1193 if (unlikely(
1183 (req_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI) || 1194 (req_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI) ||
1184 (req_ctx->data_buff_type == SSI_DMA_BUF_MLLI) || 1195 (req_ctx->data_buff_type == SSI_DMA_BUF_MLLI) ||
1185 !req_ctx->is_single_pass)) { 1196 !req_ctx->is_single_pass)) {
1186 SSI_LOG_DEBUG("Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n", 1197 dev_dbg(dev, "Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n",
1187 (unsigned int)ctx->drvdata->mlli_sram_addr, 1198 (unsigned int)ctx->drvdata->mlli_sram_addr,
1188 req_ctx->mlli_params.mlli_len); 1199 req_ctx->mlli_params.mlli_len);
1189 /* Copy MLLI table host-to-sram */ 1200 /* Copy MLLI table host-to-sram */
1190 hw_desc_init(&desc[*seq_size]); 1201 hw_desc_init(&desc[*seq_size]);
1191 set_din_type(&desc[*seq_size], DMA_DLLI, 1202 set_din_type(&desc[*seq_size], DMA_DLLI,
@@ -1333,6 +1344,7 @@ static int validate_data_size(struct ssi_aead_ctx *ctx,
1333 struct aead_request *req) 1344 struct aead_request *req)
1334{ 1345{
1335 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 1346 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
1347 struct device *dev = drvdata_to_dev(ctx->drvdata);
1336 unsigned int assoclen = req->assoclen; 1348 unsigned int assoclen = req->assoclen;
1337 unsigned int cipherlen = (direct == DRV_CRYPTO_DIRECTION_DECRYPT) ? 1349 unsigned int cipherlen = (direct == DRV_CRYPTO_DIRECTION_DECRYPT) ?
1338 (req->cryptlen - ctx->authsize) : req->cryptlen; 1350 (req->cryptlen - ctx->authsize) : req->cryptlen;
@@ -1371,7 +1383,7 @@ static int validate_data_size(struct ssi_aead_ctx *ctx,
1371 areq_ctx->is_single_pass = false; 1383 areq_ctx->is_single_pass = false;
1372 break; 1384 break;
1373 default: 1385 default:
1374 SSI_LOG_ERR("Unexpected flow mode (%d)\n", ctx->flow_mode); 1386 dev_err(dev, "Unexpected flow mode (%d)\n", ctx->flow_mode);
1375 goto data_size_err; 1387 goto data_size_err;
1376 } 1388 }
1377 1389
@@ -1554,6 +1566,7 @@ static int config_ccm_adata(struct aead_request *req)
1554{ 1566{
1555 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 1567 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
1556 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 1568 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
1569 struct device *dev = drvdata_to_dev(ctx->drvdata);
1557 struct aead_req_ctx *req_ctx = aead_request_ctx(req); 1570 struct aead_req_ctx *req_ctx = aead_request_ctx(req);
1558 //unsigned int size_of_a = 0, rem_a_size = 0; 1571 //unsigned int size_of_a = 0, rem_a_size = 0;
1559 unsigned int lp = req->iv[0]; 1572 unsigned int lp = req->iv[0];
@@ -1575,7 +1588,7 @@ static int config_ccm_adata(struct aead_request *req)
1575 /* taken from crypto/ccm.c */ 1588 /* taken from crypto/ccm.c */
1576 /* 2 <= L <= 8, so 1 <= L' <= 7. */ 1589 /* 2 <= L <= 8, so 1 <= L' <= 7. */
1577 if (l < 2 || l > 8) { 1590 if (l < 2 || l > 8) {
1578 SSI_LOG_ERR("illegal iv value %X\n", req->iv[0]); 1591 dev_err(dev, "illegal iv value %X\n", req->iv[0]);
1579 return -EINVAL; 1592 return -EINVAL;
1580 } 1593 }
1581 memcpy(b0, req->iv, AES_BLOCK_SIZE); 1594 memcpy(b0, req->iv, AES_BLOCK_SIZE);
@@ -1588,8 +1601,10 @@ static int config_ccm_adata(struct aead_request *req)
1588 *b0 |= 64; /* Enable bit 6 if Adata exists. */ 1601 *b0 |= 64; /* Enable bit 6 if Adata exists. */
1589 1602
1590 rc = set_msg_len(b0 + 16 - l, cryptlen, l); /* Write L'. */ 1603 rc = set_msg_len(b0 + 16 - l, cryptlen, l); /* Write L'. */
1591 if (rc != 0) 1604 if (rc != 0) {
1605 dev_err(dev, "message len overflow detected");
1592 return rc; 1606 return rc;
1607 }
1593 /* END of "taken from crypto/ccm.c" */ 1608 /* END of "taken from crypto/ccm.c" */
1594 1609
1595 /* l(a) - size of associated data. */ 1610 /* l(a) - size of associated data. */
@@ -1812,7 +1827,6 @@ static inline int ssi_aead_gcm(
1812 unsigned int *seq_size) 1827 unsigned int *seq_size)
1813{ 1828{
1814 struct aead_req_ctx *req_ctx = aead_request_ctx(req); 1829 struct aead_req_ctx *req_ctx = aead_request_ctx(req);
1815 unsigned int idx = *seq_size;
1816 unsigned int cipher_flow_mode; 1830 unsigned int cipher_flow_mode;
1817 1831
1818 if (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) { 1832 if (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
@@ -1829,7 +1843,6 @@ static inline int ssi_aead_gcm(
1829 ssi_aead_create_assoc_desc(req, DIN_HASH, desc, seq_size); 1843 ssi_aead_create_assoc_desc(req, DIN_HASH, desc, seq_size);
1830 ssi_aead_gcm_setup_gctr_desc(req, desc, seq_size); 1844 ssi_aead_gcm_setup_gctr_desc(req, desc, seq_size);
1831 ssi_aead_process_gcm_result_desc(req, desc, seq_size); 1845 ssi_aead_process_gcm_result_desc(req, desc, seq_size);
1832 idx = *seq_size;
1833 return 0; 1846 return 0;
1834 } 1847 }
1835 1848
@@ -1844,7 +1857,6 @@ static inline int ssi_aead_gcm(
1844 ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, seq_size); 1857 ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, seq_size);
1845 ssi_aead_process_gcm_result_desc(req, desc, seq_size); 1858 ssi_aead_process_gcm_result_desc(req, desc, seq_size);
1846 1859
1847 idx = *seq_size;
1848 return 0; 1860 return 0;
1849} 1861}
1850 1862
@@ -1861,13 +1873,13 @@ static inline void ssi_aead_dump_gcm(
1861 return; 1873 return;
1862 1874
1863 if (title) { 1875 if (title) {
1864 SSI_LOG_DEBUG("----------------------------------------------------------------------------------"); 1876 dev_dbg(dev, "----------------------------------------------------------------------------------");
1865 SSI_LOG_DEBUG("%s\n", title); 1877 dev_dbg(dev, "%s\n", title);
1866 } 1878 }
1867 1879
1868 SSI_LOG_DEBUG("cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d\n", 1880 dev_dbg(dev, "cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d\n",
1869 ctx->cipher_mode, ctx->authsize, ctx->enc_keylen, 1881 ctx->cipher_mode, ctx->authsize, ctx->enc_keylen,
1870 req->assoclen, req_ctx->cryptlen); 1882 req->assoclen, req_ctx->cryptlen);
1871 1883
1872 if (ctx->enckey) 1884 if (ctx->enckey)
1873 dump_byte_array("mac key", ctx->enckey, 16); 1885 dump_byte_array("mac key", ctx->enckey, 16);
@@ -1897,6 +1909,7 @@ static int config_gcm_context(struct aead_request *req)
1897 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 1909 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
1898 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 1910 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
1899 struct aead_req_ctx *req_ctx = aead_request_ctx(req); 1911 struct aead_req_ctx *req_ctx = aead_request_ctx(req);
1912 struct device *dev = drvdata_to_dev(ctx->drvdata);
1900 1913
1901 unsigned int cryptlen = (req_ctx->gen_ctx.op_type == 1914 unsigned int cryptlen = (req_ctx->gen_ctx.op_type ==
1902 DRV_CRYPTO_DIRECTION_ENCRYPT) ? 1915 DRV_CRYPTO_DIRECTION_ENCRYPT) ?
@@ -1904,7 +1917,8 @@ static int config_gcm_context(struct aead_request *req)
1904 (req->cryptlen - ctx->authsize); 1917 (req->cryptlen - ctx->authsize);
1905 __be32 counter = cpu_to_be32(2); 1918 __be32 counter = cpu_to_be32(2);
1906 1919
1907 SSI_LOG_DEBUG("%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", __func__, cryptlen, req->assoclen, ctx->authsize); 1920 dev_dbg(dev, "%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n",
1921 __func__, cryptlen, req->assoclen, ctx->authsize);
1908 1922
1909 memset(req_ctx->hkey, 0, AES_BLOCK_SIZE); 1923 memset(req_ctx->hkey, 0, AES_BLOCK_SIZE);
1910 1924
@@ -1958,20 +1972,20 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
1958 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 1972 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
1959 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 1973 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
1960 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 1974 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
1961 struct device *dev = &ctx->drvdata->plat_dev->dev; 1975 struct device *dev = drvdata_to_dev(ctx->drvdata);
1962 struct ssi_crypto_req ssi_req = {}; 1976 struct ssi_crypto_req ssi_req = {};
1963 1977
1964 SSI_LOG_DEBUG("%s context=%p req=%p iv=%p src=%p src_ofs=%d dst=%p dst_ofs=%d cryptolen=%d\n", 1978 dev_dbg(dev, "%s context=%p req=%p iv=%p src=%p src_ofs=%d dst=%p dst_ofs=%d cryptolen=%d\n",
1965 ((direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Encrypt" : "Decrypt"), 1979 ((direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Enc" : "Dec"),
1966 ctx, req, req->iv, sg_virt(req->src), req->src->offset, 1980 ctx, req, req->iv, sg_virt(req->src), req->src->offset,
1967 sg_virt(req->dst), req->dst->offset, req->cryptlen); 1981 sg_virt(req->dst), req->dst->offset, req->cryptlen);
1968 1982
1969 /* STAT_PHASE_0: Init and sanity checks */ 1983 /* STAT_PHASE_0: Init and sanity checks */
1970 1984
1971 /* Check data length according to mode */ 1985 /* Check data length according to mode */
1972 if (unlikely(validate_data_size(ctx, direct, req) != 0)) { 1986 if (unlikely(validate_data_size(ctx, direct, req) != 0)) {
1973 SSI_LOG_ERR("Unsupported crypt/assoc len %d/%d.\n", 1987 dev_err(dev, "Unsupported crypt/assoc len %d/%d.\n",
1974 req->cryptlen, req->assoclen); 1988 req->cryptlen, req->assoclen);
1975 crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN); 1989 crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN);
1976 return -EINVAL; 1990 return -EINVAL;
1977 } 1991 }
@@ -2017,7 +2031,8 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
2017 if (ctx->cipher_mode == DRV_CIPHER_CCM) { 2031 if (ctx->cipher_mode == DRV_CIPHER_CCM) {
2018 rc = config_ccm_adata(req); 2032 rc = config_ccm_adata(req);
2019 if (unlikely(rc != 0)) { 2033 if (unlikely(rc != 0)) {
2020 SSI_LOG_ERR("config_ccm_adata() returned with a failure %d!", rc); 2034 dev_dbg(dev, "config_ccm_adata() returned with a failure %d!",
2035 rc);
2021 goto exit; 2036 goto exit;
2022 } 2037 }
2023 } else { 2038 } else {
@@ -2031,7 +2046,8 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
2031 if (ctx->cipher_mode == DRV_CIPHER_GCTR) { 2046 if (ctx->cipher_mode == DRV_CIPHER_GCTR) {
2032 rc = config_gcm_context(req); 2047 rc = config_gcm_context(req);
2033 if (unlikely(rc != 0)) { 2048 if (unlikely(rc != 0)) {
2034 SSI_LOG_ERR("config_gcm_context() returned with a failure %d!", rc); 2049 dev_dbg(dev, "config_gcm_context() returned with a failure %d!",
2050 rc);
2035 goto exit; 2051 goto exit;
2036 } 2052 }
2037 } 2053 }
@@ -2039,7 +2055,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
2039 2055
2040 rc = ssi_buffer_mgr_map_aead_request(ctx->drvdata, req); 2056 rc = ssi_buffer_mgr_map_aead_request(ctx->drvdata, req);
2041 if (unlikely(rc != 0)) { 2057 if (unlikely(rc != 0)) {
2042 SSI_LOG_ERR("map_request() failed\n"); 2058 dev_err(dev, "map_request() failed\n");
2043 goto exit; 2059 goto exit;
2044 } 2060 }
2045 2061
@@ -2095,7 +2111,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
2095 break; 2111 break;
2096#endif 2112#endif
2097 default: 2113 default:
2098 SSI_LOG_ERR("Unsupported authenc (%d)\n", ctx->auth_mode); 2114 dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode);
2099 ssi_buffer_mgr_unmap_aead_request(dev, req); 2115 ssi_buffer_mgr_unmap_aead_request(dev, req);
2100 rc = -ENOTSUPP; 2116 rc = -ENOTSUPP;
2101 goto exit; 2117 goto exit;
@@ -2106,7 +2122,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
2106 rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 1); 2122 rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 1);
2107 2123
2108 if (unlikely(rc != -EINPROGRESS)) { 2124 if (unlikely(rc != -EINPROGRESS)) {
2109 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 2125 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
2110 ssi_buffer_mgr_unmap_aead_request(dev, req); 2126 ssi_buffer_mgr_unmap_aead_request(dev, req);
2111 } 2127 }
2112 2128
@@ -2139,10 +2155,13 @@ static int ssi_rfc4309_ccm_encrypt(struct aead_request *req)
2139 /* Very similar to ssi_aead_encrypt() above. */ 2155 /* Very similar to ssi_aead_encrypt() above. */
2140 2156
2141 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 2157 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
2158 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
2159 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2160 struct device *dev = drvdata_to_dev(ctx->drvdata);
2142 int rc = -EINVAL; 2161 int rc = -EINVAL;
2143 2162
2144 if (!valid_assoclen(req)) { 2163 if (!valid_assoclen(req)) {
2145 SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); 2164 dev_err(dev, "invalid Assoclen:%u\n", req->assoclen);
2146 goto out; 2165 goto out;
2147 } 2166 }
2148 2167
@@ -2183,13 +2202,14 @@ static int ssi_aead_decrypt(struct aead_request *req)
2183#if SSI_CC_HAS_AES_CCM 2202#if SSI_CC_HAS_AES_CCM
2184static int ssi_rfc4309_ccm_decrypt(struct aead_request *req) 2203static int ssi_rfc4309_ccm_decrypt(struct aead_request *req)
2185{ 2204{
2186 /* Very similar to ssi_aead_decrypt() above. */ 2205 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
2187 2206 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2207 struct device *dev = drvdata_to_dev(ctx->drvdata);
2188 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 2208 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
2189 int rc = -EINVAL; 2209 int rc = -EINVAL;
2190 2210
2191 if (!valid_assoclen(req)) { 2211 if (!valid_assoclen(req)) {
2192 SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); 2212 dev_err(dev, "invalid Assoclen:%u\n", req->assoclen);
2193 goto out; 2213 goto out;
2194 } 2214 }
2195 2215
@@ -2214,9 +2234,9 @@ out:
2214static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) 2234static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
2215{ 2235{
2216 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 2236 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2217 int rc = 0; 2237 struct device *dev = drvdata_to_dev(ctx->drvdata);
2218 2238
2219 SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key); 2239 dev_dbg(dev, "%s() keylen %d, key %p\n", __func__, keylen, key);
2220 2240
2221 if (keylen < 4) 2241 if (keylen < 4)
2222 return -EINVAL; 2242 return -EINVAL;
@@ -2224,17 +2244,15 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
2224 keylen -= 4; 2244 keylen -= 4;
2225 memcpy(ctx->ctr_nonce, key + keylen, 4); 2245 memcpy(ctx->ctr_nonce, key + keylen, 4);
2226 2246
2227 rc = ssi_aead_setkey(tfm, key, keylen); 2247 return ssi_aead_setkey(tfm, key, keylen);
2228
2229 return rc;
2230} 2248}
2231 2249
2232static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) 2250static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
2233{ 2251{
2234 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); 2252 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2235 int rc = 0; 2253 struct device *dev = drvdata_to_dev(ctx->drvdata);
2236 2254
2237 SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key); 2255 dev_dbg(dev, "%s() keylen %d, key %p\n", __func__, keylen, key);
2238 2256
2239 if (keylen < 4) 2257 if (keylen < 4)
2240 return -EINVAL; 2258 return -EINVAL;
@@ -2242,9 +2260,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
2242 keylen -= 4; 2260 keylen -= 4;
2243 memcpy(ctx->ctr_nonce, key + keylen, 4); 2261 memcpy(ctx->ctr_nonce, key + keylen, 4);
2244 2262
2245 rc = ssi_aead_setkey(tfm, key, keylen); 2263 return ssi_aead_setkey(tfm, key, keylen);
2246
2247 return rc;
2248} 2264}
2249 2265
2250static int ssi_gcm_setauthsize(struct crypto_aead *authenc, 2266static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
@@ -2269,7 +2285,10 @@ static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
2269static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc, 2285static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc,
2270 unsigned int authsize) 2286 unsigned int authsize)
2271{ 2287{
2272 SSI_LOG_DEBUG("authsize %d\n", authsize); 2288 struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc);
2289 struct device *dev = drvdata_to_dev(ctx->drvdata);
2290
2291 dev_dbg(dev, "authsize %d\n", authsize);
2273 2292
2274 switch (authsize) { 2293 switch (authsize) {
2275 case 8: 2294 case 8:
@@ -2286,7 +2305,10 @@ static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc,
2286static int ssi_rfc4543_gcm_setauthsize(struct crypto_aead *authenc, 2305static int ssi_rfc4543_gcm_setauthsize(struct crypto_aead *authenc,
2287 unsigned int authsize) 2306 unsigned int authsize)
2288{ 2307{
2289 SSI_LOG_DEBUG("authsize %d\n", authsize); 2308 struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc);
2309 struct device *dev = drvdata_to_dev(ctx->drvdata);
2310
2311 dev_dbg(dev, "authsize %d\n", authsize);
2290 2312
2291 if (authsize != 16) 2313 if (authsize != 16)
2292 return -EINVAL; 2314 return -EINVAL;
@@ -2298,11 +2320,14 @@ static int ssi_rfc4106_gcm_encrypt(struct aead_request *req)
2298{ 2320{
2299 /* Very similar to ssi_aead_encrypt() above. */ 2321 /* Very similar to ssi_aead_encrypt() above. */
2300 2322
2323 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
2324 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2325 struct device *dev = drvdata_to_dev(ctx->drvdata);
2301 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 2326 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
2302 int rc = -EINVAL; 2327 int rc = -EINVAL;
2303 2328
2304 if (!valid_assoclen(req)) { 2329 if (!valid_assoclen(req)) {
2305 SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); 2330 dev_err(dev, "invalid Assoclen:%u\n", req->assoclen);
2306 goto out; 2331 goto out;
2307 } 2332 }
2308 2333
@@ -2350,11 +2375,14 @@ static int ssi_rfc4106_gcm_decrypt(struct aead_request *req)
2350{ 2375{
2351 /* Very similar to ssi_aead_decrypt() above. */ 2376 /* Very similar to ssi_aead_decrypt() above. */
2352 2377
2378 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
2379 struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
2380 struct device *dev = drvdata_to_dev(ctx->drvdata);
2353 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 2381 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
2354 int rc = -EINVAL; 2382 int rc = -EINVAL;
2355 2383
2356 if (!valid_assoclen(req)) { 2384 if (!valid_assoclen(req)) {
2357 SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); 2385 dev_err(dev, "invalid Assoclen:%u\n", req->assoclen);
2358 goto out; 2386 goto out;
2359 } 2387 }
2360 2388
@@ -2654,16 +2682,17 @@ static struct ssi_alg_template aead_algs[] = {
2654#endif /*SSI_CC_HAS_AES_GCM*/ 2682#endif /*SSI_CC_HAS_AES_GCM*/
2655}; 2683};
2656 2684
2657static struct ssi_crypto_alg *ssi_aead_create_alg(struct ssi_alg_template *template) 2685static struct ssi_crypto_alg *ssi_aead_create_alg(
2686 struct ssi_alg_template *template,
2687 struct device *dev)
2658{ 2688{
2659 struct ssi_crypto_alg *t_alg; 2689 struct ssi_crypto_alg *t_alg;
2660 struct aead_alg *alg; 2690 struct aead_alg *alg;
2661 2691
2662 t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); 2692 t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
2663 if (!t_alg) { 2693 if (!t_alg)
2664 SSI_LOG_ERR("failed to allocate t_alg\n");
2665 return ERR_PTR(-ENOMEM); 2694 return ERR_PTR(-ENOMEM);
2666 } 2695
2667 alg = &template->template_aead; 2696 alg = &template->template_aead;
2668 2697
2669 snprintf(alg->base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", template->name); 2698 snprintf(alg->base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", template->name);
@@ -2713,6 +2742,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata)
2713 struct ssi_crypto_alg *t_alg; 2742 struct ssi_crypto_alg *t_alg;
2714 int rc = -ENOMEM; 2743 int rc = -ENOMEM;
2715 int alg; 2744 int alg;
2745 struct device *dev = drvdata_to_dev(drvdata);
2716 2746
2717 aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL); 2747 aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL);
2718 if (!aead_handle) { 2748 if (!aead_handle) {
@@ -2720,36 +2750,36 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata)
2720 goto fail0; 2750 goto fail0;
2721 } 2751 }
2722 2752
2753 INIT_LIST_HEAD(&aead_handle->aead_list);
2723 drvdata->aead_handle = aead_handle; 2754 drvdata->aead_handle = aead_handle;
2724 2755
2725 aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( 2756 aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc(
2726 drvdata, MAX_HMAC_DIGEST_SIZE); 2757 drvdata, MAX_HMAC_DIGEST_SIZE);
2727 if (aead_handle->sram_workspace_addr == NULL_SRAM_ADDR) { 2758 if (aead_handle->sram_workspace_addr == NULL_SRAM_ADDR) {
2728 SSI_LOG_ERR("SRAM pool exhausted\n"); 2759 dev_err(dev, "SRAM pool exhausted\n");
2729 rc = -ENOMEM; 2760 rc = -ENOMEM;
2730 goto fail1; 2761 goto fail1;
2731 } 2762 }
2732 2763
2733 INIT_LIST_HEAD(&aead_handle->aead_list);
2734
2735 /* Linux crypto */ 2764 /* Linux crypto */
2736 for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) { 2765 for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) {
2737 t_alg = ssi_aead_create_alg(&aead_algs[alg]); 2766 t_alg = ssi_aead_create_alg(&aead_algs[alg], dev);
2738 if (IS_ERR(t_alg)) { 2767 if (IS_ERR(t_alg)) {
2739 rc = PTR_ERR(t_alg); 2768 rc = PTR_ERR(t_alg);
2740 SSI_LOG_ERR("%s alg allocation failed\n", 2769 dev_err(dev, "%s alg allocation failed\n",
2741 aead_algs[alg].driver_name); 2770 aead_algs[alg].driver_name);
2742 goto fail1; 2771 goto fail1;
2743 } 2772 }
2744 t_alg->drvdata = drvdata; 2773 t_alg->drvdata = drvdata;
2745 rc = crypto_register_aead(&t_alg->aead_alg); 2774 rc = crypto_register_aead(&t_alg->aead_alg);
2746 if (unlikely(rc != 0)) { 2775 if (unlikely(rc != 0)) {
2747 SSI_LOG_ERR("%s alg registration failed\n", 2776 dev_err(dev, "%s alg registration failed\n",
2748 t_alg->aead_alg.base.cra_driver_name); 2777 t_alg->aead_alg.base.cra_driver_name);
2749 goto fail2; 2778 goto fail2;
2750 } else { 2779 } else {
2751 list_add_tail(&t_alg->entry, &aead_handle->aead_list); 2780 list_add_tail(&t_alg->entry, &aead_handle->aead_list);
2752 SSI_LOG_DEBUG("Registered %s\n", t_alg->aead_alg.base.cra_driver_name); 2781 dev_dbg(dev, "Registered %s\n",
2782 t_alg->aead_alg.base.cra_driver_name);
2753 } 2783 }
2754 } 2784 }
2755 2785
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index 63936091d524..1f8a225530a8 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -33,14 +33,10 @@
33#include "ssi_hash.h" 33#include "ssi_hash.h"
34#include "ssi_aead.h" 34#include "ssi_aead.h"
35 35
36#ifdef CC_DEBUG
37#define GET_DMA_BUFFER_TYPE(buff_type) ( \ 36#define GET_DMA_BUFFER_TYPE(buff_type) ( \
38 ((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \ 37 ((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \
39 ((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \ 38 ((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \
40 ((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID") 39 ((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID")
41#else
42#define GET_DMA_BUFFER_TYPE(buff_type)
43#endif
44 40
45enum dma_buffer_type { 41enum dma_buffer_type {
46 DMA_NULL_TYPE = -1, 42 DMA_NULL_TYPE = -1,
@@ -76,16 +72,12 @@ struct buffer_array {
76 * @lbytes: [OUT] Returns the amount of bytes at the last entry 72 * @lbytes: [OUT] Returns the amount of bytes at the last entry
77 */ 73 */
78static unsigned int ssi_buffer_mgr_get_sgl_nents( 74static unsigned int ssi_buffer_mgr_get_sgl_nents(
79 struct scatterlist *sg_list, unsigned int nbytes, u32 *lbytes, bool *is_chained) 75 struct device *dev, struct scatterlist *sg_list,
76 unsigned int nbytes, u32 *lbytes, bool *is_chained)
80{ 77{
81 unsigned int nents = 0; 78 unsigned int nents = 0;
82 79
83 while (nbytes != 0) { 80 while (nbytes != 0) {
84 if (sg_is_chain(sg_list)) {
85 SSI_LOG_ERR("Unexpected chained entry "
86 "in sg (entry =0x%X)\n", nents);
87 BUG();
88 }
89 if (sg_list->length != 0) { 81 if (sg_list->length != 0) {
90 nents++; 82 nents++;
91 /* get the number of bytes in the last entry */ 83 /* get the number of bytes in the last entry */
@@ -98,7 +90,7 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents(
98 *is_chained = true; 90 *is_chained = true;
99 } 91 }
100 } 92 }
101 SSI_LOG_DEBUG("nents %d last bytes %d\n", nents, *lbytes); 93 dev_dbg(dev, "nents %d last bytes %d\n", nents, *lbytes);
102 return nents; 94 return nents;
103} 95}
104 96
@@ -134,20 +126,20 @@ void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len)
134 * @direct: 126 * @direct:
135 */ 127 */
136void ssi_buffer_mgr_copy_scatterlist_portion( 128void ssi_buffer_mgr_copy_scatterlist_portion(
137 u8 *dest, struct scatterlist *sg, 129 struct device *dev, u8 *dest,
138 u32 to_skip, u32 end, 130 struct scatterlist *sg, u32 to_skip,
139 enum ssi_sg_cpy_direct direct) 131 u32 end, enum ssi_sg_cpy_direct direct)
140{ 132{
141 u32 nents, lbytes; 133 u32 nents, lbytes;
142 134
143 nents = ssi_buffer_mgr_get_sgl_nents(sg, end, &lbytes, NULL); 135 nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, end, &lbytes, NULL);
144 sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, 136 sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip,
145 (direct == SSI_SG_TO_BUF)); 137 (direct == SSI_SG_TO_BUF));
146} 138}
147 139
148static inline int ssi_buffer_mgr_render_buff_to_mlli( 140static inline int ssi_buffer_mgr_render_buff_to_mlli(
149 dma_addr_t buff_dma, u32 buff_size, u32 *curr_nents, 141 struct device *dev, dma_addr_t buff_dma, u32 buff_size,
150 u32 **mlli_entry_pp) 142 u32 *curr_nents, u32 **mlli_entry_pp)
151{ 143{
152 u32 *mlli_entry_p = *mlli_entry_pp; 144 u32 *mlli_entry_p = *mlli_entry_pp;
153 u32 new_nents; 145 u32 new_nents;
@@ -161,9 +153,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli(
161 while (buff_size > CC_MAX_MLLI_ENTRY_SIZE) { 153 while (buff_size > CC_MAX_MLLI_ENTRY_SIZE) {
162 cc_lli_set_addr(mlli_entry_p, buff_dma); 154 cc_lli_set_addr(mlli_entry_p, buff_dma);
163 cc_lli_set_size(mlli_entry_p, CC_MAX_MLLI_ENTRY_SIZE); 155 cc_lli_set_size(mlli_entry_p, CC_MAX_MLLI_ENTRY_SIZE);
164 SSI_LOG_DEBUG("entry[%d]: single_buff=0x%08X size=%08X\n", *curr_nents, 156 dev_dbg(dev, "entry[%d]: single_buff=0x%08X size=%08X\n",
165 mlli_entry_p[LLI_WORD0_OFFSET], 157 *curr_nents, mlli_entry_p[LLI_WORD0_OFFSET],
166 mlli_entry_p[LLI_WORD1_OFFSET]); 158 mlli_entry_p[LLI_WORD1_OFFSET]);
167 buff_dma += CC_MAX_MLLI_ENTRY_SIZE; 159 buff_dma += CC_MAX_MLLI_ENTRY_SIZE;
168 buff_size -= CC_MAX_MLLI_ENTRY_SIZE; 160 buff_size -= CC_MAX_MLLI_ENTRY_SIZE;
169 mlli_entry_p = mlli_entry_p + 2; 161 mlli_entry_p = mlli_entry_p + 2;
@@ -172,9 +164,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli(
172 /*Last entry */ 164 /*Last entry */
173 cc_lli_set_addr(mlli_entry_p, buff_dma); 165 cc_lli_set_addr(mlli_entry_p, buff_dma);
174 cc_lli_set_size(mlli_entry_p, buff_size); 166 cc_lli_set_size(mlli_entry_p, buff_size);
175 SSI_LOG_DEBUG("entry[%d]: single_buff=0x%08X size=%08X\n", *curr_nents, 167 dev_dbg(dev, "entry[%d]: single_buff=0x%08X size=%08X\n",
176 mlli_entry_p[LLI_WORD0_OFFSET], 168 *curr_nents, mlli_entry_p[LLI_WORD0_OFFSET],
177 mlli_entry_p[LLI_WORD1_OFFSET]); 169 mlli_entry_p[LLI_WORD1_OFFSET]);
178 mlli_entry_p = mlli_entry_p + 2; 170 mlli_entry_p = mlli_entry_p + 2;
179 *mlli_entry_pp = mlli_entry_p; 171 *mlli_entry_pp = mlli_entry_p;
180 (*curr_nents)++; 172 (*curr_nents)++;
@@ -182,8 +174,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli(
182} 174}
183 175
184static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( 176static inline int ssi_buffer_mgr_render_scatterlist_to_mlli(
185 struct scatterlist *sgl, u32 sgl_data_len, u32 sgl_offset, 177 struct device *dev, struct scatterlist *sgl,
186 u32 *curr_nents, u32 **mlli_entry_pp) 178 u32 sgl_data_len, u32 sgl_offset, u32 *curr_nents,
179 u32 **mlli_entry_pp)
187{ 180{
188 struct scatterlist *curr_sgl = sgl; 181 struct scatterlist *curr_sgl = sgl;
189 u32 *mlli_entry_p = *mlli_entry_pp; 182 u32 *mlli_entry_p = *mlli_entry_pp;
@@ -197,8 +190,8 @@ static inline int ssi_buffer_mgr_render_scatterlist_to_mlli(
197 sgl_data_len; 190 sgl_data_len;
198 sgl_data_len -= entry_data_len; 191 sgl_data_len -= entry_data_len;
199 rc = ssi_buffer_mgr_render_buff_to_mlli( 192 rc = ssi_buffer_mgr_render_buff_to_mlli(
200 sg_dma_address(curr_sgl) + sgl_offset, entry_data_len, 193 dev, sg_dma_address(curr_sgl) + sgl_offset,
201 curr_nents, &mlli_entry_p); 194 entry_data_len, curr_nents, &mlli_entry_p);
202 if (rc != 0) 195 if (rc != 0)
203 return rc; 196 return rc;
204 197
@@ -217,14 +210,14 @@ static int ssi_buffer_mgr_generate_mlli(
217 u32 total_nents = 0, prev_total_nents = 0; 210 u32 total_nents = 0, prev_total_nents = 0;
218 int rc = 0, i; 211 int rc = 0, i;
219 212
220 SSI_LOG_DEBUG("NUM of SG's = %d\n", sg_data->num_of_buffers); 213 dev_dbg(dev, "NUM of SG's = %d\n", sg_data->num_of_buffers);
221 214
222 /* Allocate memory from the pointed pool */ 215 /* Allocate memory from the pointed pool */
223 mlli_params->mlli_virt_addr = dma_pool_alloc( 216 mlli_params->mlli_virt_addr = dma_pool_alloc(
224 mlli_params->curr_pool, GFP_KERNEL, 217 mlli_params->curr_pool, GFP_KERNEL,
225 &mlli_params->mlli_dma_addr); 218 &mlli_params->mlli_dma_addr);
226 if (unlikely(!mlli_params->mlli_virt_addr)) { 219 if (unlikely(!mlli_params->mlli_virt_addr)) {
227 SSI_LOG_ERR("dma_pool_alloc() failed\n"); 220 dev_err(dev, "dma_pool_alloc() failed\n");
228 rc = -ENOMEM; 221 rc = -ENOMEM;
229 goto build_mlli_exit; 222 goto build_mlli_exit;
230 } 223 }
@@ -234,12 +227,12 @@ static int ssi_buffer_mgr_generate_mlli(
234 for (i = 0; i < sg_data->num_of_buffers; i++) { 227 for (i = 0; i < sg_data->num_of_buffers; i++) {
235 if (sg_data->type[i] == DMA_SGL_TYPE) 228 if (sg_data->type[i] == DMA_SGL_TYPE)
236 rc = ssi_buffer_mgr_render_scatterlist_to_mlli( 229 rc = ssi_buffer_mgr_render_scatterlist_to_mlli(
237 sg_data->entry[i].sgl, 230 dev, sg_data->entry[i].sgl,
238 sg_data->total_data_len[i], sg_data->offset[i], &total_nents, 231 sg_data->total_data_len[i], sg_data->offset[i],
239 &mlli_p); 232 &total_nents, &mlli_p);
240 else /*DMA_BUFF_TYPE*/ 233 else /*DMA_BUFF_TYPE*/
241 rc = ssi_buffer_mgr_render_buff_to_mlli( 234 rc = ssi_buffer_mgr_render_buff_to_mlli(
242 sg_data->entry[i].buffer_dma, 235 dev, sg_data->entry[i].buffer_dma,
243 sg_data->total_data_len[i], &total_nents, 236 sg_data->total_data_len[i], &total_nents,
244 &mlli_p); 237 &mlli_p);
245 if (rc != 0) 238 if (rc != 0)
@@ -259,26 +252,23 @@ static int ssi_buffer_mgr_generate_mlli(
259 /* Set MLLI size for the bypass operation */ 252 /* Set MLLI size for the bypass operation */
260 mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE); 253 mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE);
261 254
262 SSI_LOG_DEBUG("MLLI params: " 255 dev_dbg(dev, "MLLI params: virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n",
263 "virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n", 256 mlli_params->mlli_virt_addr, &mlli_params->mlli_dma_addr,
264 mlli_params->mlli_virt_addr, 257 mlli_params->mlli_len);
265 mlli_params->mlli_dma_addr,
266 mlli_params->mlli_len);
267 258
268build_mlli_exit: 259build_mlli_exit:
269 return rc; 260 return rc;
270} 261}
271 262
272static inline void ssi_buffer_mgr_add_buffer_entry( 263static inline void ssi_buffer_mgr_add_buffer_entry(
273 struct buffer_array *sgl_data, 264 struct device *dev, struct buffer_array *sgl_data,
274 dma_addr_t buffer_dma, unsigned int buffer_len, 265 dma_addr_t buffer_dma, unsigned int buffer_len,
275 bool is_last_entry, u32 *mlli_nents) 266 bool is_last_entry, u32 *mlli_nents)
276{ 267{
277 unsigned int index = sgl_data->num_of_buffers; 268 unsigned int index = sgl_data->num_of_buffers;
278 269
279 SSI_LOG_DEBUG("index=%u single_buff=%pad " 270 dev_dbg(dev, "index=%u single_buff=%pad buffer_len=0x%08X is_last=%d\n",
280 "buffer_len=0x%08X is_last=%d\n", 271 index, &buffer_dma, buffer_len, is_last_entry);
281 index, buffer_dma, buffer_len, is_last_entry);
282 sgl_data->nents[index] = 1; 272 sgl_data->nents[index] = 1;
283 sgl_data->entry[index].buffer_dma = buffer_dma; 273 sgl_data->entry[index].buffer_dma = buffer_dma;
284 sgl_data->offset[index] = 0; 274 sgl_data->offset[index] = 0;
@@ -292,6 +282,7 @@ static inline void ssi_buffer_mgr_add_buffer_entry(
292} 282}
293 283
294static inline void ssi_buffer_mgr_add_scatterlist_entry( 284static inline void ssi_buffer_mgr_add_scatterlist_entry(
285 struct device *dev,
295 struct buffer_array *sgl_data, 286 struct buffer_array *sgl_data,
296 unsigned int nents, 287 unsigned int nents,
297 struct scatterlist *sgl, 288 struct scatterlist *sgl,
@@ -302,8 +293,8 @@ static inline void ssi_buffer_mgr_add_scatterlist_entry(
302{ 293{
303 unsigned int index = sgl_data->num_of_buffers; 294 unsigned int index = sgl_data->num_of_buffers;
304 295
305 SSI_LOG_DEBUG("index=%u nents=%u sgl=%pK data_len=0x%08X is_last=%d\n", 296 dev_dbg(dev, "index=%u nents=%u sgl=%pK data_len=0x%08X is_last=%d\n",
306 index, nents, sgl, data_len, is_last_table); 297 index, nents, sgl, data_len, is_last_table);
307 sgl_data->nents[index] = nents; 298 sgl_data->nents[index] = nents;
308 sgl_data->entry[index].sgl = sgl; 299 sgl_data->entry[index].sgl = sgl;
309 sgl_data->offset[index] = data_offset; 300 sgl_data->offset[index] = data_offset;
@@ -327,7 +318,7 @@ ssi_buffer_mgr_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents,
327 if (!l_sg) 318 if (!l_sg)
328 break; 319 break;
329 if (unlikely(dma_map_sg(dev, l_sg, 1, direction) != 1)) { 320 if (unlikely(dma_map_sg(dev, l_sg, 1, direction) != 1)) {
330 SSI_LOG_ERR("dma_map_page() sg buffer failed\n"); 321 dev_err(dev, "dma_map_page() sg buffer failed\n");
331 goto err; 322 goto err;
332 } 323 }
333 l_sg = sg_next(l_sg); 324 l_sg = sg_next(l_sg);
@@ -356,26 +347,22 @@ static int ssi_buffer_mgr_map_scatterlist(
356 if (sg_is_last(sg)) { 347 if (sg_is_last(sg)) {
357 /* One entry only case -set to DLLI */ 348 /* One entry only case -set to DLLI */
358 if (unlikely(dma_map_sg(dev, sg, 1, direction) != 1)) { 349 if (unlikely(dma_map_sg(dev, sg, 1, direction) != 1)) {
359 SSI_LOG_ERR("dma_map_sg() single buffer failed\n"); 350 dev_err(dev, "dma_map_sg() single buffer failed\n");
360 return -ENOMEM; 351 return -ENOMEM;
361 } 352 }
362 SSI_LOG_DEBUG("Mapped sg: dma_address=%pad " 353 dev_dbg(dev, "Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n",
363 "page=%p addr=%pK offset=%u " 354 &sg_dma_address(sg), sg_page(sg), sg_virt(sg),
364 "length=%u\n", 355 sg->offset, sg->length);
365 sg_dma_address(sg),
366 sg_page(sg),
367 sg_virt(sg),
368 sg->offset, sg->length);
369 *lbytes = nbytes; 356 *lbytes = nbytes;
370 *nents = 1; 357 *nents = 1;
371 *mapped_nents = 1; 358 *mapped_nents = 1;
372 } else { /*sg_is_last*/ 359 } else { /*sg_is_last*/
373 *nents = ssi_buffer_mgr_get_sgl_nents(sg, nbytes, lbytes, 360 *nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, nbytes, lbytes,
374 &is_chained); 361 &is_chained);
375 if (*nents > max_sg_nents) { 362 if (*nents > max_sg_nents) {
376 *nents = 0; 363 *nents = 0;
377 SSI_LOG_ERR("Too many fragments. current %d max %d\n", 364 dev_err(dev, "Too many fragments. current %d max %d\n",
378 *nents, max_sg_nents); 365 *nents, max_sg_nents);
379 return -ENOMEM; 366 return -ENOMEM;
380 } 367 }
381 if (!is_chained) { 368 if (!is_chained) {
@@ -385,7 +372,7 @@ static int ssi_buffer_mgr_map_scatterlist(
385 *mapped_nents = dma_map_sg(dev, sg, *nents, direction); 372 *mapped_nents = dma_map_sg(dev, sg, *nents, direction);
386 if (unlikely(*mapped_nents == 0)) { 373 if (unlikely(*mapped_nents == 0)) {
387 *nents = 0; 374 *nents = 0;
388 SSI_LOG_ERR("dma_map_sg() sg buffer failed\n"); 375 dev_err(dev, "dma_map_sg() sg buffer failed\n");
389 return -ENOMEM; 376 return -ENOMEM;
390 } 377 }
391 } else { 378 } else {
@@ -398,7 +385,7 @@ static int ssi_buffer_mgr_map_scatterlist(
398 direction); 385 direction);
399 if (unlikely(*mapped_nents != *nents)) { 386 if (unlikely(*mapped_nents != *nents)) {
400 *nents = *mapped_nents; 387 *nents = *mapped_nents;
401 SSI_LOG_ERR("dma_map_sg() sg buffer failed\n"); 388 dev_err(dev, "dma_map_sg() sg buffer failed\n");
402 return -ENOMEM; 389 return -ENOMEM;
403 } 390 }
404 } 391 }
@@ -414,26 +401,22 @@ ssi_aead_handle_config_buf(struct device *dev,
414 struct buffer_array *sg_data, 401 struct buffer_array *sg_data,
415 unsigned int assoclen) 402 unsigned int assoclen)
416{ 403{
417 SSI_LOG_DEBUG(" handle additional data config set to DLLI\n"); 404 dev_dbg(dev, " handle additional data config set to DLLI\n");
418 /* create sg for the current buffer */ 405 /* create sg for the current buffer */
419 sg_init_one(&areq_ctx->ccm_adata_sg, config_data, AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size); 406 sg_init_one(&areq_ctx->ccm_adata_sg, config_data, AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size);
420 if (unlikely(dma_map_sg(dev, &areq_ctx->ccm_adata_sg, 1, 407 if (unlikely(dma_map_sg(dev, &areq_ctx->ccm_adata_sg, 1,
421 DMA_TO_DEVICE) != 1)) { 408 DMA_TO_DEVICE) != 1)) {
422 SSI_LOG_ERR("dma_map_sg() " 409 dev_err(dev, "dma_map_sg() config buffer failed\n");
423 "config buffer failed\n"); 410 return -ENOMEM;
424 return -ENOMEM;
425 } 411 }
426 SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " 412 dev_dbg(dev, "Mapped curr_buff: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n",
427 "page=%p addr=%pK " 413 &sg_dma_address(&areq_ctx->ccm_adata_sg),
428 "offset=%u length=%u\n", 414 sg_page(&areq_ctx->ccm_adata_sg),
429 sg_dma_address(&areq_ctx->ccm_adata_sg), 415 sg_virt(&areq_ctx->ccm_adata_sg),
430 sg_page(&areq_ctx->ccm_adata_sg), 416 areq_ctx->ccm_adata_sg.offset, areq_ctx->ccm_adata_sg.length);
431 sg_virt(&areq_ctx->ccm_adata_sg),
432 areq_ctx->ccm_adata_sg.offset,
433 areq_ctx->ccm_adata_sg.length);
434 /* prepare for case of MLLI */ 417 /* prepare for case of MLLI */
435 if (assoclen > 0) { 418 if (assoclen > 0) {
436 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1, 419 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1,
437 &areq_ctx->ccm_adata_sg, 420 &areq_ctx->ccm_adata_sg,
438 (AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size), 421 (AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size),
439 0, false, NULL); 422 0, false, NULL);
@@ -447,28 +430,23 @@ static inline int ssi_ahash_handle_curr_buf(struct device *dev,
447 u32 curr_buff_cnt, 430 u32 curr_buff_cnt,
448 struct buffer_array *sg_data) 431 struct buffer_array *sg_data)
449{ 432{
450 SSI_LOG_DEBUG(" handle curr buff %x set to DLLI\n", curr_buff_cnt); 433 dev_dbg(dev, " handle curr buff %x set to DLLI\n", curr_buff_cnt);
451 /* create sg for the current buffer */ 434 /* create sg for the current buffer */
452 sg_init_one(areq_ctx->buff_sg, curr_buff, curr_buff_cnt); 435 sg_init_one(areq_ctx->buff_sg, curr_buff, curr_buff_cnt);
453 if (unlikely(dma_map_sg(dev, areq_ctx->buff_sg, 1, 436 if (unlikely(dma_map_sg(dev, areq_ctx->buff_sg, 1,
454 DMA_TO_DEVICE) != 1)) { 437 DMA_TO_DEVICE) != 1)) {
455 SSI_LOG_ERR("dma_map_sg() " 438 dev_err(dev, "dma_map_sg() src buffer failed\n");
456 "src buffer failed\n"); 439 return -ENOMEM;
457 return -ENOMEM;
458 } 440 }
459 SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " 441 dev_dbg(dev, "Mapped curr_buff: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n",
460 "page=%p addr=%pK " 442 &sg_dma_address(areq_ctx->buff_sg), sg_page(areq_ctx->buff_sg),
461 "offset=%u length=%u\n", 443 sg_virt(areq_ctx->buff_sg), areq_ctx->buff_sg->offset,
462 sg_dma_address(areq_ctx->buff_sg), 444 areq_ctx->buff_sg->length);
463 sg_page(areq_ctx->buff_sg),
464 sg_virt(areq_ctx->buff_sg),
465 areq_ctx->buff_sg->offset,
466 areq_ctx->buff_sg->length);
467 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_DLLI; 445 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_DLLI;
468 areq_ctx->curr_sg = areq_ctx->buff_sg; 446 areq_ctx->curr_sg = areq_ctx->buff_sg;
469 areq_ctx->in_nents = 0; 447 areq_ctx->in_nents = 0;
470 /* prepare for case of MLLI */ 448 /* prepare for case of MLLI */
471 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1, areq_ctx->buff_sg, 449 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1, areq_ctx->buff_sg,
472 curr_buff_cnt, 0, false, NULL); 450 curr_buff_cnt, 0, false, NULL);
473 return 0; 451 return 0;
474} 452}
@@ -483,9 +461,8 @@ void ssi_buffer_mgr_unmap_blkcipher_request(
483 struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx; 461 struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx;
484 462
485 if (likely(req_ctx->gen_ctx.iv_dma_addr != 0)) { 463 if (likely(req_ctx->gen_ctx.iv_dma_addr != 0)) {
486 SSI_LOG_DEBUG("Unmapped iv: iv_dma_addr=%pad iv_size=%u\n", 464 dev_dbg(dev, "Unmapped iv: iv_dma_addr=%pad iv_size=%u\n",
487 req_ctx->gen_ctx.iv_dma_addr, 465 &req_ctx->gen_ctx.iv_dma_addr, ivsize);
488 ivsize);
489 dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr, 466 dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr,
490 ivsize, 467 ivsize,
491 req_ctx->is_giv ? DMA_BIDIRECTIONAL : 468 req_ctx->is_giv ? DMA_BIDIRECTIONAL :
@@ -499,11 +476,11 @@ void ssi_buffer_mgr_unmap_blkcipher_request(
499 } 476 }
500 477
501 dma_unmap_sg(dev, src, req_ctx->in_nents, DMA_BIDIRECTIONAL); 478 dma_unmap_sg(dev, src, req_ctx->in_nents, DMA_BIDIRECTIONAL);
502 SSI_LOG_DEBUG("Unmapped req->src=%pK\n", sg_virt(src)); 479 dev_dbg(dev, "Unmapped req->src=%pK\n", sg_virt(src));
503 480
504 if (src != dst) { 481 if (src != dst) {
505 dma_unmap_sg(dev, dst, req_ctx->out_nents, DMA_BIDIRECTIONAL); 482 dma_unmap_sg(dev, dst, req_ctx->out_nents, DMA_BIDIRECTIONAL);
506 SSI_LOG_DEBUG("Unmapped req->dst=%pK\n", sg_virt(dst)); 483 dev_dbg(dev, "Unmapped req->dst=%pK\n", sg_virt(dst));
507 } 484 }
508} 485}
509 486
@@ -519,7 +496,7 @@ int ssi_buffer_mgr_map_blkcipher_request(
519 struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx; 496 struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx;
520 struct mlli_params *mlli_params = &req_ctx->mlli_params; 497 struct mlli_params *mlli_params = &req_ctx->mlli_params;
521 struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; 498 struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
522 struct device *dev = &drvdata->plat_dev->dev; 499 struct device *dev = drvdata_to_dev(drvdata);
523 struct buffer_array sg_data; 500 struct buffer_array sg_data;
524 u32 dummy = 0; 501 u32 dummy = 0;
525 int rc = 0; 502 int rc = 0;
@@ -539,13 +516,12 @@ int ssi_buffer_mgr_map_blkcipher_request(
539 DMA_TO_DEVICE); 516 DMA_TO_DEVICE);
540 if (unlikely(dma_mapping_error(dev, 517 if (unlikely(dma_mapping_error(dev,
541 req_ctx->gen_ctx.iv_dma_addr))) { 518 req_ctx->gen_ctx.iv_dma_addr))) {
542 SSI_LOG_ERR("Mapping iv %u B at va=%pK " 519 dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n",
543 "for DMA failed\n", ivsize, info); 520 ivsize, info);
544 return -ENOMEM; 521 return -ENOMEM;
545 } 522 }
546 SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n", 523 dev_dbg(dev, "Mapped iv %u B at va=%pK to dma=%pad\n",
547 ivsize, info, 524 ivsize, info, &req_ctx->gen_ctx.iv_dma_addr);
548 req_ctx->gen_ctx.iv_dma_addr);
549 } else { 525 } else {
550 req_ctx->gen_ctx.iv_dma_addr = 0; 526 req_ctx->gen_ctx.iv_dma_addr = 0;
551 } 527 }
@@ -567,7 +543,7 @@ int ssi_buffer_mgr_map_blkcipher_request(
567 /* Handle inplace operation */ 543 /* Handle inplace operation */
568 if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) { 544 if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) {
569 req_ctx->out_nents = 0; 545 req_ctx->out_nents = 0;
570 ssi_buffer_mgr_add_scatterlist_entry(&sg_data, 546 ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data,
571 req_ctx->in_nents, 547 req_ctx->in_nents,
572 src, nbytes, 0, 548 src, nbytes, 0,
573 true, 549 true,
@@ -587,12 +563,12 @@ int ssi_buffer_mgr_map_blkcipher_request(
587 req_ctx->dma_buf_type = SSI_DMA_BUF_MLLI; 563 req_ctx->dma_buf_type = SSI_DMA_BUF_MLLI;
588 564
589 if (unlikely((req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI))) { 565 if (unlikely((req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI))) {
590 ssi_buffer_mgr_add_scatterlist_entry(&sg_data, 566 ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data,
591 req_ctx->in_nents, 567 req_ctx->in_nents,
592 src, nbytes, 0, 568 src, nbytes, 0,
593 true, 569 true,
594 &req_ctx->in_mlli_nents); 570 &req_ctx->in_mlli_nents);
595 ssi_buffer_mgr_add_scatterlist_entry(&sg_data, 571 ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data,
596 req_ctx->out_nents, 572 req_ctx->out_nents,
597 dst, nbytes, 0, 573 dst, nbytes, 0,
598 true, 574 true,
@@ -607,8 +583,8 @@ int ssi_buffer_mgr_map_blkcipher_request(
607 goto ablkcipher_exit; 583 goto ablkcipher_exit;
608 } 584 }
609 585
610 SSI_LOG_DEBUG("areq_ctx->dma_buf_type = %s\n", 586 dev_dbg(dev, "areq_ctx->dma_buf_type = %s\n",
611 GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type)); 587 GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type));
612 588
613 return 0; 589 return 0;
614 590
@@ -674,30 +650,34 @@ void ssi_buffer_mgr_unmap_aead_request(
674 *allocated and should be released 650 *allocated and should be released
675 */ 651 */
676 if (areq_ctx->mlli_params.curr_pool) { 652 if (areq_ctx->mlli_params.curr_pool) {
677 SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n", 653 dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n",
678 areq_ctx->mlli_params.mlli_dma_addr, 654 &areq_ctx->mlli_params.mlli_dma_addr,
679 areq_ctx->mlli_params.mlli_virt_addr); 655 areq_ctx->mlli_params.mlli_virt_addr);
680 dma_pool_free(areq_ctx->mlli_params.curr_pool, 656 dma_pool_free(areq_ctx->mlli_params.curr_pool,
681 areq_ctx->mlli_params.mlli_virt_addr, 657 areq_ctx->mlli_params.mlli_virt_addr,
682 areq_ctx->mlli_params.mlli_dma_addr); 658 areq_ctx->mlli_params.mlli_dma_addr);
683 } 659 }
684 660
685 SSI_LOG_DEBUG("Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n", sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, req->assoclen, req->cryptlen); 661 dev_dbg(dev, "Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n",
662 sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents,
663 req->assoclen, req->cryptlen);
686 size_to_unmap = req->assoclen + req->cryptlen; 664 size_to_unmap = req->assoclen + req->cryptlen;
687 if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) 665 if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT)
688 size_to_unmap += areq_ctx->req_authsize; 666 size_to_unmap += areq_ctx->req_authsize;
689 if (areq_ctx->is_gcm4543) 667 if (areq_ctx->is_gcm4543)
690 size_to_unmap += crypto_aead_ivsize(tfm); 668 size_to_unmap += crypto_aead_ivsize(tfm);
691 669
692 dma_unmap_sg(dev, req->src, ssi_buffer_mgr_get_sgl_nents(req->src, size_to_unmap, &dummy, &chained), DMA_BIDIRECTIONAL); 670 dma_unmap_sg(dev, req->src,
671 ssi_buffer_mgr_get_sgl_nents(dev, req->src, size_to_unmap,
672 &dummy, &chained),
673 DMA_BIDIRECTIONAL);
693 if (unlikely(req->src != req->dst)) { 674 if (unlikely(req->src != req->dst)) {
694 SSI_LOG_DEBUG("Unmapping dst sgl: req->dst=%pK\n", 675 dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n",
695 sg_virt(req->dst)); 676 sg_virt(req->dst));
696 dma_unmap_sg(dev, req->dst, 677 dma_unmap_sg(dev, req->dst,
697 ssi_buffer_mgr_get_sgl_nents(req->dst, 678 ssi_buffer_mgr_get_sgl_nents(dev, req->dst,
698 size_to_unmap, 679 size_to_unmap,
699 &dummy, 680 &dummy, &chained),
700 &chained),
701 DMA_BIDIRECTIONAL); 681 DMA_BIDIRECTIONAL);
702 } 682 }
703 if (drvdata->coherent && 683 if (drvdata->coherent &&
@@ -712,13 +692,14 @@ void ssi_buffer_mgr_unmap_aead_request(
712 * data memory overriding that caused by cache coherence problem. 692 * data memory overriding that caused by cache coherence problem.
713 */ 693 */
714 ssi_buffer_mgr_copy_scatterlist_portion( 694 ssi_buffer_mgr_copy_scatterlist_portion(
715 areq_ctx->backup_mac, req->src, 695 dev, areq_ctx->backup_mac, req->src,
716 size_to_skip + req->cryptlen - areq_ctx->req_authsize, 696 size_to_skip + req->cryptlen - areq_ctx->req_authsize,
717 size_to_skip + req->cryptlen, SSI_SG_FROM_BUF); 697 size_to_skip + req->cryptlen, SSI_SG_FROM_BUF);
718 } 698 }
719} 699}
720 700
721static inline int ssi_buffer_mgr_get_aead_icv_nents( 701static inline int ssi_buffer_mgr_get_aead_icv_nents(
702 struct device *dev,
722 struct scatterlist *sgl, 703 struct scatterlist *sgl,
723 unsigned int sgl_nents, 704 unsigned int sgl_nents,
724 unsigned int authsize, 705 unsigned int authsize,
@@ -757,12 +738,12 @@ static inline int ssi_buffer_mgr_get_aead_icv_nents(
757 nents = 2; 738 nents = 2;
758 *is_icv_fragmented = true; 739 *is_icv_fragmented = true;
759 } else { 740 } else {
760 SSI_LOG_ERR("Unsupported num. of ICV fragments (> %d)\n", 741 dev_err(dev, "Unsupported num. of ICV fragments (> %d)\n",
761 MAX_ICV_NENTS_SUPPORTED); 742 MAX_ICV_NENTS_SUPPORTED);
762 nents = -1; /*unsupported*/ 743 nents = -1; /*unsupported*/
763 } 744 }
764 SSI_LOG_DEBUG("is_frag=%s icv_nents=%u\n", 745 dev_dbg(dev, "is_frag=%s icv_nents=%u\n",
765 (*is_icv_fragmented ? "true" : "false"), nents); 746 (*is_icv_fragmented ? "true" : "false"), nents);
766 747
767 return nents; 748 return nents;
768} 749}
@@ -775,7 +756,7 @@ static inline int ssi_buffer_mgr_aead_chain_iv(
775{ 756{
776 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 757 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
777 unsigned int hw_iv_size = areq_ctx->hw_iv_size; 758 unsigned int hw_iv_size = areq_ctx->hw_iv_size;
778 struct device *dev = &drvdata->plat_dev->dev; 759 struct device *dev = drvdata_to_dev(drvdata);
779 int rc = 0; 760 int rc = 0;
780 761
781 if (unlikely(!req->iv)) { 762 if (unlikely(!req->iv)) {
@@ -786,22 +767,22 @@ static inline int ssi_buffer_mgr_aead_chain_iv(
786 areq_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, req->iv, hw_iv_size, 767 areq_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, req->iv, hw_iv_size,
787 DMA_BIDIRECTIONAL); 768 DMA_BIDIRECTIONAL);
788 if (unlikely(dma_mapping_error(dev, areq_ctx->gen_ctx.iv_dma_addr))) { 769 if (unlikely(dma_mapping_error(dev, areq_ctx->gen_ctx.iv_dma_addr))) {
789 SSI_LOG_ERR("Mapping iv %u B at va=%pK for DMA failed\n", 770 dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n",
790 hw_iv_size, req->iv); 771 hw_iv_size, req->iv);
791 rc = -ENOMEM; 772 rc = -ENOMEM;
792 goto chain_iv_exit; 773 goto chain_iv_exit;
793 } 774 }
794 775
795 SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n", 776 dev_dbg(dev, "Mapped iv %u B at va=%pK to dma=%pad\n",
796 hw_iv_size, req->iv, 777 hw_iv_size, req->iv, &areq_ctx->gen_ctx.iv_dma_addr);
797 areq_ctx->gen_ctx.iv_dma_addr);
798 if (do_chain && areq_ctx->plaintext_authenticate_only) { // TODO: what about CTR?? ask Ron 778 if (do_chain && areq_ctx->plaintext_authenticate_only) { // TODO: what about CTR?? ask Ron
799 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 779 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
800 unsigned int iv_size_to_authenc = crypto_aead_ivsize(tfm); 780 unsigned int iv_size_to_authenc = crypto_aead_ivsize(tfm);
801 unsigned int iv_ofs = GCM_BLOCK_RFC4_IV_OFFSET; 781 unsigned int iv_ofs = GCM_BLOCK_RFC4_IV_OFFSET;
802 /* Chain to given list */ 782 /* Chain to given list */
803 ssi_buffer_mgr_add_buffer_entry( 783 ssi_buffer_mgr_add_buffer_entry(
804 sg_data, areq_ctx->gen_ctx.iv_dma_addr + iv_ofs, 784 dev, sg_data,
785 areq_ctx->gen_ctx.iv_dma_addr + iv_ofs,
805 iv_size_to_authenc, is_last, 786 iv_size_to_authenc, is_last,
806 &areq_ctx->assoc.mlli_nents); 787 &areq_ctx->assoc.mlli_nents);
807 areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; 788 areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI;
@@ -824,6 +805,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
824 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 805 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
825 unsigned int sg_index = 0; 806 unsigned int sg_index = 0;
826 u32 size_of_assoc = req->assoclen; 807 u32 size_of_assoc = req->assoclen;
808 struct device *dev = drvdata_to_dev(drvdata);
827 809
828 if (areq_ctx->is_gcm4543) 810 if (areq_ctx->is_gcm4543)
829 size_of_assoc += crypto_aead_ivsize(tfm); 811 size_of_assoc += crypto_aead_ivsize(tfm);
@@ -837,9 +819,9 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
837 areq_ctx->assoc_buff_type = SSI_DMA_BUF_NULL; 819 areq_ctx->assoc_buff_type = SSI_DMA_BUF_NULL;
838 areq_ctx->assoc.nents = 0; 820 areq_ctx->assoc.nents = 0;
839 areq_ctx->assoc.mlli_nents = 0; 821 areq_ctx->assoc.mlli_nents = 0;
840 SSI_LOG_DEBUG("Chain assoc of length 0: buff_type=%s nents=%u\n", 822 dev_dbg(dev, "Chain assoc of length 0: buff_type=%s nents=%u\n",
841 GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), 823 GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type),
842 areq_ctx->assoc.nents); 824 areq_ctx->assoc.nents);
843 goto chain_assoc_exit; 825 goto chain_assoc_exit;
844 } 826 }
845 827
@@ -853,16 +835,16 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
853 current_sg = sg_next(current_sg); 835 current_sg = sg_next(current_sg);
854 //if have reached the end of the sgl, then this is unexpected 836 //if have reached the end of the sgl, then this is unexpected
855 if (!current_sg) { 837 if (!current_sg) {
856 SSI_LOG_ERR("reached end of sg list. unexpected\n"); 838 dev_err(dev, "reached end of sg list. unexpected\n");
857 BUG(); 839 return -EINVAL;
858 } 840 }
859 sg_index += current_sg->length; 841 sg_index += current_sg->length;
860 mapped_nents++; 842 mapped_nents++;
861 } 843 }
862 } 844 }
863 if (unlikely(mapped_nents > LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) { 845 if (unlikely(mapped_nents > LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) {
864 SSI_LOG_ERR("Too many fragments. current %d max %d\n", 846 dev_err(dev, "Too many fragments. current %d max %d\n",
865 mapped_nents, LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); 847 mapped_nents, LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES);
866 return -ENOMEM; 848 return -ENOMEM;
867 } 849 }
868 areq_ctx->assoc.nents = mapped_nents; 850 areq_ctx->assoc.nents = mapped_nents;
@@ -873,9 +855,9 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
873 if (areq_ctx->ccm_hdr_size != ccm_header_size_null) { 855 if (areq_ctx->ccm_hdr_size != ccm_header_size_null) {
874 if (unlikely((mapped_nents + 1) > 856 if (unlikely((mapped_nents + 1) >
875 LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) { 857 LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) {
876 SSI_LOG_ERR("CCM case.Too many fragments. Current %d max %d\n", 858 dev_err(dev, "CCM case.Too many fragments. Current %d max %d\n",
877 (areq_ctx->assoc.nents + 1), 859 (areq_ctx->assoc.nents + 1),
878 LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); 860 LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES);
879 rc = -ENOMEM; 861 rc = -ENOMEM;
880 goto chain_assoc_exit; 862 goto chain_assoc_exit;
881 } 863 }
@@ -889,11 +871,11 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
889 871
890 if (unlikely((do_chain) || 872 if (unlikely((do_chain) ||
891 (areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI))) { 873 (areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI))) {
892 SSI_LOG_DEBUG("Chain assoc: buff_type=%s nents=%u\n", 874 dev_dbg(dev, "Chain assoc: buff_type=%s nents=%u\n",
893 GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), 875 GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type),
894 areq_ctx->assoc.nents); 876 areq_ctx->assoc.nents);
895 ssi_buffer_mgr_add_scatterlist_entry( 877 ssi_buffer_mgr_add_scatterlist_entry(
896 sg_data, areq_ctx->assoc.nents, 878 dev, sg_data, areq_ctx->assoc.nents,
897 req->src, req->assoclen, 0, is_last, 879 req->src, req->assoclen, 0, is_last,
898 &areq_ctx->assoc.mlli_nents); 880 &areq_ctx->assoc.mlli_nents);
899 areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; 881 areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI;
@@ -951,10 +933,11 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
951 unsigned int authsize = areq_ctx->req_authsize; 933 unsigned int authsize = areq_ctx->req_authsize;
952 int rc = 0, icv_nents; 934 int rc = 0, icv_nents;
953 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 935 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
936 struct device *dev = drvdata_to_dev(drvdata);
954 937
955 if (likely(req->src == req->dst)) { 938 if (likely(req->src == req->dst)) {
956 /*INPLACE*/ 939 /*INPLACE*/
957 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 940 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data,
958 areq_ctx->src.nents, 941 areq_ctx->src.nents,
959 areq_ctx->src_sgl, 942 areq_ctx->src_sgl,
960 areq_ctx->cryptlen, 943 areq_ctx->cryptlen,
@@ -962,7 +945,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
962 is_last_table, 945 is_last_table,
963 &areq_ctx->src.mlli_nents); 946 &areq_ctx->src.mlli_nents);
964 947
965 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->src_sgl, 948 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev,
949 areq_ctx->src_sgl,
966 areq_ctx->src.nents, 950 areq_ctx->src.nents,
967 authsize, 951 authsize,
968 *src_last_bytes, 952 *src_last_bytes,
@@ -990,7 +974,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
990 skip += crypto_aead_ivsize(tfm); 974 skip += crypto_aead_ivsize(tfm);
991 975
992 ssi_buffer_mgr_copy_scatterlist_portion( 976 ssi_buffer_mgr_copy_scatterlist_portion(
993 areq_ctx->backup_mac, req->src, 977 dev, areq_ctx->backup_mac,
978 req->src,
994 (skip + req->cryptlen - 979 (skip + req->cryptlen -
995 areq_ctx->req_authsize), 980 areq_ctx->req_authsize),
996 skip + req->cryptlen, 981 skip + req->cryptlen,
@@ -1013,14 +998,14 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
1013 998
1014 } else if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) { 999 } else if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) {
1015 /*NON-INPLACE and DECRYPT*/ 1000 /*NON-INPLACE and DECRYPT*/
1016 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1001 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data,
1017 areq_ctx->src.nents, 1002 areq_ctx->src.nents,
1018 areq_ctx->src_sgl, 1003 areq_ctx->src_sgl,
1019 areq_ctx->cryptlen, 1004 areq_ctx->cryptlen,
1020 areq_ctx->src_offset, 1005 areq_ctx->src_offset,
1021 is_last_table, 1006 is_last_table,
1022 &areq_ctx->src.mlli_nents); 1007 &areq_ctx->src.mlli_nents);
1023 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1008 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data,
1024 areq_ctx->dst.nents, 1009 areq_ctx->dst.nents,
1025 areq_ctx->dst_sgl, 1010 areq_ctx->dst_sgl,
1026 areq_ctx->cryptlen, 1011 areq_ctx->cryptlen,
@@ -1028,7 +1013,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
1028 is_last_table, 1013 is_last_table,
1029 &areq_ctx->dst.mlli_nents); 1014 &areq_ctx->dst.mlli_nents);
1030 1015
1031 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->src_sgl, 1016 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev,
1017 areq_ctx->src_sgl,
1032 areq_ctx->src.nents, 1018 areq_ctx->src.nents,
1033 authsize, 1019 authsize,
1034 *src_last_bytes, 1020 *src_last_bytes,
@@ -1043,15 +1029,15 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
1043 * verification is made by CPU compare in order to simplify 1029 * verification is made by CPU compare in order to simplify
1044 * MAC verification upon request completion 1030 * MAC verification upon request completion
1045 */ 1031 */
1046 u32 size_to_skip = req->assoclen; 1032 u32 size_to_skip = req->assoclen;
1047 1033
1048 if (areq_ctx->is_gcm4543) 1034 if (areq_ctx->is_gcm4543)
1049 size_to_skip += crypto_aead_ivsize(tfm); 1035 size_to_skip += crypto_aead_ivsize(tfm);
1050 1036
1051 ssi_buffer_mgr_copy_scatterlist_portion( 1037 ssi_buffer_mgr_copy_scatterlist_portion(
1052 areq_ctx->backup_mac, req->src, 1038 dev, areq_ctx->backup_mac, req->src,
1053 size_to_skip + req->cryptlen - areq_ctx->req_authsize, 1039 size_to_skip + req->cryptlen - areq_ctx->req_authsize,
1054 size_to_skip + req->cryptlen, SSI_SG_TO_BUF); 1040 size_to_skip + req->cryptlen, SSI_SG_TO_BUF);
1055 areq_ctx->icv_virt_addr = areq_ctx->backup_mac; 1041 areq_ctx->icv_virt_addr = areq_ctx->backup_mac;
1056 } else { /* Contig. ICV */ 1042 } else { /* Contig. ICV */
1057 /*Should hanlde if the sg is not contig.*/ 1043 /*Should hanlde if the sg is not contig.*/
@@ -1065,14 +1051,14 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
1065 1051
1066 } else { 1052 } else {
1067 /*NON-INPLACE and ENCRYPT*/ 1053 /*NON-INPLACE and ENCRYPT*/
1068 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1054 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data,
1069 areq_ctx->dst.nents, 1055 areq_ctx->dst.nents,
1070 areq_ctx->dst_sgl, 1056 areq_ctx->dst_sgl,
1071 areq_ctx->cryptlen, 1057 areq_ctx->cryptlen,
1072 areq_ctx->dst_offset, 1058 areq_ctx->dst_offset,
1073 is_last_table, 1059 is_last_table,
1074 &areq_ctx->dst.mlli_nents); 1060 &areq_ctx->dst.mlli_nents);
1075 ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1061 ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data,
1076 areq_ctx->src.nents, 1062 areq_ctx->src.nents,
1077 areq_ctx->src_sgl, 1063 areq_ctx->src_sgl,
1078 areq_ctx->cryptlen, 1064 areq_ctx->cryptlen,
@@ -1080,7 +1066,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
1080 is_last_table, 1066 is_last_table,
1081 &areq_ctx->src.mlli_nents); 1067 &areq_ctx->src.mlli_nents);
1082 1068
1083 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->dst_sgl, 1069 icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev,
1070 areq_ctx->dst_sgl,
1084 areq_ctx->dst.nents, 1071 areq_ctx->dst.nents,
1085 authsize, 1072 authsize,
1086 *dst_last_bytes, 1073 *dst_last_bytes,
@@ -1115,7 +1102,7 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1115 bool is_last_table, bool do_chain) 1102 bool is_last_table, bool do_chain)
1116{ 1103{
1117 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 1104 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
1118 struct device *dev = &drvdata->plat_dev->dev; 1105 struct device *dev = drvdata_to_dev(drvdata);
1119 enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type; 1106 enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type;
1120 unsigned int authsize = areq_ctx->req_authsize; 1107 unsigned int authsize = areq_ctx->req_authsize;
1121 int src_last_bytes = 0, dst_last_bytes = 0; 1108 int src_last_bytes = 0, dst_last_bytes = 0;
@@ -1134,10 +1121,9 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1134 1121
1135 offset = size_to_skip; 1122 offset = size_to_skip;
1136 1123
1137 if (!sg_data) { 1124 if (!sg_data)
1138 rc = -EINVAL; 1125 return -EINVAL;
1139 goto chain_data_exit; 1126
1140 }
1141 areq_ctx->src_sgl = req->src; 1127 areq_ctx->src_sgl = req->src;
1142 areq_ctx->dst_sgl = req->dst; 1128 areq_ctx->dst_sgl = req->dst;
1143 1129
@@ -1145,7 +1131,10 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1145 size_for_map += crypto_aead_ivsize(tfm); 1131 size_for_map += crypto_aead_ivsize(tfm);
1146 1132
1147 size_for_map += (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? authsize : 0; 1133 size_for_map += (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? authsize : 0;
1148 src_mapped_nents = ssi_buffer_mgr_get_sgl_nents(req->src, size_for_map, &src_last_bytes, &chained); 1134 src_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->src,
1135 size_for_map,
1136 &src_last_bytes,
1137 &chained);
1149 sg_index = areq_ctx->src_sgl->length; 1138 sg_index = areq_ctx->src_sgl->length;
1150 //check where the data starts 1139 //check where the data starts
1151 while (sg_index <= size_to_skip) { 1140 while (sg_index <= size_to_skip) {
@@ -1153,15 +1142,15 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1153 areq_ctx->src_sgl = sg_next(areq_ctx->src_sgl); 1142 areq_ctx->src_sgl = sg_next(areq_ctx->src_sgl);
1154 //if have reached the end of the sgl, then this is unexpected 1143 //if have reached the end of the sgl, then this is unexpected
1155 if (!areq_ctx->src_sgl) { 1144 if (!areq_ctx->src_sgl) {
1156 SSI_LOG_ERR("reached end of sg list. unexpected\n"); 1145 dev_err(dev, "reached end of sg list. unexpected\n");
1157 BUG(); 1146 return -EINVAL;
1158 } 1147 }
1159 sg_index += areq_ctx->src_sgl->length; 1148 sg_index += areq_ctx->src_sgl->length;
1160 src_mapped_nents--; 1149 src_mapped_nents--;
1161 } 1150 }
1162 if (unlikely(src_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { 1151 if (unlikely(src_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) {
1163 SSI_LOG_ERR("Too many fragments. current %d max %d\n", 1152 dev_err(dev, "Too many fragments. current %d max %d\n",
1164 src_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); 1153 src_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES);
1165 return -ENOMEM; 1154 return -ENOMEM;
1166 } 1155 }
1167 1156
@@ -1187,7 +1176,10 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1187 } 1176 }
1188 } 1177 }
1189 1178
1190 dst_mapped_nents = ssi_buffer_mgr_get_sgl_nents(req->dst, size_for_map, &dst_last_bytes, &chained); 1179 dst_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->dst,
1180 size_for_map,
1181 &dst_last_bytes,
1182 &chained);
1191 sg_index = areq_ctx->dst_sgl->length; 1183 sg_index = areq_ctx->dst_sgl->length;
1192 offset = size_to_skip; 1184 offset = size_to_skip;
1193 1185
@@ -1197,15 +1189,15 @@ static inline int ssi_buffer_mgr_aead_chain_data(
1197 areq_ctx->dst_sgl = sg_next(areq_ctx->dst_sgl); 1189 areq_ctx->dst_sgl = sg_next(areq_ctx->dst_sgl);
1198 //if have reached the end of the sgl, then this is unexpected 1190 //if have reached the end of the sgl, then this is unexpected
1199 if (!areq_ctx->dst_sgl) { 1191 if (!areq_ctx->dst_sgl) {
1200 SSI_LOG_ERR("reached end of sg list. unexpected\n"); 1192 dev_err(dev, "reached end of sg list. unexpected\n");
1201 BUG(); 1193 return -EINVAL;
1202 } 1194 }
1203 sg_index += areq_ctx->dst_sgl->length; 1195 sg_index += areq_ctx->dst_sgl->length;
1204 dst_mapped_nents--; 1196 dst_mapped_nents--;
1205 } 1197 }
1206 if (unlikely(dst_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { 1198 if (unlikely(dst_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) {
1207 SSI_LOG_ERR("Too many fragments. current %d max %d\n", 1199 dev_err(dev, "Too many fragments. current %d max %d\n",
1208 dst_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); 1200 dst_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES);
1209 return -ENOMEM; 1201 return -ENOMEM;
1210 } 1202 }
1211 areq_ctx->dst.nents = dst_mapped_nents; 1203 areq_ctx->dst.nents = dst_mapped_nents;
@@ -1285,7 +1277,7 @@ int ssi_buffer_mgr_map_aead_request(
1285{ 1277{
1286 struct aead_req_ctx *areq_ctx = aead_request_ctx(req); 1278 struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
1287 struct mlli_params *mlli_params = &areq_ctx->mlli_params; 1279 struct mlli_params *mlli_params = &areq_ctx->mlli_params;
1288 struct device *dev = &drvdata->plat_dev->dev; 1280 struct device *dev = drvdata_to_dev(drvdata);
1289 struct buffer_array sg_data; 1281 struct buffer_array sg_data;
1290 unsigned int authsize = areq_ctx->req_authsize; 1282 unsigned int authsize = areq_ctx->req_authsize;
1291 struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; 1283 struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
@@ -1312,7 +1304,7 @@ int ssi_buffer_mgr_map_aead_request(
1312 * data memory overriding that caused by cache coherence problem. 1304 * data memory overriding that caused by cache coherence problem.
1313 */ 1305 */
1314 ssi_buffer_mgr_copy_scatterlist_portion( 1306 ssi_buffer_mgr_copy_scatterlist_portion(
1315 areq_ctx->backup_mac, req->src, 1307 dev, areq_ctx->backup_mac, req->src,
1316 size_to_skip + req->cryptlen - areq_ctx->req_authsize, 1308 size_to_skip + req->cryptlen - areq_ctx->req_authsize,
1317 size_to_skip + req->cryptlen, SSI_SG_TO_BUF); 1309 size_to_skip + req->cryptlen, SSI_SG_TO_BUF);
1318 } 1310 }
@@ -1327,8 +1319,8 @@ int ssi_buffer_mgr_map_aead_request(
1327 MAX_MAC_SIZE, 1319 MAX_MAC_SIZE,
1328 DMA_BIDIRECTIONAL); 1320 DMA_BIDIRECTIONAL);
1329 if (unlikely(dma_mapping_error(dev, areq_ctx->mac_buf_dma_addr))) { 1321 if (unlikely(dma_mapping_error(dev, areq_ctx->mac_buf_dma_addr))) {
1330 SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK for DMA failed\n", 1322 dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n",
1331 MAX_MAC_SIZE, areq_ctx->mac_buf); 1323 MAX_MAC_SIZE, areq_ctx->mac_buf);
1332 rc = -ENOMEM; 1324 rc = -ENOMEM;
1333 goto aead_map_failure; 1325 goto aead_map_failure;
1334 } 1326 }
@@ -1340,9 +1332,10 @@ int ssi_buffer_mgr_map_aead_request(
1340 DMA_TO_DEVICE); 1332 DMA_TO_DEVICE);
1341 1333
1342 if (unlikely(dma_mapping_error(dev, areq_ctx->ccm_iv0_dma_addr))) { 1334 if (unlikely(dma_mapping_error(dev, areq_ctx->ccm_iv0_dma_addr))) {
1343 SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK " 1335 dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n",
1344 "for DMA failed\n", AES_BLOCK_SIZE, 1336 AES_BLOCK_SIZE,
1345 (areq_ctx->ccm_config + CCM_CTR_COUNT_0_OFFSET)); 1337 (areq_ctx->ccm_config +
1338 CCM_CTR_COUNT_0_OFFSET));
1346 areq_ctx->ccm_iv0_dma_addr = 0; 1339 areq_ctx->ccm_iv0_dma_addr = 0;
1347 rc = -ENOMEM; 1340 rc = -ENOMEM;
1348 goto aead_map_failure; 1341 goto aead_map_failure;
@@ -1362,8 +1355,8 @@ int ssi_buffer_mgr_map_aead_request(
1362 AES_BLOCK_SIZE, 1355 AES_BLOCK_SIZE,
1363 DMA_BIDIRECTIONAL); 1356 DMA_BIDIRECTIONAL);
1364 if (unlikely(dma_mapping_error(dev, areq_ctx->hkey_dma_addr))) { 1357 if (unlikely(dma_mapping_error(dev, areq_ctx->hkey_dma_addr))) {
1365 SSI_LOG_ERR("Mapping hkey %u B at va=%pK for DMA failed\n", 1358 dev_err(dev, "Mapping hkey %u B at va=%pK for DMA failed\n",
1366 AES_BLOCK_SIZE, areq_ctx->hkey); 1359 AES_BLOCK_SIZE, areq_ctx->hkey);
1367 rc = -ENOMEM; 1360 rc = -ENOMEM;
1368 goto aead_map_failure; 1361 goto aead_map_failure;
1369 } 1362 }
@@ -1373,8 +1366,8 @@ int ssi_buffer_mgr_map_aead_request(
1373 AES_BLOCK_SIZE, 1366 AES_BLOCK_SIZE,
1374 DMA_TO_DEVICE); 1367 DMA_TO_DEVICE);
1375 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_block_len_dma_addr))) { 1368 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_block_len_dma_addr))) {
1376 SSI_LOG_ERR("Mapping gcm_len_block %u B at va=%pK for DMA failed\n", 1369 dev_err(dev, "Mapping gcm_len_block %u B at va=%pK for DMA failed\n",
1377 AES_BLOCK_SIZE, &areq_ctx->gcm_len_block); 1370 AES_BLOCK_SIZE, &areq_ctx->gcm_len_block);
1378 rc = -ENOMEM; 1371 rc = -ENOMEM;
1379 goto aead_map_failure; 1372 goto aead_map_failure;
1380 } 1373 }
@@ -1385,9 +1378,8 @@ int ssi_buffer_mgr_map_aead_request(
1385 DMA_TO_DEVICE); 1378 DMA_TO_DEVICE);
1386 1379
1387 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc1_dma_addr))) { 1380 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc1_dma_addr))) {
1388 SSI_LOG_ERR("Mapping gcm_iv_inc1 %u B at va=%pK " 1381 dev_err(dev, "Mapping gcm_iv_inc1 %u B at va=%pK for DMA failed\n",
1389 "for DMA failed\n", AES_BLOCK_SIZE, 1382 AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc1));
1390 (areq_ctx->gcm_iv_inc1));
1391 areq_ctx->gcm_iv_inc1_dma_addr = 0; 1383 areq_ctx->gcm_iv_inc1_dma_addr = 0;
1392 rc = -ENOMEM; 1384 rc = -ENOMEM;
1393 goto aead_map_failure; 1385 goto aead_map_failure;
@@ -1399,9 +1391,8 @@ int ssi_buffer_mgr_map_aead_request(
1399 DMA_TO_DEVICE); 1391 DMA_TO_DEVICE);
1400 1392
1401 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc2_dma_addr))) { 1393 if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc2_dma_addr))) {
1402 SSI_LOG_ERR("Mapping gcm_iv_inc2 %u B at va=%pK " 1394 dev_err(dev, "Mapping gcm_iv_inc2 %u B at va=%pK for DMA failed\n",
1403 "for DMA failed\n", AES_BLOCK_SIZE, 1395 AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc2));
1404 (areq_ctx->gcm_iv_inc2));
1405 areq_ctx->gcm_iv_inc2_dma_addr = 0; 1396 areq_ctx->gcm_iv_inc2_dma_addr = 0;
1406 rc = -ENOMEM; 1397 rc = -ENOMEM;
1407 goto aead_map_failure; 1398 goto aead_map_failure;
@@ -1481,9 +1472,10 @@ int ssi_buffer_mgr_map_aead_request(
1481 goto aead_map_failure; 1472 goto aead_map_failure;
1482 1473
1483 ssi_buffer_mgr_update_aead_mlli_nents(drvdata, req); 1474 ssi_buffer_mgr_update_aead_mlli_nents(drvdata, req);
1484 SSI_LOG_DEBUG("assoc params mn %d\n", areq_ctx->assoc.mlli_nents); 1475 dev_dbg(dev, "assoc params mn %d\n",
1485 SSI_LOG_DEBUG("src params mn %d\n", areq_ctx->src.mlli_nents); 1476 areq_ctx->assoc.mlli_nents);
1486 SSI_LOG_DEBUG("dst params mn %d\n", areq_ctx->dst.mlli_nents); 1477 dev_dbg(dev, "src params mn %d\n", areq_ctx->src.mlli_nents);
1478 dev_dbg(dev, "dst params mn %d\n", areq_ctx->dst.mlli_nents);
1487 } 1479 }
1488 return 0; 1480 return 0;
1489 1481
@@ -1496,7 +1488,7 @@ int ssi_buffer_mgr_map_hash_request_final(
1496 struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update) 1488 struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update)
1497{ 1489{
1498 struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; 1490 struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx;
1499 struct device *dev = &drvdata->plat_dev->dev; 1491 struct device *dev = drvdata_to_dev(drvdata);
1500 u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 : 1492 u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 :
1501 areq_ctx->buff0; 1493 areq_ctx->buff0;
1502 u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt : 1494 u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt :
@@ -1507,11 +1499,8 @@ int ssi_buffer_mgr_map_hash_request_final(
1507 u32 dummy = 0; 1499 u32 dummy = 0;
1508 u32 mapped_nents = 0; 1500 u32 mapped_nents = 0;
1509 1501
1510 SSI_LOG_DEBUG(" final params : curr_buff=%pK " 1502 dev_dbg(dev, "final params : curr_buff=%pK curr_buff_cnt=0x%X nbytes = 0x%X src=%pK curr_index=%u\n",
1511 "curr_buff_cnt=0x%X nbytes = 0x%X " 1503 curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index);
1512 "src=%pK curr_index=%u\n",
1513 curr_buff, *curr_buff_cnt, nbytes,
1514 src, areq_ctx->buff_index);
1515 /* Init the type of the dma buffer */ 1504 /* Init the type of the dma buffer */
1516 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL; 1505 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL;
1517 mlli_params->curr_pool = NULL; 1506 mlli_params->curr_pool = NULL;
@@ -1557,7 +1546,7 @@ int ssi_buffer_mgr_map_hash_request_final(
1557 if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { 1546 if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) {
1558 mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; 1547 mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
1559 /* add the src data to the sg_data */ 1548 /* add the src data to the sg_data */
1560 ssi_buffer_mgr_add_scatterlist_entry(&sg_data, 1549 ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data,
1561 areq_ctx->in_nents, 1550 areq_ctx->in_nents,
1562 src, nbytes, 0, true, 1551 src, nbytes, 0, true,
1563 &areq_ctx->mlli_nents); 1552 &areq_ctx->mlli_nents);
@@ -1568,8 +1557,8 @@ int ssi_buffer_mgr_map_hash_request_final(
1568 } 1557 }
1569 /* change the buffer index for the unmap function */ 1558 /* change the buffer index for the unmap function */
1570 areq_ctx->buff_index = (areq_ctx->buff_index ^ 1); 1559 areq_ctx->buff_index = (areq_ctx->buff_index ^ 1);
1571 SSI_LOG_DEBUG("areq_ctx->data_dma_buf_type = %s\n", 1560 dev_dbg(dev, "areq_ctx->data_dma_buf_type = %s\n",
1572 GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type)); 1561 GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type));
1573 return 0; 1562 return 0;
1574 1563
1575fail_unmap_din: 1564fail_unmap_din:
@@ -1586,7 +1575,7 @@ int ssi_buffer_mgr_map_hash_request_update(
1586 struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size) 1575 struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size)
1587{ 1576{
1588 struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; 1577 struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx;
1589 struct device *dev = &drvdata->plat_dev->dev; 1578 struct device *dev = drvdata_to_dev(drvdata);
1590 u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 : 1579 u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 :
1591 areq_ctx->buff0; 1580 areq_ctx->buff0;
1592 u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt : 1581 u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt :
@@ -1604,11 +1593,8 @@ int ssi_buffer_mgr_map_hash_request_update(
1604 u32 dummy = 0; 1593 u32 dummy = 0;
1605 u32 mapped_nents = 0; 1594 u32 mapped_nents = 0;
1606 1595
1607 SSI_LOG_DEBUG(" update params : curr_buff=%pK " 1596 dev_dbg(dev, " update params : curr_buff=%pK curr_buff_cnt=0x%X nbytes=0x%X src=%pK curr_index=%u\n",
1608 "curr_buff_cnt=0x%X nbytes=0x%X " 1597 curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index);
1609 "src=%pK curr_index=%u\n",
1610 curr_buff, *curr_buff_cnt, nbytes,
1611 src, areq_ctx->buff_index);
1612 /* Init the type of the dma buffer */ 1598 /* Init the type of the dma buffer */
1613 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL; 1599 areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL;
1614 mlli_params->curr_pool = NULL; 1600 mlli_params->curr_pool = NULL;
@@ -1617,14 +1603,11 @@ int ssi_buffer_mgr_map_hash_request_update(
1617 areq_ctx->in_nents = 0; 1603 areq_ctx->in_nents = 0;
1618 1604
1619 if (unlikely(total_in_len < block_size)) { 1605 if (unlikely(total_in_len < block_size)) {
1620 SSI_LOG_DEBUG(" less than one block: curr_buff=%pK " 1606 dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n",
1621 "*curr_buff_cnt=0x%X copy_to=%pK\n", 1607 curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]);
1622 curr_buff, *curr_buff_cnt,
1623 &curr_buff[*curr_buff_cnt]);
1624 areq_ctx->in_nents = 1608 areq_ctx->in_nents =
1625 ssi_buffer_mgr_get_sgl_nents(src, 1609 ssi_buffer_mgr_get_sgl_nents(dev, src, nbytes, &dummy,
1626 nbytes, 1610 NULL);
1627 &dummy, NULL);
1628 sg_copy_to_buffer(src, areq_ctx->in_nents, 1611 sg_copy_to_buffer(src, areq_ctx->in_nents,
1629 &curr_buff[*curr_buff_cnt], nbytes); 1612 &curr_buff[*curr_buff_cnt], nbytes);
1630 *curr_buff_cnt += nbytes; 1613 *curr_buff_cnt += nbytes;
@@ -1636,17 +1619,15 @@ int ssi_buffer_mgr_map_hash_request_update(
1636 /* update data len */ 1619 /* update data len */
1637 update_data_len = total_in_len - *next_buff_cnt; 1620 update_data_len = total_in_len - *next_buff_cnt;
1638 1621
1639 SSI_LOG_DEBUG(" temp length : *next_buff_cnt=0x%X " 1622 dev_dbg(dev, " temp length : *next_buff_cnt=0x%X update_data_len=0x%X\n",
1640 "update_data_len=0x%X\n",
1641 *next_buff_cnt, update_data_len); 1623 *next_buff_cnt, update_data_len);
1642 1624
1643 /* Copy the new residue to next buffer */ 1625 /* Copy the new residue to next buffer */
1644 if (*next_buff_cnt != 0) { 1626 if (*next_buff_cnt != 0) {
1645 SSI_LOG_DEBUG(" handle residue: next buff %pK skip data %u" 1627 dev_dbg(dev, " handle residue: next buff %pK skip data %u residue %u\n",
1646 " residue %u\n", next_buff, 1628 next_buff, (update_data_len - *curr_buff_cnt),
1647 (update_data_len - *curr_buff_cnt), 1629 *next_buff_cnt);
1648 *next_buff_cnt); 1630 ssi_buffer_mgr_copy_scatterlist_portion(dev, next_buff, src,
1649 ssi_buffer_mgr_copy_scatterlist_portion(next_buff, src,
1650 (update_data_len - *curr_buff_cnt), 1631 (update_data_len - *curr_buff_cnt),
1651 nbytes, SSI_SG_TO_BUF); 1632 nbytes, SSI_SG_TO_BUF);
1652 /* change the buffer index for next operation */ 1633 /* change the buffer index for next operation */
@@ -1688,7 +1669,7 @@ int ssi_buffer_mgr_map_hash_request_update(
1688 if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { 1669 if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) {
1689 mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; 1670 mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
1690 /* add the src data to the sg_data */ 1671 /* add the src data to the sg_data */
1691 ssi_buffer_mgr_add_scatterlist_entry(&sg_data, 1672 ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data,
1692 areq_ctx->in_nents, 1673 areq_ctx->in_nents,
1693 src, 1674 src,
1694 (update_data_len - *curr_buff_cnt), 1675 (update_data_len - *curr_buff_cnt),
@@ -1725,29 +1706,26 @@ void ssi_buffer_mgr_unmap_hash_request(
1725 *allocated and should be released 1706 *allocated and should be released
1726 */ 1707 */
1727 if (areq_ctx->mlli_params.curr_pool) { 1708 if (areq_ctx->mlli_params.curr_pool) {
1728 SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n", 1709 dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n",
1729 areq_ctx->mlli_params.mlli_dma_addr, 1710 &areq_ctx->mlli_params.mlli_dma_addr,
1730 areq_ctx->mlli_params.mlli_virt_addr); 1711 areq_ctx->mlli_params.mlli_virt_addr);
1731 dma_pool_free(areq_ctx->mlli_params.curr_pool, 1712 dma_pool_free(areq_ctx->mlli_params.curr_pool,
1732 areq_ctx->mlli_params.mlli_virt_addr, 1713 areq_ctx->mlli_params.mlli_virt_addr,
1733 areq_ctx->mlli_params.mlli_dma_addr); 1714 areq_ctx->mlli_params.mlli_dma_addr);
1734 } 1715 }
1735 1716
1736 if ((src) && likely(areq_ctx->in_nents != 0)) { 1717 if ((src) && likely(areq_ctx->in_nents != 0)) {
1737 SSI_LOG_DEBUG("Unmapped sg src: virt=%pK dma=%pad len=0x%X\n", 1718 dev_dbg(dev, "Unmapped sg src: virt=%pK dma=%pad len=0x%X\n",
1738 sg_virt(src), 1719 sg_virt(src), &sg_dma_address(src), sg_dma_len(src));
1739 sg_dma_address(src),
1740 sg_dma_len(src));
1741 dma_unmap_sg(dev, src, 1720 dma_unmap_sg(dev, src,
1742 areq_ctx->in_nents, DMA_TO_DEVICE); 1721 areq_ctx->in_nents, DMA_TO_DEVICE);
1743 } 1722 }
1744 1723
1745 if (*prev_len != 0) { 1724 if (*prev_len != 0) {
1746 SSI_LOG_DEBUG("Unmapped buffer: areq_ctx->buff_sg=%pK" 1725 dev_dbg(dev, "Unmapped buffer: areq_ctx->buff_sg=%pK dma=%pad len 0x%X\n",
1747 " dma=%pad len 0x%X\n", 1726 sg_virt(areq_ctx->buff_sg),
1748 sg_virt(areq_ctx->buff_sg), 1727 &sg_dma_address(areq_ctx->buff_sg),
1749 sg_dma_address(areq_ctx->buff_sg), 1728 sg_dma_len(areq_ctx->buff_sg));
1750 sg_dma_len(areq_ctx->buff_sg));
1751 dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); 1729 dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE);
1752 if (!do_revert) { 1730 if (!do_revert) {
1753 /* clean the previous data length for update operation */ 1731 /* clean the previous data length for update operation */
@@ -1761,7 +1739,7 @@ void ssi_buffer_mgr_unmap_hash_request(
1761int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) 1739int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
1762{ 1740{
1763 struct buff_mgr_handle *buff_mgr_handle; 1741 struct buff_mgr_handle *buff_mgr_handle;
1764 struct device *dev = &drvdata->plat_dev->dev; 1742 struct device *dev = drvdata_to_dev(drvdata);
1765 1743
1766 buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL); 1744 buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL);
1767 if (!buff_mgr_handle) 1745 if (!buff_mgr_handle)
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h
index 41f5223730f8..1032f25edcab 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.h
+++ b/drivers/staging/ccree/ssi_buffer_mgr.h
@@ -80,7 +80,10 @@ int ssi_buffer_mgr_map_hash_request_update(struct ssi_drvdata *drvdata, void *ct
80 80
81void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert); 81void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert);
82 82
83void ssi_buffer_mgr_copy_scatterlist_portion(u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum ssi_sg_cpy_direct direct); 83void ssi_buffer_mgr_copy_scatterlist_portion(struct device *dev, u8 *dest,
84 struct scatterlist *sg,
85 u32 to_skip, u32 end,
86 enum ssi_sg_cpy_direct direct);
84 87
85void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len); 88void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len);
86 89
diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 8d31a93fd8b7..ee85cbf7c9ae 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -181,45 +181,42 @@ static int ssi_blkcipher_init(struct crypto_tfm *tfm)
181 struct crypto_alg *alg = tfm->__crt_alg; 181 struct crypto_alg *alg = tfm->__crt_alg;
182 struct ssi_crypto_alg *ssi_alg = 182 struct ssi_crypto_alg *ssi_alg =
183 container_of(alg, struct ssi_crypto_alg, crypto_alg); 183 container_of(alg, struct ssi_crypto_alg, crypto_alg);
184 struct device *dev; 184 struct device *dev = drvdata_to_dev(ssi_alg->drvdata);
185 int rc = 0; 185 int rc = 0;
186 unsigned int max_key_buf_size = get_max_keysize(tfm); 186 unsigned int max_key_buf_size = get_max_keysize(tfm);
187 187
188 SSI_LOG_DEBUG("Initializing context @%p for %s\n", 188 dev_dbg(dev, "Initializing context @%p for %s\n", ctx_p,
189 ctx_p, crypto_tfm_alg_name(tfm)); 189 crypto_tfm_alg_name(tfm));
190 190
191 ctx_p->cipher_mode = ssi_alg->cipher_mode; 191 ctx_p->cipher_mode = ssi_alg->cipher_mode;
192 ctx_p->flow_mode = ssi_alg->flow_mode; 192 ctx_p->flow_mode = ssi_alg->flow_mode;
193 ctx_p->drvdata = ssi_alg->drvdata; 193 ctx_p->drvdata = ssi_alg->drvdata;
194 dev = &ctx_p->drvdata->plat_dev->dev;
195 194
196 /* Allocate key buffer, cache line aligned */ 195 /* Allocate key buffer, cache line aligned */
197 ctx_p->user.key = kmalloc(max_key_buf_size, GFP_KERNEL | GFP_DMA); 196 ctx_p->user.key = kmalloc(max_key_buf_size, GFP_KERNEL | GFP_DMA);
198 if (!ctx_p->user.key) { 197 if (!ctx_p->user.key)
199 SSI_LOG_ERR("Allocating key buffer in context failed\n"); 198 return -ENOMEM;
200 rc = -ENOMEM; 199
201 } 200 dev_dbg(dev, "Allocated key buffer in context. key=@%p\n",
202 SSI_LOG_DEBUG("Allocated key buffer in context. key=@%p\n", 201 ctx_p->user.key);
203 ctx_p->user.key);
204 202
205 /* Map key buffer */ 203 /* Map key buffer */
206 ctx_p->user.key_dma_addr = dma_map_single(dev, (void *)ctx_p->user.key, 204 ctx_p->user.key_dma_addr = dma_map_single(dev, (void *)ctx_p->user.key,
207 max_key_buf_size, 205 max_key_buf_size,
208 DMA_TO_DEVICE); 206 DMA_TO_DEVICE);
209 if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) { 207 if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) {
210 SSI_LOG_ERR("Mapping Key %u B at va=%pK for DMA failed\n", 208 dev_err(dev, "Mapping Key %u B at va=%pK for DMA failed\n",
211 max_key_buf_size, ctx_p->user.key); 209 max_key_buf_size, ctx_p->user.key);
212 return -ENOMEM; 210 return -ENOMEM;
213 } 211 }
214 SSI_LOG_DEBUG("Mapped key %u B at va=%pK to dma=%pad\n", 212 dev_dbg(dev, "Mapped key %u B at va=%pK to dma=%pad\n",
215 max_key_buf_size, ctx_p->user.key, 213 max_key_buf_size, ctx_p->user.key, &ctx_p->user.key_dma_addr);
216 ctx_p->user.key_dma_addr);
217 214
218 if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) { 215 if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
219 /* Alloc hash tfm for essiv */ 216 /* Alloc hash tfm for essiv */
220 ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0); 217 ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0);
221 if (IS_ERR(ctx_p->shash_tfm)) { 218 if (IS_ERR(ctx_p->shash_tfm)) {
222 SSI_LOG_ERR("Error allocating hash tfm for ESSIV.\n"); 219 dev_err(dev, "Error allocating hash tfm for ESSIV.\n");
223 return PTR_ERR(ctx_p->shash_tfm); 220 return PTR_ERR(ctx_p->shash_tfm);
224 } 221 }
225 } 222 }
@@ -230,11 +227,11 @@ static int ssi_blkcipher_init(struct crypto_tfm *tfm)
230static void ssi_blkcipher_exit(struct crypto_tfm *tfm) 227static void ssi_blkcipher_exit(struct crypto_tfm *tfm)
231{ 228{
232 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); 229 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
233 struct device *dev = &ctx_p->drvdata->plat_dev->dev; 230 struct device *dev = drvdata_to_dev(ctx_p->drvdata);
234 unsigned int max_key_buf_size = get_max_keysize(tfm); 231 unsigned int max_key_buf_size = get_max_keysize(tfm);
235 232
236 SSI_LOG_DEBUG("Clearing context @%p for %s\n", 233 dev_dbg(dev, "Clearing context @%p for %s\n",
237 crypto_tfm_ctx(tfm), crypto_tfm_alg_name(tfm)); 234 crypto_tfm_ctx(tfm), crypto_tfm_alg_name(tfm));
238 235
239 if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) { 236 if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
240 /* Free hash tfm for essiv */ 237 /* Free hash tfm for essiv */
@@ -245,12 +242,12 @@ static void ssi_blkcipher_exit(struct crypto_tfm *tfm)
245 /* Unmap key buffer */ 242 /* Unmap key buffer */
246 dma_unmap_single(dev, ctx_p->user.key_dma_addr, max_key_buf_size, 243 dma_unmap_single(dev, ctx_p->user.key_dma_addr, max_key_buf_size,
247 DMA_TO_DEVICE); 244 DMA_TO_DEVICE);
248 SSI_LOG_DEBUG("Unmapped key buffer key_dma_addr=%pad\n", 245 dev_dbg(dev, "Unmapped key buffer key_dma_addr=%pad\n",
249 ctx_p->user.key_dma_addr); 246 &ctx_p->user.key_dma_addr);
250 247
251 /* Free key buffer in context */ 248 /* Free key buffer in context */
252 kfree(ctx_p->user.key); 249 kfree(ctx_p->user.key);
253 SSI_LOG_DEBUG("Free key buffer in context. key=@%p\n", ctx_p->user.key); 250 dev_dbg(dev, "Free key buffer in context. key=@%p\n", ctx_p->user.key);
254} 251}
255 252
256struct tdes_keys { 253struct tdes_keys {
@@ -298,16 +295,14 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
298 unsigned int keylen) 295 unsigned int keylen)
299{ 296{
300 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); 297 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
301 struct device *dev = &ctx_p->drvdata->plat_dev->dev; 298 struct device *dev = drvdata_to_dev(ctx_p->drvdata);
302 u32 tmp[DES_EXPKEY_WORDS]; 299 u32 tmp[DES_EXPKEY_WORDS];
303 unsigned int max_key_buf_size = get_max_keysize(tfm); 300 unsigned int max_key_buf_size = get_max_keysize(tfm);
304 301
305 SSI_LOG_DEBUG("Setting key in context @%p for %s. keylen=%u\n", 302 dev_dbg(dev, "Setting key in context @%p for %s. keylen=%u\n",
306 ctx_p, crypto_tfm_alg_name(tfm), keylen); 303 ctx_p, crypto_tfm_alg_name(tfm), keylen);
307 dump_byte_array("key", (u8 *)key, keylen); 304 dump_byte_array("key", (u8 *)key, keylen);
308 305
309 SSI_LOG_DEBUG("after FIPS check");
310
311 /* STAT_PHASE_0: Init and sanity checks */ 306 /* STAT_PHASE_0: Init and sanity checks */
312 307
313#if SSI_CC_HAS_MULTI2 308#if SSI_CC_HAS_MULTI2
@@ -317,7 +312,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
317#endif /*SSI_CC_HAS_MULTI2*/ 312#endif /*SSI_CC_HAS_MULTI2*/
318 313
319 if (unlikely(validate_keys_sizes(ctx_p, keylen) != 0)) { 314 if (unlikely(validate_keys_sizes(ctx_p, keylen) != 0)) {
320 SSI_LOG_ERR("Unsupported key size %d.\n", keylen); 315 dev_err(dev, "Unsupported key size %d.\n", keylen);
321 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); 316 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
322 return -EINVAL; 317 return -EINVAL;
323 } 318 }
@@ -327,13 +322,14 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
327 struct arm_hw_key_info *hki = (struct arm_hw_key_info *)key; 322 struct arm_hw_key_info *hki = (struct arm_hw_key_info *)key;
328 323
329 if (unlikely(ctx_p->flow_mode != S_DIN_to_AES)) { 324 if (unlikely(ctx_p->flow_mode != S_DIN_to_AES)) {
330 SSI_LOG_ERR("HW key not supported for non-AES flows\n"); 325 dev_err(dev, "HW key not supported for non-AES flows\n");
331 return -EINVAL; 326 return -EINVAL;
332 } 327 }
333 328
334 ctx_p->hw.key1_slot = hw_key_to_cc_hw_key(hki->hw_key1); 329 ctx_p->hw.key1_slot = hw_key_to_cc_hw_key(hki->hw_key1);
335 if (unlikely(ctx_p->hw.key1_slot == END_OF_KEYS)) { 330 if (unlikely(ctx_p->hw.key1_slot == END_OF_KEYS)) {
336 SSI_LOG_ERR("Unsupported hw key1 number (%d)\n", hki->hw_key1); 331 dev_err(dev, "Unsupported hw key1 number (%d)\n",
332 hki->hw_key1);
337 return -EINVAL; 333 return -EINVAL;
338 } 334 }
339 335
@@ -341,18 +337,20 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
341 (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) || 337 (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) ||
342 (ctx_p->cipher_mode == DRV_CIPHER_BITLOCKER)) { 338 (ctx_p->cipher_mode == DRV_CIPHER_BITLOCKER)) {
343 if (unlikely(hki->hw_key1 == hki->hw_key2)) { 339 if (unlikely(hki->hw_key1 == hki->hw_key2)) {
344 SSI_LOG_ERR("Illegal hw key numbers (%d,%d)\n", hki->hw_key1, hki->hw_key2); 340 dev_err(dev, "Illegal hw key numbers (%d,%d)\n",
341 hki->hw_key1, hki->hw_key2);
345 return -EINVAL; 342 return -EINVAL;
346 } 343 }
347 ctx_p->hw.key2_slot = hw_key_to_cc_hw_key(hki->hw_key2); 344 ctx_p->hw.key2_slot = hw_key_to_cc_hw_key(hki->hw_key2);
348 if (unlikely(ctx_p->hw.key2_slot == END_OF_KEYS)) { 345 if (unlikely(ctx_p->hw.key2_slot == END_OF_KEYS)) {
349 SSI_LOG_ERR("Unsupported hw key2 number (%d)\n", hki->hw_key2); 346 dev_err(dev, "Unsupported hw key2 number (%d)\n",
347 hki->hw_key2);
350 return -EINVAL; 348 return -EINVAL;
351 } 349 }
352 } 350 }
353 351
354 ctx_p->keylen = keylen; 352 ctx_p->keylen = keylen;
355 SSI_LOG_DEBUG("ssi_is_hw_key ret 0"); 353 dev_dbg(dev, "ssi_is_hw_key ret 0");
356 354
357 return 0; 355 return 0;
358 } 356 }
@@ -362,19 +360,19 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
362 if (unlikely(!des_ekey(tmp, key)) && 360 if (unlikely(!des_ekey(tmp, key)) &&
363 (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_WEAK_KEY)) { 361 (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_WEAK_KEY)) {
364 tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; 362 tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
365 SSI_LOG_DEBUG("weak DES key"); 363 dev_dbg(dev, "weak DES key");
366 return -EINVAL; 364 return -EINVAL;
367 } 365 }
368 } 366 }
369 if ((ctx_p->cipher_mode == DRV_CIPHER_XTS) && 367 if ((ctx_p->cipher_mode == DRV_CIPHER_XTS) &&
370 xts_check_key(tfm, key, keylen) != 0) { 368 xts_check_key(tfm, key, keylen) != 0) {
371 SSI_LOG_DEBUG("weak XTS key"); 369 dev_dbg(dev, "weak XTS key");
372 return -EINVAL; 370 return -EINVAL;
373 } 371 }
374 if ((ctx_p->flow_mode == S_DIN_to_DES) && 372 if ((ctx_p->flow_mode == S_DIN_to_DES) &&
375 (keylen == DES3_EDE_KEY_SIZE) && 373 (keylen == DES3_EDE_KEY_SIZE) &&
376 ssi_verify_3des_keys(key, keylen) != 0) { 374 ssi_verify_3des_keys(key, keylen) != 0) {
377 SSI_LOG_DEBUG("weak 3DES key"); 375 dev_dbg(dev, "weak 3DES key");
378 return -EINVAL; 376 return -EINVAL;
379 } 377 }
380 378
@@ -389,7 +387,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
389 if (ctx_p->key_round_number < CC_MULTI2_MIN_NUM_ROUNDS || 387 if (ctx_p->key_round_number < CC_MULTI2_MIN_NUM_ROUNDS ||
390 ctx_p->key_round_number > CC_MULTI2_MAX_NUM_ROUNDS) { 388 ctx_p->key_round_number > CC_MULTI2_MAX_NUM_ROUNDS) {
391 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); 389 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
392 SSI_LOG_DEBUG("SSI_CC_HAS_MULTI2 einval"); 390 dev_dbg(dev, "SSI_CC_HAS_MULTI2 einval");
393 return -EINVAL; 391 return -EINVAL;
394#endif /*SSI_CC_HAS_MULTI2*/ 392#endif /*SSI_CC_HAS_MULTI2*/
395 } else { 393 } else {
@@ -407,7 +405,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
407 405
408 err = crypto_shash_digest(desc, ctx_p->user.key, key_len, ctx_p->user.key + key_len); 406 err = crypto_shash_digest(desc, ctx_p->user.key, key_len, ctx_p->user.key + key_len);
409 if (err) { 407 if (err) {
410 SSI_LOG_ERR("Failed to hash ESSIV key.\n"); 408 dev_err(dev, "Failed to hash ESSIV key.\n");
411 return err; 409 return err;
412 } 410 }
413 } 411 }
@@ -416,7 +414,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
416 max_key_buf_size, DMA_TO_DEVICE); 414 max_key_buf_size, DMA_TO_DEVICE);
417 ctx_p->keylen = keylen; 415 ctx_p->keylen = keylen;
418 416
419 SSI_LOG_DEBUG("return safely"); 417 dev_dbg(dev, "return safely");
420 return 0; 418 return 0;
421} 419}
422 420
@@ -430,6 +428,7 @@ ssi_blkcipher_create_setup_desc(
430 unsigned int *seq_size) 428 unsigned int *seq_size)
431{ 429{
432 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); 430 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
431 struct device *dev = drvdata_to_dev(ctx_p->drvdata);
433 int cipher_mode = ctx_p->cipher_mode; 432 int cipher_mode = ctx_p->cipher_mode;
434 int flow_mode = ctx_p->flow_mode; 433 int flow_mode = ctx_p->flow_mode;
435 int direction = req_ctx->gen_ctx.op_type; 434 int direction = req_ctx->gen_ctx.op_type;
@@ -540,8 +539,7 @@ ssi_blkcipher_create_setup_desc(
540 (*seq_size)++; 539 (*seq_size)++;
541 break; 540 break;
542 default: 541 default:
543 SSI_LOG_ERR("Unsupported cipher mode (%d)\n", cipher_mode); 542 dev_err(dev, "Unsupported cipher mode (%d)\n", cipher_mode);
544 BUG();
545 } 543 }
546} 544}
547 545
@@ -601,6 +599,7 @@ ssi_blkcipher_create_data_desc(
601 unsigned int *seq_size) 599 unsigned int *seq_size)
602{ 600{
603 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); 601 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
602 struct device *dev = drvdata_to_dev(ctx_p->drvdata);
604 unsigned int flow_mode = ctx_p->flow_mode; 603 unsigned int flow_mode = ctx_p->flow_mode;
605 604
606 switch (ctx_p->flow_mode) { 605 switch (ctx_p->flow_mode) {
@@ -616,15 +615,15 @@ ssi_blkcipher_create_data_desc(
616 break; 615 break;
617#endif /*SSI_CC_HAS_MULTI2*/ 616#endif /*SSI_CC_HAS_MULTI2*/
618 default: 617 default:
619 SSI_LOG_ERR("invalid flow mode, flow_mode = %d\n", flow_mode); 618 dev_err(dev, "invalid flow mode, flow_mode = %d\n", flow_mode);
620 return; 619 return;
621 } 620 }
622 /* Process */ 621 /* Process */
623 if (likely(req_ctx->dma_buf_type == SSI_DMA_BUF_DLLI)) { 622 if (likely(req_ctx->dma_buf_type == SSI_DMA_BUF_DLLI)) {
624 SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n", 623 dev_dbg(dev, " data params addr %pad length 0x%X\n",
625 sg_dma_address(src), nbytes); 624 &sg_dma_address(src), nbytes);
626 SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n", 625 dev_dbg(dev, " data params addr %pad length 0x%X\n",
627 sg_dma_address(dst), nbytes); 626 &sg_dma_address(dst), nbytes);
628 hw_desc_init(&desc[*seq_size]); 627 hw_desc_init(&desc[*seq_size]);
629 set_din_type(&desc[*seq_size], DMA_DLLI, sg_dma_address(src), 628 set_din_type(&desc[*seq_size], DMA_DLLI, sg_dma_address(src),
630 nbytes, NS_BIT); 629 nbytes, NS_BIT);
@@ -637,9 +636,8 @@ ssi_blkcipher_create_data_desc(
637 (*seq_size)++; 636 (*seq_size)++;
638 } else { 637 } else {
639 /* bypass */ 638 /* bypass */
640 SSI_LOG_DEBUG(" bypass params addr %pad " 639 dev_dbg(dev, " bypass params addr %pad length 0x%X addr 0x%08X\n",
641 "length 0x%X addr 0x%08X\n", 640 &req_ctx->mlli_params.mlli_dma_addr,
642 req_ctx->mlli_params.mlli_dma_addr,
643 req_ctx->mlli_params.mlli_len, 641 req_ctx->mlli_params.mlli_len,
644 (unsigned int)ctx_p->drvdata->mlli_sram_addr); 642 (unsigned int)ctx_p->drvdata->mlli_sram_addr);
645 hw_desc_init(&desc[*seq_size]); 643 hw_desc_init(&desc[*seq_size]);
@@ -657,21 +655,18 @@ ssi_blkcipher_create_data_desc(
657 ctx_p->drvdata->mlli_sram_addr, 655 ctx_p->drvdata->mlli_sram_addr,
658 req_ctx->in_mlli_nents, NS_BIT); 656 req_ctx->in_mlli_nents, NS_BIT);
659 if (req_ctx->out_nents == 0) { 657 if (req_ctx->out_nents == 0) {
660 SSI_LOG_DEBUG(" din/dout params addr 0x%08X " 658 dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n",
661 "addr 0x%08X\n", 659 (unsigned int)ctx_p->drvdata->mlli_sram_addr,
662 (unsigned int)ctx_p->drvdata->mlli_sram_addr, 660 (unsigned int)ctx_p->drvdata->mlli_sram_addr);
663 (unsigned int)ctx_p->drvdata->mlli_sram_addr);
664 set_dout_mlli(&desc[*seq_size], 661 set_dout_mlli(&desc[*seq_size],
665 ctx_p->drvdata->mlli_sram_addr, 662 ctx_p->drvdata->mlli_sram_addr,
666 req_ctx->in_mlli_nents, NS_BIT, 663 req_ctx->in_mlli_nents, NS_BIT,
667 (!areq ? 0 : 1)); 664 (!areq ? 0 : 1));
668 } else { 665 } else {
669 SSI_LOG_DEBUG(" din/dout params " 666 dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n",
670 "addr 0x%08X addr 0x%08X\n",
671 (unsigned int)ctx_p->drvdata->mlli_sram_addr, 667 (unsigned int)ctx_p->drvdata->mlli_sram_addr,
672 (unsigned int)ctx_p->drvdata->mlli_sram_addr + 668 (unsigned int)ctx_p->drvdata->mlli_sram_addr +
673 (u32)LLI_ENTRY_BYTE_SIZE * 669 (u32)LLI_ENTRY_BYTE_SIZE * req_ctx->in_nents);
674 req_ctx->in_nents);
675 set_dout_mlli(&desc[*seq_size], 670 set_dout_mlli(&desc[*seq_size],
676 (ctx_p->drvdata->mlli_sram_addr + 671 (ctx_p->drvdata->mlli_sram_addr +
677 (LLI_ENTRY_BYTE_SIZE * 672 (LLI_ENTRY_BYTE_SIZE *
@@ -697,16 +692,10 @@ static int ssi_blkcipher_complete(struct device *dev,
697 void __iomem *cc_base) 692 void __iomem *cc_base)
698{ 693{
699 int completion_error = 0; 694 int completion_error = 0;
700 u32 inflight_counter;
701 struct ablkcipher_request *req = (struct ablkcipher_request *)areq; 695 struct ablkcipher_request *req = (struct ablkcipher_request *)areq;
702 696
703 ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); 697 ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
704 698 kfree(req_ctx->iv);
705 /*Set the inflight couter value to local variable*/
706 inflight_counter = ctx_p->drvdata->inflight_counter;
707 /*Decrease the inflight counter*/
708 if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
709 ctx_p->drvdata->inflight_counter--;
710 699
711 if (areq) { 700 if (areq) {
712 /* 701 /*
@@ -742,20 +731,20 @@ static int ssi_blkcipher_process(
742 enum drv_crypto_direction direction) 731 enum drv_crypto_direction direction)
743{ 732{
744 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); 733 struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
745 struct device *dev = &ctx_p->drvdata->plat_dev->dev; 734 struct device *dev = drvdata_to_dev(ctx_p->drvdata);
746 struct cc_hw_desc desc[MAX_ABLKCIPHER_SEQ_LEN]; 735 struct cc_hw_desc desc[MAX_ABLKCIPHER_SEQ_LEN];
747 struct ssi_crypto_req ssi_req = {}; 736 struct ssi_crypto_req ssi_req = {};
748 int rc, seq_len = 0, cts_restore_flag = 0; 737 int rc, seq_len = 0, cts_restore_flag = 0;
749 738
750 SSI_LOG_DEBUG("%s areq=%p info=%p nbytes=%d\n", 739 dev_dbg(dev, "%s areq=%p info=%p nbytes=%d\n",
751 ((direction == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Encrypt" : "Decrypt"), 740 ((direction == DRV_CRYPTO_DIRECTION_ENCRYPT) ?
752 areq, info, nbytes); 741 "Encrypt" : "Decrypt"), areq, info, nbytes);
753 742
754 /* STAT_PHASE_0: Init and sanity checks */ 743 /* STAT_PHASE_0: Init and sanity checks */
755 744
756 /* TODO: check data length according to mode */ 745 /* TODO: check data length according to mode */
757 if (unlikely(validate_data_size(ctx_p, nbytes))) { 746 if (unlikely(validate_data_size(ctx_p, nbytes))) {
758 SSI_LOG_ERR("Unsupported data size %d.\n", nbytes); 747 dev_err(dev, "Unsupported data size %d.\n", nbytes);
759 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN); 748 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN);
760 rc = -EINVAL; 749 rc = -EINVAL;
761 goto exit_process; 750 goto exit_process;
@@ -765,6 +754,17 @@ static int ssi_blkcipher_process(
765 rc = 0; 754 rc = 0;
766 goto exit_process; 755 goto exit_process;
767 } 756 }
757
758 /* The IV we are handed may be allocted from the stack so
759 * we must copy it to a DMAable buffer before use.
760 */
761 req_ctx->iv = kmalloc(ivsize, GFP_KERNEL);
762 if (!req_ctx->iv) {
763 rc = -ENOMEM;
764 goto exit_process;
765 }
766 memcpy(req_ctx->iv, info, ivsize);
767
768 /*For CTS in case of data size aligned to 16 use CBC mode*/ 768 /*For CTS in case of data size aligned to 16 use CBC mode*/
769 if (((nbytes % AES_BLOCK_SIZE) == 0) && (ctx_p->cipher_mode == DRV_CIPHER_CBC_CTS)) { 769 if (((nbytes % AES_BLOCK_SIZE) == 0) && (ctx_p->cipher_mode == DRV_CIPHER_CBC_CTS)) {
770 ctx_p->cipher_mode = DRV_CIPHER_CBC; 770 ctx_p->cipher_mode = DRV_CIPHER_CBC;
@@ -786,9 +786,11 @@ static int ssi_blkcipher_process(
786 786
787 /* STAT_PHASE_1: Map buffers */ 787 /* STAT_PHASE_1: Map buffers */
788 788
789 rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, info, src, dst); 789 rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx,
790 ivsize, nbytes, req_ctx->iv,
791 src, dst);
790 if (unlikely(rc != 0)) { 792 if (unlikely(rc != 0)) {
791 SSI_LOG_ERR("map_request() failed\n"); 793 dev_err(dev, "map_request() failed\n");
792 goto exit_process; 794 goto exit_process;
793 } 795 }
794 796
@@ -838,8 +840,10 @@ exit_process:
838 if (cts_restore_flag != 0) 840 if (cts_restore_flag != 0)
839 ctx_p->cipher_mode = DRV_CIPHER_CBC_CTS; 841 ctx_p->cipher_mode = DRV_CIPHER_CBC_CTS;
840 842
841 if (rc != -EINPROGRESS) 843 if (rc != -EINPROGRESS) {
842 kfree(req_ctx->backup_info); 844 kfree(req_ctx->backup_info);
845 kfree(req_ctx->iv);
846 }
843 847
844 return rc; 848 return rc;
845} 849}
@@ -1245,16 +1249,15 @@ static struct ssi_alg_template blkcipher_algs[] = {
1245}; 1249};
1246 1250
1247static 1251static
1248struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template *template) 1252struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template
1253 *template, struct device *dev)
1249{ 1254{
1250 struct ssi_crypto_alg *t_alg; 1255 struct ssi_crypto_alg *t_alg;
1251 struct crypto_alg *alg; 1256 struct crypto_alg *alg;
1252 1257
1253 t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); 1258 t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
1254 if (!t_alg) { 1259 if (!t_alg)
1255 SSI_LOG_ERR("failed to allocate t_alg\n");
1256 return ERR_PTR(-ENOMEM); 1260 return ERR_PTR(-ENOMEM);
1257 }
1258 1261
1259 alg = &t_alg->crypto_alg; 1262 alg = &t_alg->crypto_alg;
1260 1263
@@ -1285,10 +1288,6 @@ int ssi_ablkcipher_free(struct ssi_drvdata *drvdata)
1285 struct ssi_crypto_alg *t_alg, *n; 1288 struct ssi_crypto_alg *t_alg, *n;
1286 struct ssi_blkcipher_handle *blkcipher_handle = 1289 struct ssi_blkcipher_handle *blkcipher_handle =
1287 drvdata->blkcipher_handle; 1290 drvdata->blkcipher_handle;
1288 struct device *dev;
1289
1290 dev = &drvdata->plat_dev->dev;
1291
1292 if (blkcipher_handle) { 1291 if (blkcipher_handle) {
1293 /* Remove registered algs */ 1292 /* Remove registered algs */
1294 list_for_each_entry_safe(t_alg, n, 1293 list_for_each_entry_safe(t_alg, n,
@@ -1308,6 +1307,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata)
1308{ 1307{
1309 struct ssi_blkcipher_handle *ablkcipher_handle; 1308 struct ssi_blkcipher_handle *ablkcipher_handle;
1310 struct ssi_crypto_alg *t_alg; 1309 struct ssi_crypto_alg *t_alg;
1310 struct device *dev = drvdata_to_dev(drvdata);
1311 int rc = -ENOMEM; 1311 int rc = -ENOMEM;
1312 int alg; 1312 int alg;
1313 1313
@@ -1315,37 +1315,38 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata)
1315 if (!ablkcipher_handle) 1315 if (!ablkcipher_handle)
1316 return -ENOMEM; 1316 return -ENOMEM;
1317 1317
1318 drvdata->blkcipher_handle = ablkcipher_handle;
1319
1320 INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list); 1318 INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list);
1319 drvdata->blkcipher_handle = ablkcipher_handle;
1321 1320
1322 /* Linux crypto */ 1321 /* Linux crypto */
1323 SSI_LOG_DEBUG("Number of algorithms = %zu\n", ARRAY_SIZE(blkcipher_algs)); 1322 dev_dbg(dev, "Number of algorithms = %zu\n",
1323 ARRAY_SIZE(blkcipher_algs));
1324 for (alg = 0; alg < ARRAY_SIZE(blkcipher_algs); alg++) { 1324 for (alg = 0; alg < ARRAY_SIZE(blkcipher_algs); alg++) {
1325 SSI_LOG_DEBUG("creating %s\n", blkcipher_algs[alg].driver_name); 1325 dev_dbg(dev, "creating %s\n", blkcipher_algs[alg].driver_name);
1326 t_alg = ssi_ablkcipher_create_alg(&blkcipher_algs[alg]); 1326 t_alg = ssi_ablkcipher_create_alg(&blkcipher_algs[alg], dev);
1327 if (IS_ERR(t_alg)) { 1327 if (IS_ERR(t_alg)) {
1328 rc = PTR_ERR(t_alg); 1328 rc = PTR_ERR(t_alg);
1329 SSI_LOG_ERR("%s alg allocation failed\n", 1329 dev_err(dev, "%s alg allocation failed\n",
1330 blkcipher_algs[alg].driver_name); 1330 blkcipher_algs[alg].driver_name);
1331 goto fail0; 1331 goto fail0;
1332 } 1332 }
1333 t_alg->drvdata = drvdata; 1333 t_alg->drvdata = drvdata;
1334 1334
1335 SSI_LOG_DEBUG("registering %s\n", blkcipher_algs[alg].driver_name); 1335 dev_dbg(dev, "registering %s\n",
1336 blkcipher_algs[alg].driver_name);
1336 rc = crypto_register_alg(&t_alg->crypto_alg); 1337 rc = crypto_register_alg(&t_alg->crypto_alg);
1337 SSI_LOG_DEBUG("%s alg registration rc = %x\n", 1338 dev_dbg(dev, "%s alg registration rc = %x\n",
1338 t_alg->crypto_alg.cra_driver_name, rc); 1339 t_alg->crypto_alg.cra_driver_name, rc);
1339 if (unlikely(rc != 0)) { 1340 if (unlikely(rc != 0)) {
1340 SSI_LOG_ERR("%s alg registration failed\n", 1341 dev_err(dev, "%s alg registration failed\n",
1341 t_alg->crypto_alg.cra_driver_name); 1342 t_alg->crypto_alg.cra_driver_name);
1342 kfree(t_alg); 1343 kfree(t_alg);
1343 goto fail0; 1344 goto fail0;
1344 } else { 1345 } else {
1345 list_add_tail(&t_alg->entry, 1346 list_add_tail(&t_alg->entry,
1346 &ablkcipher_handle->blkcipher_alg_list); 1347 &ablkcipher_handle->blkcipher_alg_list);
1347 SSI_LOG_DEBUG("Registered %s\n", 1348 dev_dbg(dev, "Registered %s\n",
1348 t_alg->crypto_alg.cra_driver_name); 1349 t_alg->crypto_alg.cra_driver_name);
1349 } 1350 }
1350 } 1351 }
1351 return 0; 1352 return 0;
diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h
index 296b375d5d89..25e6335c0d94 100644
--- a/drivers/staging/ccree/ssi_cipher.h
+++ b/drivers/staging/ccree/ssi_cipher.h
@@ -27,11 +27,11 @@
27#include "ssi_buffer_mgr.h" 27#include "ssi_buffer_mgr.h"
28 28
29/* Crypto cipher flags */ 29/* Crypto cipher flags */
30#define CC_CRYPTO_CIPHER_KEY_KFDE0 (1 << 0) 30#define CC_CRYPTO_CIPHER_KEY_KFDE0 BIT(0)
31#define CC_CRYPTO_CIPHER_KEY_KFDE1 (1 << 1) 31#define CC_CRYPTO_CIPHER_KEY_KFDE1 BIT(1)
32#define CC_CRYPTO_CIPHER_KEY_KFDE2 (1 << 2) 32#define CC_CRYPTO_CIPHER_KEY_KFDE2 BIT(2)
33#define CC_CRYPTO_CIPHER_KEY_KFDE3 (1 << 3) 33#define CC_CRYPTO_CIPHER_KEY_KFDE3 BIT(3)
34#define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4) 34#define CC_CRYPTO_CIPHER_DU_SIZE_512B BIT(4)
35 35
36#define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3) 36#define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3)
37 37
@@ -43,6 +43,7 @@ struct blkcipher_req_ctx {
43 u32 out_nents; 43 u32 out_nents;
44 u32 out_mlli_nents; 44 u32 out_mlli_nents;
45 u8 *backup_info; /*store iv for generated IV flow*/ 45 u8 *backup_info; /*store iv for generated IV flow*/
46 u8 *iv;
46 bool is_giv; 47 bool is_giv;
47 struct mlli_params mlli_params; 48 struct mlli_params mlli_params;
48}; 49};
@@ -75,7 +76,7 @@ struct arm_hw_key_info {
75 76
76static inline bool ssi_is_hw_key(struct crypto_tfm *tfm) 77static inline bool ssi_is_hw_key(struct crypto_tfm *tfm)
77{ 78{
78 return 0; 79 return false;
79} 80}
80 81
81#endif /* CRYPTO_TFM_REQ_HW_KEY */ 82#endif /* CRYPTO_TFM_REQ_HW_KEY */
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 9c6f1200c130..1a3c481fa92a 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -74,70 +74,46 @@
74#include "ssi_fips.h" 74#include "ssi_fips.h"
75 75
76#ifdef DX_DUMP_BYTES 76#ifdef DX_DUMP_BYTES
77void dump_byte_array(const char *name, const u8 *the_array, unsigned long size) 77void dump_byte_array(const char *name, const u8 *buf, size_t len)
78{ 78{
79 int i, line_offset = 0, ret = 0; 79 char prefix[NAME_LEN];
80 const u8 *cur_byte;
81 char line_buf[80];
82 80
83 if (!the_array) { 81 if (!buf)
84 SSI_LOG_ERR("cannot dump array - NULL pointer\n");
85 return; 82 return;
86 }
87 83
88 ret = snprintf(line_buf, sizeof(line_buf), "%s[%lu]: ", name, size); 84 snprintf(prefix, sizeof(prefix), "%s[%lu]: ", name, len);
89 if (ret < 0) {
90 SSI_LOG_ERR("snprintf returned %d . aborting buffer array dump\n", ret);
91 return;
92 }
93 line_offset = ret;
94 for (i = 0, cur_byte = the_array;
95 (i < size) && (line_offset < sizeof(line_buf)); i++, cur_byte++) {
96 ret = snprintf(line_buf + line_offset,
97 sizeof(line_buf) - line_offset,
98 "0x%02X ", *cur_byte);
99 if (ret < 0) {
100 SSI_LOG_ERR("snprintf returned %d . aborting buffer array dump\n", ret);
101 return;
102 }
103 line_offset += ret;
104 if (line_offset > 75) { /* Cut before line end */
105 SSI_LOG_DEBUG("%s\n", line_buf);
106 line_offset = 0;
107 }
108 }
109 85
110 if (line_offset > 0) /* Dump remaining line */ 86 print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, len,
111 SSI_LOG_DEBUG("%s\n", line_buf); 87 false);
112} 88}
113#endif 89#endif
114 90
115static irqreturn_t cc_isr(int irq, void *dev_id) 91static irqreturn_t cc_isr(int irq, void *dev_id)
116{ 92{
117 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)dev_id; 93 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)dev_id;
118 void __iomem *cc_base = drvdata->cc_base; 94 struct device *dev = drvdata_to_dev(drvdata);
119 u32 irr; 95 u32 irr;
120 u32 imr; 96 u32 imr;
121 97
122 /* STAT_OP_TYPE_GENERIC STAT_PHASE_0: Interrupt */ 98 /* STAT_OP_TYPE_GENERIC STAT_PHASE_0: Interrupt */
123 99
124 /* read the interrupt status */ 100 /* read the interrupt status */
125 irr = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRR)); 101 irr = cc_ioread(drvdata, CC_REG(HOST_IRR));
126 SSI_LOG_DEBUG("Got IRR=0x%08X\n", irr); 102 dev_dbg(dev, "Got IRR=0x%08X\n", irr);
127 if (unlikely(irr == 0)) { /* Probably shared interrupt line */ 103 if (unlikely(irr == 0)) { /* Probably shared interrupt line */
128 SSI_LOG_ERR("Got interrupt with empty IRR\n"); 104 dev_err(dev, "Got interrupt with empty IRR\n");
129 return IRQ_NONE; 105 return IRQ_NONE;
130 } 106 }
131 imr = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR)); 107 imr = cc_ioread(drvdata, CC_REG(HOST_IMR));
132 108
133 /* clear interrupt - must be before processing events */ 109 /* clear interrupt - must be before processing events */
134 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), irr); 110 cc_iowrite(drvdata, CC_REG(HOST_ICR), irr);
135 111
136 drvdata->irq = irr; 112 drvdata->irq = irr;
137 /* Completion interrupt - most probable */ 113 /* Completion interrupt - most probable */
138 if (likely((irr & SSI_COMP_IRQ_MASK) != 0)) { 114 if (likely((irr & SSI_COMP_IRQ_MASK) != 0)) {
139 /* Mask AXI completion interrupt - will be unmasked in Deferred service handler */ 115 /* Mask AXI completion interrupt - will be unmasked in Deferred service handler */
140 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), imr | SSI_COMP_IRQ_MASK); 116 cc_iowrite(drvdata, CC_REG(HOST_IMR), imr | SSI_COMP_IRQ_MASK);
141 irr &= ~SSI_COMP_IRQ_MASK; 117 irr &= ~SSI_COMP_IRQ_MASK;
142 complete_request(drvdata); 118 complete_request(drvdata);
143 } 119 }
@@ -145,7 +121,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
145 /* TEE FIPS interrupt */ 121 /* TEE FIPS interrupt */
146 if (likely((irr & SSI_GPR0_IRQ_MASK) != 0)) { 122 if (likely((irr & SSI_GPR0_IRQ_MASK) != 0)) {
147 /* Mask interrupt - will be unmasked in Deferred service handler */ 123 /* Mask interrupt - will be unmasked in Deferred service handler */
148 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), imr | SSI_GPR0_IRQ_MASK); 124 cc_iowrite(drvdata, CC_REG(HOST_IMR), imr | SSI_GPR0_IRQ_MASK);
149 irr &= ~SSI_GPR0_IRQ_MASK; 125 irr &= ~SSI_GPR0_IRQ_MASK;
150 fips_handler(drvdata); 126 fips_handler(drvdata);
151 } 127 }
@@ -155,14 +131,16 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
155 u32 axi_err; 131 u32 axi_err;
156 132
157 /* Read the AXI error ID */ 133 /* Read the AXI error ID */
158 axi_err = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR)); 134 axi_err = cc_ioread(drvdata, CC_REG(AXIM_MON_ERR));
159 SSI_LOG_DEBUG("AXI completion error: axim_mon_err=0x%08X\n", axi_err); 135 dev_dbg(dev, "AXI completion error: axim_mon_err=0x%08X\n",
136 axi_err);
160 137
161 irr &= ~SSI_AXI_ERR_IRQ_MASK; 138 irr &= ~SSI_AXI_ERR_IRQ_MASK;
162 } 139 }
163 140
164 if (unlikely(irr != 0)) { 141 if (unlikely(irr != 0)) {
165 SSI_LOG_DEBUG("IRR includes unknown cause bits (0x%08X)\n", irr); 142 dev_dbg(dev, "IRR includes unknown cause bits (0x%08X)\n",
143 irr);
166 /* Just warning */ 144 /* Just warning */
167 } 145 }
168 146
@@ -172,48 +150,48 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
172int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) 150int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe)
173{ 151{
174 unsigned int val, cache_params; 152 unsigned int val, cache_params;
175 void __iomem *cc_base = drvdata->cc_base; 153 struct device *dev = drvdata_to_dev(drvdata);
176 154
177 /* Unmask all AXI interrupt sources AXI_CFG1 register */ 155 /* Unmask all AXI interrupt sources AXI_CFG1 register */
178 val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG)); 156 val = cc_ioread(drvdata, CC_REG(AXIM_CFG));
179 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG), val & ~SSI_AXI_IRQ_MASK); 157 cc_iowrite(drvdata, CC_REG(AXIM_CFG), val & ~SSI_AXI_IRQ_MASK);
180 SSI_LOG_DEBUG("AXIM_CFG=0x%08X\n", CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG))); 158 dev_dbg(dev, "AXIM_CFG=0x%08X\n",
159 cc_ioread(drvdata, CC_REG(AXIM_CFG)));
181 160
182 /* Clear all pending interrupts */ 161 /* Clear all pending interrupts */
183 val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRR)); 162 val = cc_ioread(drvdata, CC_REG(HOST_IRR));
184 SSI_LOG_DEBUG("IRR=0x%08X\n", val); 163 dev_dbg(dev, "IRR=0x%08X\n", val);
185 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), val); 164 cc_iowrite(drvdata, CC_REG(HOST_ICR), val);
186 165
187 /* Unmask relevant interrupt cause */ 166 /* Unmask relevant interrupt cause */
188 val = (~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | SSI_GPR0_IRQ_MASK)); 167 val = (unsigned int)(~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK |
189 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), val); 168 SSI_GPR0_IRQ_MASK));
169 cc_iowrite(drvdata, CC_REG(HOST_IMR), val);
190 170
191#ifdef DX_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET 171#ifdef DX_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET
192#ifdef DX_IRQ_DELAY 172#ifdef DX_IRQ_DELAY
193 /* Set CC IRQ delay */ 173 /* Set CC IRQ delay */
194 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL), 174 cc_iowrite(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL), DX_IRQ_DELAY);
195 DX_IRQ_DELAY);
196#endif 175#endif
197 if (CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL)) > 0) { 176 if (cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)) > 0) {
198 SSI_LOG_DEBUG("irq_delay=%d CC cycles\n", 177 dev_dbg(dev, "irq_delay=%d CC cycles\n",
199 CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL))); 178 cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)));
200 } 179 }
201#endif 180#endif
202 181
203 cache_params = (drvdata->coherent ? CC_COHERENT_CACHE_PARAMS : 0x0); 182 cache_params = (drvdata->coherent ? CC_COHERENT_CACHE_PARAMS : 0x0);
204 183
205 val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS)); 184 val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS));
206 185
207 if (is_probe) 186 if (is_probe)
208 SSI_LOG_INFO("Cache params previous: 0x%08X\n", val); 187 dev_info(dev, "Cache params previous: 0x%08X\n", val);
209 188
210 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS), 189 cc_iowrite(drvdata, CC_REG(AXIM_CACHE_PARAMS), cache_params);
211 cache_params); 190 val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS));
212 val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS));
213 191
214 if (is_probe) 192 if (is_probe)
215 SSI_LOG_INFO("Cache params current: 0x%08X (expect: 0x%08X)\n", 193 dev_info(dev, "Cache params current: 0x%08X (expect: 0x%08X)\n",
216 val, cache_params); 194 val, cache_params);
217 195
218 return 0; 196 return 0;
219} 197}
@@ -222,181 +200,172 @@ static int init_cc_resources(struct platform_device *plat_dev)
222{ 200{
223 struct resource *req_mem_cc_regs = NULL; 201 struct resource *req_mem_cc_regs = NULL;
224 void __iomem *cc_base = NULL; 202 void __iomem *cc_base = NULL;
225 bool irq_registered = false; 203 struct ssi_drvdata *new_drvdata;
226 struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata),
227 GFP_KERNEL);
228 struct device *dev = &plat_dev->dev; 204 struct device *dev = &plat_dev->dev;
229 struct device_node *np = dev->of_node; 205 struct device_node *np = dev->of_node;
230 u32 signature_val; 206 u32 signature_val;
207 dma_addr_t dma_mask;
231 int rc = 0; 208 int rc = 0;
232 209
233 if (unlikely(!new_drvdata)) { 210 new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL);
234 SSI_LOG_ERR("Failed to allocate drvdata"); 211 if (!new_drvdata)
235 rc = -ENOMEM; 212 return -ENOMEM;
236 goto init_cc_res_err; 213
237 } 214 platform_set_drvdata(plat_dev, new_drvdata);
215 new_drvdata->plat_dev = plat_dev;
238 216
239 new_drvdata->clk = of_clk_get(np, 0); 217 new_drvdata->clk = of_clk_get(np, 0);
240 new_drvdata->coherent = of_dma_is_coherent(np); 218 new_drvdata->coherent = of_dma_is_coherent(np);
241 219
242 /*Initialize inflight counter used in dx_ablkcipher_secure_complete used for count of BYSPASS blocks operations*/
243 new_drvdata->inflight_counter = 0;
244
245 dev_set_drvdata(&plat_dev->dev, new_drvdata);
246 /* Get device resources */ 220 /* Get device resources */
247 /* First CC registers space */ 221 /* First CC registers space */
248 new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); 222 req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
249 if (unlikely(!new_drvdata->res_mem)) {
250 SSI_LOG_ERR("Failed getting IO memory resource\n");
251 rc = -ENODEV;
252 goto init_cc_res_err;
253 }
254 SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n",
255 new_drvdata->res_mem->name,
256 new_drvdata->res_mem->start,
257 new_drvdata->res_mem->end);
258 /* Map registers space */ 223 /* Map registers space */
259 req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); 224 new_drvdata->cc_base = devm_ioremap_resource(dev, req_mem_cc_regs);
260 if (unlikely(!req_mem_cc_regs)) { 225 if (IS_ERR(new_drvdata->cc_base)) {
261 SSI_LOG_ERR("Couldn't allocate registers memory region at " 226 dev_err(dev, "Failed to ioremap registers");
262 "0x%08X\n", (unsigned int)new_drvdata->res_mem->start); 227 return PTR_ERR(new_drvdata->cc_base);
263 rc = -EBUSY;
264 goto init_cc_res_err;
265 } 228 }
266 cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); 229
267 if (unlikely(!cc_base)) { 230 dev_dbg(dev, "Got MEM resource (%s): %pR\n", req_mem_cc_regs->name,
268 SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", 231 req_mem_cc_regs);
269 (unsigned int)new_drvdata->res_mem->start, 232 dev_dbg(dev, "CC registers mapped from %pa to 0x%p\n",
270 (unsigned int)resource_size(new_drvdata->res_mem)); 233 &req_mem_cc_regs->start, new_drvdata->cc_base);
271 rc = -ENOMEM; 234
272 goto init_cc_res_err; 235 cc_base = new_drvdata->cc_base;
273 }
274 SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base);
275 new_drvdata->cc_base = cc_base;
276 236
277 /* Then IRQ */ 237 /* Then IRQ */
278 new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); 238 new_drvdata->irq = platform_get_irq(plat_dev, 0);
279 if (unlikely(!new_drvdata->res_irq)) { 239 if (new_drvdata->irq < 0) {
280 SSI_LOG_ERR("Failed getting IRQ resource\n"); 240 dev_err(dev, "Failed getting IRQ resource\n");
281 rc = -ENODEV; 241 return new_drvdata->irq;
282 goto init_cc_res_err;
283 }
284 rc = request_irq(new_drvdata->res_irq->start, cc_isr,
285 IRQF_SHARED, "arm_cc7x", new_drvdata);
286 if (unlikely(rc != 0)) {
287 SSI_LOG_ERR("Could not register to interrupt %llu\n",
288 (unsigned long long)new_drvdata->res_irq->start);
289 goto init_cc_res_err;
290 } 242 }
291 init_completion(&new_drvdata->icache_setup_completion);
292 243
293 irq_registered = true; 244 rc = devm_request_irq(dev, new_drvdata->irq, cc_isr,
294 SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", 245 IRQF_SHARED, "arm_cc7x", new_drvdata);
295 new_drvdata->res_irq->name, 246 if (rc) {
296 (unsigned long long)new_drvdata->res_irq->start); 247 dev_err(dev, "Could not register to interrupt %d\n",
248 new_drvdata->irq);
249 return rc;
250 }
251 dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq);
297 252
298 new_drvdata->plat_dev = plat_dev; 253 if (!plat_dev->dev.dma_mask)
254 plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask;
299 255
300 rc = cc_clk_on(new_drvdata); 256 dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
301 if (rc) 257 while (dma_mask > 0x7fffffffUL) {
302 goto init_cc_res_err; 258 if (dma_supported(&plat_dev->dev, dma_mask)) {
259 rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
260 if (!rc)
261 break;
262 }
263 dma_mask >>= 1;
264 }
303 265
304 if (!new_drvdata->plat_dev->dev.dma_mask) 266 if (rc) {
305 new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; 267 dev_err(dev, "Failed in dma_set_mask, mask=%par\n",
268 &dma_mask);
269 return rc;
270 }
306 271
307 if (!new_drvdata->plat_dev->dev.coherent_dma_mask) 272 rc = cc_clk_on(new_drvdata);
308 new_drvdata->plat_dev->dev.coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); 273 if (rc) {
274 dev_err(dev, "Failed to enable clock");
275 return rc;
276 }
309 277
310 /* Verify correct mapping */ 278 /* Verify correct mapping */
311 signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); 279 signature_val = cc_ioread(new_drvdata, CC_REG(HOST_SIGNATURE));
312 if (signature_val != DX_DEV_SIGNATURE) { 280 if (signature_val != DX_DEV_SIGNATURE) {
313 SSI_LOG_ERR("Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", 281 dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n",
314 signature_val, (u32)DX_DEV_SIGNATURE); 282 signature_val, (u32)DX_DEV_SIGNATURE);
315 rc = -EINVAL; 283 rc = -EINVAL;
316 goto init_cc_res_err; 284 goto post_clk_err;
317 } 285 }
318 SSI_LOG_DEBUG("CC SIGNATURE=0x%08X\n", signature_val); 286 dev_dbg(dev, "CC SIGNATURE=0x%08X\n", signature_val);
319 287
320 /* Display HW versions */ 288 /* Display HW versions */
321 SSI_LOG(KERN_INFO, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n", SSI_DEV_NAME_STR, 289 dev_info(dev, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n",
322 CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_VERSION)), DRV_MODULE_VERSION); 290 SSI_DEV_NAME_STR,
291 cc_ioread(new_drvdata, CC_REG(HOST_VERSION)),
292 DRV_MODULE_VERSION);
323 293
324 rc = init_cc_regs(new_drvdata, true); 294 rc = init_cc_regs(new_drvdata, true);
325 if (unlikely(rc != 0)) { 295 if (unlikely(rc != 0)) {
326 SSI_LOG_ERR("init_cc_regs failed\n"); 296 dev_err(dev, "init_cc_regs failed\n");
327 goto init_cc_res_err; 297 goto post_clk_err;
328 } 298 }
329 299
330#ifdef ENABLE_CC_SYSFS 300#ifdef ENABLE_CC_SYSFS
331 rc = ssi_sysfs_init(&plat_dev->dev.kobj, new_drvdata); 301 rc = ssi_sysfs_init(&dev->kobj, new_drvdata);
332 if (unlikely(rc != 0)) { 302 if (unlikely(rc != 0)) {
333 SSI_LOG_ERR("init_stat_db failed\n"); 303 dev_err(dev, "init_stat_db failed\n");
334 goto init_cc_res_err; 304 goto post_regs_err;
335 } 305 }
336#endif 306#endif
337 307
308 rc = ssi_fips_init(new_drvdata);
309 if (unlikely(rc != 0)) {
310 dev_err(dev, "SSI_FIPS_INIT failed 0x%x\n", rc);
311 goto post_sysfs_err;
312 }
338 rc = ssi_sram_mgr_init(new_drvdata); 313 rc = ssi_sram_mgr_init(new_drvdata);
339 if (unlikely(rc != 0)) { 314 if (unlikely(rc != 0)) {
340 SSI_LOG_ERR("ssi_sram_mgr_init failed\n"); 315 dev_err(dev, "ssi_sram_mgr_init failed\n");
341 goto init_cc_res_err; 316 goto post_fips_init_err;
342 } 317 }
343 318
344 new_drvdata->mlli_sram_addr = 319 new_drvdata->mlli_sram_addr =
345 ssi_sram_mgr_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE); 320 ssi_sram_mgr_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE);
346 if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { 321 if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) {
347 SSI_LOG_ERR("Failed to alloc MLLI Sram buffer\n"); 322 dev_err(dev, "Failed to alloc MLLI Sram buffer\n");
348 rc = -ENOMEM; 323 rc = -ENOMEM;
349 goto init_cc_res_err; 324 goto post_sram_mgr_err;
350 } 325 }
351 326
352 rc = request_mgr_init(new_drvdata); 327 rc = request_mgr_init(new_drvdata);
353 if (unlikely(rc != 0)) { 328 if (unlikely(rc != 0)) {
354 SSI_LOG_ERR("request_mgr_init failed\n"); 329 dev_err(dev, "request_mgr_init failed\n");
355 goto init_cc_res_err; 330 goto post_sram_mgr_err;
356 } 331 }
357 332
358 rc = ssi_buffer_mgr_init(new_drvdata); 333 rc = ssi_buffer_mgr_init(new_drvdata);
359 if (unlikely(rc != 0)) { 334 if (unlikely(rc != 0)) {
360 SSI_LOG_ERR("buffer_mgr_init failed\n"); 335 dev_err(dev, "buffer_mgr_init failed\n");
361 goto init_cc_res_err; 336 goto post_req_mgr_err;
362 } 337 }
363 338
364 rc = ssi_power_mgr_init(new_drvdata); 339 rc = ssi_power_mgr_init(new_drvdata);
365 if (unlikely(rc != 0)) { 340 if (unlikely(rc != 0)) {
366 SSI_LOG_ERR("ssi_power_mgr_init failed\n"); 341 dev_err(dev, "ssi_power_mgr_init failed\n");
367 goto init_cc_res_err; 342 goto post_buf_mgr_err;
368 }
369
370 rc = ssi_fips_init(new_drvdata);
371 if (unlikely(rc != 0)) {
372 SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc);
373 goto init_cc_res_err;
374 } 343 }
375 344
376 rc = ssi_ivgen_init(new_drvdata); 345 rc = ssi_ivgen_init(new_drvdata);
377 if (unlikely(rc != 0)) { 346 if (unlikely(rc != 0)) {
378 SSI_LOG_ERR("ssi_ivgen_init failed\n"); 347 dev_err(dev, "ssi_ivgen_init failed\n");
379 goto init_cc_res_err; 348 goto post_power_mgr_err;
380 } 349 }
381 350
382 /* Allocate crypto algs */ 351 /* Allocate crypto algs */
383 rc = ssi_ablkcipher_alloc(new_drvdata); 352 rc = ssi_ablkcipher_alloc(new_drvdata);
384 if (unlikely(rc != 0)) { 353 if (unlikely(rc != 0)) {
385 SSI_LOG_ERR("ssi_ablkcipher_alloc failed\n"); 354 dev_err(dev, "ssi_ablkcipher_alloc failed\n");
386 goto init_cc_res_err; 355 goto post_ivgen_err;
387 } 356 }
388 357
389 /* hash must be allocated before aead since hash exports APIs */ 358 /* hash must be allocated before aead since hash exports APIs */
390 rc = ssi_hash_alloc(new_drvdata); 359 rc = ssi_hash_alloc(new_drvdata);
391 if (unlikely(rc != 0)) { 360 if (unlikely(rc != 0)) {
392 SSI_LOG_ERR("ssi_hash_alloc failed\n"); 361 dev_err(dev, "ssi_hash_alloc failed\n");
393 goto init_cc_res_err; 362 goto post_cipher_err;
394 } 363 }
395 364
396 rc = ssi_aead_alloc(new_drvdata); 365 rc = ssi_aead_alloc(new_drvdata);
397 if (unlikely(rc != 0)) { 366 if (unlikely(rc != 0)) {
398 SSI_LOG_ERR("ssi_aead_alloc failed\n"); 367 dev_err(dev, "ssi_aead_alloc failed\n");
399 goto init_cc_res_err; 368 goto post_hash_err;
400 } 369 }
401 370
402 /* If we got here and FIPS mode is enabled 371 /* If we got here and FIPS mode is enabled
@@ -407,52 +376,43 @@ static int init_cc_resources(struct platform_device *plat_dev)
407 376
408 return 0; 377 return 0;
409 378
410init_cc_res_err: 379post_hash_err:
411 SSI_LOG_ERR("Freeing CC HW resources!\n"); 380 ssi_hash_free(new_drvdata);
412 381post_cipher_err:
413 if (new_drvdata) { 382 ssi_ablkcipher_free(new_drvdata);
414 ssi_aead_free(new_drvdata); 383post_ivgen_err:
415 ssi_hash_free(new_drvdata); 384 ssi_ivgen_fini(new_drvdata);
416 ssi_ablkcipher_free(new_drvdata); 385post_power_mgr_err:
417 ssi_ivgen_fini(new_drvdata); 386 ssi_power_mgr_fini(new_drvdata);
418 ssi_power_mgr_fini(new_drvdata); 387post_buf_mgr_err:
419 ssi_buffer_mgr_fini(new_drvdata); 388 ssi_buffer_mgr_fini(new_drvdata);
420 request_mgr_fini(new_drvdata); 389post_req_mgr_err:
421 ssi_sram_mgr_fini(new_drvdata); 390 request_mgr_fini(new_drvdata);
422 ssi_fips_fini(new_drvdata); 391post_sram_mgr_err:
392 ssi_sram_mgr_fini(new_drvdata);
393post_fips_init_err:
394 ssi_fips_fini(new_drvdata);
395post_sysfs_err:
423#ifdef ENABLE_CC_SYSFS 396#ifdef ENABLE_CC_SYSFS
424 ssi_sysfs_fini(); 397 ssi_sysfs_fini();
425#endif 398#endif
426 399post_regs_err:
427 if (req_mem_cc_regs) { 400 fini_cc_regs(new_drvdata);
428 if (irq_registered) { 401post_clk_err:
429 free_irq(new_drvdata->res_irq->start, new_drvdata); 402 cc_clk_off(new_drvdata);
430 new_drvdata->res_irq = NULL;
431 iounmap(cc_base);
432 new_drvdata->cc_base = NULL;
433 }
434 release_mem_region(new_drvdata->res_mem->start,
435 resource_size(new_drvdata->res_mem));
436 new_drvdata->res_mem = NULL;
437 }
438 kfree(new_drvdata);
439 dev_set_drvdata(&plat_dev->dev, NULL);
440 }
441
442 return rc; 403 return rc;
443} 404}
444 405
445void fini_cc_regs(struct ssi_drvdata *drvdata) 406void fini_cc_regs(struct ssi_drvdata *drvdata)
446{ 407{
447 /* Mask all interrupts */ 408 /* Mask all interrupts */
448 WRITE_REGISTER(drvdata->cc_base + 409 cc_iowrite(drvdata, CC_REG(HOST_IMR), 0xFFFFFFFF);
449 CC_REG_OFFSET(HOST_RGF, HOST_IMR), 0xFFFFFFFF);
450} 410}
451 411
452static void cleanup_cc_resources(struct platform_device *plat_dev) 412static void cleanup_cc_resources(struct platform_device *plat_dev)
453{ 413{
454 struct ssi_drvdata *drvdata = 414 struct ssi_drvdata *drvdata =
455 (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev); 415 (struct ssi_drvdata *)platform_get_drvdata(plat_dev);
456 416
457 ssi_aead_free(drvdata); 417 ssi_aead_free(drvdata);
458 ssi_hash_free(drvdata); 418 ssi_hash_free(drvdata);
@@ -466,22 +426,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
466#ifdef ENABLE_CC_SYSFS 426#ifdef ENABLE_CC_SYSFS
467 ssi_sysfs_fini(); 427 ssi_sysfs_fini();
468#endif 428#endif
469
470 fini_cc_regs(drvdata); 429 fini_cc_regs(drvdata);
471 cc_clk_off(drvdata); 430 cc_clk_off(drvdata);
472 free_irq(drvdata->res_irq->start, drvdata);
473 drvdata->res_irq = NULL;
474
475 if (drvdata->cc_base) {
476 iounmap(drvdata->cc_base);
477 release_mem_region(drvdata->res_mem->start,
478 resource_size(drvdata->res_mem));
479 drvdata->cc_base = NULL;
480 drvdata->res_mem = NULL;
481 }
482
483 kfree(drvdata);
484 dev_set_drvdata(&plat_dev->dev, NULL);
485} 431}
486 432
487int cc_clk_on(struct ssi_drvdata *drvdata) 433int cc_clk_on(struct ssi_drvdata *drvdata)
@@ -514,18 +460,19 @@ void cc_clk_off(struct ssi_drvdata *drvdata)
514static int cc7x_probe(struct platform_device *plat_dev) 460static int cc7x_probe(struct platform_device *plat_dev)
515{ 461{
516 int rc; 462 int rc;
463 struct device *dev = &plat_dev->dev;
517#if defined(CONFIG_ARM) && defined(CC_DEBUG) 464#if defined(CONFIG_ARM) && defined(CC_DEBUG)
518 u32 ctr, cacheline_size; 465 u32 ctr, cacheline_size;
519 466
520 asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr)); 467 asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr));
521 cacheline_size = 4 << ((ctr >> 16) & 0xf); 468 cacheline_size = 4 << ((ctr >> 16) & 0xf);
522 SSI_LOG_DEBUG("CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = %u\n", 469 dev_dbg(dev, "CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = %u\n",
523 cacheline_size, L1_CACHE_BYTES); 470 cacheline_size, L1_CACHE_BYTES);
524 471
525 asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (ctr)); 472 asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (ctr));
526 SSI_LOG_DEBUG("Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, Part 0x%03X, Rev r%dp%d\n", 473 dev_dbg(dev, "Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, Part 0x%03X, Rev r%dp%d\n",
527 (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF, 474 (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF,
528 (ctr >> 20) & 0xF, ctr & 0xF); 475 (ctr >> 20) & 0xF, ctr & 0xF);
529#endif 476#endif
530 477
531 /* Map registers space */ 478 /* Map registers space */
@@ -533,18 +480,20 @@ static int cc7x_probe(struct platform_device *plat_dev)
533 if (rc != 0) 480 if (rc != 0)
534 return rc; 481 return rc;
535 482
536 SSI_LOG(KERN_INFO, "ARM cc7x_ree device initialized\n"); 483 dev_info(dev, "ARM ccree device initialized\n");
537 484
538 return 0; 485 return 0;
539} 486}
540 487
541static int cc7x_remove(struct platform_device *plat_dev) 488static int cc7x_remove(struct platform_device *plat_dev)
542{ 489{
543 SSI_LOG_DEBUG("Releasing cc7x resources...\n"); 490 struct device *dev = &plat_dev->dev;
491
492 dev_dbg(dev, "Releasing cc7x resources...\n");
544 493
545 cleanup_cc_resources(plat_dev); 494 cleanup_cc_resources(plat_dev);
546 495
547 SSI_LOG(KERN_INFO, "ARM cc7x_ree device terminated\n"); 496 dev_info(dev, "ARM ccree device terminated\n");
548 497
549 return 0; 498 return 0;
550} 499}
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index b6ad89ae9bee..94c755cafb47 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -37,13 +37,11 @@
37#include <crypto/hash.h> 37#include <crypto/hash.h>
38#include <linux/version.h> 38#include <linux/version.h>
39#include <linux/clk.h> 39#include <linux/clk.h>
40#include <linux/platform_device.h>
40 41
41/* Registers definitions from shared/hw/ree_include */ 42/* Registers definitions from shared/hw/ree_include */
42#include "dx_reg_base_host.h"
43#include "dx_host.h" 43#include "dx_host.h"
44#include "cc_regs.h"
45#include "dx_reg_common.h" 44#include "dx_reg_common.h"
46#include "cc_hal.h"
47#define CC_SUPPORT_SHA DX_DEV_SHA_MAX 45#define CC_SUPPORT_SHA DX_DEV_SHA_MAX
48#include "cc_crypto_ctx.h" 46#include "cc_crypto_ctx.h"
49#include "ssi_sysfs.h" 47#include "ssi_sysfs.h"
@@ -68,12 +66,19 @@
68#define SSI_AXI_IRQ_MASK ((1 << DX_AXIM_CFG_BRESPMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \ 66#define SSI_AXI_IRQ_MASK ((1 << DX_AXIM_CFG_BRESPMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \
69 (1 << DX_AXIM_CFG_INFLTMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_COMPMASK_BIT_SHIFT)) 67 (1 << DX_AXIM_CFG_INFLTMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_COMPMASK_BIT_SHIFT))
70 68
71#define SSI_AXI_ERR_IRQ_MASK (1 << DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) 69#define SSI_AXI_ERR_IRQ_MASK BIT(DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT)
72 70
73#define SSI_COMP_IRQ_MASK (1 << DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) 71#define SSI_COMP_IRQ_MASK BIT(DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT)
72
73#define AXIM_MON_COMP_VALUE GENMASK(DX_AXIM_MON_COMP_VALUE_BIT_SIZE + \
74 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT, \
75 DX_AXIM_MON_COMP_VALUE_BIT_SHIFT)
76
77/* Register name mangling macro */
78#define CC_REG(reg_name) DX_ ## reg_name ## _REG_OFFSET
74 79
75/* TEE FIPS status interrupt */ 80/* TEE FIPS status interrupt */
76#define SSI_GPR0_IRQ_MASK (1 << DX_HOST_IRR_GPR0_BIT_SHIFT) 81#define SSI_GPR0_IRQ_MASK BIT(DX_HOST_IRR_GPR0_BIT_SHIFT)
77 82
78#define SSI_CRA_PRIO 3000 83#define SSI_CRA_PRIO 3000
79 84
@@ -90,19 +95,6 @@
90 * field in the HW descriptor. The DMA engine +8 that value. 95 * field in the HW descriptor. The DMA engine +8 that value.
91 */ 96 */
92 97
93/* Logging macros */
94#define SSI_LOG(level, format, ...) \
95 printk(level "cc715ree::%s: " format, __func__, ##__VA_ARGS__)
96#define SSI_LOG_ERR(format, ...) SSI_LOG(KERN_ERR, format, ##__VA_ARGS__)
97#define SSI_LOG_WARNING(format, ...) SSI_LOG(KERN_WARNING, format, ##__VA_ARGS__)
98#define SSI_LOG_NOTICE(format, ...) SSI_LOG(KERN_NOTICE, format, ##__VA_ARGS__)
99#define SSI_LOG_INFO(format, ...) SSI_LOG(KERN_INFO, format, ##__VA_ARGS__)
100#ifdef CC_DEBUG
101#define SSI_LOG_DEBUG(format, ...) SSI_LOG(KERN_DEBUG, format, ##__VA_ARGS__)
102#else /* Debug log messages are removed at compile time for non-DEBUG config. */
103#define SSI_LOG_DEBUG(format, ...) do {} while (0)
104#endif
105
106#define MIN(a, b) (((a) < (b)) ? (a) : (b)) 98#define MIN(a, b) (((a) < (b)) ? (a) : (b))
107#define MAX(a, b) (((a) > (b)) ? (a) : (b)) 99#define MAX(a, b) (((a) > (b)) ? (a) : (b))
108 100
@@ -128,10 +120,8 @@ struct ssi_crypto_req {
128 * @fw_ver: SeP loaded firmware version 120 * @fw_ver: SeP loaded firmware version
129 */ 121 */
130struct ssi_drvdata { 122struct ssi_drvdata {
131 struct resource *res_mem;
132 struct resource *res_irq;
133 void __iomem *cc_base; 123 void __iomem *cc_base;
134 unsigned int irq; 124 int irq;
135 u32 irq_mask; 125 u32 irq_mask;
136 u32 fw_ver; 126 u32 fw_ver;
137 /* Calibration time of start/stop 127 /* Calibration time of start/stop
@@ -140,7 +130,6 @@ struct ssi_drvdata {
140 u32 monitor_null_cycles; 130 u32 monitor_null_cycles;
141 struct platform_device *plat_dev; 131 struct platform_device *plat_dev;
142 ssi_sram_addr_t mlli_sram_addr; 132 ssi_sram_addr_t mlli_sram_addr;
143 struct completion icache_setup_completion;
144 void *buff_mgr_handle; 133 void *buff_mgr_handle;
145 void *hash_handle; 134 void *hash_handle;
146 void *aead_handle; 135 void *aead_handle;
@@ -149,7 +138,6 @@ struct ssi_drvdata {
149 void *fips_handle; 138 void *fips_handle;
150 void *ivgen_handle; 139 void *ivgen_handle;
151 void *sram_mgr_handle; 140 void *sram_mgr_handle;
152 u32 inflight_counter;
153 struct clk *clk; 141 struct clk *clk;
154 bool coherent; 142 bool coherent;
155}; 143};
@@ -187,11 +175,16 @@ struct async_gen_req_ctx {
187 enum drv_crypto_direction op_type; 175 enum drv_crypto_direction op_type;
188}; 176};
189 177
178static inline struct device *drvdata_to_dev(struct ssi_drvdata *drvdata)
179{
180 return &drvdata->plat_dev->dev;
181}
182
190#ifdef DX_DUMP_BYTES 183#ifdef DX_DUMP_BYTES
191void dump_byte_array(const char *name, const u8 *the_array, unsigned long size); 184void dump_byte_array(const char *name, const u8 *the_array, unsigned long size);
192#else 185#else
193#define dump_byte_array(name, array, size) do { \ 186static inline void dump_byte_array(const char *name, const u8 *the_array,
194} while (0); 187 unsigned long size) {};
195#endif 188#endif
196 189
197int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe); 190int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe);
@@ -199,5 +192,15 @@ void fini_cc_regs(struct ssi_drvdata *drvdata);
199int cc_clk_on(struct ssi_drvdata *drvdata); 192int cc_clk_on(struct ssi_drvdata *drvdata);
200void cc_clk_off(struct ssi_drvdata *drvdata); 193void cc_clk_off(struct ssi_drvdata *drvdata);
201 194
195static inline void cc_iowrite(struct ssi_drvdata *drvdata, u32 reg, u32 val)
196{
197 iowrite32(val, (drvdata->cc_base + reg));
198}
199
200static inline u32 cc_ioread(struct ssi_drvdata *drvdata, u32 reg)
201{
202 return ioread32(drvdata->cc_base + reg);
203}
204
202#endif /*__SSI_DRIVER_H__*/ 205#endif /*__SSI_DRIVER_H__*/
203 206
diff --git a/drivers/staging/ccree/ssi_fips.c b/drivers/staging/ccree/ssi_fips.c
index 33d53d64603d..4aea99fa129f 100644
--- a/drivers/staging/ccree/ssi_fips.c
+++ b/drivers/staging/ccree/ssi_fips.c
@@ -19,7 +19,6 @@
19 19
20#include "ssi_config.h" 20#include "ssi_config.h"
21#include "ssi_driver.h" 21#include "ssi_driver.h"
22#include "cc_hal.h"
23#include "ssi_fips.h" 22#include "ssi_fips.h"
24 23
25static void fips_dsr(unsigned long devarg); 24static void fips_dsr(unsigned long devarg);
@@ -34,9 +33,8 @@ struct ssi_fips_handle {
34static bool cc_get_tee_fips_status(struct ssi_drvdata *drvdata) 33static bool cc_get_tee_fips_status(struct ssi_drvdata *drvdata)
35{ 34{
36 u32 reg; 35 u32 reg;
37 void __iomem *cc_base = drvdata->cc_base;
38 36
39 reg = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, GPR_HOST)); 37 reg = cc_ioread(drvdata, CC_REG(GPR_HOST));
40 return (reg == (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK)); 38 return (reg == (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK));
41} 39}
42 40
@@ -46,12 +44,11 @@ static bool cc_get_tee_fips_status(struct ssi_drvdata *drvdata)
46 */ 44 */
47void cc_set_ree_fips_status(struct ssi_drvdata *drvdata, bool status) 45void cc_set_ree_fips_status(struct ssi_drvdata *drvdata, bool status)
48{ 46{
49 void __iomem *cc_base = drvdata->cc_base;
50 int val = CC_FIPS_SYNC_REE_STATUS; 47 int val = CC_FIPS_SYNC_REE_STATUS;
51 48
52 val |= (status ? CC_FIPS_SYNC_MODULE_OK : CC_FIPS_SYNC_MODULE_ERROR); 49 val |= (status ? CC_FIPS_SYNC_MODULE_OK : CC_FIPS_SYNC_MODULE_ERROR);
53 50
54 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_GPR0), val); 51 cc_iowrite(drvdata, CC_REG(HOST_GPR0), val);
55} 52}
56 53
57void ssi_fips_fini(struct ssi_drvdata *drvdata) 54void ssi_fips_fini(struct ssi_drvdata *drvdata)
@@ -76,41 +73,42 @@ void fips_handler(struct ssi_drvdata *drvdata)
76 tasklet_schedule(&fips_handle_ptr->tasklet); 73 tasklet_schedule(&fips_handle_ptr->tasklet);
77} 74}
78 75
79static inline void tee_fips_error(void) 76static inline void tee_fips_error(struct device *dev)
80{ 77{
81 if (fips_enabled) 78 if (fips_enabled)
82 panic("ccree: TEE reported cryptographic error in fips mode!\n"); 79 panic("ccree: TEE reported cryptographic error in fips mode!\n");
83 else 80 else
84 SSI_LOG_ERR("TEE reported error!\n"); 81 dev_err(dev, "TEE reported error!\n");
85} 82}
86 83
87/* Deferred service handler, run as interrupt-fired tasklet */ 84/* Deferred service handler, run as interrupt-fired tasklet */
88static void fips_dsr(unsigned long devarg) 85static void fips_dsr(unsigned long devarg)
89{ 86{
90 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg; 87 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg;
91 void __iomem *cc_base = drvdata->cc_base; 88 struct device *dev = drvdata_to_dev(drvdata);
92 u32 irq, state, val; 89 u32 irq, state, val;
93 90
94 irq = (drvdata->irq & (SSI_GPR0_IRQ_MASK)); 91 irq = (drvdata->irq & (SSI_GPR0_IRQ_MASK));
95 92
96 if (irq) { 93 if (irq) {
97 state = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, GPR_HOST)); 94 state = cc_ioread(drvdata, CC_REG(GPR_HOST));
98 95
99 if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK)) 96 if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK))
100 tee_fips_error(); 97 tee_fips_error(dev);
101 } 98 }
102 99
103 /* after verifing that there is nothing to do, 100 /* after verifing that there is nothing to do,
104 * unmask AXI completion interrupt. 101 * unmask AXI completion interrupt.
105 */ 102 */
106 val = (CC_REG_OFFSET(HOST_RGF, HOST_IMR) & ~irq); 103 val = (CC_REG(HOST_IMR) & ~irq);
107 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), val); 104 cc_iowrite(drvdata, CC_REG(HOST_IMR), val);
108} 105}
109 106
110/* The function called once at driver entry point .*/ 107/* The function called once at driver entry point .*/
111int ssi_fips_init(struct ssi_drvdata *p_drvdata) 108int ssi_fips_init(struct ssi_drvdata *p_drvdata)
112{ 109{
113 struct ssi_fips_handle *fips_h; 110 struct ssi_fips_handle *fips_h;
111 struct device *dev = drvdata_to_dev(p_drvdata);
114 112
115 fips_h = kzalloc(sizeof(*fips_h), GFP_KERNEL); 113 fips_h = kzalloc(sizeof(*fips_h), GFP_KERNEL);
116 if (!fips_h) 114 if (!fips_h)
@@ -118,11 +116,11 @@ int ssi_fips_init(struct ssi_drvdata *p_drvdata)
118 116
119 p_drvdata->fips_handle = fips_h; 117 p_drvdata->fips_handle = fips_h;
120 118
121 SSI_LOG_DEBUG("Initializing fips tasklet\n"); 119 dev_dbg(dev, "Initializing fips tasklet\n");
122 tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata); 120 tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata);
123 121
124 if (!cc_get_tee_fips_status(p_drvdata)) 122 if (!cc_get_tee_fips_status(p_drvdata))
125 tee_fips_error(); 123 tee_fips_error(dev);
126 124
127 return 0; 125 return 0;
128} 126}
diff --git a/drivers/staging/ccree/ssi_fips.h b/drivers/staging/ccree/ssi_fips.h
index 369ddf9478e7..63bcca7f3af9 100644
--- a/drivers/staging/ccree/ssi_fips.h
+++ b/drivers/staging/ccree/ssi_fips.h
@@ -40,8 +40,8 @@ static inline int ssi_fips_init(struct ssi_drvdata *p_drvdata)
40} 40}
41 41
42static inline void ssi_fips_fini(struct ssi_drvdata *drvdata) {} 42static inline void ssi_fips_fini(struct ssi_drvdata *drvdata) {}
43void cc_set_ree_fips_status(struct ssi_drvdata *drvdata, bool ok) {} 43static inline void cc_set_ree_fips_status(struct ssi_drvdata *drvdata, bool ok) {}
44void fips_handler(struct ssi_drvdata *drvdata) {} 44static inline void fips_handler(struct ssi_drvdata *drvdata) {}
45 45
46#endif /* CONFIG_CRYPTO_FIPS */ 46#endif /* CONFIG_CRYPTO_FIPS */
47 47
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 13291aeaf350..d79090ed7f9c 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -134,14 +134,13 @@ static int ssi_hash_map_result(struct device *dev,
134 digestsize, 134 digestsize,
135 DMA_BIDIRECTIONAL); 135 DMA_BIDIRECTIONAL);
136 if (unlikely(dma_mapping_error(dev, state->digest_result_dma_addr))) { 136 if (unlikely(dma_mapping_error(dev, state->digest_result_dma_addr))) {
137 SSI_LOG_ERR("Mapping digest result buffer %u B for DMA failed\n", 137 dev_err(dev, "Mapping digest result buffer %u B for DMA failed\n",
138 digestsize); 138 digestsize);
139 return -ENOMEM; 139 return -ENOMEM;
140 } 140 }
141 SSI_LOG_DEBUG("Mapped digest result buffer %u B " 141 dev_dbg(dev, "Mapped digest result buffer %u B at va=%pK to dma=%pad\n",
142 "at va=%pK to dma=%pad\n",
143 digestsize, state->digest_result_buff, 142 digestsize, state->digest_result_buff,
144 state->digest_result_dma_addr); 143 &state->digest_result_dma_addr);
145 144
146 return 0; 145 return 0;
147} 146}
@@ -158,54 +157,50 @@ static int ssi_hash_map_request(struct device *dev,
158 int rc = -ENOMEM; 157 int rc = -ENOMEM;
159 158
160 state->buff0 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA); 159 state->buff0 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA);
161 if (!state->buff0) { 160 if (!state->buff0)
162 SSI_LOG_ERR("Allocating buff0 in context failed\n");
163 goto fail0; 161 goto fail0;
164 } 162
165 state->buff1 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA); 163 state->buff1 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA);
166 if (!state->buff1) { 164 if (!state->buff1)
167 SSI_LOG_ERR("Allocating buff1 in context failed\n");
168 goto fail_buff0; 165 goto fail_buff0;
169 } 166
170 state->digest_result_buff = kzalloc(SSI_MAX_HASH_DIGEST_SIZE, GFP_KERNEL | GFP_DMA); 167 state->digest_result_buff = kzalloc(SSI_MAX_HASH_DIGEST_SIZE, GFP_KERNEL | GFP_DMA);
171 if (!state->digest_result_buff) { 168 if (!state->digest_result_buff)
172 SSI_LOG_ERR("Allocating digest_result_buff in context failed\n");
173 goto fail_buff1; 169 goto fail_buff1;
174 } 170
175 state->digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA); 171 state->digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA);
176 if (!state->digest_buff) { 172 if (!state->digest_buff)
177 SSI_LOG_ERR("Allocating digest-buffer in context failed\n");
178 goto fail_digest_result_buff; 173 goto fail_digest_result_buff;
179 }
180 174
181 SSI_LOG_DEBUG("Allocated digest-buffer in context ctx->digest_buff=@%p\n", state->digest_buff); 175 dev_dbg(dev, "Allocated digest-buffer in context ctx->digest_buff=@%p\n",
176 state->digest_buff);
182 if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) { 177 if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) {
183 state->digest_bytes_len = kzalloc(HASH_LEN_SIZE, GFP_KERNEL | GFP_DMA); 178 state->digest_bytes_len = kzalloc(HASH_LEN_SIZE, GFP_KERNEL | GFP_DMA);
184 if (!state->digest_bytes_len) { 179 if (!state->digest_bytes_len)
185 SSI_LOG_ERR("Allocating digest-bytes-len in context failed\n");
186 goto fail1; 180 goto fail1;
187 } 181
188 SSI_LOG_DEBUG("Allocated digest-bytes-len in context state->>digest_bytes_len=@%p\n", state->digest_bytes_len); 182 dev_dbg(dev, "Allocated digest-bytes-len in context state->>digest_bytes_len=@%p\n",
183 state->digest_bytes_len);
189 } else { 184 } else {
190 state->digest_bytes_len = NULL; 185 state->digest_bytes_len = NULL;
191 } 186 }
192 187
193 state->opad_digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA); 188 state->opad_digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA);
194 if (!state->opad_digest_buff) { 189 if (!state->opad_digest_buff)
195 SSI_LOG_ERR("Allocating opad-digest-buffer in context failed\n");
196 goto fail2; 190 goto fail2;
197 } 191
198 SSI_LOG_DEBUG("Allocated opad-digest-buffer in context state->digest_bytes_len=@%p\n", state->opad_digest_buff); 192 dev_dbg(dev, "Allocated opad-digest-buffer in context state->digest_bytes_len=@%p\n",
193 state->opad_digest_buff);
199 194
200 state->digest_buff_dma_addr = dma_map_single(dev, (void *)state->digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL); 195 state->digest_buff_dma_addr = dma_map_single(dev, (void *)state->digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL);
201 if (dma_mapping_error(dev, state->digest_buff_dma_addr)) { 196 if (dma_mapping_error(dev, state->digest_buff_dma_addr)) {
202 SSI_LOG_ERR("Mapping digest len %d B at va=%pK for DMA failed\n", 197 dev_err(dev, "Mapping digest len %d B at va=%pK for DMA failed\n",
203 ctx->inter_digestsize, state->digest_buff); 198 ctx->inter_digestsize, state->digest_buff);
204 goto fail3; 199 goto fail3;
205 } 200 }
206 SSI_LOG_DEBUG("Mapped digest %d B at va=%pK to dma=%pad\n", 201 dev_dbg(dev, "Mapped digest %d B at va=%pK to dma=%pad\n",
207 ctx->inter_digestsize, state->digest_buff, 202 ctx->inter_digestsize, state->digest_buff,
208 state->digest_buff_dma_addr); 203 &state->digest_buff_dma_addr);
209 204
210 if (is_hmac) { 205 if (is_hmac) {
211 dma_sync_single_for_cpu(dev, ctx->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); 206 dma_sync_single_for_cpu(dev, ctx->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL);
@@ -240,7 +235,7 @@ static int ssi_hash_map_request(struct device *dev,
240 235
241 rc = send_request(ctx->drvdata, &ssi_req, &desc, 1, 0); 236 rc = send_request(ctx->drvdata, &ssi_req, &desc, 1, 0);
242 if (unlikely(rc != 0)) { 237 if (unlikely(rc != 0)) {
243 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 238 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
244 goto fail4; 239 goto fail4;
245 } 240 }
246 } 241 }
@@ -248,13 +243,13 @@ static int ssi_hash_map_request(struct device *dev,
248 if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) { 243 if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) {
249 state->digest_bytes_len_dma_addr = dma_map_single(dev, (void *)state->digest_bytes_len, HASH_LEN_SIZE, DMA_BIDIRECTIONAL); 244 state->digest_bytes_len_dma_addr = dma_map_single(dev, (void *)state->digest_bytes_len, HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
250 if (dma_mapping_error(dev, state->digest_bytes_len_dma_addr)) { 245 if (dma_mapping_error(dev, state->digest_bytes_len_dma_addr)) {
251 SSI_LOG_ERR("Mapping digest len %u B at va=%pK for DMA failed\n", 246 dev_err(dev, "Mapping digest len %u B at va=%pK for DMA failed\n",
252 HASH_LEN_SIZE, state->digest_bytes_len); 247 HASH_LEN_SIZE, state->digest_bytes_len);
253 goto fail4; 248 goto fail4;
254 } 249 }
255 SSI_LOG_DEBUG("Mapped digest len %u B at va=%pK to dma=%pad\n", 250 dev_dbg(dev, "Mapped digest len %u B at va=%pK to dma=%pad\n",
256 HASH_LEN_SIZE, state->digest_bytes_len, 251 HASH_LEN_SIZE, state->digest_bytes_len,
257 state->digest_bytes_len_dma_addr); 252 &state->digest_bytes_len_dma_addr);
258 } else { 253 } else {
259 state->digest_bytes_len_dma_addr = 0; 254 state->digest_bytes_len_dma_addr = 0;
260 } 255 }
@@ -262,14 +257,14 @@ static int ssi_hash_map_request(struct device *dev,
262 if (is_hmac && ctx->hash_mode != DRV_HASH_NULL) { 257 if (is_hmac && ctx->hash_mode != DRV_HASH_NULL) {
263 state->opad_digest_dma_addr = dma_map_single(dev, (void *)state->opad_digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL); 258 state->opad_digest_dma_addr = dma_map_single(dev, (void *)state->opad_digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL);
264 if (dma_mapping_error(dev, state->opad_digest_dma_addr)) { 259 if (dma_mapping_error(dev, state->opad_digest_dma_addr)) {
265 SSI_LOG_ERR("Mapping opad digest %d B at va=%pK for DMA failed\n", 260 dev_err(dev, "Mapping opad digest %d B at va=%pK for DMA failed\n",
266 ctx->inter_digestsize, 261 ctx->inter_digestsize,
267 state->opad_digest_buff); 262 state->opad_digest_buff);
268 goto fail5; 263 goto fail5;
269 } 264 }
270 SSI_LOG_DEBUG("Mapped opad digest %d B at va=%pK to dma=%pad\n", 265 dev_dbg(dev, "Mapped opad digest %d B at va=%pK to dma=%pad\n",
271 ctx->inter_digestsize, state->opad_digest_buff, 266 ctx->inter_digestsize, state->opad_digest_buff,
272 state->opad_digest_dma_addr); 267 &state->opad_digest_dma_addr);
273 } else { 268 } else {
274 state->opad_digest_dma_addr = 0; 269 state->opad_digest_dma_addr = 0;
275 } 270 }
@@ -316,22 +311,22 @@ static void ssi_hash_unmap_request(struct device *dev,
316 if (state->digest_buff_dma_addr != 0) { 311 if (state->digest_buff_dma_addr != 0) {
317 dma_unmap_single(dev, state->digest_buff_dma_addr, 312 dma_unmap_single(dev, state->digest_buff_dma_addr,
318 ctx->inter_digestsize, DMA_BIDIRECTIONAL); 313 ctx->inter_digestsize, DMA_BIDIRECTIONAL);
319 SSI_LOG_DEBUG("Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", 314 dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n",
320 state->digest_buff_dma_addr); 315 &state->digest_buff_dma_addr);
321 state->digest_buff_dma_addr = 0; 316 state->digest_buff_dma_addr = 0;
322 } 317 }
323 if (state->digest_bytes_len_dma_addr != 0) { 318 if (state->digest_bytes_len_dma_addr != 0) {
324 dma_unmap_single(dev, state->digest_bytes_len_dma_addr, 319 dma_unmap_single(dev, state->digest_bytes_len_dma_addr,
325 HASH_LEN_SIZE, DMA_BIDIRECTIONAL); 320 HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
326 SSI_LOG_DEBUG("Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n", 321 dev_dbg(dev, "Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n",
327 state->digest_bytes_len_dma_addr); 322 &state->digest_bytes_len_dma_addr);
328 state->digest_bytes_len_dma_addr = 0; 323 state->digest_bytes_len_dma_addr = 0;
329 } 324 }
330 if (state->opad_digest_dma_addr != 0) { 325 if (state->opad_digest_dma_addr != 0) {
331 dma_unmap_single(dev, state->opad_digest_dma_addr, 326 dma_unmap_single(dev, state->opad_digest_dma_addr,
332 ctx->inter_digestsize, DMA_BIDIRECTIONAL); 327 ctx->inter_digestsize, DMA_BIDIRECTIONAL);
333 SSI_LOG_DEBUG("Unmapped opad-digest: opad_digest_dma_addr=%pad\n", 328 dev_dbg(dev, "Unmapped opad-digest: opad_digest_dma_addr=%pad\n",
334 state->opad_digest_dma_addr); 329 &state->opad_digest_dma_addr);
335 state->opad_digest_dma_addr = 0; 330 state->opad_digest_dma_addr = 0;
336 } 331 }
337 332
@@ -352,11 +347,9 @@ static void ssi_hash_unmap_result(struct device *dev,
352 state->digest_result_dma_addr, 347 state->digest_result_dma_addr,
353 digestsize, 348 digestsize,
354 DMA_BIDIRECTIONAL); 349 DMA_BIDIRECTIONAL);
355 SSI_LOG_DEBUG("unmpa digest result buffer " 350 dev_dbg(dev, "unmpa digest result buffer va (%pK) pa (%pad) len %u\n",
356 "va (%pK) pa (%pad) len %u\n", 351 state->digest_result_buff,
357 state->digest_result_buff, 352 &state->digest_result_dma_addr, digestsize);
358 state->digest_result_dma_addr,
359 digestsize);
360 memcpy(result, 353 memcpy(result,
361 state->digest_result_buff, 354 state->digest_result_buff,
362 digestsize); 355 digestsize);
@@ -369,7 +362,7 @@ static void ssi_hash_update_complete(struct device *dev, void *ssi_req, void __i
369 struct ahash_request *req = (struct ahash_request *)ssi_req; 362 struct ahash_request *req = (struct ahash_request *)ssi_req;
370 struct ahash_req_ctx *state = ahash_request_ctx(req); 363 struct ahash_req_ctx *state = ahash_request_ctx(req);
371 364
372 SSI_LOG_DEBUG("req=%pK\n", req); 365 dev_dbg(dev, "req=%pK\n", req);
373 366
374 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); 367 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false);
375 req->base.complete(&req->base, 0); 368 req->base.complete(&req->base, 0);
@@ -383,7 +376,7 @@ static void ssi_hash_digest_complete(struct device *dev, void *ssi_req, void __i
383 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 376 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
384 u32 digestsize = crypto_ahash_digestsize(tfm); 377 u32 digestsize = crypto_ahash_digestsize(tfm);
385 378
386 SSI_LOG_DEBUG("req=%pK\n", req); 379 dev_dbg(dev, "req=%pK\n", req);
387 380
388 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); 381 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false);
389 ssi_hash_unmap_result(dev, state, digestsize, req->result); 382 ssi_hash_unmap_result(dev, state, digestsize, req->result);
@@ -399,7 +392,7 @@ static void ssi_hash_complete(struct device *dev, void *ssi_req, void __iomem *c
399 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 392 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
400 u32 digestsize = crypto_ahash_digestsize(tfm); 393 u32 digestsize = crypto_ahash_digestsize(tfm);
401 394
402 SSI_LOG_DEBUG("req=%pK\n", req); 395 dev_dbg(dev, "req=%pK\n", req);
403 396
404 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); 397 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false);
405 ssi_hash_unmap_result(dev, state, digestsize, req->result); 398 ssi_hash_unmap_result(dev, state, digestsize, req->result);
@@ -414,7 +407,7 @@ static int ssi_hash_digest(struct ahash_req_ctx *state,
414 unsigned int nbytes, u8 *result, 407 unsigned int nbytes, u8 *result,
415 void *async_req) 408 void *async_req)
416{ 409{
417 struct device *dev = &ctx->drvdata->plat_dev->dev; 410 struct device *dev = drvdata_to_dev(ctx->drvdata);
418 bool is_hmac = ctx->is_hmac; 411 bool is_hmac = ctx->is_hmac;
419 struct ssi_crypto_req ssi_req = {}; 412 struct ssi_crypto_req ssi_req = {};
420 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 413 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
@@ -423,20 +416,21 @@ static int ssi_hash_digest(struct ahash_req_ctx *state,
423 int idx = 0; 416 int idx = 0;
424 int rc = 0; 417 int rc = 0;
425 418
426 SSI_LOG_DEBUG("===== %s-digest (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); 419 dev_dbg(dev, "===== %s-digest (%d) ====\n", is_hmac ? "hmac" : "hash",
420 nbytes);
427 421
428 if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { 422 if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) {
429 SSI_LOG_ERR("map_ahash_source() failed\n"); 423 dev_err(dev, "map_ahash_source() failed\n");
430 return -ENOMEM; 424 return -ENOMEM;
431 } 425 }
432 426
433 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 427 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
434 SSI_LOG_ERR("map_ahash_digest() failed\n"); 428 dev_err(dev, "map_ahash_digest() failed\n");
435 return -ENOMEM; 429 return -ENOMEM;
436 } 430 }
437 431
438 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { 432 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) {
439 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 433 dev_err(dev, "map_ahash_request_final() failed\n");
440 return -ENOMEM; 434 return -ENOMEM;
441 } 435 }
442 436
@@ -553,7 +547,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE);
553 if (async_req) { 547 if (async_req) {
554 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 548 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
555 if (unlikely(rc != -EINPROGRESS)) { 549 if (unlikely(rc != -EINPROGRESS)) {
556 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 550 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
557 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 551 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
558 ssi_hash_unmap_result(dev, state, digestsize, result); 552 ssi_hash_unmap_result(dev, state, digestsize, result);
559 ssi_hash_unmap_request(dev, state, ctx); 553 ssi_hash_unmap_request(dev, state, ctx);
@@ -561,7 +555,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE);
561 } else { 555 } else {
562 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 556 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
563 if (rc != 0) { 557 if (rc != 0) {
564 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 558 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
565 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 559 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
566 } else { 560 } else {
567 ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); 561 ssi_buffer_mgr_unmap_hash_request(dev, state, src, false);
@@ -579,14 +573,14 @@ static int ssi_hash_update(struct ahash_req_ctx *state,
579 unsigned int nbytes, 573 unsigned int nbytes,
580 void *async_req) 574 void *async_req)
581{ 575{
582 struct device *dev = &ctx->drvdata->plat_dev->dev; 576 struct device *dev = drvdata_to_dev(ctx->drvdata);
583 struct ssi_crypto_req ssi_req = {}; 577 struct ssi_crypto_req ssi_req = {};
584 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 578 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
585 u32 idx = 0; 579 u32 idx = 0;
586 int rc; 580 int rc;
587 581
588 SSI_LOG_DEBUG("===== %s-update (%d) ====\n", ctx->is_hmac ? 582 dev_dbg(dev, "===== %s-update (%d) ====\n", ctx->is_hmac ?
589 "hmac" : "hash", nbytes); 583 "hmac" : "hash", nbytes);
590 584
591 if (nbytes == 0) { 585 if (nbytes == 0) {
592 /* no real updates required */ 586 /* no real updates required */
@@ -596,12 +590,12 @@ static int ssi_hash_update(struct ahash_req_ctx *state,
596 rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, src, nbytes, block_size); 590 rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, src, nbytes, block_size);
597 if (unlikely(rc)) { 591 if (unlikely(rc)) {
598 if (rc == 1) { 592 if (rc == 1) {
599 SSI_LOG_DEBUG(" data size not require HW update %x\n", 593 dev_dbg(dev, " data size not require HW update %x\n",
600 nbytes); 594 nbytes);
601 /* No hardware updates are required */ 595 /* No hardware updates are required */
602 return 0; 596 return 0;
603 } 597 }
604 SSI_LOG_ERR("map_ahash_request_update() failed\n"); 598 dev_err(dev, "map_ahash_request_update() failed\n");
605 return -ENOMEM; 599 return -ENOMEM;
606 } 600 }
607 601
@@ -653,13 +647,13 @@ static int ssi_hash_update(struct ahash_req_ctx *state,
653 if (async_req) { 647 if (async_req) {
654 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 648 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
655 if (unlikely(rc != -EINPROGRESS)) { 649 if (unlikely(rc != -EINPROGRESS)) {
656 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 650 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
657 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 651 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
658 } 652 }
659 } else { 653 } else {
660 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 654 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
661 if (rc != 0) { 655 if (rc != 0) {
662 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 656 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
663 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 657 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
664 } else { 658 } else {
665 ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); 659 ssi_buffer_mgr_unmap_hash_request(dev, state, src, false);
@@ -676,21 +670,22 @@ static int ssi_hash_finup(struct ahash_req_ctx *state,
676 u8 *result, 670 u8 *result,
677 void *async_req) 671 void *async_req)
678{ 672{
679 struct device *dev = &ctx->drvdata->plat_dev->dev; 673 struct device *dev = drvdata_to_dev(ctx->drvdata);
680 bool is_hmac = ctx->is_hmac; 674 bool is_hmac = ctx->is_hmac;
681 struct ssi_crypto_req ssi_req = {}; 675 struct ssi_crypto_req ssi_req = {};
682 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 676 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
683 int idx = 0; 677 int idx = 0;
684 int rc; 678 int rc;
685 679
686 SSI_LOG_DEBUG("===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); 680 dev_dbg(dev, "===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash",
681 nbytes);
687 682
688 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { 683 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) {
689 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 684 dev_err(dev, "map_ahash_request_final() failed\n");
690 return -ENOMEM; 685 return -ENOMEM;
691 } 686 }
692 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 687 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
693 SSI_LOG_ERR("map_ahash_digest() failed\n"); 688 dev_err(dev, "map_ahash_digest() failed\n");
694 return -ENOMEM; 689 return -ENOMEM;
695 } 690 }
696 691
@@ -783,14 +778,14 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE);
783 if (async_req) { 778 if (async_req) {
784 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 779 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
785 if (unlikely(rc != -EINPROGRESS)) { 780 if (unlikely(rc != -EINPROGRESS)) {
786 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 781 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
787 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 782 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
788 ssi_hash_unmap_result(dev, state, digestsize, result); 783 ssi_hash_unmap_result(dev, state, digestsize, result);
789 } 784 }
790 } else { 785 } else {
791 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 786 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
792 if (rc != 0) { 787 if (rc != 0) {
793 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 788 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
794 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 789 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
795 ssi_hash_unmap_result(dev, state, digestsize, result); 790 ssi_hash_unmap_result(dev, state, digestsize, result);
796 } else { 791 } else {
@@ -810,22 +805,23 @@ static int ssi_hash_final(struct ahash_req_ctx *state,
810 u8 *result, 805 u8 *result,
811 void *async_req) 806 void *async_req)
812{ 807{
813 struct device *dev = &ctx->drvdata->plat_dev->dev; 808 struct device *dev = drvdata_to_dev(ctx->drvdata);
814 bool is_hmac = ctx->is_hmac; 809 bool is_hmac = ctx->is_hmac;
815 struct ssi_crypto_req ssi_req = {}; 810 struct ssi_crypto_req ssi_req = {};
816 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 811 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
817 int idx = 0; 812 int idx = 0;
818 int rc; 813 int rc;
819 814
820 SSI_LOG_DEBUG("===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); 815 dev_dbg(dev, "===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash",
816 nbytes);
821 817
822 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 0) != 0)) { 818 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 0) != 0)) {
823 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 819 dev_err(dev, "map_ahash_request_final() failed\n");
824 return -ENOMEM; 820 return -ENOMEM;
825 } 821 }
826 822
827 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 823 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
828 SSI_LOG_ERR("map_ahash_digest() failed\n"); 824 dev_err(dev, "map_ahash_digest() failed\n");
829 return -ENOMEM; 825 return -ENOMEM;
830 } 826 }
831 827
@@ -927,14 +923,14 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE);
927 if (async_req) { 923 if (async_req) {
928 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 924 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
929 if (unlikely(rc != -EINPROGRESS)) { 925 if (unlikely(rc != -EINPROGRESS)) {
930 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 926 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
931 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 927 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
932 ssi_hash_unmap_result(dev, state, digestsize, result); 928 ssi_hash_unmap_result(dev, state, digestsize, result);
933 } 929 }
934 } else { 930 } else {
935 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 931 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
936 if (rc != 0) { 932 if (rc != 0) {
937 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 933 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
938 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); 934 ssi_buffer_mgr_unmap_hash_request(dev, state, src, true);
939 ssi_hash_unmap_result(dev, state, digestsize, result); 935 ssi_hash_unmap_result(dev, state, digestsize, result);
940 } else { 936 } else {
@@ -948,7 +944,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE);
948 944
949static int ssi_hash_init(struct ahash_req_ctx *state, struct ssi_hash_ctx *ctx) 945static int ssi_hash_init(struct ahash_req_ctx *state, struct ssi_hash_ctx *ctx)
950{ 946{
951 struct device *dev = &ctx->drvdata->plat_dev->dev; 947 struct device *dev = drvdata_to_dev(ctx->drvdata);
952 948
953 state->xcbc_count = 0; 949 state->xcbc_count = 0;
954 950
@@ -970,10 +966,12 @@ static int ssi_hash_setkey(void *hash,
970 int i, idx = 0, rc = 0; 966 int i, idx = 0, rc = 0;
971 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 967 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
972 ssi_sram_addr_t larval_addr; 968 ssi_sram_addr_t larval_addr;
973 969 struct device *dev;
974 SSI_LOG_DEBUG("start keylen: %d", keylen);
975 970
976 ctx = crypto_ahash_ctx(((struct crypto_ahash *)hash)); 971 ctx = crypto_ahash_ctx(((struct crypto_ahash *)hash));
972 dev = drvdata_to_dev(ctx->drvdata);
973 dev_dbg(dev, "start keylen: %d", keylen);
974
977 blocksize = crypto_tfm_alg_blocksize(&((struct crypto_ahash *)hash)->base); 975 blocksize = crypto_tfm_alg_blocksize(&((struct crypto_ahash *)hash)->base);
978 digestsize = crypto_ahash_digestsize(((struct crypto_ahash *)hash)); 976 digestsize = crypto_ahash_digestsize(((struct crypto_ahash *)hash));
979 977
@@ -989,18 +987,16 @@ static int ssi_hash_setkey(void *hash,
989 987
990 if (keylen != 0) { 988 if (keylen != 0) {
991 ctx->key_params.key_dma_addr = dma_map_single( 989 ctx->key_params.key_dma_addr = dma_map_single(
992 &ctx->drvdata->plat_dev->dev, 990 dev, (void *)key,
993 (void *)key,
994 keylen, DMA_TO_DEVICE); 991 keylen, DMA_TO_DEVICE);
995 if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, 992 if (unlikely(dma_mapping_error(dev,
996 ctx->key_params.key_dma_addr))) { 993 ctx->key_params.key_dma_addr))) {
997 SSI_LOG_ERR("Mapping key va=0x%p len=%u for" 994 dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n",
998 " DMA failed\n", key, keylen); 995 key, keylen);
999 return -ENOMEM; 996 return -ENOMEM;
1000 } 997 }
1001 SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " 998 dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n",
1002 "keylen=%u\n", ctx->key_params.key_dma_addr, 999 &ctx->key_params.key_dma_addr, ctx->key_params.keylen);
1003 ctx->key_params.keylen);
1004 1000
1005 if (keylen > blocksize) { 1001 if (keylen > blocksize) {
1006 /* Load hash initial state */ 1002 /* Load hash initial state */
@@ -1079,7 +1075,7 @@ static int ssi_hash_setkey(void *hash,
1079 1075
1080 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); 1076 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0);
1081 if (unlikely(rc != 0)) { 1077 if (unlikely(rc != 0)) {
1082 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 1078 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1083 goto out; 1079 goto out;
1084 } 1080 }
1085 1081
@@ -1139,12 +1135,10 @@ out:
1139 crypto_ahash_set_flags((struct crypto_ahash *)hash, CRYPTO_TFM_RES_BAD_KEY_LEN); 1135 crypto_ahash_set_flags((struct crypto_ahash *)hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
1140 1136
1141 if (ctx->key_params.key_dma_addr) { 1137 if (ctx->key_params.key_dma_addr) {
1142 dma_unmap_single(&ctx->drvdata->plat_dev->dev, 1138 dma_unmap_single(dev, ctx->key_params.key_dma_addr,
1143 ctx->key_params.key_dma_addr,
1144 ctx->key_params.keylen, DMA_TO_DEVICE); 1139 ctx->key_params.keylen, DMA_TO_DEVICE);
1145 SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", 1140 dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n",
1146 ctx->key_params.key_dma_addr, 1141 &ctx->key_params.key_dma_addr, ctx->key_params.keylen);
1147 ctx->key_params.keylen);
1148 } 1142 }
1149 return rc; 1143 return rc;
1150} 1144}
@@ -1154,10 +1148,11 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
1154{ 1148{
1155 struct ssi_crypto_req ssi_req = {}; 1149 struct ssi_crypto_req ssi_req = {};
1156 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1150 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1151 struct device *dev = drvdata_to_dev(ctx->drvdata);
1157 int idx = 0, rc = 0; 1152 int idx = 0, rc = 0;
1158 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 1153 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
1159 1154
1160 SSI_LOG_DEBUG("===== setkey (%d) ====\n", keylen); 1155 dev_dbg(dev, "===== setkey (%d) ====\n", keylen);
1161 1156
1162 switch (keylen) { 1157 switch (keylen) {
1163 case AES_KEYSIZE_128: 1158 case AES_KEYSIZE_128:
@@ -1171,19 +1166,15 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
1171 ctx->key_params.keylen = keylen; 1166 ctx->key_params.keylen = keylen;
1172 1167
1173 ctx->key_params.key_dma_addr = dma_map_single( 1168 ctx->key_params.key_dma_addr = dma_map_single(
1174 &ctx->drvdata->plat_dev->dev, 1169 dev, (void *)key,
1175 (void *)key,
1176 keylen, DMA_TO_DEVICE); 1170 keylen, DMA_TO_DEVICE);
1177 if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, 1171 if (unlikely(dma_mapping_error(dev, ctx->key_params.key_dma_addr))) {
1178 ctx->key_params.key_dma_addr))) { 1172 dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n",
1179 SSI_LOG_ERR("Mapping key va=0x%p len=%u for" 1173 key, keylen);
1180 " DMA failed\n", key, keylen);
1181 return -ENOMEM; 1174 return -ENOMEM;
1182 } 1175 }
1183 SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " 1176 dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n",
1184 "keylen=%u\n", 1177 &ctx->key_params.key_dma_addr, ctx->key_params.keylen);
1185 ctx->key_params.key_dma_addr,
1186 ctx->key_params.keylen);
1187 1178
1188 ctx->is_hmac = true; 1179 ctx->is_hmac = true;
1189 /* 1. Load the AES key */ 1180 /* 1. Load the AES key */
@@ -1226,12 +1217,10 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
1226 if (rc != 0) 1217 if (rc != 0)
1227 crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN); 1218 crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN);
1228 1219
1229 dma_unmap_single(&ctx->drvdata->plat_dev->dev, 1220 dma_unmap_single(dev, ctx->key_params.key_dma_addr,
1230 ctx->key_params.key_dma_addr,
1231 ctx->key_params.keylen, DMA_TO_DEVICE); 1221 ctx->key_params.keylen, DMA_TO_DEVICE);
1232 SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", 1222 dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n",
1233 ctx->key_params.key_dma_addr, 1223 &ctx->key_params.key_dma_addr, ctx->key_params.keylen);
1234 ctx->key_params.keylen);
1235 1224
1236 return rc; 1225 return rc;
1237} 1226}
@@ -1241,8 +1230,9 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash,
1241 const u8 *key, unsigned int keylen) 1230 const u8 *key, unsigned int keylen)
1242{ 1231{
1243 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1232 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1233 struct device *dev = drvdata_to_dev(ctx->drvdata);
1244 1234
1245 SSI_LOG_DEBUG("===== setkey (%d) ====\n", keylen); 1235 dev_dbg(dev, "===== setkey (%d) ====\n", keylen);
1246 1236
1247 ctx->is_hmac = true; 1237 ctx->is_hmac = true;
1248 1238
@@ -1259,16 +1249,14 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash,
1259 1249
1260 /* STAT_PHASE_1: Copy key to ctx */ 1250 /* STAT_PHASE_1: Copy key to ctx */
1261 1251
1262 dma_sync_single_for_cpu(&ctx->drvdata->plat_dev->dev, 1252 dma_sync_single_for_cpu(dev, ctx->opad_tmp_keys_dma_addr,
1263 ctx->opad_tmp_keys_dma_addr,
1264 keylen, DMA_TO_DEVICE); 1253 keylen, DMA_TO_DEVICE);
1265 1254
1266 memcpy(ctx->opad_tmp_keys_buff, key, keylen); 1255 memcpy(ctx->opad_tmp_keys_buff, key, keylen);
1267 if (keylen == 24) 1256 if (keylen == 24)
1268 memset(ctx->opad_tmp_keys_buff + 24, 0, CC_AES_KEY_SIZE_MAX - 24); 1257 memset(ctx->opad_tmp_keys_buff + 24, 0, CC_AES_KEY_SIZE_MAX - 24);
1269 1258
1270 dma_sync_single_for_device(&ctx->drvdata->plat_dev->dev, 1259 dma_sync_single_for_device(dev, ctx->opad_tmp_keys_dma_addr,
1271 ctx->opad_tmp_keys_dma_addr,
1272 keylen, DMA_TO_DEVICE); 1260 keylen, DMA_TO_DEVICE);
1273 1261
1274 ctx->key_params.keylen = keylen; 1262 ctx->key_params.keylen = keylen;
@@ -1279,23 +1267,21 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash,
1279 1267
1280static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) 1268static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx)
1281{ 1269{
1282 struct device *dev = &ctx->drvdata->plat_dev->dev; 1270 struct device *dev = drvdata_to_dev(ctx->drvdata);
1283 1271
1284 if (ctx->digest_buff_dma_addr != 0) { 1272 if (ctx->digest_buff_dma_addr != 0) {
1285 dma_unmap_single(dev, ctx->digest_buff_dma_addr, 1273 dma_unmap_single(dev, ctx->digest_buff_dma_addr,
1286 sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); 1274 sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL);
1287 SSI_LOG_DEBUG("Unmapped digest-buffer: " 1275 dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n",
1288 "digest_buff_dma_addr=%pad\n", 1276 &ctx->digest_buff_dma_addr);
1289 ctx->digest_buff_dma_addr);
1290 ctx->digest_buff_dma_addr = 0; 1277 ctx->digest_buff_dma_addr = 0;
1291 } 1278 }
1292 if (ctx->opad_tmp_keys_dma_addr != 0) { 1279 if (ctx->opad_tmp_keys_dma_addr != 0) {
1293 dma_unmap_single(dev, ctx->opad_tmp_keys_dma_addr, 1280 dma_unmap_single(dev, ctx->opad_tmp_keys_dma_addr,
1294 sizeof(ctx->opad_tmp_keys_buff), 1281 sizeof(ctx->opad_tmp_keys_buff),
1295 DMA_BIDIRECTIONAL); 1282 DMA_BIDIRECTIONAL);
1296 SSI_LOG_DEBUG("Unmapped opad-digest: " 1283 dev_dbg(dev, "Unmapped opad-digest: opad_tmp_keys_dma_addr=%pad\n",
1297 "opad_tmp_keys_dma_addr=%pad\n", 1284 &ctx->opad_tmp_keys_dma_addr);
1298 ctx->opad_tmp_keys_dma_addr);
1299 ctx->opad_tmp_keys_dma_addr = 0; 1285 ctx->opad_tmp_keys_dma_addr = 0;
1300 } 1286 }
1301 1287
@@ -1304,30 +1290,30 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx)
1304 1290
1305static int ssi_hash_alloc_ctx(struct ssi_hash_ctx *ctx) 1291static int ssi_hash_alloc_ctx(struct ssi_hash_ctx *ctx)
1306{ 1292{
1307 struct device *dev = &ctx->drvdata->plat_dev->dev; 1293 struct device *dev = drvdata_to_dev(ctx->drvdata);
1308 1294
1309 ctx->key_params.keylen = 0; 1295 ctx->key_params.keylen = 0;
1310 1296
1311 ctx->digest_buff_dma_addr = dma_map_single(dev, (void *)ctx->digest_buff, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); 1297 ctx->digest_buff_dma_addr = dma_map_single(dev, (void *)ctx->digest_buff, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL);
1312 if (dma_mapping_error(dev, ctx->digest_buff_dma_addr)) { 1298 if (dma_mapping_error(dev, ctx->digest_buff_dma_addr)) {
1313 SSI_LOG_ERR("Mapping digest len %zu B at va=%pK for DMA failed\n", 1299 dev_err(dev, "Mapping digest len %zu B at va=%pK for DMA failed\n",
1314 sizeof(ctx->digest_buff), ctx->digest_buff); 1300 sizeof(ctx->digest_buff), ctx->digest_buff);
1315 goto fail; 1301 goto fail;
1316 } 1302 }
1317 SSI_LOG_DEBUG("Mapped digest %zu B at va=%pK to dma=%pad\n", 1303 dev_dbg(dev, "Mapped digest %zu B at va=%pK to dma=%pad\n",
1318 sizeof(ctx->digest_buff), ctx->digest_buff, 1304 sizeof(ctx->digest_buff), ctx->digest_buff,
1319 ctx->digest_buff_dma_addr); 1305 &ctx->digest_buff_dma_addr);
1320 1306
1321 ctx->opad_tmp_keys_dma_addr = dma_map_single(dev, (void *)ctx->opad_tmp_keys_buff, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL); 1307 ctx->opad_tmp_keys_dma_addr = dma_map_single(dev, (void *)ctx->opad_tmp_keys_buff, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL);
1322 if (dma_mapping_error(dev, ctx->opad_tmp_keys_dma_addr)) { 1308 if (dma_mapping_error(dev, ctx->opad_tmp_keys_dma_addr)) {
1323 SSI_LOG_ERR("Mapping opad digest %zu B at va=%pK for DMA failed\n", 1309 dev_err(dev, "Mapping opad digest %zu B at va=%pK for DMA failed\n",
1324 sizeof(ctx->opad_tmp_keys_buff), 1310 sizeof(ctx->opad_tmp_keys_buff),
1325 ctx->opad_tmp_keys_buff); 1311 ctx->opad_tmp_keys_buff);
1326 goto fail; 1312 goto fail;
1327 } 1313 }
1328 SSI_LOG_DEBUG("Mapped opad_tmp_keys %zu B at va=%pK to dma=%pad\n", 1314 dev_dbg(dev, "Mapped opad_tmp_keys %zu B at va=%pK to dma=%pad\n",
1329 sizeof(ctx->opad_tmp_keys_buff), ctx->opad_tmp_keys_buff, 1315 sizeof(ctx->opad_tmp_keys_buff), ctx->opad_tmp_keys_buff,
1330 ctx->opad_tmp_keys_dma_addr); 1316 &ctx->opad_tmp_keys_dma_addr);
1331 1317
1332 ctx->is_hmac = false; 1318 ctx->is_hmac = false;
1333 return 0; 1319 return 0;
@@ -1361,8 +1347,9 @@ static int ssi_ahash_cra_init(struct crypto_tfm *tfm)
1361static void ssi_hash_cra_exit(struct crypto_tfm *tfm) 1347static void ssi_hash_cra_exit(struct crypto_tfm *tfm)
1362{ 1348{
1363 struct ssi_hash_ctx *ctx = crypto_tfm_ctx(tfm); 1349 struct ssi_hash_ctx *ctx = crypto_tfm_ctx(tfm);
1350 struct device *dev = drvdata_to_dev(ctx->drvdata);
1364 1351
1365 SSI_LOG_DEBUG("ssi_hash_cra_exit"); 1352 dev_dbg(dev, "ssi_hash_cra_exit");
1366 ssi_hash_free_ctx(ctx); 1353 ssi_hash_free_ctx(ctx);
1367} 1354}
1368 1355
@@ -1371,7 +1358,7 @@ static int ssi_mac_update(struct ahash_request *req)
1371 struct ahash_req_ctx *state = ahash_request_ctx(req); 1358 struct ahash_req_ctx *state = ahash_request_ctx(req);
1372 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 1359 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1373 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 1360 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1374 struct device *dev = &ctx->drvdata->plat_dev->dev; 1361 struct device *dev = drvdata_to_dev(ctx->drvdata);
1375 unsigned int block_size = crypto_tfm_alg_blocksize(&tfm->base); 1362 unsigned int block_size = crypto_tfm_alg_blocksize(&tfm->base);
1376 struct ssi_crypto_req ssi_req = {}; 1363 struct ssi_crypto_req ssi_req = {};
1377 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 1364 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
@@ -1388,12 +1375,12 @@ static int ssi_mac_update(struct ahash_request *req)
1388 rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, req->src, req->nbytes, block_size); 1375 rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, req->src, req->nbytes, block_size);
1389 if (unlikely(rc)) { 1376 if (unlikely(rc)) {
1390 if (rc == 1) { 1377 if (rc == 1) {
1391 SSI_LOG_DEBUG(" data size not require HW update %x\n", 1378 dev_dbg(dev, " data size not require HW update %x\n",
1392 req->nbytes); 1379 req->nbytes);
1393 /* No hardware updates are required */ 1380 /* No hardware updates are required */
1394 return 0; 1381 return 0;
1395 } 1382 }
1396 SSI_LOG_ERR("map_ahash_request_update() failed\n"); 1383 dev_err(dev, "map_ahash_request_update() failed\n");
1397 return -ENOMEM; 1384 return -ENOMEM;
1398 } 1385 }
1399 1386
@@ -1420,7 +1407,7 @@ static int ssi_mac_update(struct ahash_request *req)
1420 1407
1421 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 1408 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
1422 if (unlikely(rc != -EINPROGRESS)) { 1409 if (unlikely(rc != -EINPROGRESS)) {
1423 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 1410 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1424 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); 1411 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true);
1425 } 1412 }
1426 return rc; 1413 return rc;
@@ -1431,7 +1418,7 @@ static int ssi_mac_final(struct ahash_request *req)
1431 struct ahash_req_ctx *state = ahash_request_ctx(req); 1418 struct ahash_req_ctx *state = ahash_request_ctx(req);
1432 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 1419 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1433 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 1420 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1434 struct device *dev = &ctx->drvdata->plat_dev->dev; 1421 struct device *dev = drvdata_to_dev(ctx->drvdata);
1435 struct ssi_crypto_req ssi_req = {}; 1422 struct ssi_crypto_req ssi_req = {};
1436 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 1423 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
1437 int idx = 0; 1424 int idx = 0;
@@ -1451,15 +1438,15 @@ static int ssi_mac_final(struct ahash_request *req)
1451 key_len = ctx->key_params.keylen; 1438 key_len = ctx->key_params.keylen;
1452 } 1439 }
1453 1440
1454 SSI_LOG_DEBUG("===== final xcbc reminder (%d) ====\n", rem_cnt); 1441 dev_dbg(dev, "===== final xcbc reminder (%d) ====\n", rem_cnt);
1455 1442
1456 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 0) != 0)) { 1443 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 0) != 0)) {
1457 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 1444 dev_err(dev, "map_ahash_request_final() failed\n");
1458 return -ENOMEM; 1445 return -ENOMEM;
1459 } 1446 }
1460 1447
1461 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 1448 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
1462 SSI_LOG_ERR("map_ahash_digest() failed\n"); 1449 dev_err(dev, "map_ahash_digest() failed\n");
1463 return -ENOMEM; 1450 return -ENOMEM;
1464 } 1451 }
1465 1452
@@ -1530,7 +1517,7 @@ static int ssi_mac_final(struct ahash_request *req)
1530 1517
1531 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 1518 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
1532 if (unlikely(rc != -EINPROGRESS)) { 1519 if (unlikely(rc != -EINPROGRESS)) {
1533 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 1520 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1534 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); 1521 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true);
1535 ssi_hash_unmap_result(dev, state, digestsize, req->result); 1522 ssi_hash_unmap_result(dev, state, digestsize, req->result);
1536 } 1523 }
@@ -1542,7 +1529,7 @@ static int ssi_mac_finup(struct ahash_request *req)
1542 struct ahash_req_ctx *state = ahash_request_ctx(req); 1529 struct ahash_req_ctx *state = ahash_request_ctx(req);
1543 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 1530 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1544 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 1531 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1545 struct device *dev = &ctx->drvdata->plat_dev->dev; 1532 struct device *dev = drvdata_to_dev(ctx->drvdata);
1546 struct ssi_crypto_req ssi_req = {}; 1533 struct ssi_crypto_req ssi_req = {};
1547 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 1534 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
1548 int idx = 0; 1535 int idx = 0;
@@ -1550,18 +1537,18 @@ static int ssi_mac_finup(struct ahash_request *req)
1550 u32 key_len = 0; 1537 u32 key_len = 0;
1551 u32 digestsize = crypto_ahash_digestsize(tfm); 1538 u32 digestsize = crypto_ahash_digestsize(tfm);
1552 1539
1553 SSI_LOG_DEBUG("===== finup xcbc(%d) ====\n", req->nbytes); 1540 dev_dbg(dev, "===== finup xcbc(%d) ====\n", req->nbytes);
1554 if (state->xcbc_count > 0 && req->nbytes == 0) { 1541 if (state->xcbc_count > 0 && req->nbytes == 0) {
1555 SSI_LOG_DEBUG("No data to update. Call to fdx_mac_final\n"); 1542 dev_dbg(dev, "No data to update. Call to fdx_mac_final\n");
1556 return ssi_mac_final(req); 1543 return ssi_mac_final(req);
1557 } 1544 }
1558 1545
1559 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { 1546 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) {
1560 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 1547 dev_err(dev, "map_ahash_request_final() failed\n");
1561 return -ENOMEM; 1548 return -ENOMEM;
1562 } 1549 }
1563 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 1550 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
1564 SSI_LOG_ERR("map_ahash_digest() failed\n"); 1551 dev_err(dev, "map_ahash_digest() failed\n");
1565 return -ENOMEM; 1552 return -ENOMEM;
1566 } 1553 }
1567 1554
@@ -1601,7 +1588,7 @@ static int ssi_mac_finup(struct ahash_request *req)
1601 1588
1602 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 1589 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
1603 if (unlikely(rc != -EINPROGRESS)) { 1590 if (unlikely(rc != -EINPROGRESS)) {
1604 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 1591 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1605 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); 1592 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true);
1606 ssi_hash_unmap_result(dev, state, digestsize, req->result); 1593 ssi_hash_unmap_result(dev, state, digestsize, req->result);
1607 } 1594 }
@@ -1613,7 +1600,7 @@ static int ssi_mac_digest(struct ahash_request *req)
1613 struct ahash_req_ctx *state = ahash_request_ctx(req); 1600 struct ahash_req_ctx *state = ahash_request_ctx(req);
1614 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 1601 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1615 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 1602 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1616 struct device *dev = &ctx->drvdata->plat_dev->dev; 1603 struct device *dev = drvdata_to_dev(ctx->drvdata);
1617 u32 digestsize = crypto_ahash_digestsize(tfm); 1604 u32 digestsize = crypto_ahash_digestsize(tfm);
1618 struct ssi_crypto_req ssi_req = {}; 1605 struct ssi_crypto_req ssi_req = {};
1619 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; 1606 struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN];
@@ -1621,19 +1608,19 @@ static int ssi_mac_digest(struct ahash_request *req)
1621 int idx = 0; 1608 int idx = 0;
1622 int rc; 1609 int rc;
1623 1610
1624 SSI_LOG_DEBUG("===== -digest mac (%d) ====\n", req->nbytes); 1611 dev_dbg(dev, "===== -digest mac (%d) ====\n", req->nbytes);
1625 1612
1626 if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { 1613 if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) {
1627 SSI_LOG_ERR("map_ahash_source() failed\n"); 1614 dev_err(dev, "map_ahash_source() failed\n");
1628 return -ENOMEM; 1615 return -ENOMEM;
1629 } 1616 }
1630 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { 1617 if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) {
1631 SSI_LOG_ERR("map_ahash_digest() failed\n"); 1618 dev_err(dev, "map_ahash_digest() failed\n");
1632 return -ENOMEM; 1619 return -ENOMEM;
1633 } 1620 }
1634 1621
1635 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { 1622 if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) {
1636 SSI_LOG_ERR("map_ahash_request_final() failed\n"); 1623 dev_err(dev, "map_ahash_request_final() failed\n");
1637 return -ENOMEM; 1624 return -ENOMEM;
1638 } 1625 }
1639 1626
@@ -1673,7 +1660,7 @@ static int ssi_mac_digest(struct ahash_request *req)
1673 1660
1674 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); 1661 rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1);
1675 if (unlikely(rc != -EINPROGRESS)) { 1662 if (unlikely(rc != -EINPROGRESS)) {
1676 SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); 1663 dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1677 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); 1664 ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true);
1678 ssi_hash_unmap_result(dev, state, digestsize, req->result); 1665 ssi_hash_unmap_result(dev, state, digestsize, req->result);
1679 ssi_hash_unmap_request(dev, state, ctx); 1666 ssi_hash_unmap_request(dev, state, ctx);
@@ -1727,8 +1714,9 @@ static int ssi_ahash_init(struct ahash_request *req)
1727 struct ahash_req_ctx *state = ahash_request_ctx(req); 1714 struct ahash_req_ctx *state = ahash_request_ctx(req);
1728 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 1715 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1729 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); 1716 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1717 struct device *dev = drvdata_to_dev(ctx->drvdata);
1730 1718
1731 SSI_LOG_DEBUG("===== init (%d) ====\n", req->nbytes); 1719 dev_dbg(dev, "===== init (%d) ====\n", req->nbytes);
1732 1720
1733 return ssi_hash_init(state, ctx); 1721 return ssi_hash_init(state, ctx);
1734} 1722}
@@ -1737,7 +1725,7 @@ static int ssi_ahash_export(struct ahash_request *req, void *out)
1737{ 1725{
1738 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); 1726 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
1739 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1727 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1740 struct device *dev = &ctx->drvdata->plat_dev->dev; 1728 struct device *dev = drvdata_to_dev(ctx->drvdata);
1741 struct ahash_req_ctx *state = ahash_request_ctx(req); 1729 struct ahash_req_ctx *state = ahash_request_ctx(req);
1742 u8 *curr_buff = state->buff_index ? state->buff1 : state->buff0; 1730 u8 *curr_buff = state->buff_index ? state->buff1 : state->buff0;
1743 u32 curr_buff_cnt = state->buff_index ? state->buff1_cnt : 1731 u32 curr_buff_cnt = state->buff_index ? state->buff1_cnt :
@@ -1778,7 +1766,7 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in)
1778{ 1766{
1779 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); 1767 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
1780 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1768 struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1781 struct device *dev = &ctx->drvdata->plat_dev->dev; 1769 struct device *dev = drvdata_to_dev(ctx->drvdata);
1782 struct ahash_req_ctx *state = ahash_request_ctx(req); 1770 struct ahash_req_ctx *state = ahash_request_ctx(req);
1783 u32 tmp; 1771 u32 tmp;
1784 int rc; 1772 int rc;
@@ -2054,17 +2042,17 @@ static struct ssi_hash_template driver_hash[] = {
2054}; 2042};
2055 2043
2056static struct ssi_hash_alg * 2044static struct ssi_hash_alg *
2057ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed) 2045ssi_hash_create_alg(struct ssi_hash_template *template, struct device *dev,
2046 bool keyed)
2058{ 2047{
2059 struct ssi_hash_alg *t_crypto_alg; 2048 struct ssi_hash_alg *t_crypto_alg;
2060 struct crypto_alg *alg; 2049 struct crypto_alg *alg;
2061 struct ahash_alg *halg; 2050 struct ahash_alg *halg;
2062 2051
2063 t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL); 2052 t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL);
2064 if (!t_crypto_alg) { 2053 if (!t_crypto_alg)
2065 SSI_LOG_ERR("failed to allocate t_crypto_alg\n");
2066 return ERR_PTR(-ENOMEM); 2054 return ERR_PTR(-ENOMEM);
2067 } 2055
2068 2056
2069 t_crypto_alg->ahash_alg = template->template_ahash; 2057 t_crypto_alg->ahash_alg = template->template_ahash;
2070 halg = &t_crypto_alg->ahash_alg; 2058 halg = &t_crypto_alg->ahash_alg;
@@ -2107,6 +2095,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata)
2107 ssi_sram_addr_t sram_buff_ofs = hash_handle->digest_len_sram_addr; 2095 ssi_sram_addr_t sram_buff_ofs = hash_handle->digest_len_sram_addr;
2108 unsigned int larval_seq_len = 0; 2096 unsigned int larval_seq_len = 0;
2109 struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)]; 2097 struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)];
2098 struct device *dev = drvdata_to_dev(drvdata);
2110 int rc = 0; 2099 int rc = 0;
2111#if (DX_DEV_SHA_MAX > 256) 2100#if (DX_DEV_SHA_MAX > 256)
2112 int i; 2101 int i;
@@ -2191,7 +2180,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata)
2191 } 2180 }
2192 rc = send_request_init(drvdata, larval_seq, larval_seq_len); 2181 rc = send_request_init(drvdata, larval_seq, larval_seq_len);
2193 if (unlikely(rc != 0)) { 2182 if (unlikely(rc != 0)) {
2194 SSI_LOG_ERR("send_request() failed (rc = %d)\n", rc); 2183 dev_err(dev, "send_request() failed (rc = %d)\n", rc);
2195 goto init_digest_const_err; 2184 goto init_digest_const_err;
2196 } 2185 }
2197 larval_seq_len = 0; 2186 larval_seq_len = 0;
@@ -2209,7 +2198,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata)
2209 } 2198 }
2210 rc = send_request_init(drvdata, larval_seq, larval_seq_len); 2199 rc = send_request_init(drvdata, larval_seq, larval_seq_len);
2211 if (unlikely(rc != 0)) { 2200 if (unlikely(rc != 0)) {
2212 SSI_LOG_ERR("send_request() failed (rc = %d)\n", rc); 2201 dev_err(dev, "send_request() failed (rc = %d)\n", rc);
2213 goto init_digest_const_err; 2202 goto init_digest_const_err;
2214 } 2203 }
2215#endif 2204#endif
@@ -2223,17 +2212,15 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
2223 struct ssi_hash_handle *hash_handle; 2212 struct ssi_hash_handle *hash_handle;
2224 ssi_sram_addr_t sram_buff; 2213 ssi_sram_addr_t sram_buff;
2225 u32 sram_size_to_alloc; 2214 u32 sram_size_to_alloc;
2215 struct device *dev = drvdata_to_dev(drvdata);
2226 int rc = 0; 2216 int rc = 0;
2227 int alg; 2217 int alg;
2228 2218
2229 hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL); 2219 hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL);
2230 if (!hash_handle) { 2220 if (!hash_handle)
2231 SSI_LOG_ERR("kzalloc failed to allocate %zu B\n", 2221 return -ENOMEM;
2232 sizeof(*hash_handle));
2233 rc = -ENOMEM;
2234 goto fail;
2235 }
2236 2222
2223 INIT_LIST_HEAD(&hash_handle->hash_list);
2237 drvdata->hash_handle = hash_handle; 2224 drvdata->hash_handle = hash_handle;
2238 2225
2239 sram_size_to_alloc = sizeof(digest_len_init) + 2226 sram_size_to_alloc = sizeof(digest_len_init) +
@@ -2249,7 +2236,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
2249 2236
2250 sram_buff = ssi_sram_mgr_alloc(drvdata, sram_size_to_alloc); 2237 sram_buff = ssi_sram_mgr_alloc(drvdata, sram_size_to_alloc);
2251 if (sram_buff == NULL_SRAM_ADDR) { 2238 if (sram_buff == NULL_SRAM_ADDR) {
2252 SSI_LOG_ERR("SRAM pool exhausted\n"); 2239 dev_err(dev, "SRAM pool exhausted\n");
2253 rc = -ENOMEM; 2240 rc = -ENOMEM;
2254 goto fail; 2241 goto fail;
2255 } 2242 }
@@ -2260,31 +2247,29 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
2260 /*must be set before the alg registration as it is being used there*/ 2247 /*must be set before the alg registration as it is being used there*/
2261 rc = ssi_hash_init_sram_digest_consts(drvdata); 2248 rc = ssi_hash_init_sram_digest_consts(drvdata);
2262 if (unlikely(rc != 0)) { 2249 if (unlikely(rc != 0)) {
2263 SSI_LOG_ERR("Init digest CONST failed (rc=%d)\n", rc); 2250 dev_err(dev, "Init digest CONST failed (rc=%d)\n", rc);
2264 goto fail; 2251 goto fail;
2265 } 2252 }
2266 2253
2267 INIT_LIST_HEAD(&hash_handle->hash_list);
2268
2269 /* ahash registration */ 2254 /* ahash registration */
2270 for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { 2255 for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) {
2271 struct ssi_hash_alg *t_alg; 2256 struct ssi_hash_alg *t_alg;
2272 int hw_mode = driver_hash[alg].hw_mode; 2257 int hw_mode = driver_hash[alg].hw_mode;
2273 2258
2274 /* register hmac version */ 2259 /* register hmac version */
2275 t_alg = ssi_hash_create_alg(&driver_hash[alg], true); 2260 t_alg = ssi_hash_create_alg(&driver_hash[alg], dev, true);
2276 if (IS_ERR(t_alg)) { 2261 if (IS_ERR(t_alg)) {
2277 rc = PTR_ERR(t_alg); 2262 rc = PTR_ERR(t_alg);
2278 SSI_LOG_ERR("%s alg allocation failed\n", 2263 dev_err(dev, "%s alg allocation failed\n",
2279 driver_hash[alg].driver_name); 2264 driver_hash[alg].driver_name);
2280 goto fail; 2265 goto fail;
2281 } 2266 }
2282 t_alg->drvdata = drvdata; 2267 t_alg->drvdata = drvdata;
2283 2268
2284 rc = crypto_register_ahash(&t_alg->ahash_alg); 2269 rc = crypto_register_ahash(&t_alg->ahash_alg);
2285 if (unlikely(rc)) { 2270 if (unlikely(rc)) {
2286 SSI_LOG_ERR("%s alg registration failed\n", 2271 dev_err(dev, "%s alg registration failed\n",
2287 driver_hash[alg].driver_name); 2272 driver_hash[alg].driver_name);
2288 kfree(t_alg); 2273 kfree(t_alg);
2289 goto fail; 2274 goto fail;
2290 } else { 2275 } else {
@@ -2297,19 +2282,19 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
2297 continue; 2282 continue;
2298 2283
2299 /* register hash version */ 2284 /* register hash version */
2300 t_alg = ssi_hash_create_alg(&driver_hash[alg], false); 2285 t_alg = ssi_hash_create_alg(&driver_hash[alg], dev, false);
2301 if (IS_ERR(t_alg)) { 2286 if (IS_ERR(t_alg)) {
2302 rc = PTR_ERR(t_alg); 2287 rc = PTR_ERR(t_alg);
2303 SSI_LOG_ERR("%s alg allocation failed\n", 2288 dev_err(dev, "%s alg allocation failed\n",
2304 driver_hash[alg].driver_name); 2289 driver_hash[alg].driver_name);
2305 goto fail; 2290 goto fail;
2306 } 2291 }
2307 t_alg->drvdata = drvdata; 2292 t_alg->drvdata = drvdata;
2308 2293
2309 rc = crypto_register_ahash(&t_alg->ahash_alg); 2294 rc = crypto_register_ahash(&t_alg->ahash_alg);
2310 if (unlikely(rc)) { 2295 if (unlikely(rc)) {
2311 SSI_LOG_ERR("%s alg registration failed\n", 2296 dev_err(dev, "%s alg registration failed\n",
2312 driver_hash[alg].driver_name); 2297 driver_hash[alg].driver_name);
2313 kfree(t_alg); 2298 kfree(t_alg);
2314 goto fail; 2299 goto fail;
2315 } else { 2300 } else {
@@ -2443,6 +2428,7 @@ static void ssi_hash_create_data_desc(struct ahash_req_ctx *areq_ctx,
2443 unsigned int *seq_size) 2428 unsigned int *seq_size)
2444{ 2429{
2445 unsigned int idx = *seq_size; 2430 unsigned int idx = *seq_size;
2431 struct device *dev = drvdata_to_dev(ctx->drvdata);
2446 2432
2447 if (likely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_DLLI)) { 2433 if (likely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_DLLI)) {
2448 hw_desc_init(&desc[idx]); 2434 hw_desc_init(&desc[idx]);
@@ -2453,7 +2439,7 @@ static void ssi_hash_create_data_desc(struct ahash_req_ctx *areq_ctx,
2453 idx++; 2439 idx++;
2454 } else { 2440 } else {
2455 if (areq_ctx->data_dma_buf_type == SSI_DMA_BUF_NULL) { 2441 if (areq_ctx->data_dma_buf_type == SSI_DMA_BUF_NULL) {
2456 SSI_LOG_DEBUG(" NULL mode\n"); 2442 dev_dbg(dev, " NULL mode\n");
2457 /* nothing to build */ 2443 /* nothing to build */
2458 return; 2444 return;
2459 } 2445 }
@@ -2493,6 +2479,7 @@ ssi_sram_addr_t ssi_ahash_get_larval_digest_sram_addr(void *drvdata, u32 mode)
2493{ 2479{
2494 struct ssi_drvdata *_drvdata = (struct ssi_drvdata *)drvdata; 2480 struct ssi_drvdata *_drvdata = (struct ssi_drvdata *)drvdata;
2495 struct ssi_hash_handle *hash_handle = _drvdata->hash_handle; 2481 struct ssi_hash_handle *hash_handle = _drvdata->hash_handle;
2482 struct device *dev = drvdata_to_dev(_drvdata);
2496 2483
2497 switch (mode) { 2484 switch (mode) {
2498 case DRV_HASH_NULL: 2485 case DRV_HASH_NULL:
@@ -2527,7 +2514,7 @@ ssi_sram_addr_t ssi_ahash_get_larval_digest_sram_addr(void *drvdata, u32 mode)
2527 sizeof(sha384_init)); 2514 sizeof(sha384_init));
2528#endif 2515#endif
2529 default: 2516 default:
2530 SSI_LOG_ERR("Invalid hash mode (%d)\n", mode); 2517 dev_err(dev, "Invalid hash mode (%d)\n", mode);
2531 } 2518 }
2532 2519
2533 /*This is valid wrong value to avoid kernel crash*/ 2520 /*This is valid wrong value to avoid kernel crash*/
diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c
index b01e03231947..3f082f41ae8f 100644
--- a/drivers/staging/ccree/ssi_ivgen.c
+++ b/drivers/staging/ccree/ssi_ivgen.c
@@ -193,12 +193,9 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata)
193 /* Allocate "this" context */ 193 /* Allocate "this" context */
194 drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), 194 drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle),
195 GFP_KERNEL); 195 GFP_KERNEL);
196 if (!drvdata->ivgen_handle) { 196 if (!drvdata->ivgen_handle)
197 SSI_LOG_ERR("Not enough memory to allocate IVGEN context " 197 return -ENOMEM;
198 "(%zu B)\n", sizeof(*drvdata->ivgen_handle)); 198
199 rc = -ENOMEM;
200 goto out;
201 }
202 ivgen_ctx = drvdata->ivgen_handle; 199 ivgen_ctx = drvdata->ivgen_handle;
203 200
204 /* Allocate pool's header for intial enc. key/IV */ 201 /* Allocate pool's header for intial enc. key/IV */
@@ -206,15 +203,15 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata)
206 &ivgen_ctx->pool_meta_dma, 203 &ivgen_ctx->pool_meta_dma,
207 GFP_KERNEL); 204 GFP_KERNEL);
208 if (!ivgen_ctx->pool_meta) { 205 if (!ivgen_ctx->pool_meta) {
209 SSI_LOG_ERR("Not enough memory to allocate DMA of pool_meta " 206 dev_err(device, "Not enough memory to allocate DMA of pool_meta (%u B)\n",
210 "(%u B)\n", SSI_IVPOOL_META_SIZE); 207 SSI_IVPOOL_META_SIZE);
211 rc = -ENOMEM; 208 rc = -ENOMEM;
212 goto out; 209 goto out;
213 } 210 }
214 /* Allocate IV pool in SRAM */ 211 /* Allocate IV pool in SRAM */
215 ivgen_ctx->pool = ssi_sram_mgr_alloc(drvdata, SSI_IVPOOL_SIZE); 212 ivgen_ctx->pool = ssi_sram_mgr_alloc(drvdata, SSI_IVPOOL_SIZE);
216 if (ivgen_ctx->pool == NULL_SRAM_ADDR) { 213 if (ivgen_ctx->pool == NULL_SRAM_ADDR) {
217 SSI_LOG_ERR("SRAM pool exhausted\n"); 214 dev_err(device, "SRAM pool exhausted\n");
218 rc = -ENOMEM; 215 rc = -ENOMEM;
219 goto out; 216 goto out;
220 } 217 }
@@ -248,6 +245,7 @@ int ssi_ivgen_getiv(
248{ 245{
249 struct ssi_ivgen_ctx *ivgen_ctx = drvdata->ivgen_handle; 246 struct ssi_ivgen_ctx *ivgen_ctx = drvdata->ivgen_handle;
250 unsigned int idx = *iv_seq_len; 247 unsigned int idx = *iv_seq_len;
248 struct device *dev = drvdata_to_dev(drvdata);
251 unsigned int t; 249 unsigned int t;
252 250
253 if ((iv_out_size != CC_AES_IV_SIZE) && 251 if ((iv_out_size != CC_AES_IV_SIZE) &&
@@ -291,7 +289,7 @@ int ssi_ivgen_getiv(
291 ivgen_ctx->next_iv_ofs += iv_out_size; 289 ivgen_ctx->next_iv_ofs += iv_out_size;
292 290
293 if ((SSI_IVPOOL_SIZE - ivgen_ctx->next_iv_ofs) < CC_AES_IV_SIZE) { 291 if ((SSI_IVPOOL_SIZE - ivgen_ctx->next_iv_ofs) < CC_AES_IV_SIZE) {
294 SSI_LOG_DEBUG("Pool exhausted, regenerating iv-pool\n"); 292 dev_dbg(dev, "Pool exhausted, regenerating iv-pool\n");
295 /* pool is drained -regenerate it! */ 293 /* pool is drained -regenerate it! */
296 return ssi_ivgen_generate_pool(ivgen_ctx, iv_seq, iv_seq_len); 294 return ssi_ivgen_generate_pool(ivgen_ctx, iv_seq, iv_seq_len);
297 } 295 }
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index 31325e6cd4b4..36a498098a70 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -40,11 +40,12 @@ int ssi_power_mgr_runtime_suspend(struct device *dev)
40 (struct ssi_drvdata *)dev_get_drvdata(dev); 40 (struct ssi_drvdata *)dev_get_drvdata(dev);
41 int rc; 41 int rc;
42 42
43 SSI_LOG_DEBUG("set HOST_POWER_DOWN_EN\n"); 43 dev_dbg(dev, "set HOST_POWER_DOWN_EN\n");
44 WRITE_REGISTER(drvdata->cc_base + CC_REG_OFFSET(HOST_RGF, HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); 44 cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE);
45 rc = ssi_request_mgr_runtime_suspend_queue(drvdata); 45 rc = ssi_request_mgr_runtime_suspend_queue(drvdata);
46 if (rc != 0) { 46 if (rc != 0) {
47 SSI_LOG_ERR("ssi_request_mgr_runtime_suspend_queue (%x)\n", rc); 47 dev_err(dev, "ssi_request_mgr_runtime_suspend_queue (%x)\n",
48 rc);
48 return rc; 49 return rc;
49 } 50 }
50 fini_cc_regs(drvdata); 51 fini_cc_regs(drvdata);
@@ -58,24 +59,24 @@ int ssi_power_mgr_runtime_resume(struct device *dev)
58 struct ssi_drvdata *drvdata = 59 struct ssi_drvdata *drvdata =
59 (struct ssi_drvdata *)dev_get_drvdata(dev); 60 (struct ssi_drvdata *)dev_get_drvdata(dev);
60 61
61 SSI_LOG_DEBUG("unset HOST_POWER_DOWN_EN\n"); 62 dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n");
62 WRITE_REGISTER(drvdata->cc_base + CC_REG_OFFSET(HOST_RGF, HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); 63 cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE);
63 64
64 rc = cc_clk_on(drvdata); 65 rc = cc_clk_on(drvdata);
65 if (rc) { 66 if (rc) {
66 SSI_LOG_ERR("failed getting clock back on. We're toast.\n"); 67 dev_err(dev, "failed getting clock back on. We're toast.\n");
67 return rc; 68 return rc;
68 } 69 }
69 70
70 rc = init_cc_regs(drvdata, false); 71 rc = init_cc_regs(drvdata, false);
71 if (rc != 0) { 72 if (rc != 0) {
72 SSI_LOG_ERR("init_cc_regs (%x)\n", rc); 73 dev_err(dev, "init_cc_regs (%x)\n", rc);
73 return rc; 74 return rc;
74 } 75 }
75 76
76 rc = ssi_request_mgr_runtime_resume_queue(drvdata); 77 rc = ssi_request_mgr_runtime_resume_queue(drvdata);
77 if (rc != 0) { 78 if (rc != 0) {
78 SSI_LOG_ERR("ssi_request_mgr_runtime_resume_queue (%x)\n", rc); 79 dev_err(dev, "ssi_request_mgr_runtime_resume_queue (%x)\n", rc);
79 return rc; 80 return rc;
80 } 81 }
81 82
@@ -109,7 +110,8 @@ int ssi_power_mgr_runtime_put_suspend(struct device *dev)
109 rc = pm_runtime_put_autosuspend(dev); 110 rc = pm_runtime_put_autosuspend(dev);
110 } else { 111 } else {
111 /* Something wrong happens*/ 112 /* Something wrong happens*/
112 BUG(); 113 dev_err(dev, "request to suspend already suspended queue");
114 rc = -EBUSY;
113 } 115 }
114 return rc; 116 return rc;
115} 117}
@@ -120,16 +122,17 @@ int ssi_power_mgr_init(struct ssi_drvdata *drvdata)
120{ 122{
121 int rc = 0; 123 int rc = 0;
122#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 124#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
123 struct platform_device *plat_dev = drvdata->plat_dev; 125 struct device *dev = drvdata_to_dev(drvdata);
126
124 /* must be before the enabling to avoid resdundent suspending */ 127 /* must be before the enabling to avoid resdundent suspending */
125 pm_runtime_set_autosuspend_delay(&plat_dev->dev, SSI_SUSPEND_TIMEOUT); 128 pm_runtime_set_autosuspend_delay(dev, SSI_SUSPEND_TIMEOUT);
126 pm_runtime_use_autosuspend(&plat_dev->dev); 129 pm_runtime_use_autosuspend(dev);
127 /* activate the PM module */ 130 /* activate the PM module */
128 rc = pm_runtime_set_active(&plat_dev->dev); 131 rc = pm_runtime_set_active(dev);
129 if (rc != 0) 132 if (rc != 0)
130 return rc; 133 return rc;
131 /* enable the PM module*/ 134 /* enable the PM module*/
132 pm_runtime_enable(&plat_dev->dev); 135 pm_runtime_enable(dev);
133#endif 136#endif
134 return rc; 137 return rc;
135} 138}
@@ -137,8 +140,6 @@ int ssi_power_mgr_init(struct ssi_drvdata *drvdata)
137void ssi_power_mgr_fini(struct ssi_drvdata *drvdata) 140void ssi_power_mgr_fini(struct ssi_drvdata *drvdata)
138{ 141{
139#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 142#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
140 struct platform_device *plat_dev = drvdata->plat_dev; 143 pm_runtime_disable(drvdata_to_dev(drvdata));
141
142 pm_runtime_disable(&plat_dev->dev);
143#endif 144#endif
144} 145}
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index e5c2f92857f6..a8a7dc672d4c 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -49,7 +49,6 @@ struct ssi_request_mgr_handle {
49 dma_addr_t dummy_comp_buff_dma; 49 dma_addr_t dummy_comp_buff_dma;
50 struct cc_hw_desc monitor_desc; 50 struct cc_hw_desc monitor_desc;
51 51
52 volatile unsigned long monitor_lock;
53#ifdef COMP_IN_WQ 52#ifdef COMP_IN_WQ
54 struct workqueue_struct *workq; 53 struct workqueue_struct *workq;
55 struct delayed_work compwork; 54 struct delayed_work compwork;
@@ -69,19 +68,19 @@ static void comp_work_handler(struct work_struct *work);
69void request_mgr_fini(struct ssi_drvdata *drvdata) 68void request_mgr_fini(struct ssi_drvdata *drvdata)
70{ 69{
71 struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle; 70 struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
71 struct device *dev = drvdata_to_dev(drvdata);
72 72
73 if (!req_mgr_h) 73 if (!req_mgr_h)
74 return; /* Not allocated */ 74 return; /* Not allocated */
75 75
76 if (req_mgr_h->dummy_comp_buff_dma != 0) { 76 if (req_mgr_h->dummy_comp_buff_dma != 0) {
77 dma_free_coherent(&drvdata->plat_dev->dev, 77 dma_free_coherent(dev, sizeof(u32), req_mgr_h->dummy_comp_buff,
78 sizeof(u32), req_mgr_h->dummy_comp_buff,
79 req_mgr_h->dummy_comp_buff_dma); 78 req_mgr_h->dummy_comp_buff_dma);
80 } 79 }
81 80
82 SSI_LOG_DEBUG("max_used_hw_slots=%d\n", (req_mgr_h->hw_queue_size - 81 dev_dbg(dev, "max_used_hw_slots=%d\n", (req_mgr_h->hw_queue_size -
83 req_mgr_h->min_free_hw_slots)); 82 req_mgr_h->min_free_hw_slots));
84 SSI_LOG_DEBUG("max_used_sw_slots=%d\n", req_mgr_h->max_used_sw_slots); 83 dev_dbg(dev, "max_used_sw_slots=%d\n", req_mgr_h->max_used_sw_slots);
85 84
86#ifdef COMP_IN_WQ 85#ifdef COMP_IN_WQ
87 flush_workqueue(req_mgr_h->workq); 86 flush_workqueue(req_mgr_h->workq);
@@ -98,6 +97,7 @@ void request_mgr_fini(struct ssi_drvdata *drvdata)
98int request_mgr_init(struct ssi_drvdata *drvdata) 97int request_mgr_init(struct ssi_drvdata *drvdata)
99{ 98{
100 struct ssi_request_mgr_handle *req_mgr_h; 99 struct ssi_request_mgr_handle *req_mgr_h;
100 struct device *dev = drvdata_to_dev(drvdata);
101 int rc = 0; 101 int rc = 0;
102 102
103 req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL); 103 req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL);
@@ -110,24 +110,24 @@ int request_mgr_init(struct ssi_drvdata *drvdata)
110 110
111 spin_lock_init(&req_mgr_h->hw_lock); 111 spin_lock_init(&req_mgr_h->hw_lock);
112#ifdef COMP_IN_WQ 112#ifdef COMP_IN_WQ
113 SSI_LOG_DEBUG("Initializing completion workqueue\n"); 113 dev_dbg(dev, "Initializing completion workqueue\n");
114 req_mgr_h->workq = create_singlethread_workqueue("arm_cc7x_wq"); 114 req_mgr_h->workq = create_singlethread_workqueue("arm_cc7x_wq");
115 if (unlikely(!req_mgr_h->workq)) { 115 if (unlikely(!req_mgr_h->workq)) {
116 SSI_LOG_ERR("Failed creating work queue\n"); 116 dev_err(dev, "Failed creating work queue\n");
117 rc = -ENOMEM; 117 rc = -ENOMEM;
118 goto req_mgr_init_err; 118 goto req_mgr_init_err;
119 } 119 }
120 INIT_DELAYED_WORK(&req_mgr_h->compwork, comp_work_handler); 120 INIT_DELAYED_WORK(&req_mgr_h->compwork, comp_work_handler);
121#else 121#else
122 SSI_LOG_DEBUG("Initializing completion tasklet\n"); 122 dev_dbg(dev, "Initializing completion tasklet\n");
123 tasklet_init(&req_mgr_h->comptask, comp_handler, (unsigned long)drvdata); 123 tasklet_init(&req_mgr_h->comptask, comp_handler, (unsigned long)drvdata);
124#endif 124#endif
125 req_mgr_h->hw_queue_size = READ_REGISTER(drvdata->cc_base + 125 req_mgr_h->hw_queue_size = cc_ioread(drvdata,
126 CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_SRAM_SIZE)); 126 CC_REG(DSCRPTR_QUEUE_SRAM_SIZE));
127 SSI_LOG_DEBUG("hw_queue_size=0x%08X\n", req_mgr_h->hw_queue_size); 127 dev_dbg(dev, "hw_queue_size=0x%08X\n", req_mgr_h->hw_queue_size);
128 if (req_mgr_h->hw_queue_size < MIN_HW_QUEUE_SIZE) { 128 if (req_mgr_h->hw_queue_size < MIN_HW_QUEUE_SIZE) {
129 SSI_LOG_ERR("Invalid HW queue size = %u (Min. required is %u)\n", 129 dev_err(dev, "Invalid HW queue size = %u (Min. required is %u)\n",
130 req_mgr_h->hw_queue_size, MIN_HW_QUEUE_SIZE); 130 req_mgr_h->hw_queue_size, MIN_HW_QUEUE_SIZE);
131 rc = -ENOMEM; 131 rc = -ENOMEM;
132 goto req_mgr_init_err; 132 goto req_mgr_init_err;
133 } 133 }
@@ -135,13 +135,12 @@ int request_mgr_init(struct ssi_drvdata *drvdata)
135 req_mgr_h->max_used_sw_slots = 0; 135 req_mgr_h->max_used_sw_slots = 0;
136 136
137 /* Allocate DMA word for "dummy" completion descriptor use */ 137 /* Allocate DMA word for "dummy" completion descriptor use */
138 req_mgr_h->dummy_comp_buff = dma_alloc_coherent(&drvdata->plat_dev->dev, 138 req_mgr_h->dummy_comp_buff = dma_alloc_coherent(dev, sizeof(u32),
139 sizeof(u32),
140 &req_mgr_h->dummy_comp_buff_dma, 139 &req_mgr_h->dummy_comp_buff_dma,
141 GFP_KERNEL); 140 GFP_KERNEL);
142 if (!req_mgr_h->dummy_comp_buff) { 141 if (!req_mgr_h->dummy_comp_buff) {
143 SSI_LOG_ERR("Not enough memory to allocate DMA (%zu) dropped " 142 dev_err(dev, "Not enough memory to allocate DMA (%zu) dropped buffer\n",
144 "buffer\n", sizeof(u32)); 143 sizeof(u32));
145 rc = -ENOMEM; 144 rc = -ENOMEM;
146 goto req_mgr_init_err; 145 goto req_mgr_init_err;
147 } 146 }
@@ -168,17 +167,17 @@ static inline void enqueue_seq(
168 int i; 167 int i;
169 168
170 for (i = 0; i < seq_len; i++) { 169 for (i = 0; i < seq_len; i++) {
171 writel_relaxed(seq[i].word[0], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 170 writel_relaxed(seq[i].word[0], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
172 writel_relaxed(seq[i].word[1], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 171 writel_relaxed(seq[i].word[1], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
173 writel_relaxed(seq[i].word[2], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 172 writel_relaxed(seq[i].word[2], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
174 writel_relaxed(seq[i].word[3], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 173 writel_relaxed(seq[i].word[3], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
175 writel_relaxed(seq[i].word[4], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 174 writel_relaxed(seq[i].word[4], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
176 wmb(); 175 wmb();
177 writel_relaxed(seq[i].word[5], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); 176 writel_relaxed(seq[i].word[5], (volatile void __iomem *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
178#ifdef DX_DUMP_DESCS 177#ifdef DX_DUMP_DESCS
179 SSI_LOG_DEBUG("desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", i, 178 dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
180 seq[i].word[0], seq[i].word[1], seq[i].word[2], 179 i, seq[i].word[0], seq[i].word[1], seq[i].word[2],
181 seq[i].word[3], seq[i].word[4], seq[i].word[5]); 180 seq[i].word[3], seq[i].word[4], seq[i].word[5]);
182#endif 181#endif
183 } 182 }
184} 183}
@@ -198,11 +197,12 @@ static void request_mgr_complete(struct device *dev, void *dx_compl_h, void __io
198} 197}
199 198
200static inline int request_mgr_queues_status_check( 199static inline int request_mgr_queues_status_check(
200 struct ssi_drvdata *drvdata,
201 struct ssi_request_mgr_handle *req_mgr_h, 201 struct ssi_request_mgr_handle *req_mgr_h,
202 void __iomem *cc_base,
203 unsigned int total_seq_len) 202 unsigned int total_seq_len)
204{ 203{
205 unsigned long poll_queue; 204 unsigned long poll_queue;
205 struct device *dev = drvdata_to_dev(drvdata);
206 206
207 /* SW queue is checked only once as it will not 207 /* SW queue is checked only once as it will not
208 * be chaned during the poll becasue the spinlock_bh 208 * be chaned during the poll becasue the spinlock_bh
@@ -211,8 +211,8 @@ static inline int request_mgr_queues_status_check(
211 if (unlikely(((req_mgr_h->req_queue_head + 1) & 211 if (unlikely(((req_mgr_h->req_queue_head + 1) &
212 (MAX_REQUEST_QUEUE_SIZE - 1)) == 212 (MAX_REQUEST_QUEUE_SIZE - 1)) ==
213 req_mgr_h->req_queue_tail)) { 213 req_mgr_h->req_queue_tail)) {
214 SSI_LOG_ERR("SW FIFO is full. req_queue_head=%d sw_fifo_len=%d\n", 214 dev_err(dev, "SW FIFO is full. req_queue_head=%d sw_fifo_len=%d\n",
215 req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE); 215 req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE);
216 return -EBUSY; 216 return -EBUSY;
217 } 217 }
218 218
@@ -222,8 +222,7 @@ static inline int request_mgr_queues_status_check(
222 /* Wait for space in HW queue. Poll constant num of iterations. */ 222 /* Wait for space in HW queue. Poll constant num of iterations. */
223 for (poll_queue = 0; poll_queue < SSI_MAX_POLL_ITER ; poll_queue++) { 223 for (poll_queue = 0; poll_queue < SSI_MAX_POLL_ITER ; poll_queue++) {
224 req_mgr_h->q_free_slots = 224 req_mgr_h->q_free_slots =
225 CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, 225 cc_ioread(drvdata, CC_REG(DSCRPTR_QUEUE_CONTENT));
226 DSCRPTR_QUEUE_CONTENT));
227 if (unlikely(req_mgr_h->q_free_slots < 226 if (unlikely(req_mgr_h->q_free_slots <
228 req_mgr_h->min_free_hw_slots)) { 227 req_mgr_h->min_free_hw_slots)) {
229 req_mgr_h->min_free_hw_slots = req_mgr_h->q_free_slots; 228 req_mgr_h->min_free_hw_slots = req_mgr_h->q_free_slots;
@@ -234,16 +233,13 @@ static inline int request_mgr_queues_status_check(
234 return 0; 233 return 0;
235 } 234 }
236 235
237 SSI_LOG_DEBUG("HW FIFO is full. q_free_slots=%d total_seq_len=%d\n", 236 dev_dbg(dev, "HW FIFO is full. q_free_slots=%d total_seq_len=%d\n",
238 req_mgr_h->q_free_slots, total_seq_len); 237 req_mgr_h->q_free_slots, total_seq_len);
239 } 238 }
240 /* No room in the HW queue try again later */ 239 /* No room in the HW queue try again later */
241 SSI_LOG_DEBUG("HW FIFO full, timeout. req_queue_head=%d " 240 dev_dbg(dev, "HW FIFO full, timeout. req_queue_head=%d sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n",
242 "sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n", 241 req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE,
243 req_mgr_h->req_queue_head, 242 req_mgr_h->q_free_slots, total_seq_len);
244 MAX_REQUEST_QUEUE_SIZE,
245 req_mgr_h->q_free_slots,
246 total_seq_len);
247 return -EAGAIN; 243 return -EAGAIN;
248} 244}
249 245
@@ -270,16 +266,17 @@ int send_request(
270 unsigned int iv_seq_len = 0; 266 unsigned int iv_seq_len = 0;
271 unsigned int total_seq_len = len; /*initial sequence length*/ 267 unsigned int total_seq_len = len; /*initial sequence length*/
272 struct cc_hw_desc iv_seq[SSI_IVPOOL_SEQ_LEN]; 268 struct cc_hw_desc iv_seq[SSI_IVPOOL_SEQ_LEN];
269 struct device *dev = drvdata_to_dev(drvdata);
273 int rc; 270 int rc;
274 unsigned int max_required_seq_len = (total_seq_len + 271 unsigned int max_required_seq_len = (total_seq_len +
275 ((ssi_req->ivgen_dma_addr_len == 0) ? 0 : 272 ((ssi_req->ivgen_dma_addr_len == 0) ? 0 :
276 SSI_IVPOOL_SEQ_LEN) + 273 SSI_IVPOOL_SEQ_LEN) +
277 ((is_dout == 0) ? 1 : 0)); 274 (!is_dout ? 1 : 0));
278 275
279#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 276#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
280 rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev); 277 rc = ssi_power_mgr_runtime_get(dev);
281 if (rc != 0) { 278 if (rc != 0) {
282 SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n", rc); 279 dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc);
283 return rc; 280 return rc;
284 } 281 }
285#endif 282#endif
@@ -291,7 +288,7 @@ int send_request(
291 * in case iv gen add the max size and in case of no dout add 1 288 * in case iv gen add the max size and in case of no dout add 1
292 * for the internal completion descriptor 289 * for the internal completion descriptor
293 */ 290 */
294 rc = request_mgr_queues_status_check(req_mgr_h, cc_base, 291 rc = request_mgr_queues_status_check(drvdata, req_mgr_h,
295 max_required_seq_len); 292 max_required_seq_len);
296 if (likely(rc == 0)) 293 if (likely(rc == 0))
297 /* There is enough place in the queue */ 294 /* There is enough place in the queue */
@@ -304,7 +301,7 @@ int send_request(
304 * (SW queue is full) 301 * (SW queue is full)
305 */ 302 */
306#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 303#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
307 ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev); 304 ssi_power_mgr_runtime_put_suspend(dev);
308#endif 305#endif
309 return rc; 306 return rc;
310 } 307 }
@@ -324,12 +321,12 @@ int send_request(
324 } 321 }
325 322
326 if (ssi_req->ivgen_dma_addr_len > 0) { 323 if (ssi_req->ivgen_dma_addr_len > 0) {
327 SSI_LOG_DEBUG("Acquire IV from pool into %d DMA addresses %pad, %pad, %pad, IV-size=%u\n", 324 dev_dbg(dev, "Acquire IV from pool into %d DMA addresses %pad, %pad, %pad, IV-size=%u\n",
328 ssi_req->ivgen_dma_addr_len, 325 ssi_req->ivgen_dma_addr_len,
329 ssi_req->ivgen_dma_addr[0], 326 &ssi_req->ivgen_dma_addr[0],
330 ssi_req->ivgen_dma_addr[1], 327 &ssi_req->ivgen_dma_addr[1],
331 ssi_req->ivgen_dma_addr[2], 328 &ssi_req->ivgen_dma_addr[2],
332 ssi_req->ivgen_size); 329 ssi_req->ivgen_size);
333 330
334 /* Acquire IV from pool */ 331 /* Acquire IV from pool */
335 rc = ssi_ivgen_getiv(drvdata, ssi_req->ivgen_dma_addr, 332 rc = ssi_ivgen_getiv(drvdata, ssi_req->ivgen_dma_addr,
@@ -337,10 +334,10 @@ int send_request(
337 ssi_req->ivgen_size, iv_seq, &iv_seq_len); 334 ssi_req->ivgen_size, iv_seq, &iv_seq_len);
338 335
339 if (unlikely(rc != 0)) { 336 if (unlikely(rc != 0)) {
340 SSI_LOG_ERR("Failed to generate IV (rc=%d)\n", rc); 337 dev_err(dev, "Failed to generate IV (rc=%d)\n", rc);
341 spin_unlock_bh(&req_mgr_h->hw_lock); 338 spin_unlock_bh(&req_mgr_h->hw_lock);
342#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 339#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
343 ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev); 340 ssi_power_mgr_runtime_put_suspend(dev);
344#endif 341#endif
345 return rc; 342 return rc;
346 } 343 }
@@ -357,7 +354,7 @@ int send_request(
357 req_mgr_h->req_queue_head = (req_mgr_h->req_queue_head + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); 354 req_mgr_h->req_queue_head = (req_mgr_h->req_queue_head + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
358 /* TODO: Use circ_buf.h ? */ 355 /* TODO: Use circ_buf.h ? */
359 356
360 SSI_LOG_DEBUG("Enqueue request head=%u\n", req_mgr_h->req_queue_head); 357 dev_dbg(dev, "Enqueue request head=%u\n", req_mgr_h->req_queue_head);
361 358
362#ifdef FLUSH_CACHE_ALL 359#ifdef FLUSH_CACHE_ALL
363 flush_cache_all(); 360 flush_cache_all();
@@ -369,11 +366,16 @@ int send_request(
369 enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1)); 366 enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1));
370 367
371 if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) { 368 if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) {
372 /*This means that there was a problem with the resume*/ 369 /* This situation should never occur. Maybe indicating problem
373 BUG(); 370 * with resuming power. Set the free slot count to 0 and hope
371 * for the best.
372 */
373 dev_err(dev, "HW free slot count mismatch.");
374 req_mgr_h->q_free_slots = 0;
375 } else {
376 /* Update the free slots in HW queue */
377 req_mgr_h->q_free_slots -= total_seq_len;
374 } 378 }
375 /* Update the free slots in HW queue */
376 req_mgr_h->q_free_slots -= total_seq_len;
377 379
378 spin_unlock_bh(&req_mgr_h->hw_lock); 380 spin_unlock_bh(&req_mgr_h->hw_lock);
379 381
@@ -383,10 +385,9 @@ int send_request(
383 */ 385 */
384 wait_for_completion(&ssi_req->seq_compl); 386 wait_for_completion(&ssi_req->seq_compl);
385 return 0; 387 return 0;
386 } else {
387 /* Operation still in process */
388 return -EINPROGRESS;
389 } 388 }
389 /* Operation still in process */
390 return -EINPROGRESS;
390} 391}
391 392
392/*! 393/*!
@@ -409,7 +410,8 @@ int send_request_init(
409 int rc = 0; 410 int rc = 0;
410 411
411 /* Wait for space in HW and SW FIFO. Poll for as much as FIFO_TIMEOUT. */ 412 /* Wait for space in HW and SW FIFO. Poll for as much as FIFO_TIMEOUT. */
412 rc = request_mgr_queues_status_check(req_mgr_h, cc_base, total_seq_len); 413 rc = request_mgr_queues_status_check(drvdata, req_mgr_h,
414 total_seq_len);
413 if (unlikely(rc != 0)) 415 if (unlikely(rc != 0))
414 return rc; 416 return rc;
415 417
@@ -418,8 +420,8 @@ int send_request_init(
418 enqueue_seq(cc_base, desc, len); 420 enqueue_seq(cc_base, desc, len);
419 421
420 /* Update the free slots in HW queue */ 422 /* Update the free slots in HW queue */
421 req_mgr_h->q_free_slots = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, 423 req_mgr_h->q_free_slots =
422 DSCRPTR_QUEUE_CONTENT)); 424 cc_ioread(drvdata, CC_REG(DSCRPTR_QUEUE_CONTENT));
423 425
424 return 0; 426 return 0;
425} 427}
@@ -448,7 +450,7 @@ static void comp_work_handler(struct work_struct *work)
448static void proc_completions(struct ssi_drvdata *drvdata) 450static void proc_completions(struct ssi_drvdata *drvdata)
449{ 451{
450 struct ssi_crypto_req *ssi_req; 452 struct ssi_crypto_req *ssi_req;
451 struct platform_device *plat_dev = drvdata->plat_dev; 453 struct device *dev = drvdata_to_dev(drvdata);
452 struct ssi_request_mgr_handle *request_mgr_handle = 454 struct ssi_request_mgr_handle *request_mgr_handle =
453 drvdata->request_mgr_handle; 455 drvdata->request_mgr_handle;
454#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 456#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
@@ -460,8 +462,13 @@ static void proc_completions(struct ssi_drvdata *drvdata)
460 462
461 /* Dequeue request */ 463 /* Dequeue request */
462 if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) { 464 if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) {
463 SSI_LOG_ERR("Request queue is empty req_queue_head==req_queue_tail==%u\n", request_mgr_handle->req_queue_head); 465 /* We are supposed to handle a completion but our
464 BUG(); 466 * queue is empty. This is not normal. Return and
467 * hope for the best.
468 */
469 dev_err(dev, "Request queue is empty head == tail %u\n",
470 request_mgr_handle->req_queue_head);
471 break;
465 } 472 }
466 473
467 ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail]; 474 ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail];
@@ -476,39 +483,40 @@ static void proc_completions(struct ssi_drvdata *drvdata)
476 u32 axi_err; 483 u32 axi_err;
477 int i; 484 int i;
478 485
479 SSI_LOG_INFO("Delay\n"); 486 dev_info(dev, "Delay\n");
480 for (i = 0; i < 1000000; i++) 487 for (i = 0; i < 1000000; i++)
481 axi_err = READ_REGISTER(drvdata->cc_base + CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR)); 488 axi_err = cc_ioread(drvdata,
489 CC_REG(AXIM_MON_ERR));
482 } 490 }
483#endif /* COMPLETION_DELAY */ 491#endif /* COMPLETION_DELAY */
484 492
485 if (likely(ssi_req->user_cb)) 493 if (likely(ssi_req->user_cb))
486 ssi_req->user_cb(&plat_dev->dev, ssi_req->user_arg, drvdata->cc_base); 494 ssi_req->user_cb(dev, ssi_req->user_arg,
495 drvdata->cc_base);
487 request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); 496 request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
488 SSI_LOG_DEBUG("Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail); 497 dev_dbg(dev, "Dequeue request tail=%u\n",
489 SSI_LOG_DEBUG("Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); 498 request_mgr_handle->req_queue_tail);
499 dev_dbg(dev, "Request completed. axi_completed=%d\n",
500 request_mgr_handle->axi_completed);
490#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 501#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
491 rc = ssi_power_mgr_runtime_put_suspend(&plat_dev->dev); 502 rc = ssi_power_mgr_runtime_put_suspend(dev);
492 if (rc != 0) 503 if (rc != 0)
493 SSI_LOG_ERR("Failed to set runtime suspension %d\n", rc); 504 dev_err(dev, "Failed to set runtime suspension %d\n",
505 rc);
494#endif 506#endif
495 } 507 }
496} 508}
497 509
498static inline u32 cc_axi_comp_count(void __iomem *cc_base) 510static inline u32 cc_axi_comp_count(struct ssi_drvdata *drvdata)
499{ 511{
500 /* The CC_HAL_READ_REGISTER macro implictly requires and uses
501 * a base MMIO register address variable named cc_base.
502 */
503 return FIELD_GET(AXIM_MON_COMP_VALUE, 512 return FIELD_GET(AXIM_MON_COMP_VALUE,
504 CC_HAL_READ_REGISTER(AXIM_MON_BASE_OFFSET)); 513 cc_ioread(drvdata, CC_REG(AXIM_MON_COMP)));
505} 514}
506 515
507/* Deferred service handler, run as interrupt-fired tasklet */ 516/* Deferred service handler, run as interrupt-fired tasklet */
508static void comp_handler(unsigned long devarg) 517static void comp_handler(unsigned long devarg)
509{ 518{
510 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg; 519 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg;
511 void __iomem *cc_base = drvdata->cc_base;
512 struct ssi_request_mgr_handle *request_mgr_handle = 520 struct ssi_request_mgr_handle *request_mgr_handle =
513 drvdata->request_mgr_handle; 521 drvdata->request_mgr_handle;
514 522
@@ -517,12 +525,16 @@ static void comp_handler(unsigned long devarg)
517 irq = (drvdata->irq & SSI_COMP_IRQ_MASK); 525 irq = (drvdata->irq & SSI_COMP_IRQ_MASK);
518 526
519 if (irq & SSI_COMP_IRQ_MASK) { 527 if (irq & SSI_COMP_IRQ_MASK) {
520 /* To avoid the interrupt from firing as we unmask it, we clear it now */ 528 /* To avoid the interrupt from firing as we unmask it,
521 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), SSI_COMP_IRQ_MASK); 529 * we clear it now
530 */
531 cc_iowrite(drvdata, CC_REG(HOST_ICR), SSI_COMP_IRQ_MASK);
522 532
523 /* Avoid race with above clear: Test completion counter once more */ 533 /* Avoid race with above clear: Test completion counter
534 * once more
535 */
524 request_mgr_handle->axi_completed += 536 request_mgr_handle->axi_completed +=
525 cc_axi_comp_count(cc_base); 537 cc_axi_comp_count(drvdata);
526 538
527 while (request_mgr_handle->axi_completed) { 539 while (request_mgr_handle->axi_completed) {
528 do { 540 do {
@@ -531,20 +543,21 @@ static void comp_handler(unsigned long devarg)
531 * request_mgr_handle->axi_completed is 0. 543 * request_mgr_handle->axi_completed is 0.
532 */ 544 */
533 request_mgr_handle->axi_completed = 545 request_mgr_handle->axi_completed =
534 cc_axi_comp_count(cc_base); 546 cc_axi_comp_count(drvdata);
535 } while (request_mgr_handle->axi_completed > 0); 547 } while (request_mgr_handle->axi_completed > 0);
536 548
537 /* To avoid the interrupt from firing as we unmask it, we clear it now */ 549 cc_iowrite(drvdata, CC_REG(HOST_ICR),
538 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), SSI_COMP_IRQ_MASK); 550 SSI_COMP_IRQ_MASK);
539 551
540 /* Avoid race with above clear: Test completion counter once more */
541 request_mgr_handle->axi_completed += 552 request_mgr_handle->axi_completed +=
542 cc_axi_comp_count(cc_base); 553 cc_axi_comp_count(drvdata);
543 } 554 }
544 } 555 }
545 /* after verifing that there is nothing to do, Unmask AXI completion interrupt */ 556 /* after verifing that there is nothing to do,
546 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), 557 * unmask AXI completion interrupt
547 CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR)) & ~irq); 558 */
559 cc_iowrite(drvdata, CC_REG(HOST_IMR),
560 cc_ioread(drvdata, CC_REG(HOST_IMR)) & ~irq);
548} 561}
549 562
550/* 563/*
diff --git a/drivers/staging/ccree/ssi_sram_mgr.c b/drivers/staging/ccree/ssi_sram_mgr.c
index f11116afe89a..07260d168c91 100644
--- a/drivers/staging/ccree/ssi_sram_mgr.c
+++ b/drivers/staging/ccree/ssi_sram_mgr.c
@@ -50,28 +50,14 @@ void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata)
50 */ 50 */
51int ssi_sram_mgr_init(struct ssi_drvdata *drvdata) 51int ssi_sram_mgr_init(struct ssi_drvdata *drvdata)
52{ 52{
53 struct ssi_sram_mgr_ctx *smgr_ctx;
54 int rc;
55
56 /* Allocate "this" context */ 53 /* Allocate "this" context */
57 drvdata->sram_mgr_handle = kzalloc( 54 drvdata->sram_mgr_handle = kzalloc(sizeof(struct ssi_sram_mgr_ctx),
58 sizeof(struct ssi_sram_mgr_ctx), GFP_KERNEL); 55 GFP_KERNEL);
59 if (!drvdata->sram_mgr_handle) {
60 SSI_LOG_ERR("Not enough memory to allocate SRAM_MGR ctx (%zu)\n",
61 sizeof(struct ssi_sram_mgr_ctx));
62 rc = -ENOMEM;
63 goto out;
64 }
65 smgr_ctx = drvdata->sram_mgr_handle;
66 56
67 /* Pool starts at start of SRAM */ 57 if (!drvdata->sram_mgr_handle)
68 smgr_ctx->sram_free_offset = 0; 58 return -ENOMEM;
69 59
70 return 0; 60 return 0;
71
72out:
73 ssi_sram_mgr_fini(drvdata);
74 return rc;
75} 61}
76 62
77/*! 63/*!
@@ -86,22 +72,23 @@ out:
86ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size) 72ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size)
87{ 73{
88 struct ssi_sram_mgr_ctx *smgr_ctx = drvdata->sram_mgr_handle; 74 struct ssi_sram_mgr_ctx *smgr_ctx = drvdata->sram_mgr_handle;
75 struct device *dev = drvdata_to_dev(drvdata);
89 ssi_sram_addr_t p; 76 ssi_sram_addr_t p;
90 77
91 if (unlikely((size & 0x3) != 0)) { 78 if (unlikely((size & 0x3) != 0)) {
92 SSI_LOG_ERR("Requested buffer size (%u) is not multiple of 4", 79 dev_err(dev, "Requested buffer size (%u) is not multiple of 4",
93 size); 80 size);
94 return NULL_SRAM_ADDR; 81 return NULL_SRAM_ADDR;
95 } 82 }
96 if (unlikely(size > (SSI_CC_SRAM_SIZE - smgr_ctx->sram_free_offset))) { 83 if (unlikely(size > (SSI_CC_SRAM_SIZE - smgr_ctx->sram_free_offset))) {
97 SSI_LOG_ERR("Not enough space to allocate %u B (at offset %llu)\n", 84 dev_err(dev, "Not enough space to allocate %u B (at offset %llu)\n",
98 size, smgr_ctx->sram_free_offset); 85 size, smgr_ctx->sram_free_offset);
99 return NULL_SRAM_ADDR; 86 return NULL_SRAM_ADDR;
100 } 87 }
101 88
102 p = smgr_ctx->sram_free_offset; 89 p = smgr_ctx->sram_free_offset;
103 smgr_ctx->sram_free_offset += size; 90 smgr_ctx->sram_free_offset += size;
104 SSI_LOG_DEBUG("Allocated %u B @ %u\n", size, (unsigned int)p); 91 dev_dbg(dev, "Allocated %u B @ %u\n", size, (unsigned int)p);
105 return p; 92 return p;
106} 93}
107 94
diff --git a/drivers/staging/ccree/ssi_sysfs.c b/drivers/staging/ccree/ssi_sysfs.c
index 0655658bba4d..5d39f15cdb59 100644
--- a/drivers/staging/ccree/ssi_sysfs.c
+++ b/drivers/staging/ccree/ssi_sysfs.c
@@ -24,277 +24,22 @@
24 24
25static struct ssi_drvdata *sys_get_drvdata(void); 25static struct ssi_drvdata *sys_get_drvdata(void);
26 26
27#ifdef CC_CYCLE_COUNT
28
29#include <asm/timex.h>
30
31struct stat_item {
32 unsigned int min;
33 unsigned int max;
34 cycles_t sum;
35 unsigned int count;
36};
37
38struct stat_name {
39 const char *op_type_name;
40 const char *stat_phase_name[MAX_STAT_PHASES];
41};
42
43static struct stat_name stat_name_db[MAX_STAT_OP_TYPES] = {
44 {
45 /* STAT_OP_TYPE_NULL */
46 .op_type_name = "NULL",
47 .stat_phase_name = {NULL},
48 },
49 {
50 .op_type_name = "Encode",
51 .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks",
52 .stat_phase_name[STAT_PHASE_1] = "Map buffers",
53 .stat_phase_name[STAT_PHASE_2] = "Create sequence",
54 .stat_phase_name[STAT_PHASE_3] = "Send Request",
55 .stat_phase_name[STAT_PHASE_4] = "HW-Q push",
56 .stat_phase_name[STAT_PHASE_5] = "Sequence completion",
57 .stat_phase_name[STAT_PHASE_6] = "HW cycles",
58 },
59 { .op_type_name = "Decode",
60 .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks",
61 .stat_phase_name[STAT_PHASE_1] = "Map buffers",
62 .stat_phase_name[STAT_PHASE_2] = "Create sequence",
63 .stat_phase_name[STAT_PHASE_3] = "Send Request",
64 .stat_phase_name[STAT_PHASE_4] = "HW-Q push",
65 .stat_phase_name[STAT_PHASE_5] = "Sequence completion",
66 .stat_phase_name[STAT_PHASE_6] = "HW cycles",
67 },
68 { .op_type_name = "Setkey",
69 .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks",
70 .stat_phase_name[STAT_PHASE_1] = "Copy key to ctx",
71 .stat_phase_name[STAT_PHASE_2] = "Create sequence",
72 .stat_phase_name[STAT_PHASE_3] = "Send Request",
73 .stat_phase_name[STAT_PHASE_4] = "HW-Q push",
74 .stat_phase_name[STAT_PHASE_5] = "Sequence completion",
75 .stat_phase_name[STAT_PHASE_6] = "HW cycles",
76 },
77 {
78 .op_type_name = "Generic",
79 .stat_phase_name[STAT_PHASE_0] = "Interrupt",
80 .stat_phase_name[STAT_PHASE_1] = "ISR-to-Tasklet",
81 .stat_phase_name[STAT_PHASE_2] = "Tasklet start-to-end",
82 .stat_phase_name[STAT_PHASE_3] = "Tasklet:user_cb()",
83 .stat_phase_name[STAT_PHASE_4] = "Tasklet:dx_X_complete() - w/o X_complete()",
84 .stat_phase_name[STAT_PHASE_5] = "",
85 .stat_phase_name[STAT_PHASE_6] = "HW cycles",
86 }
87};
88
89/*
90 * Structure used to create a directory
91 * and its attributes in sysfs.
92 */
93struct sys_dir {
94 struct kobject *sys_dir_kobj;
95 struct attribute_group sys_dir_attr_group;
96 struct attribute **sys_dir_attr_list;
97 u32 num_of_attrs;
98 struct ssi_drvdata *drvdata; /* Associated driver context */
99};
100
101/* top level directory structures */
102struct sys_dir sys_top_dir;
103
104static DEFINE_SPINLOCK(stat_lock);
105
106/* List of DBs */
107static struct stat_item stat_host_db[MAX_STAT_OP_TYPES][MAX_STAT_PHASES];
108static struct stat_item stat_cc_db[MAX_STAT_OP_TYPES][MAX_STAT_PHASES];
109
110static void init_db(struct stat_item item[MAX_STAT_OP_TYPES][MAX_STAT_PHASES])
111{
112 unsigned int i, j;
113
114 /* Clear db */
115 for (i = 0; i < MAX_STAT_OP_TYPES; i++) {
116 for (j = 0; j < MAX_STAT_PHASES; j++) {
117 item[i][j].min = 0xFFFFFFFF;
118 item[i][j].max = 0;
119 item[i][j].sum = 0;
120 item[i][j].count = 0;
121 }
122 }
123}
124
125static void update_db(struct stat_item *item, unsigned int result)
126{
127 item->count++;
128 item->sum += result;
129 if (result < item->min)
130 item->min = result;
131 if (result > item->max)
132 item->max = result;
133}
134
135static void display_db(struct stat_item item[MAX_STAT_OP_TYPES][MAX_STAT_PHASES])
136{
137 unsigned int i, j;
138 u64 avg;
139
140 for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) {
141 for (j = 0; j < MAX_STAT_PHASES; j++) {
142 if (item[i][j].count > 0) {
143 avg = (u64)item[i][j].sum;
144 do_div(avg, item[i][j].count);
145 SSI_LOG_ERR("%s, %s: min=%d avg=%d max=%d sum=%lld count=%d\n",
146 stat_name_db[i].op_type_name,
147 stat_name_db[i].stat_phase_name[j],
148 item[i][j].min, (int)avg,
149 item[i][j].max,
150 (long long)item[i][j].sum,
151 item[i][j].count);
152 }
153 }
154 }
155}
156
157/**************************************
158 * Attributes show functions section *
159 **************************************/
160
161static ssize_t ssi_sys_stats_host_db_clear(struct kobject *kobj,
162 struct kobj_attribute *attr,
163 const char *buf, size_t count)
164{
165 init_db(stat_host_db);
166 return count;
167}
168
169static ssize_t ssi_sys_stats_cc_db_clear(struct kobject *kobj,
170 struct kobj_attribute *attr,
171 const char *buf, size_t count)
172{
173 init_db(stat_cc_db);
174 return count;
175}
176
177static ssize_t ssi_sys_stat_host_db_show(struct kobject *kobj,
178 struct kobj_attribute *attr, char *buf)
179{
180 int i, j;
181 char line[512];
182 u32 min_cyc, max_cyc;
183 u64 avg;
184 ssize_t buf_len, tmp_len = 0;
185
186 buf_len = scnprintf(buf, PAGE_SIZE,
187 "phase\t\t\t\t\t\t\tmin[cy]\tavg[cy]\tmax[cy]\t#samples\n");
188 if (buf_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/
189 return buf_len;
190 for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) {
191 for (j = 0; j < MAX_STAT_PHASES - 1; j++) {
192 if (stat_host_db[i][j].count > 0) {
193 avg = (u64)stat_host_db[i][j].sum;
194 do_div(avg, stat_host_db[i][j].count);
195 min_cyc = stat_host_db[i][j].min;
196 max_cyc = stat_host_db[i][j].max;
197 } else {
198 avg = min_cyc = max_cyc = 0;
199 }
200 tmp_len = scnprintf(line, 512,
201 "%s::%s\t\t\t\t\t%6u\t%6u\t%6u\t%7u\n",
202 stat_name_db[i].op_type_name,
203 stat_name_db[i].stat_phase_name[j],
204 min_cyc, (unsigned int)avg, max_cyc,
205 stat_host_db[i][j].count);
206 if (tmp_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/
207 return buf_len;
208 if (buf_len + tmp_len >= PAGE_SIZE)
209 return buf_len;
210 buf_len += tmp_len;
211 strncat(buf, line, 512);
212 }
213 }
214 return buf_len;
215}
216
217static ssize_t ssi_sys_stat_cc_db_show(struct kobject *kobj,
218 struct kobj_attribute *attr, char *buf)
219{
220 int i;
221 char line[256];
222 u32 min_cyc, max_cyc;
223 u64 avg;
224 ssize_t buf_len, tmp_len = 0;
225
226 buf_len = scnprintf(buf, PAGE_SIZE,
227 "phase\tmin[cy]\tavg[cy]\tmax[cy]\t#samples\n");
228 if (buf_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/
229 return buf_len;
230 for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) {
231 if (stat_cc_db[i][STAT_PHASE_6].count > 0) {
232 avg = (u64)stat_cc_db[i][STAT_PHASE_6].sum;
233 do_div(avg, stat_cc_db[i][STAT_PHASE_6].count);
234 min_cyc = stat_cc_db[i][STAT_PHASE_6].min;
235 max_cyc = stat_cc_db[i][STAT_PHASE_6].max;
236 } else {
237 avg = min_cyc = max_cyc = 0;
238 }
239 tmp_len = scnprintf(line, 256, "%s\t%6u\t%6u\t%6u\t%7u\n",
240 stat_name_db[i].op_type_name, min_cyc,
241 (unsigned int)avg, max_cyc,
242 stat_cc_db[i][STAT_PHASE_6].count);
243
244 if (tmp_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/
245 return buf_len;
246
247 if (buf_len + tmp_len >= PAGE_SIZE)
248 return buf_len;
249 buf_len += tmp_len;
250 strncat(buf, line, 256);
251 }
252 return buf_len;
253}
254
255void update_host_stat(unsigned int op_type, unsigned int phase, cycles_t result)
256{
257 unsigned long flags;
258
259 spin_lock_irqsave(&stat_lock, flags);
260 update_db(&stat_host_db[op_type][phase], (unsigned int)result);
261 spin_unlock_irqrestore(&stat_lock, flags);
262}
263
264void update_cc_stat(
265 unsigned int op_type,
266 unsigned int phase,
267 unsigned int elapsed_cycles)
268{
269 update_db(&stat_cc_db[op_type][phase], elapsed_cycles);
270}
271
272void display_all_stat_db(void)
273{
274 SSI_LOG_ERR("\n======= CYCLE COUNT STATS =======\n");
275 display_db(stat_host_db);
276 SSI_LOG_ERR("\n======= CC HW CYCLE COUNT STATS =======\n");
277 display_db(stat_cc_db);
278}
279#endif /*CC_CYCLE_COUNT*/
280
281static ssize_t ssi_sys_regdump_show(struct kobject *kobj, 27static ssize_t ssi_sys_regdump_show(struct kobject *kobj,
282 struct kobj_attribute *attr, char *buf) 28 struct kobj_attribute *attr, char *buf)
283{ 29{
284 struct ssi_drvdata *drvdata = sys_get_drvdata(); 30 struct ssi_drvdata *drvdata = sys_get_drvdata();
285 u32 register_value; 31 u32 register_value;
286 void __iomem *cc_base = drvdata->cc_base;
287 int offset = 0; 32 int offset = 0;
288 33
289 register_value = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); 34 register_value = cc_ioread(drvdata, CC_REG(HOST_SIGNATURE));
290 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_SIGNATURE ", DX_HOST_SIGNATURE_REG_OFFSET, register_value); 35 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_SIGNATURE ", DX_HOST_SIGNATURE_REG_OFFSET, register_value);
291 register_value = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRR)); 36 register_value = cc_ioread(drvdata, CC_REG(HOST_IRR));
292 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_IRR ", DX_HOST_IRR_REG_OFFSET, register_value); 37 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_IRR ", DX_HOST_IRR_REG_OFFSET, register_value);
293 register_value = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_POWER_DOWN_EN)); 38 register_value = cc_ioread(drvdata, CC_REG(HOST_POWER_DOWN_EN));
294 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_POWER_DOWN_EN ", DX_HOST_POWER_DOWN_EN_REG_OFFSET, register_value); 39 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "HOST_POWER_DOWN_EN ", DX_HOST_POWER_DOWN_EN_REG_OFFSET, register_value);
295 register_value = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR)); 40 register_value = cc_ioread(drvdata, CC_REG(AXIM_MON_ERR));
296 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "AXIM_MON_ERR ", DX_AXIM_MON_ERR_REG_OFFSET, register_value); 41 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "AXIM_MON_ERR ", DX_AXIM_MON_ERR_REG_OFFSET, register_value);
297 register_value = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_CONTENT)); 42 register_value = cc_ioread(drvdata, CC_REG(DSCRPTR_QUEUE_CONTENT));
298 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "DSCRPTR_QUEUE_CONTENT", DX_DSCRPTR_QUEUE_CONTENT_REG_OFFSET, register_value); 43 offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 0x%08X\n", "DSCRPTR_QUEUE_CONTENT", DX_DSCRPTR_QUEUE_CONTENT_REG_OFFSET, register_value);
299 return offset; 44 return offset;
300} 45}
@@ -304,12 +49,6 @@ static ssize_t ssi_sys_help_show(struct kobject *kobj,
304{ 49{
305 char *help_str[] = { 50 char *help_str[] = {
306 "cat reg_dump ", "Print several of CC register values", 51 "cat reg_dump ", "Print several of CC register values",
307 #if defined CC_CYCLE_COUNT
308 "cat stats_host ", "Print host statistics",
309 "echo <number> > stats_host", "Clear host statistics database",
310 "cat stats_cc ", "Print CC statistics",
311 "echo <number> > stats_cc ", "Clear CC statistics database",
312 #endif
313 }; 52 };
314 int i = 0, offset = 0; 53 int i = 0, offset = 0;
315 54
@@ -376,7 +115,7 @@ static int sys_init_dir(struct sys_dir *sys_dir, struct ssi_drvdata *drvdata,
376 return -ENOMEM; 115 return -ENOMEM;
377 /* allocate memory for directory's attributes list */ 116 /* allocate memory for directory's attributes list */
378 sys_dir->sys_dir_attr_list = 117 sys_dir->sys_dir_attr_list =
379 kzalloc(sizeof(struct attribute *) * (num_of_attrs + 1), 118 kcalloc(num_of_attrs + 1, sizeof(struct attribute *),
380 GFP_KERNEL); 119 GFP_KERNEL);
381 120
382 if (!(sys_dir->sys_dir_attr_list)) { 121 if (!(sys_dir->sys_dir_attr_list)) {
@@ -413,14 +152,9 @@ static void sys_free_dir(struct sys_dir *sys_dir)
413int ssi_sysfs_init(struct kobject *sys_dev_obj, struct ssi_drvdata *drvdata) 152int ssi_sysfs_init(struct kobject *sys_dev_obj, struct ssi_drvdata *drvdata)
414{ 153{
415 int retval; 154 int retval;
155 struct device *dev = drvdata_to_dev(drvdata);
416 156
417#if defined CC_CYCLE_COUNT 157 dev_info(dev, "setup sysfs under %s\n", sys_dev_obj->name);
418 /* Init. statistics */
419 init_db(stat_host_db);
420 init_db(stat_cc_db);
421#endif
422
423 SSI_LOG_ERR("setup sysfs under %s\n", sys_dev_obj->name);
424 158
425 /* Initialize top directory */ 159 /* Initialize top directory */
426 retval = sys_init_dir(&sys_top_dir, drvdata, sys_dev_obj, "cc_info", 160 retval = sys_init_dir(&sys_top_dir, drvdata, sys_dev_obj, "cc_info",
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 7a655ed071a3..4218fc0e17f1 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -785,8 +785,8 @@ config COMEDI_ADV_PCI_DIO
785 ---help--- 785 ---help---
786 Enable support for Advantech PCI DIO cards 786 Enable support for Advantech PCI DIO cards
787 PCI-1730, PCI-1733, PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, 787 PCI-1730, PCI-1733, PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U,
788 PCI-1750, PCI-1751, PCI-1752, PCI-1753/E, PCI-1754, PCI-1756 and 788 PCI-1750, PCI-1751, PCI-1752, PCI-1753/E, PCI-1754, PCI-1756,
789 PCI-1762 789 PCI-1761 and PCI-1762
790 790
791 To compile this driver as a module, choose M here: the module will be 791 To compile this driver as a module, choose M here: the module will be
792 called adv_pci_dio. 792 called adv_pci_dio.
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index 620cec13d74c..a8186687ca2c 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -12,9 +12,9 @@
12 * Devices: [Advantech] PCI-1730 (adv_pci_dio), PCI-1733, 12 * Devices: [Advantech] PCI-1730 (adv_pci_dio), PCI-1733,
13 * PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, PCI-1750, 13 * PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, PCI-1750,
14 * PCI-1751, PCI-1752, PCI-1753, PCI-1753+PCI-1753E, 14 * PCI-1751, PCI-1752, PCI-1753, PCI-1753+PCI-1753E,
15 * PCI-1754, PCI-1756, PCI-1762 15 * PCI-1754, PCI-1756, PCI-1761, PCI-1762
16 * Author: Michal Dobes <dobes@tesnet.cz> 16 * Author: Michal Dobes <dobes@tesnet.cz>
17 * Updated: Mon, 09 Jan 2012 12:40:46 +0000 17 * Updated: Fri, 25 Aug 2017 07:23:06 +0300
18 * Status: untested 18 * Status: untested
19 * 19 *
20 * Configuration Options: not applicable, uses PCI auto config 20 * Configuration Options: not applicable, uses PCI auto config
@@ -50,6 +50,11 @@
50/* PCI-1752, PCI-1756 special registers */ 50/* PCI-1752, PCI-1756 special registers */
51#define PCI1752_CFC_REG 0x12 /* R/W: channel freeze function */ 51#define PCI1752_CFC_REG 0x12 /* R/W: channel freeze function */
52 52
53/* PCI-1761 interrupt control registers */
54#define PCI1761_INT_EN_REG 0x03 /* R/W: enable/disable interrupts */
55#define PCI1761_INT_RF_REG 0x04 /* R/W: falling/rising edge */
56#define PCI1761_INT_CLR_REG 0x05 /* R/W: clear interrupts */
57
53/* PCI-1762 interrupt control registers */ 58/* PCI-1762 interrupt control registers */
54#define PCI1762_INT_REG 0x06 /* R/W: status/control */ 59#define PCI1762_INT_REG 0x06 /* R/W: status/control */
55 60
@@ -72,6 +77,7 @@ enum pci_dio_boardid {
72 TYPE_PCI1753E, 77 TYPE_PCI1753E,
73 TYPE_PCI1754, 78 TYPE_PCI1754,
74 TYPE_PCI1756, 79 TYPE_PCI1756,
80 TYPE_PCI1761,
75 TYPE_PCI1762 81 TYPE_PCI1762
76}; 82};
77 83
@@ -181,6 +187,13 @@ static const struct dio_boardtype boardtypes[] = {
181 .id_reg = 0x10, 187 .id_reg = 0x10,
182 .is_16bit = 1, 188 .is_16bit = 1,
183 }, 189 },
190 [TYPE_PCI1761] = {
191 .name = "pci1761",
192 .nsubdevs = 3,
193 .sdi[1] = { 8, 0x01 }, /* ISO DI 0-7 */
194 .sdo[1] = { 8, 0x00 }, /* RELAY DO 0-7 */
195 .id_reg = 0x02,
196 },
184 [TYPE_PCI1762] = { 197 [TYPE_PCI1762] = {
185 .name = "pci1762", 198 .name = "pci1762",
186 .nsubdevs = 3, 199 .nsubdevs = 3,
@@ -309,6 +322,14 @@ static int pci_dio_reset(struct comedi_device *dev, unsigned long cardtype)
309 outw(0x08, dev->iobase + PCI1754_INT_REG(3)); 322 outw(0x08, dev->iobase + PCI1754_INT_REG(3));
310 } 323 }
311 break; 324 break;
325 case TYPE_PCI1761:
326 /* disable interrupts */
327 outb(0, dev->iobase + PCI1761_INT_EN_REG);
328 /* clear interrupts */
329 outb(0xff, dev->iobase + PCI1761_INT_CLR_REG);
330 /* set rising edge trigger */
331 outb(0, dev->iobase + PCI1761_INT_RF_REG);
332 break;
312 case TYPE_PCI1762: 333 case TYPE_PCI1762:
313 outw(0x0101, dev->iobase + PCI1762_INT_REG); 334 outw(0x0101, dev->iobase + PCI1762_INT_REG);
314 break; 335 break;
@@ -496,6 +517,7 @@ static const struct pci_device_id adv_pci_dio_pci_table[] = {
496 { PCI_VDEVICE(ADVANTECH, 0x1753), TYPE_PCI1753 }, 517 { PCI_VDEVICE(ADVANTECH, 0x1753), TYPE_PCI1753 },
497 { PCI_VDEVICE(ADVANTECH, 0x1754), TYPE_PCI1754 }, 518 { PCI_VDEVICE(ADVANTECH, 0x1754), TYPE_PCI1754 },
498 { PCI_VDEVICE(ADVANTECH, 0x1756), TYPE_PCI1756 }, 519 { PCI_VDEVICE(ADVANTECH, 0x1756), TYPE_PCI1756 },
520 { PCI_VDEVICE(ADVANTECH, 0x1761), TYPE_PCI1761 },
499 { PCI_VDEVICE(ADVANTECH, 0x1762), TYPE_PCI1762 }, 521 { PCI_VDEVICE(ADVANTECH, 0x1762), TYPE_PCI1762 },
500 { 0 } 522 { 0 }
501}; 523};
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index ccfd642998be..c7e8194984e5 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -93,6 +93,7 @@ struct waveform_private {
93 unsigned int ai_scan_period; /* AI scan period in usec */ 93 unsigned int ai_scan_period; /* AI scan period in usec */
94 unsigned int ai_convert_period; /* AI conversion period in usec */ 94 unsigned int ai_convert_period; /* AI conversion period in usec */
95 struct timer_list ao_timer; /* timer for AO commands */ 95 struct timer_list ao_timer; /* timer for AO commands */
96 struct comedi_device *dev; /* parent comedi device */
96 u64 ao_last_scan_time; /* time of previous AO scan in usec */ 97 u64 ao_last_scan_time; /* time of previous AO scan in usec */
97 unsigned int ao_scan_period; /* AO scan period in usec */ 98 unsigned int ao_scan_period; /* AO scan period in usec */
98 unsigned short ao_loopbacks[N_CHANS]; 99 unsigned short ao_loopbacks[N_CHANS];
@@ -201,10 +202,10 @@ static unsigned short fake_waveform(struct comedi_device *dev,
201 * It should run in the background; therefore it is scheduled by 202 * It should run in the background; therefore it is scheduled by
202 * a timer mechanism. 203 * a timer mechanism.
203 */ 204 */
204static void waveform_ai_timer(unsigned long arg) 205static void waveform_ai_timer(struct timer_list *t)
205{ 206{
206 struct comedi_device *dev = (struct comedi_device *)arg; 207 struct waveform_private *devpriv = from_timer(devpriv, t, ai_timer);
207 struct waveform_private *devpriv = dev->private; 208 struct comedi_device *dev = devpriv->dev;
208 struct comedi_subdevice *s = dev->read_subdev; 209 struct comedi_subdevice *s = dev->read_subdev;
209 struct comedi_async *async = s->async; 210 struct comedi_async *async = s->async;
210 struct comedi_cmd *cmd = &async->cmd; 211 struct comedi_cmd *cmd = &async->cmd;
@@ -438,10 +439,10 @@ static int waveform_ai_insn_read(struct comedi_device *dev,
438 * This is the background routine to handle AO commands, scheduled by 439 * This is the background routine to handle AO commands, scheduled by
439 * a timer mechanism. 440 * a timer mechanism.
440 */ 441 */
441static void waveform_ao_timer(unsigned long arg) 442static void waveform_ao_timer(struct timer_list *t)
442{ 443{
443 struct comedi_device *dev = (struct comedi_device *)arg; 444 struct waveform_private *devpriv = from_timer(devpriv, t, ao_timer);
444 struct waveform_private *devpriv = dev->private; 445 struct comedi_device *dev = devpriv->dev;
445 struct comedi_subdevice *s = dev->write_subdev; 446 struct comedi_subdevice *s = dev->write_subdev;
446 struct comedi_async *async = s->async; 447 struct comedi_async *async = s->async;
447 struct comedi_cmd *cmd = &async->cmd; 448 struct comedi_cmd *cmd = &async->cmd;
@@ -686,8 +687,9 @@ static int waveform_common_attach(struct comedi_device *dev,
686 for (i = 0; i < s->n_chan; i++) 687 for (i = 0; i < s->n_chan; i++)
687 devpriv->ao_loopbacks[i] = s->maxdata / 2; 688 devpriv->ao_loopbacks[i] = s->maxdata / 2;
688 689
689 setup_timer(&devpriv->ai_timer, waveform_ai_timer, (unsigned long)dev); 690 devpriv->dev = dev;
690 setup_timer(&devpriv->ao_timer, waveform_ao_timer, (unsigned long)dev); 691 timer_setup(&devpriv->ai_timer, waveform_ai_timer, 0);
692 timer_setup(&devpriv->ao_timer, waveform_ao_timer, 0);
691 693
692 dev_info(dev->class_dev, 694 dev_info(dev->class_dev,
693 "%s: %u microvolt, %u microsecond waveform attached\n", 695 "%s: %u microvolt, %u microsecond waveform attached\n",
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 5d157951f63f..ddd4aeab6365 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -440,6 +440,7 @@ static inline int timer_period(void)
440 440
441struct das16_private_struct { 441struct das16_private_struct {
442 struct comedi_isadma *dma; 442 struct comedi_isadma *dma;
443 struct comedi_device *dev;
443 unsigned int clockbase; 444 unsigned int clockbase;
444 unsigned int ctrl_reg; 445 unsigned int ctrl_reg;
445 unsigned int divisor1; 446 unsigned int divisor1;
@@ -525,10 +526,10 @@ static void das16_interrupt(struct comedi_device *dev)
525 comedi_handle_events(dev, s); 526 comedi_handle_events(dev, s);
526} 527}
527 528
528static void das16_timer_interrupt(unsigned long arg) 529static void das16_timer_interrupt(struct timer_list *t)
529{ 530{
530 struct comedi_device *dev = (struct comedi_device *)arg; 531 struct das16_private_struct *devpriv = from_timer(devpriv, t, timer);
531 struct das16_private_struct *devpriv = dev->private; 532 struct comedi_device *dev = devpriv->dev;
532 unsigned long flags; 533 unsigned long flags;
533 534
534 das16_interrupt(dev); 535 das16_interrupt(dev);
@@ -934,6 +935,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
934{ 935{
935 struct das16_private_struct *devpriv = dev->private; 936 struct das16_private_struct *devpriv = dev->private;
936 937
938 timer_setup(&devpriv->timer, das16_timer_interrupt, 0);
939
937 /* only DMA channels 3 and 1 are valid */ 940 /* only DMA channels 3 and 1 are valid */
938 if (!(dma_chan == 1 || dma_chan == 3)) 941 if (!(dma_chan == 1 || dma_chan == 3))
939 return; 942 return;
@@ -941,10 +944,6 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
941 /* DMA uses two buffers */ 944 /* DMA uses two buffers */
942 devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan, 945 devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
943 DAS16_DMA_SIZE, COMEDI_ISADMA_READ); 946 DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
944 if (devpriv->dma) {
945 setup_timer(&devpriv->timer, das16_timer_interrupt,
946 (unsigned long)dev);
947 }
948} 947}
949 948
950static void das16_free_dma(struct comedi_device *dev) 949static void das16_free_dma(struct comedi_device *dev)
@@ -952,8 +951,7 @@ static void das16_free_dma(struct comedi_device *dev)
952 struct das16_private_struct *devpriv = dev->private; 951 struct das16_private_struct *devpriv = dev->private;
953 952
954 if (devpriv) { 953 if (devpriv) {
955 if (devpriv->timer.data) 954 del_timer_sync(&devpriv->timer);
956 del_timer_sync(&devpriv->timer);
957 comedi_isadma_free(devpriv->dma); 955 comedi_isadma_free(devpriv->dma);
958 } 956 }
959} 957}
@@ -1046,6 +1044,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1046 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); 1044 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
1047 if (!devpriv) 1045 if (!devpriv)
1048 return -ENOMEM; 1046 return -ENOMEM;
1047 devpriv->dev = dev;
1049 1048
1050 if (board->size < 0x400) { 1049 if (board->size < 0x400) {
1051 ret = comedi_request_region(dev, it->options[0], board->size); 1050 ret = comedi_request_region(dev, it->options[0], board->size);
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index d5295bbdd28c..217a4b884689 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1062,6 +1062,8 @@ static void dt282x_alloc_dma(struct comedi_device *dev,
1062 PAGE_SIZE, 0); 1062 PAGE_SIZE, 0);
1063 if (!devpriv->dma) 1063 if (!devpriv->dma)
1064 free_irq(irq_num, dev); 1064 free_irq(irq_num, dev);
1065 else
1066 dev->irq = irq_num;
1065} 1067}
1066 1068
1067static void dt282x_free_dma(struct comedi_device *dev) 1069static void dt282x_free_dma(struct comedi_device *dev)
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index f1c2a20a7d4d..cbff3b41bb45 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -96,6 +96,7 @@ struct jr3_pci_poll_delay {
96 96
97struct jr3_pci_dev_private { 97struct jr3_pci_dev_private {
98 struct timer_list timer; 98 struct timer_list timer;
99 struct comedi_device *dev;
99}; 100};
100 101
101union jr3_pci_single_range { 102union jr3_pci_single_range {
@@ -585,10 +586,10 @@ jr3_pci_poll_subdevice(struct comedi_subdevice *s)
585 return result; 586 return result;
586} 587}
587 588
588static void jr3_pci_poll_dev(unsigned long data) 589static void jr3_pci_poll_dev(struct timer_list *t)
589{ 590{
590 struct comedi_device *dev = (struct comedi_device *)data; 591 struct jr3_pci_dev_private *devpriv = from_timer(devpriv, t, timer);
591 struct jr3_pci_dev_private *devpriv = dev->private; 592 struct comedi_device *dev = devpriv->dev;
592 struct jr3_pci_subdev_private *spriv; 593 struct jr3_pci_subdev_private *spriv;
593 struct comedi_subdevice *s; 594 struct comedi_subdevice *s;
594 unsigned long flags; 595 unsigned long flags;
@@ -770,7 +771,8 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
770 spriv->next_time_min = jiffies + msecs_to_jiffies(500); 771 spriv->next_time_min = jiffies + msecs_to_jiffies(500);
771 } 772 }
772 773
773 setup_timer(&devpriv->timer, jr3_pci_poll_dev, (unsigned long)dev); 774 devpriv->dev = dev;
775 timer_setup(&devpriv->timer, jr3_pci_poll_dev, 0);
774 devpriv->timer.expires = jiffies + msecs_to_jiffies(1000); 776 devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
775 add_timer(&devpriv->timer); 777 add_timer(&devpriv->timer);
776 778
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index c80527db9c19..e226275972c0 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -408,9 +408,8 @@ static int s526_gpct_winsn(struct comedi_device *dev,
408 */ 408 */
409 if ((data[1] <= data[0]) || !data[0]) 409 if ((data[1] <= data[0]) || !data[0])
410 return -EINVAL; 410 return -EINVAL;
411 411 /* to write the PULSE_WIDTH */
412 /* Fall thru to write the PULSE_WIDTH */ 412 /* fall through */
413
414 case INSN_CONFIG_GPCT_QUADRATURE_ENCODER: 413 case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
415 case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: 414 case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR:
416 s526_gpct_write(dev, chan, data[0]); 415 s526_gpct_write(dev, chan, data[0]);
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index c1b6079384e9..d9bf5da1b8e5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -291,7 +291,7 @@ static void dgnc_free_irq(struct dgnc_board *brd)
291 * waiter needs to be woken up, and (b) whether the poller needs to 291 * waiter needs to be woken up, and (b) whether the poller needs to
292 * be rescheduled. 292 * be rescheduled.
293 */ 293 */
294static void dgnc_poll_handler(ulong dummy) 294static void dgnc_poll_handler(struct timer_list *unused)
295{ 295{
296 struct dgnc_board *brd; 296 struct dgnc_board *brd;
297 unsigned long flags; 297 unsigned long flags;
@@ -323,7 +323,7 @@ static void dgnc_poll_handler(ulong dummy)
323 if ((ulong)new_time >= 2 * dgnc_poll_tick) 323 if ((ulong)new_time >= 2 * dgnc_poll_tick)
324 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); 324 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
325 325
326 setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0); 326 timer_setup(&dgnc_poll_timer, dgnc_poll_handler, 0);
327 dgnc_poll_timer.expires = dgnc_poll_time; 327 dgnc_poll_timer.expires = dgnc_poll_time;
328 spin_unlock_irqrestore(&dgnc_poll_lock, flags); 328 spin_unlock_irqrestore(&dgnc_poll_lock, flags);
329 329
@@ -392,8 +392,6 @@ static int dgnc_start(void)
392 unsigned long flags; 392 unsigned long flags;
393 struct device *dev; 393 struct device *dev;
394 394
395 init_timer(&dgnc_poll_timer);
396
397 rc = register_chrdev(0, "dgnc", &dgnc_board_fops); 395 rc = register_chrdev(0, "dgnc", &dgnc_board_fops);
398 if (rc < 0) { 396 if (rc < 0) {
399 pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc); 397 pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
@@ -419,7 +417,7 @@ static int dgnc_start(void)
419 417
420 /* Start the poller */ 418 /* Start the poller */
421 spin_lock_irqsave(&dgnc_poll_lock, flags); 419 spin_lock_irqsave(&dgnc_poll_lock, flags);
422 setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0); 420 timer_setup(&dgnc_poll_timer, dgnc_poll_handler, 0);
423 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); 421 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
424 dgnc_poll_timer.expires = dgnc_poll_time; 422 dgnc_poll_timer.expires = dgnc_poll_time;
425 spin_unlock_irqrestore(&dgnc_poll_lock, flags); 423 spin_unlock_irqrestore(&dgnc_poll_lock, flags);
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index 764d6fe0d030..efdb11a5e27f 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -104,7 +104,6 @@ struct board_ops {
104 * struct dgnc_board - Per board information. 104 * struct dgnc_board - Per board information.
105 * @boardnum: Board number (0 - 32). 105 * @boardnum: Board number (0 - 32).
106 * 106 *
107 * @type: Type of board.
108 * @name: Product name. 107 * @name: Product name.
109 * @pdev: Pointer to the pci_dev structure. 108 * @pdev: Pointer to the pci_dev structure.
110 * @bd_flags: Board flags. 109 * @bd_flags: Board flags.
@@ -140,13 +139,9 @@ struct board_ops {
140 * @dpastatus: Board status as defined by DPA. 139 * @dpastatus: Board status as defined by DPA.
141 * @bd_dividend: Board/UART's specific dividend. 140 * @bd_dividend: Board/UART's specific dividend.
142 * @bd_ops: Pointer to board operations structure. 141 * @bd_ops: Pointer to board operations structure.
143 * @proc_entry_pointer: Proc/<board> entry
144 * @dgnc_board_table: Proc/<board> entry
145 */ 142 */
146struct dgnc_board { 143struct dgnc_board {
147 int boardnum; 144 int boardnum;
148
149 int type;
150 char *name; 145 char *name;
151 struct pci_dev *pdev; 146 struct pci_dev *pdev;
152 unsigned long bd_flags; 147 unsigned long bd_flags;
@@ -200,10 +195,6 @@ struct dgnc_board {
200 uint bd_dividend; 195 uint bd_dividend;
201 196
202 struct board_ops *bd_ops; 197 struct board_ops *bd_ops;
203
204 struct proc_dir_entry *proc_entry_pointer;
205 struct dgnc_proc_entry *dgnc_board_table;
206
207}; 198};
208 199
209/* Unit flag definitions for un_flags. */ 200/* Unit flag definitions for un_flags. */
@@ -233,7 +224,6 @@ struct device;
233 */ 224 */
234struct un_t { 225struct un_t {
235 struct channel_t *un_ch; 226 struct channel_t *un_ch;
236 ulong un_time;
237 uint un_type; 227 uint un_type;
238 uint un_open_count; 228 uint un_open_count;
239 struct tty_struct *un_tty; 229 struct tty_struct *un_tty;
@@ -321,8 +311,6 @@ struct un_t {
321 * @ch_err_overrun: Count of overruns on channel. 311 * @ch_err_overrun: Count of overruns on channel.
322 * @ch_xon_sends: Count of xons transmitted. 312 * @ch_xon_sends: Count of xons transmitted.
323 * @ch_xoff_sends: Count of xoffs transmitted. 313 * @ch_xoff_sends: Count of xoffs transmitted.
324 * @proc_entry_pointer: Proc/<board>/<channel> entry.
325 * @dgnc_channel_table: Proc/<board>/<channel> entry.
326 */ 314 */
327struct channel_t { 315struct channel_t {
328 struct dgnc_board *ch_bd; 316 struct dgnc_board *ch_bd;
@@ -391,10 +379,6 @@ struct channel_t {
391 379
392 ulong ch_xon_sends; 380 ulong ch_xon_sends;
393 ulong ch_xoff_sends; 381 ulong ch_xoff_sends;
394
395 struct proc_dir_entry *proc_entry_pointer;
396 struct dgnc_proc_entry *dgnc_channel_table;
397
398}; 382};
399 383
400extern uint dgnc_major; /* Our driver/mgmt major */ 384extern uint dgnc_major; /* Our driver/mgmt major */
diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 1943e66fec57..0ae229c3aaaa 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1182,7 +1182,6 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
1182 unsigned long flags; 1182 unsigned long flags;
1183 struct channel_t *ch; 1183 struct channel_t *ch;
1184 struct un_t *un; 1184 struct un_t *un;
1185 int rc = 0;
1186 1185
1187 if (!tty) 1186 if (!tty)
1188 return -ENXIO; 1187 return -ENXIO;
@@ -1199,12 +1198,10 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
1199 un->un_flags |= UN_EMPTY; 1198 un->un_flags |= UN_EMPTY;
1200 spin_unlock_irqrestore(&ch->ch_lock, flags); 1199 spin_unlock_irqrestore(&ch->ch_lock, flags);
1201 1200
1202 rc = wait_event_interruptible_timeout(un->un_flags_wait, 1201 /* If returned value is non-zero, user ctrl-c'ed us */
1203 ((un->un_flags & UN_EMPTY) == 0), 1202 return wait_event_interruptible_timeout(un->un_flags_wait,
1204 msecs_to_jiffies(seconds * 1000)); 1203 ((un->un_flags & UN_EMPTY) == 0),
1205 1204 msecs_to_jiffies(seconds * 1000));
1206 /* If ret is non-zero, user ctrl-c'ed us */
1207 return rc;
1208} 1205}
1209 1206
1210/* 1207/*
diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
index a899614ce829..6d1cad85957b 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -253,7 +253,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
253static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) 253static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
254{ 254{
255 u16 *vmem16; 255 u16 *vmem16;
256 __be16 *txbuf16 = par->txbuf.buf; 256 __be16 *txbuf16;
257 size_t remain; 257 size_t remain;
258 size_t to_copy; 258 size_t to_copy;
259 size_t tx_array_size; 259 size_t tx_array_size;
@@ -267,10 +267,10 @@ static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
267 remain = len / 2; 267 remain = len / 2;
268 vmem16 = (u16 *)(par->info->screen_buffer + offset); 268 vmem16 = (u16 *)(par->info->screen_buffer + offset);
269 tx_array_size = par->txbuf.len / 2; 269 tx_array_size = par->txbuf.len / 2;
270 txbuf16 = par->txbuf.buf + 1; 270 txbuf16 = par->txbuf.buf + 1;
271 tx_array_size -= 2; 271 tx_array_size -= 2;
272 *(u8 *)(par->txbuf.buf) = 0x00; 272 *(u8 *)(par->txbuf.buf) = 0x00;
273 startbyte_size = 1; 273 startbyte_size = 1;
274 274
275 while (remain) { 275 while (remain) {
276 to_copy = min(tx_array_size, remain); 276 to_copy = min(tx_array_size, remain);
diff --git a/drivers/staging/fbtft/fb_ssd1331.c b/drivers/staging/fbtft/fb_ssd1331.c
index 9aa9864fcf30..e4a759b54ba0 100644
--- a/drivers/staging/fbtft/fb_ssd1331.c
+++ b/drivers/staging/fbtft/fb_ssd1331.c
@@ -26,7 +26,13 @@ static int init_display(struct fbtft_par *par)
26 par->fbtftops.reset(par); 26 par->fbtftops.reset(par);
27 27
28 write_reg(par, 0xae); /* Display Off */ 28 write_reg(par, 0xae); /* Display Off */
29 write_reg(par, 0xa0, 0x70 | (par->bgr << 2)); /* Set Colour Depth */ 29
30 /* Set Column Address Mapping, COM Scan Direction and Colour Depth */
31 if (par->info->var.rotate == 180)
32 write_reg(par, 0xa0, 0x60 | (par->bgr << 2));
33 else
34 write_reg(par, 0xa0, 0x72 | (par->bgr << 2));
35
30 write_reg(par, 0x72); /* RGB colour */ 36 write_reg(par, 0x72); /* RGB colour */
31 write_reg(par, 0xa1, 0x00); /* Set Display Start Line */ 37 write_reg(par, 0xa1, 0x00); /* Set Display Start Line */
32 write_reg(par, 0xa2, 0x00); /* Set Display Offset */ 38 write_reg(par, 0xa2, 0x00); /* Set Display Offset */
diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c
index 48e3b3fd9fed..8eb5e7f10fb5 100644
--- a/drivers/staging/fbtft/fb_uc1611.c
+++ b/drivers/staging/fbtft/fb_uc1611.c
@@ -225,7 +225,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
225 u8 *buf8 = par->txbuf.buf; 225 u8 *buf8 = par->txbuf.buf;
226 u16 *buf16 = par->txbuf.buf; 226 u16 *buf16 = par->txbuf.buf;
227 int line_length = par->info->fix.line_length; 227 int line_length = par->info->fix.line_length;
228 int y_start = (offset / line_length); 228 int y_start = offset / line_length;
229 int y_end = (offset + len - 1) / line_length; 229 int y_end = (offset + len - 1) / line_length;
230 int x, y, i; 230 int x, y, i;
231 int ret = 0; 231 int ret = 0;
diff --git a/drivers/staging/fbtft/fb_uc1701.c b/drivers/staging/fbtft/fb_uc1701.c
index b78045fe5393..78899a172c7e 100644
--- a/drivers/staging/fbtft/fb_uc1701.c
+++ b/drivers/staging/fbtft/fb_uc1701.c
@@ -127,7 +127,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
127static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) 127static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
128{ 128{
129 u16 *vmem16 = (u16 *)par->info->screen_buffer; 129 u16 *vmem16 = (u16 *)par->info->screen_buffer;
130 u8 *buf = par->txbuf.buf; 130 u8 *buf;
131 int x, y, i; 131 int x, y, i;
132 int ret = 0; 132 int ret = 0;
133 133
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index a80b5d115ff8..81e8af72f87d 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -10,33 +10,33 @@
10 * 10 *
11 *****************************************************************************/ 11 *****************************************************************************/
12 12
13#define define_fbtft_write_reg(func, type, modifier) \ 13#define define_fbtft_write_reg(func, buffer_type, data_type, modifier) \
14void func(struct fbtft_par *par, int len, ...) \ 14void func(struct fbtft_par *par, int len, ...) \
15{ \ 15{ \
16 va_list args; \ 16 va_list args; \
17 int i, ret; \ 17 int i, ret; \
18 int offset = 0; \ 18 int offset = 0; \
19 type *buf = (type *)par->buf; \ 19 buffer_type *buf = (buffer_type *)par->buf; \
20 \ 20 \
21 if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) { \ 21 if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) { \
22 va_start(args, len); \ 22 va_start(args, len); \
23 for (i = 0; i < len; i++) { \ 23 for (i = 0; i < len; i++) { \
24 buf[i] = (type)va_arg(args, unsigned int); \ 24 buf[i] = modifier((data_type)va_arg(args, unsigned int)); \
25 } \ 25 } \
26 va_end(args); \ 26 va_end(args); \
27 fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, par->info->device, type, buf, len, "%s: ", __func__); \ 27 fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, par->info->device, buffer_type, buf, len, "%s: ", __func__); \
28 } \ 28 } \
29 \ 29 \
30 va_start(args, len); \ 30 va_start(args, len); \
31 \ 31 \
32 if (par->startbyte) { \ 32 if (par->startbyte) { \
33 *(u8 *)par->buf = par->startbyte; \ 33 *(u8 *)par->buf = par->startbyte; \
34 buf = (type *)(par->buf + 1); \ 34 buf = (buffer_type *)(par->buf + 1); \
35 offset = 1; \ 35 offset = 1; \
36 } \ 36 } \
37 \ 37 \
38 *buf = modifier((type)va_arg(args, unsigned int)); \ 38 *buf = modifier((data_type)va_arg(args, unsigned int)); \
39 ret = fbtft_write_buf_dc(par, par->buf, sizeof(type) + offset, 0); \ 39 ret = fbtft_write_buf_dc(par, par->buf, sizeof(data_type) + offset, 0); \
40 if (ret < 0) \ 40 if (ret < 0) \
41 goto out; \ 41 goto out; \
42 len--; \ 42 len--; \
@@ -47,18 +47,18 @@ void func(struct fbtft_par *par, int len, ...) \
47 if (len) { \ 47 if (len) { \
48 i = len; \ 48 i = len; \
49 while (i--) \ 49 while (i--) \
50 *buf++ = modifier((type)va_arg(args, unsigned int)); \ 50 *buf++ = modifier((data_type)va_arg(args, unsigned int)); \
51 fbtft_write_buf_dc(par, par->buf, \ 51 fbtft_write_buf_dc(par, par->buf, \
52 len * (sizeof(type) + offset), 1); \ 52 len * (sizeof(data_type) + offset), 1); \
53 } \ 53 } \
54out: \ 54out: \
55 va_end(args); \ 55 va_end(args); \
56} \ 56} \
57EXPORT_SYMBOL(func); 57EXPORT_SYMBOL(func);
58 58
59define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, ) 59define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
60define_fbtft_write_reg(fbtft_write_reg16_bus8, u16, cpu_to_be16) 60define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
61define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, ) 61define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
62 62
63void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...) 63void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
64{ 64{
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 26017fe9df93..0d8ed002adcb 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -104,9 +104,11 @@ static void free_rx_fd(struct dpaa2_eth_priv *priv,
104 /* We don't support any other format */ 104 /* We don't support any other format */
105 return; 105 return;
106 106
107 /* For S/G frames, we first need to free all SG entries */ 107 /* For S/G frames, we first need to free all SG entries
108 * except the first one, which was taken care of already
109 */
108 sgt = vaddr + dpaa2_fd_get_offset(fd); 110 sgt = vaddr + dpaa2_fd_get_offset(fd);
109 for (i = 0; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) { 111 for (i = 1; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) {
110 addr = dpaa2_sg_get_addr(&sgt[i]); 112 addr = dpaa2_sg_get_addr(&sgt[i]);
111 sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr); 113 sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
112 dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, 114 dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
@@ -131,16 +133,15 @@ static struct sk_buff *build_linear_skb(struct dpaa2_eth_priv *priv,
131 u16 fd_offset = dpaa2_fd_get_offset(fd); 133 u16 fd_offset = dpaa2_fd_get_offset(fd);
132 u32 fd_length = dpaa2_fd_get_len(fd); 134 u32 fd_length = dpaa2_fd_get_len(fd);
133 135
134 skb = build_skb(fd_vaddr, DPAA2_ETH_RX_BUF_SIZE + 136 ch->buf_count--;
135 SKB_DATA_ALIGN(sizeof(struct skb_shared_info))); 137
138 skb = build_skb(fd_vaddr, DPAA2_ETH_SKB_SIZE);
136 if (unlikely(!skb)) 139 if (unlikely(!skb))
137 return NULL; 140 return NULL;
138 141
139 skb_reserve(skb, fd_offset); 142 skb_reserve(skb, fd_offset);
140 skb_put(skb, fd_length); 143 skb_put(skb, fd_length);
141 144
142 ch->buf_count--;
143
144 return skb; 145 return skb;
145} 146}
146 147
@@ -176,10 +177,21 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv *priv,
176 177
177 if (i == 0) { 178 if (i == 0) {
178 /* We build the skb around the first data buffer */ 179 /* We build the skb around the first data buffer */
179 skb = build_skb(sg_vaddr, DPAA2_ETH_RX_BUF_SIZE + 180 skb = build_skb(sg_vaddr, DPAA2_ETH_SKB_SIZE);
180 SKB_DATA_ALIGN(sizeof(struct skb_shared_info))); 181 if (unlikely(!skb)) {
181 if (unlikely(!skb)) 182 /* Free the first SG entry now, since we already
182 return NULL; 183 * unmapped it and obtained the virtual address
184 */
185 skb_free_frag(sg_vaddr);
186
187 /* We still need to subtract the buffers used
188 * by this FD from our software counter
189 */
190 while (!dpaa2_sg_is_final(&sgt[i]) &&
191 i < DPAA2_ETH_MAX_SG_ENTRIES)
192 i++;
193 break;
194 }
183 195
184 sg_offset = dpaa2_sg_get_offset(sge); 196 sg_offset = dpaa2_sg_get_offset(sge);
185 skb_reserve(skb, sg_offset); 197 skb_reserve(skb, sg_offset);
@@ -206,6 +218,8 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv *priv,
206 break; 218 break;
207 } 219 }
208 220
221 WARN_ONCE(i == DPAA2_ETH_MAX_SG_ENTRIES, "Final bit not set in SGT");
222
209 /* Count all data buffers + SG table buffer */ 223 /* Count all data buffers + SG table buffer */
210 ch->buf_count -= i + 2; 224 ch->buf_count -= i + 2;
211 225
@@ -557,10 +571,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
557 percpu_stats = this_cpu_ptr(priv->percpu_stats); 571 percpu_stats = this_cpu_ptr(priv->percpu_stats);
558 percpu_extras = this_cpu_ptr(priv->percpu_extras); 572 percpu_extras = this_cpu_ptr(priv->percpu_extras);
559 573
560 if (unlikely(skb_headroom(skb) < DPAA2_ETH_NEEDED_HEADROOM(priv))) { 574 if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) {
561 struct sk_buff *ns; 575 struct sk_buff *ns;
562 576
563 ns = skb_realloc_headroom(skb, DPAA2_ETH_NEEDED_HEADROOM(priv)); 577 ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
564 if (unlikely(!ns)) { 578 if (unlikely(!ns)) {
565 percpu_stats->tx_dropped++; 579 percpu_stats->tx_dropped++;
566 goto err_alloc_headroom; 580 goto err_alloc_headroom;
@@ -718,6 +732,23 @@ static int set_tx_csum(struct dpaa2_eth_priv *priv, bool enable)
718 return 0; 732 return 0;
719} 733}
720 734
735/* Free buffers acquired from the buffer pool or which were meant to
736 * be released in the pool
737 */
738static void free_bufs(struct dpaa2_eth_priv *priv, u64 *buf_array, int count)
739{
740 struct device *dev = priv->net_dev->dev.parent;
741 void *vaddr;
742 int i;
743
744 for (i = 0; i < count; i++) {
745 vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]);
746 dma_unmap_single(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE,
747 DMA_BIDIRECTIONAL);
748 skb_free_frag(vaddr);
749 }
750}
751
721/* Perform a single release command to add buffers 752/* Perform a single release command to add buffers
722 * to the specified buffer pool 753 * to the specified buffer pool
723 */ 754 */
@@ -727,17 +758,17 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
727 u64 buf_array[DPAA2_ETH_BUFS_PER_CMD]; 758 u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
728 void *buf; 759 void *buf;
729 dma_addr_t addr; 760 dma_addr_t addr;
730 int i; 761 int i, err;
731 762
732 for (i = 0; i < DPAA2_ETH_BUFS_PER_CMD; i++) { 763 for (i = 0; i < DPAA2_ETH_BUFS_PER_CMD; i++) {
733 /* Allocate buffer visible to WRIOP + skb shared info + 764 /* Allocate buffer visible to WRIOP + skb shared info +
734 * alignment padding 765 * alignment padding
735 */ 766 */
736 buf = napi_alloc_frag(DPAA2_ETH_BUF_RAW_SIZE); 767 buf = napi_alloc_frag(dpaa2_eth_buf_raw_size(priv));
737 if (unlikely(!buf)) 768 if (unlikely(!buf))
738 goto err_alloc; 769 goto err_alloc;
739 770
740 buf = PTR_ALIGN(buf, DPAA2_ETH_RX_BUF_ALIGN); 771 buf = PTR_ALIGN(buf, priv->rx_buf_align);
741 772
742 addr = dma_map_single(dev, buf, DPAA2_ETH_RX_BUF_SIZE, 773 addr = dma_map_single(dev, buf, DPAA2_ETH_RX_BUF_SIZE,
743 DMA_FROM_DEVICE); 774 DMA_FROM_DEVICE);
@@ -748,28 +779,33 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
748 779
749 /* tracing point */ 780 /* tracing point */
750 trace_dpaa2_eth_buf_seed(priv->net_dev, 781 trace_dpaa2_eth_buf_seed(priv->net_dev,
751 buf, DPAA2_ETH_BUF_RAW_SIZE, 782 buf, dpaa2_eth_buf_raw_size(priv),
752 addr, DPAA2_ETH_RX_BUF_SIZE, 783 addr, DPAA2_ETH_RX_BUF_SIZE,
753 bpid); 784 bpid);
754 } 785 }
755 786
756release_bufs: 787release_bufs:
757 /* In case the portal is busy, retry until successful. 788 /* In case the portal is busy, retry until successful */
758 * The buffer release function would only fail if the QBMan portal 789 while ((err = dpaa2_io_service_release(NULL, bpid,
759 * was busy, which implies portal contention (i.e. more CPUs than 790 buf_array, i)) == -EBUSY)
760 * portals, i.e. GPPs w/o affine DPIOs). For all practical purposes,
761 * there is little we can realistically do, short of giving up -
762 * in which case we'd risk depleting the buffer pool and never again
763 * receiving the Rx interrupt which would kick-start the refill logic.
764 * So just keep retrying, at the risk of being moved to ksoftirqd.
765 */
766 while (dpaa2_io_service_release(NULL, bpid, buf_array, i))
767 cpu_relax(); 791 cpu_relax();
792
793 /* If release command failed, clean up and bail out;
794 * not much else we can do about it
795 */
796 if (err) {
797 free_bufs(priv, buf_array, i);
798 return 0;
799 }
800
768 return i; 801 return i;
769 802
770err_map: 803err_map:
771 skb_free_frag(buf); 804 skb_free_frag(buf);
772err_alloc: 805err_alloc:
806 /* If we managed to allocate at least some buffers,
807 * release them to hardware
808 */
773 if (i) 809 if (i)
774 goto release_bufs; 810 goto release_bufs;
775 811
@@ -811,10 +847,8 @@ static int seed_pool(struct dpaa2_eth_priv *priv, u16 bpid)
811 */ 847 */
812static void drain_bufs(struct dpaa2_eth_priv *priv, int count) 848static void drain_bufs(struct dpaa2_eth_priv *priv, int count)
813{ 849{
814 struct device *dev = priv->net_dev->dev.parent;
815 u64 buf_array[DPAA2_ETH_BUFS_PER_CMD]; 850 u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
816 void *vaddr; 851 int ret;
817 int ret, i;
818 852
819 do { 853 do {
820 ret = dpaa2_io_service_acquire(NULL, priv->bpid, 854 ret = dpaa2_io_service_acquire(NULL, priv->bpid,
@@ -823,15 +857,7 @@ static void drain_bufs(struct dpaa2_eth_priv *priv, int count)
823 netdev_err(priv->net_dev, "dpaa2_io_service_acquire() failed\n"); 857 netdev_err(priv->net_dev, "dpaa2_io_service_acquire() failed\n");
824 return; 858 return;
825 } 859 }
826 for (i = 0; i < ret; i++) { 860 free_bufs(priv, buf_array, ret);
827 /* Same logic as on regular Rx path */
828 vaddr = dpaa2_iova_to_virt(priv->iommu_domain,
829 buf_array[i]);
830 dma_unmap_single(dev, buf_array[i],
831 DPAA2_ETH_RX_BUF_SIZE,
832 DMA_FROM_DEVICE);
833 skb_free_frag(vaddr);
834 }
835 } while (ret); 861 } while (ret);
836} 862}
837 863
@@ -927,13 +953,14 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget)
927 break; 953 break;
928 } 954 }
929 955
930 if (cleaned < budget) { 956 if (cleaned < budget && napi_complete_done(napi, cleaned)) {
931 napi_complete_done(napi, cleaned);
932 /* Re-enable data available notifications */ 957 /* Re-enable data available notifications */
933 do { 958 do {
934 err = dpaa2_io_service_rearm(NULL, &ch->nctx); 959 err = dpaa2_io_service_rearm(NULL, &ch->nctx);
935 cpu_relax(); 960 cpu_relax();
936 } while (err == -EBUSY); 961 } while (err == -EBUSY);
962 WARN_ONCE(err, "CDAN notifications rearm failed on core %d",
963 ch->nctx.desired_cpu);
937 } 964 }
938 965
939 ch->stats.frames += cleaned; 966 ch->stats.frames += cleaned;
@@ -1415,34 +1442,32 @@ static struct fsl_mc_device *setup_dpcon(struct dpaa2_eth_priv *priv)
1415 err = dpcon_open(priv->mc_io, 0, dpcon->obj_desc.id, &dpcon->mc_handle); 1442 err = dpcon_open(priv->mc_io, 0, dpcon->obj_desc.id, &dpcon->mc_handle);
1416 if (err) { 1443 if (err) {
1417 dev_err(dev, "dpcon_open() failed\n"); 1444 dev_err(dev, "dpcon_open() failed\n");
1418 goto err_open; 1445 goto free;
1419 } 1446 }
1420 1447
1421 err = dpcon_reset(priv->mc_io, 0, dpcon->mc_handle); 1448 err = dpcon_reset(priv->mc_io, 0, dpcon->mc_handle);
1422 if (err) { 1449 if (err) {
1423 dev_err(dev, "dpcon_reset() failed\n"); 1450 dev_err(dev, "dpcon_reset() failed\n");
1424 goto err_reset; 1451 goto close;
1425 } 1452 }
1426 1453
1427 err = dpcon_get_attributes(priv->mc_io, 0, dpcon->mc_handle, &attrs); 1454 err = dpcon_get_attributes(priv->mc_io, 0, dpcon->mc_handle, &attrs);
1428 if (err) { 1455 if (err) {
1429 dev_err(dev, "dpcon_get_attributes() failed\n"); 1456 dev_err(dev, "dpcon_get_attributes() failed\n");
1430 goto err_get_attr; 1457 goto close;
1431 } 1458 }
1432 1459
1433 err = dpcon_enable(priv->mc_io, 0, dpcon->mc_handle); 1460 err = dpcon_enable(priv->mc_io, 0, dpcon->mc_handle);
1434 if (err) { 1461 if (err) {
1435 dev_err(dev, "dpcon_enable() failed\n"); 1462 dev_err(dev, "dpcon_enable() failed\n");
1436 goto err_enable; 1463 goto close;
1437 } 1464 }
1438 1465
1439 return dpcon; 1466 return dpcon;
1440 1467
1441err_enable: 1468close:
1442err_get_attr:
1443err_reset:
1444 dpcon_close(priv->mc_io, 0, dpcon->mc_handle); 1469 dpcon_close(priv->mc_io, 0, dpcon->mc_handle);
1445err_open: 1470free:
1446 fsl_mc_object_free(dpcon); 1471 fsl_mc_object_free(dpcon);
1447 1472
1448 return NULL; 1473 return NULL;
@@ -1749,66 +1774,32 @@ static void free_dpbp(struct dpaa2_eth_priv *priv)
1749 fsl_mc_object_free(priv->dpbp_dev); 1774 fsl_mc_object_free(priv->dpbp_dev);
1750} 1775}
1751 1776
1752/* Configure the DPNI object this interface is associated with */ 1777static int set_buffer_layout(struct dpaa2_eth_priv *priv)
1753static int setup_dpni(struct fsl_mc_device *ls_dev)
1754{ 1778{
1755 struct device *dev = &ls_dev->dev; 1779 struct device *dev = priv->net_dev->dev.parent;
1756 struct dpaa2_eth_priv *priv;
1757 struct net_device *net_dev;
1758 struct dpni_buffer_layout buf_layout = {0}; 1780 struct dpni_buffer_layout buf_layout = {0};
1759 int err; 1781 int err;
1760 1782
1761 net_dev = dev_get_drvdata(dev); 1783 /* We need to check for WRIOP version 1.0.0, but depending on the MC
1762 priv = netdev_priv(net_dev); 1784 * version, this number is not always provided correctly on rev1.
1763 1785 * We need to check for both alternatives in this situation.
1764 /* get a handle for the DPNI object */ 1786 */
1765 err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token); 1787 if (priv->dpni_attrs.wriop_version == DPAA2_WRIOP_VERSION(0, 0, 0) ||
1766 if (err) { 1788 priv->dpni_attrs.wriop_version == DPAA2_WRIOP_VERSION(1, 0, 0))
1767 dev_err(dev, "dpni_open() failed\n"); 1789 priv->rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN_REV1;
1768 goto err_open; 1790 else
1769 } 1791 priv->rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN;
1770
1771 ls_dev->mc_io = priv->mc_io;
1772 ls_dev->mc_handle = priv->mc_token;
1773
1774 err = dpni_reset(priv->mc_io, 0, priv->mc_token);
1775 if (err) {
1776 dev_err(dev, "dpni_reset() failed\n");
1777 goto err_reset;
1778 }
1779
1780 err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token,
1781 &priv->dpni_attrs);
1782 if (err) {
1783 dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err);
1784 goto err_get_attr;
1785 }
1786 1792
1787 /* Configure buffer layouts */ 1793 /* tx buffer */
1788 /* rx buffer */
1789 buf_layout.pass_parser_result = true;
1790 buf_layout.pass_frame_status = true; 1794 buf_layout.pass_frame_status = true;
1791 buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE; 1795 buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
1792 buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
1793 buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
1794 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
1795 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
1796 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
1797 err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
1798 DPNI_QUEUE_RX, &buf_layout);
1799 if (err) {
1800 dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
1801 goto err_buf_layout;
1802 }
1803
1804 /* tx buffer */
1805 buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS | 1796 buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
1806 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE; 1797 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
1807 err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token, 1798 err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
1808 DPNI_QUEUE_TX, &buf_layout); 1799 DPNI_QUEUE_TX, &buf_layout);
1809 if (err) { 1800 if (err) {
1810 dev_err(dev, "dpni_set_buffer_layout(TX) failed\n"); 1801 dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
1811 goto err_buf_layout; 1802 return err;
1812 } 1803 }
1813 1804
1814 /* tx-confirm buffer */ 1805 /* tx-confirm buffer */
@@ -1817,7 +1808,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
1817 DPNI_QUEUE_TX_CONFIRM, &buf_layout); 1808 DPNI_QUEUE_TX_CONFIRM, &buf_layout);
1818 if (err) { 1809 if (err) {
1819 dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n"); 1810 dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
1820 goto err_buf_layout; 1811 return err;
1821 } 1812 }
1822 1813
1823 /* Now that we've set our tx buffer layout, retrieve the minimum 1814 /* Now that we've set our tx buffer layout, retrieve the minimum
@@ -1827,24 +1818,76 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
1827 &priv->tx_data_offset); 1818 &priv->tx_data_offset);
1828 if (err) { 1819 if (err) {
1829 dev_err(dev, "dpni_get_tx_data_offset() failed\n"); 1820 dev_err(dev, "dpni_get_tx_data_offset() failed\n");
1830 goto err_data_offset; 1821 return err;
1831 } 1822 }
1832 1823
1833 if ((priv->tx_data_offset % 64) != 0) 1824 if ((priv->tx_data_offset % 64) != 0)
1834 dev_warn(dev, "Tx data offset (%d) not a multiple of 64B\n", 1825 dev_warn(dev, "Tx data offset (%d) not a multiple of 64B\n",
1835 priv->tx_data_offset); 1826 priv->tx_data_offset);
1836 1827
1837 /* Accommodate software annotation space (SWA) */ 1828 /* rx buffer */
1838 priv->tx_data_offset += DPAA2_ETH_SWA_SIZE; 1829 buf_layout.pass_parser_result = true;
1830 buf_layout.data_align = priv->rx_buf_align;
1831 buf_layout.data_head_room = dpaa2_eth_rx_head_room(priv);
1832 buf_layout.private_data_size = 0;
1833 buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
1834 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
1835 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
1836 DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM;
1837 err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
1838 DPNI_QUEUE_RX, &buf_layout);
1839 if (err) {
1840 dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
1841 return err;
1842 }
1839 1843
1840 return 0; 1844 return 0;
1845}
1841 1846
1842err_data_offset: 1847/* Configure the DPNI object this interface is associated with */
1843err_buf_layout: 1848static int setup_dpni(struct fsl_mc_device *ls_dev)
1844err_get_attr: 1849{
1845err_reset: 1850 struct device *dev = &ls_dev->dev;
1851 struct dpaa2_eth_priv *priv;
1852 struct net_device *net_dev;
1853 int err;
1854
1855 net_dev = dev_get_drvdata(dev);
1856 priv = netdev_priv(net_dev);
1857
1858 /* get a handle for the DPNI object */
1859 err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token);
1860 if (err) {
1861 dev_err(dev, "dpni_open() failed\n");
1862 return err;
1863 }
1864
1865 ls_dev->mc_io = priv->mc_io;
1866 ls_dev->mc_handle = priv->mc_token;
1867
1868 err = dpni_reset(priv->mc_io, 0, priv->mc_token);
1869 if (err) {
1870 dev_err(dev, "dpni_reset() failed\n");
1871 goto close;
1872 }
1873
1874 err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token,
1875 &priv->dpni_attrs);
1876 if (err) {
1877 dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err);
1878 goto close;
1879 }
1880
1881 err = set_buffer_layout(priv);
1882 if (err)
1883 goto close;
1884
1885
1886 return 0;
1887
1888close:
1846 dpni_close(priv->mc_io, 0, priv->mc_token); 1889 dpni_close(priv->mc_io, 0, priv->mc_token);
1847err_open: 1890
1848 return err; 1891 return err;
1849} 1892}
1850 1893
@@ -2085,7 +2128,7 @@ static int bind_dpni(struct dpaa2_eth_priv *priv)
2085 */ 2128 */
2086 err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_SUPPORTED); 2129 err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_SUPPORTED);
2087 if (err) 2130 if (err)
2088 netdev_err(net_dev, "Failed to configure hashing\n"); 2131 dev_err(dev, "Failed to configure hashing\n");
2089 2132
2090 /* Configure handling of error frames */ 2133 /* Configure handling of error frames */
2091 err_cfg.errors = DPAA2_FAS_RX_ERR_MASK; 2134 err_cfg.errors = DPAA2_FAS_RX_ERR_MASK;
@@ -2230,6 +2273,7 @@ static int netdev_init(struct net_device *net_dev)
2230{ 2273{
2231 struct device *dev = net_dev->dev.parent; 2274 struct device *dev = net_dev->dev.parent;
2232 struct dpaa2_eth_priv *priv = netdev_priv(net_dev); 2275 struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
2276 u16 rx_headroom, req_headroom;
2233 u8 bcast_addr[ETH_ALEN]; 2277 u8 bcast_addr[ETH_ALEN];
2234 u8 num_queues; 2278 u8 num_queues;
2235 int err; 2279 int err;
@@ -2251,7 +2295,20 @@ static int netdev_init(struct net_device *net_dev)
2251 /* Reserve enough space to align buffer as per hardware requirement; 2295 /* Reserve enough space to align buffer as per hardware requirement;
2252 * NOTE: priv->tx_data_offset MUST be initialized at this point. 2296 * NOTE: priv->tx_data_offset MUST be initialized at this point.
2253 */ 2297 */
2254 net_dev->needed_headroom = DPAA2_ETH_NEEDED_HEADROOM(priv); 2298 net_dev->needed_headroom = dpaa2_eth_needed_headroom(priv);
2299
2300 /* If headroom guaranteed by hardware in the Rx frame buffer is
2301 * smaller than the Tx headroom required by the stack, issue a
2302 * one time warning. This will most likely mean skbs forwarded to
2303 * another DPAA2 network interface will get reallocated, with a
2304 * significant performance impact.
2305 */
2306 req_headroom = LL_RESERVED_SPACE(net_dev) - ETH_HLEN;
2307 rx_headroom = ALIGN(DPAA2_ETH_RX_HWA_SIZE +
2308 dpaa2_eth_rx_head_room(priv), priv->rx_buf_align);
2309 if (req_headroom > rx_headroom)
2310 dev_info_once(dev, "Required headroom (%d) greater than available (%d)\n",
2311 req_headroom, rx_headroom);
2255 2312
2256 /* Set MTU limits */ 2313 /* Set MTU limits */
2257 net_dev->min_mtu = 68; 2314 net_dev->min_mtu = 68;
@@ -2303,7 +2360,7 @@ static irqreturn_t dpni_irq0_handler(int irq_num, void *arg)
2303 2360
2304static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg) 2361static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
2305{ 2362{
2306 u32 status = 0, clear = 0; 2363 u32 status = ~0;
2307 struct device *dev = (struct device *)arg; 2364 struct device *dev = (struct device *)arg;
2308 struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev); 2365 struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev);
2309 struct net_device *net_dev = dev_get_drvdata(dev); 2366 struct net_device *net_dev = dev_get_drvdata(dev);
@@ -2313,18 +2370,12 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
2313 DPNI_IRQ_INDEX, &status); 2370 DPNI_IRQ_INDEX, &status);
2314 if (unlikely(err)) { 2371 if (unlikely(err)) {
2315 netdev_err(net_dev, "Can't get irq status (err %d)\n", err); 2372 netdev_err(net_dev, "Can't get irq status (err %d)\n", err);
2316 clear = 0xffffffff; 2373 return IRQ_HANDLED;
2317 goto out;
2318 } 2374 }
2319 2375
2320 if (status & DPNI_IRQ_EVENT_LINK_CHANGED) { 2376 if (status & DPNI_IRQ_EVENT_LINK_CHANGED)
2321 clear |= DPNI_IRQ_EVENT_LINK_CHANGED;
2322 link_state_update(netdev_priv(net_dev)); 2377 link_state_update(netdev_priv(net_dev));
2323 }
2324 2378
2325out:
2326 dpni_clear_irq_status(dpni_dev->mc_io, 0, dpni_dev->mc_handle,
2327 DPNI_IRQ_INDEX, clear);
2328 return IRQ_HANDLED; 2379 return IRQ_HANDLED;
2329} 2380}
2330 2381
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index bfbabae1aad8..5b3ab9f62d5e 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -45,6 +45,8 @@
45 45
46#include "dpaa2-eth-trace.h" 46#include "dpaa2-eth-trace.h"
47 47
48#define DPAA2_WRIOP_VERSION(x, y, z) ((x) << 10 | (y) << 5 | (z) << 0)
49
48#define DPAA2_ETH_STORE_SIZE 16 50#define DPAA2_ETH_STORE_SIZE 16
49 51
50/* Maximum number of scatter-gather entries in an ingress frame, 52/* Maximum number of scatter-gather entries in an ingress frame,
@@ -80,23 +82,21 @@
80 */ 82 */
81#define DPAA2_ETH_BUFS_PER_CMD 7 83#define DPAA2_ETH_BUFS_PER_CMD 7
82 84
83/* Hardware requires alignment for ingress/egress buffer addresses 85/* Hardware requires alignment for ingress/egress buffer addresses */
84 * and ingress buffer lengths.
85 */
86#define DPAA2_ETH_RX_BUF_SIZE 2048
87#define DPAA2_ETH_TX_BUF_ALIGN 64 86#define DPAA2_ETH_TX_BUF_ALIGN 64
88#define DPAA2_ETH_RX_BUF_ALIGN 256
89#define DPAA2_ETH_NEEDED_HEADROOM(p_priv) \
90 ((p_priv)->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN)
91 87
92/* Hardware only sees DPAA2_ETH_RX_BUF_SIZE, but we need to allocate ingress 88#define DPAA2_ETH_RX_BUF_SIZE 2048
93 * buffers large enough to allow building an skb around them and also account 89#define DPAA2_ETH_SKB_SIZE \
94 * for alignment restrictions 90 (DPAA2_ETH_RX_BUF_SIZE + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
91
92/* Hardware annotation area in RX buffers */
93#define DPAA2_ETH_RX_HWA_SIZE 64
94
95/* Due to a limitation in WRIOP 1.0.0, the RX buffer data must be aligned
96 * to 256B. For newer revisions, the requirement is only for 64B alignment
95 */ 97 */
96#define DPAA2_ETH_BUF_RAW_SIZE \ 98#define DPAA2_ETH_RX_BUF_ALIGN_REV1 256
97 (DPAA2_ETH_RX_BUF_SIZE + \ 99#define DPAA2_ETH_RX_BUF_ALIGN 64
98 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + \
99 DPAA2_ETH_RX_BUF_ALIGN)
100 100
101/* We are accommodating a skb backpointer and some S/G info 101/* We are accommodating a skb backpointer and some S/G info
102 * in the frame's software annotation. The hardware 102 * in the frame's software annotation. The hardware
@@ -134,7 +134,7 @@ struct dpaa2_eth_swa {
134 DPAA2_FD_CTRL_FAERR) 134 DPAA2_FD_CTRL_FAERR)
135 135
136/* Annotation bits in FD CTRL */ 136/* Annotation bits in FD CTRL */
137#define DPAA2_FD_CTRL_ASAL 0x00020000 /* ASAL = 128 */ 137#define DPAA2_FD_CTRL_ASAL 0x00010000 /* ASAL = 64 */
138#define DPAA2_FD_CTRL_PTA 0x00800000 138#define DPAA2_FD_CTRL_PTA 0x00800000
139#define DPAA2_FD_CTRL_PTV1 0x00400000 139#define DPAA2_FD_CTRL_PTV1 0x00400000
140 140
@@ -318,6 +318,7 @@ struct dpaa2_eth_priv {
318 struct iommu_domain *iommu_domain; 318 struct iommu_domain *iommu_domain;
319 319
320 u16 tx_qdid; 320 u16 tx_qdid;
321 u16 rx_buf_align;
321 struct fsl_mc_io *mc_io; 322 struct fsl_mc_io *mc_io;
322 /* Cores which have an affine DPIO/DPCON. 323 /* Cores which have an affine DPIO/DPCON.
323 * This is the cpu set on which Rx and Tx conf frames are processed 324 * This is the cpu set on which Rx and Tx conf frames are processed
@@ -353,6 +354,29 @@ struct dpaa2_eth_priv {
353extern const struct ethtool_ops dpaa2_ethtool_ops; 354extern const struct ethtool_ops dpaa2_ethtool_ops;
354extern const char dpaa2_eth_drv_version[]; 355extern const char dpaa2_eth_drv_version[];
355 356
357/* Hardware only sees DPAA2_ETH_RX_BUF_SIZE, but the skb built around
358 * the buffer also needs space for its shared info struct, and we need
359 * to allocate enough to accommodate hardware alignment restrictions
360 */
361static inline unsigned int dpaa2_eth_buf_raw_size(struct dpaa2_eth_priv *priv)
362{
363 return DPAA2_ETH_SKB_SIZE + priv->rx_buf_align;
364}
365
366static inline
367unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
368{
369 return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - HH_DATA_MOD;
370}
371
372/* Extra headroom space requested to hardware, in order to make sure there's
373 * no realloc'ing in forwarding scenarios
374 */
375static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
376{
377 return dpaa2_eth_needed_headroom(priv) - DPAA2_ETH_RX_HWA_SIZE;
378}
379
356static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv) 380static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv)
357{ 381{
358 return priv->dpni_attrs.num_queues; 382 return priv->dpni_attrs.num_queues;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 031179ab3a22..ebe8fd6ccf2c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -76,10 +76,22 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
76static void dpaa2_eth_get_drvinfo(struct net_device *net_dev, 76static void dpaa2_eth_get_drvinfo(struct net_device *net_dev,
77 struct ethtool_drvinfo *drvinfo) 77 struct ethtool_drvinfo *drvinfo)
78{ 78{
79 struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
80 u16 fw_major, fw_minor;
81 int err;
82
79 strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); 83 strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
80 strlcpy(drvinfo->version, dpaa2_eth_drv_version, 84 strlcpy(drvinfo->version, dpaa2_eth_drv_version,
81 sizeof(drvinfo->version)); 85 sizeof(drvinfo->version));
82 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 86
87 err = dpni_get_api_version(priv->mc_io, 0, &fw_major, &fw_minor);
88 if (!err)
89 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
90 "%u.%u", fw_major, fw_minor);
91 else
92 strlcpy(drvinfo->fw_version, "N/A",
93 sizeof(drvinfo->fw_version));
94
83 strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent), 95 strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent),
84 sizeof(drvinfo->bus_info)); 96 sizeof(drvinfo->bus_info));
85} 97}
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
index 57df22292233..3120e22496d0 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
@@ -538,4 +538,9 @@ struct dpni_rsp_get_taildrop {
538 __le32 threshold; 538 __le32 threshold;
539}; 539};
540 540
541struct dpni_rsp_get_api_version {
542 u16 major;
543 u16 minor;
544};
545
541#endif /* _FSL_DPNI_CMD_H */ 546#endif /* _FSL_DPNI_CMD_H */
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.c b/drivers/staging/fsl-dpaa2/ethernet/dpni.c
index 04a5b14bc1c5..e8be76181c36 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.c
@@ -1594,3 +1594,35 @@ int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1594 1594
1595 return 0; 1595 return 0;
1596} 1596}
1597
1598/**
1599 * dpni_get_api_version() - Get Data Path Network Interface API version
1600 * @mc_io: Pointer to MC portal's I/O object
1601 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1602 * @major_ver: Major version of data path network interface API
1603 * @minor_ver: Minor version of data path network interface API
1604 *
1605 * Return: '0' on Success; Error code otherwise.
1606 */
1607int dpni_get_api_version(struct fsl_mc_io *mc_io,
1608 u32 cmd_flags,
1609 u16 *major_ver,
1610 u16 *minor_ver)
1611{
1612 struct dpni_rsp_get_api_version *rsp_params;
1613 struct mc_command cmd = { 0 };
1614 int err;
1615
1616 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
1617 cmd_flags, 0);
1618
1619 err = mc_send_command(mc_io, &cmd);
1620 if (err)
1621 return err;
1622
1623 rsp_params = (struct dpni_rsp_get_api_version *)cmd.params;
1624 *major_ver = le16_to_cpu(rsp_params->major);
1625 *minor_ver = le16_to_cpu(rsp_params->minor);
1626
1627 return 0;
1628}
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.h b/drivers/staging/fsl-dpaa2/ethernet/dpni.h
index 282e5e85ffa7..ce86a816af45 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.h
@@ -829,4 +829,9 @@ struct dpni_rule_cfg {
829 u8 key_size; 829 u8 key_size;
830}; 830};
831 831
832int dpni_get_api_version(struct fsl_mc_io *mc_io,
833 u32 cmd_flags,
834 u16 *major_ver,
835 u16 *minor_ver);
836
832#endif /* __FSL_DPNI_H */ 837#endif /* __FSL_DPNI_H */
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index f8096828f5b7..a609ec82daf3 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
76 if (d) 76 if (d)
77 return d; 77 return d;
78 78
79 if (unlikely(cpu >= num_possible_cpus())) 79 if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus())
80 return NULL; 80 return NULL;
81 81
82 /* 82 /*
@@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
121 return NULL; 121 return NULL;
122 122
123 /* check if CPU is out of range (-1 means any cpu) */ 123 /* check if CPU is out of range (-1 means any cpu) */
124 if (desc->cpu >= num_possible_cpus()) { 124 if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) {
125 kfree(obj); 125 kfree(obj);
126 return NULL; 126 return NULL;
127 } 127 }
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
index 038da4d1ebd0..f74a6f1764bb 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
@@ -137,7 +137,7 @@ static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info)
137{ 137{
138 struct irq_chip *chip = info->chip; 138 struct irq_chip *chip = info->chip;
139 139
140 if (WARN_ON((!chip))) 140 if (WARN_ON(!chip))
141 return; 141 return;
142 142
143 /* 143 /*
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/drivers/staging/fsl-mc/include/dpaa2-io.h
index c5646096c5d4..afc2d060d077 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -54,6 +54,8 @@ struct device;
54 * for dequeue. 54 * for dequeue.
55 */ 55 */
56 56
57#define DPAA2_IO_ANY_CPU -1
58
57/** 59/**
58 * struct dpaa2_io_desc - The DPIO descriptor 60 * struct dpaa2_io_desc - The DPIO descriptor
59 * @receives_notifications: Use notificaton mode. Non-zero if the DPIO 61 * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
@@ -91,8 +93,8 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
91 * @cb: The callback to be invoked when the notification arrives 93 * @cb: The callback to be invoked when the notification arrives
92 * @is_cdan: Zero for FQDAN, non-zero for CDAN 94 * @is_cdan: Zero for FQDAN, non-zero for CDAN
93 * @id: FQID or channel ID, needed for rearm 95 * @id: FQID or channel ID, needed for rearm
94 * @desired_cpu: The cpu on which the notifications will show up. -1 means 96 * @desired_cpu: The cpu on which the notifications will show up. Use
95 * any CPU. 97 * DPAA2_IO_ANY_CPU if don't care
96 * @dpio_id: The dpio index 98 * @dpio_id: The dpio index
97 * @qman64: The 64-bit context value shows up in the FQDAN/CDAN. 99 * @qman64: The 64-bit context value shows up in the FQDAN/CDAN.
98 * @node: The list node 100 * @node: The list node
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index 41a49c8194e5..bba7e9c888b3 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -217,13 +217,6 @@ static void fwtty_log_tx_error(struct fwtty_port *port, int rcode)
217 } 217 }
218} 218}
219 219
220static void fwtty_txn_constructor(void *this)
221{
222 struct fwtty_transaction *txn = this;
223
224 init_timer(&txn->fw_txn.split_timeout_timer);
225}
226
227static void fwtty_common_callback(struct fw_card *card, int rcode, 220static void fwtty_common_callback(struct fw_card *card, int rcode,
228 void *payload, size_t len, void *cb_data) 221 void *payload, size_t len, void *cb_data)
229{ 222{
@@ -1806,9 +1799,9 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset)
1806 (*port->fwcon_ops->notify)(FWCON_NOTIFY_DETACH, port->con_data); 1799 (*port->fwcon_ops->notify)(FWCON_NOTIFY_DETACH, port->con_data);
1807} 1800}
1808 1801
1809static void fwserial_plug_timeout(unsigned long data) 1802static void fwserial_plug_timeout(struct timer_list *t)
1810{ 1803{
1811 struct fwtty_peer *peer = (struct fwtty_peer *)data; 1804 struct fwtty_peer *peer = from_timer(peer, t, timer);
1812 struct fwtty_port *port; 1805 struct fwtty_port *port;
1813 1806
1814 spin_lock_bh(&peer->lock); 1807 spin_lock_bh(&peer->lock);
@@ -1860,7 +1853,6 @@ static int fwserial_connect_peer(struct fwtty_peer *peer)
1860 1853
1861 fill_plug_req(pkt, peer->port); 1854 fill_plug_req(pkt, peer->port);
1862 1855
1863 setup_timer(&peer->timer, fwserial_plug_timeout, (unsigned long)peer);
1864 mod_timer(&peer->timer, jiffies + VIRT_CABLE_PLUG_TIMEOUT); 1856 mod_timer(&peer->timer, jiffies + VIRT_CABLE_PLUG_TIMEOUT);
1865 spin_unlock_bh(&peer->lock); 1857 spin_unlock_bh(&peer->lock);
1866 1858
@@ -2098,7 +2090,7 @@ static int fwserial_add_peer(struct fw_serial *serial, struct fw_unit *unit)
2098 spin_lock_init(&peer->lock); 2090 spin_lock_init(&peer->lock);
2099 peer->port = NULL; 2091 peer->port = NULL;
2100 2092
2101 init_timer(&peer->timer); 2093 timer_setup(&peer->timer, fwserial_plug_timeout, 0);
2102 INIT_WORK(&peer->work, fwserial_peer_workfn); 2094 INIT_WORK(&peer->work, fwserial_peer_workfn);
2103 INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect); 2095 INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect);
2104 2096
@@ -2863,7 +2855,7 @@ static int __init fwserial_init(void)
2863 2855
2864 fwtty_txn_cache = kmem_cache_create("fwtty_txn_cache", 2856 fwtty_txn_cache = kmem_cache_create("fwtty_txn_cache",
2865 sizeof(struct fwtty_transaction), 2857 sizeof(struct fwtty_transaction),
2866 0, 0, fwtty_txn_constructor); 2858 0, 0, NULL);
2867 if (!fwtty_txn_cache) { 2859 if (!fwtty_txn_cache) {
2868 err = -ENOMEM; 2860 err = -ENOMEM;
2869 goto unregister_loop; 2861 goto unregister_loop;
diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index 9ab6ce231f11..0527b0d1c1d0 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -26,6 +26,7 @@
26#include <linux/icmp.h> 26#include <linux/icmp.h>
27#include <linux/icmpv6.h> 27#include <linux/icmpv6.h>
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/errno.h>
29#include <net/ndisc.h> 30#include <net/ndisc.h>
30 31
31#include "gdm_lte.h" 32#include "gdm_lte.h"
@@ -118,6 +119,10 @@ static int gdm_lte_emulate_arp(struct sk_buff *skb_in, u32 nic_type)
118 void *mac_header_data; 119 void *mac_header_data;
119 u32 mac_header_len; 120 u32 mac_header_len;
120 121
122 /* Check for skb->len, discard if empty */
123 if (skb_in->len == 0)
124 return -ENODATA;
125
121 /* Format the mac header so that it can be put to skb */ 126 /* Format the mac header so that it can be put to skb */
122 if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) { 127 if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) {
123 memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr)); 128 memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr));
@@ -241,13 +246,13 @@ static int gdm_lte_emulate_ndp(struct sk_buff *skb_in, u32 nic_type)
241 if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) { 246 if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) {
242 memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr)); 247 memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr));
243 if (ntohs(vlan_eth.h_vlan_encapsulated_proto) != ETH_P_IPV6) 248 if (ntohs(vlan_eth.h_vlan_encapsulated_proto) != ETH_P_IPV6)
244 return -1; 249 return -EPROTONOSUPPORT;
245 mac_header_data = &vlan_eth; 250 mac_header_data = &vlan_eth;
246 mac_header_len = VLAN_ETH_HLEN; 251 mac_header_len = VLAN_ETH_HLEN;
247 } else { 252 } else {
248 memcpy(&eth, skb_in->data, sizeof(struct ethhdr)); 253 memcpy(&eth, skb_in->data, sizeof(struct ethhdr));
249 if (ntohs(eth.h_proto) != ETH_P_IPV6) 254 if (ntohs(eth.h_proto) != ETH_P_IPV6)
250 return -1; 255 return -EPROTONOSUPPORT;
251 mac_header_data = &eth; 256 mac_header_data = &eth;
252 mac_header_len = ETH_HLEN; 257 mac_header_len = ETH_HLEN;
253 } 258 }
@@ -255,13 +260,13 @@ static int gdm_lte_emulate_ndp(struct sk_buff *skb_in, u32 nic_type)
255 /* Check if this is IPv6 ICMP packet */ 260 /* Check if this is IPv6 ICMP packet */
256 ipv6_in = (struct ipv6hdr *)(skb_in->data + mac_header_len); 261 ipv6_in = (struct ipv6hdr *)(skb_in->data + mac_header_len);
257 if (ipv6_in->version != 6 || ipv6_in->nexthdr != IPPROTO_ICMPV6) 262 if (ipv6_in->version != 6 || ipv6_in->nexthdr != IPPROTO_ICMPV6)
258 return -1; 263 return -EPROTONOSUPPORT;
259 264
260 /* Check if this is NDP packet */ 265 /* Check if this is NDP packet */
261 icmp6_in = (struct icmp6hdr *)(skb_in->data + mac_header_len + 266 icmp6_in = (struct icmp6hdr *)(skb_in->data + mac_header_len +
262 sizeof(struct ipv6hdr)); 267 sizeof(struct ipv6hdr));
263 if (icmp6_in->icmp6_type == NDISC_ROUTER_SOLICITATION) { /* Check RS */ 268 if (icmp6_in->icmp6_type == NDISC_ROUTER_SOLICITATION) { /* Check RS */
264 return -1; 269 return -EPROTONOSUPPORT;
265 } else if (icmp6_in->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) { 270 } else if (icmp6_in->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
266 /* Check NS */ 271 /* Check NS */
267 u8 icmp_na[sizeof(struct icmp6hdr) + 272 u8 icmp_na[sizeof(struct icmp6hdr) +
@@ -305,7 +310,7 @@ static int gdm_lte_emulate_ndp(struct sk_buff *skb_in, u32 nic_type)
305 icmp6_out.icmp6_cksum = icmp6_checksum(&ipv6_out, 310 icmp6_out.icmp6_cksum = icmp6_checksum(&ipv6_out,
306 (u16 *)icmp_na, sizeof(icmp_na)); 311 (u16 *)icmp_na, sizeof(icmp_na));
307 } else { 312 } else {
308 return -1; 313 return -EINVAL;
309 } 314 }
310 315
311 /* Fill the destination mac with source mac of the received packet */ 316 /* Fill the destination mac with source mac of the received packet */
@@ -412,7 +417,7 @@ static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev)
412 nic_type = gdm_lte_tx_nic_type(dev, skb); 417 nic_type = gdm_lte_tx_nic_type(dev, skb);
413 if (nic_type == 0) { 418 if (nic_type == 0) {
414 netdev_err(dev, "tx - invalid nic_type\n"); 419 netdev_err(dev, "tx - invalid nic_type\n");
415 return -1; 420 return -EMEDIUMTYPE;
416 } 421 }
417 422
418 if (nic_type & NIC_TYPE_ARP) { 423 if (nic_type & NIC_TYPE_ARP) {
@@ -539,7 +544,7 @@ int gdm_lte_event_init(void)
539 } 544 }
540 545
541 pr_err("event init failed\n"); 546 pr_err("event init failed\n");
542 return -1; 547 return -ENODATA;
543} 548}
544 549
545void gdm_lte_event_exit(void) 550void gdm_lte_event_exit(void)
diff --git a/drivers/staging/greybus/Documentation/firmware/authenticate.c b/drivers/staging/greybus/Documentation/firmware/authenticate.c
index b836f0a20c36..806e75b7f405 100644
--- a/drivers/staging/greybus/Documentation/firmware/authenticate.c
+++ b/drivers/staging/greybus/Documentation/firmware/authenticate.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * Sample code to test CAP protocol 3 * Sample code to test CAP protocol
3 * 4 *
diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/drivers/staging/greybus/Documentation/firmware/firmware.c
index c73dee9d13c1..31d9c23e2eeb 100644
--- a/drivers/staging/greybus/Documentation/firmware/firmware.c
+++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * Sample code to test firmware-management protocol 3 * Sample code to test firmware-management protocol
3 * 4 *
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c
index 0412f3d06efb..b0c66112eb18 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Arche Platform driver to control APB. 3 * Arche Platform driver to control APB.
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/clk.h> 9#include <linux/clk.h>
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index 21ac92d0f533..ace4eb365c0e 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Arche Platform driver to enable Unipro link. 3 * Arche Platform driver to enable Unipro link.
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/clk.h> 9#include <linux/clk.h>
diff --git a/drivers/staging/greybus/arche_platform.h b/drivers/staging/greybus/arche_platform.h
index bcffc69d0960..02056351d25a 100644
--- a/drivers/staging/greybus/arche_platform.h
+++ b/drivers/staging/greybus/arche_platform.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Arche Platform driver to enable Unipro link. 3 * Arche Platform driver to enable Unipro link.
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 * Copyright 2015-2016 Linaro Ltd. 6 * Copyright 2015-2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __ARCHE_PLATFORM_H 9#ifndef __ARCHE_PLATFORM_H
diff --git a/drivers/staging/greybus/arpc.h b/drivers/staging/greybus/arpc.h
index c0b63c0130c5..3534ba1a4e6c 100644
--- a/drivers/staging/greybus/arpc.h
+++ b/drivers/staging/greybus/arpc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or 3 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license. 4 * redistributing this file, you may do so under either license.
diff --git a/drivers/staging/greybus/audio_apbridgea.c b/drivers/staging/greybus/audio_apbridgea.c
index 1b4252d5d255..7ebb1bde5cb7 100644
--- a/drivers/staging/greybus/audio_apbridgea.c
+++ b/drivers/staging/greybus/audio_apbridgea.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Audio Device Class Protocol helpers 3 * Greybus Audio Device Class Protocol helpers
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include "greybus.h" 8#include "greybus.h"
diff --git a/drivers/staging/greybus/audio_apbridgea.h b/drivers/staging/greybus/audio_apbridgea.h
index b94cb05c89e4..42ac6059bfc7 100644
--- a/drivers/staging/greybus/audio_apbridgea.h
+++ b/drivers/staging/greybus/audio_apbridgea.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: BSD-3-Clause
1/** 2/**
2 * Copyright (c) 2015-2016 Google Inc. 3 * Copyright (c) 2015-2016 Google Inc.
3 * All rights reserved. 4 * All rights reserved.
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index a6d01f0761f3..fdb9e83cc34b 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * APBridge ALSA SoC dummy codec driver 3 * APBridge ALSA SoC dummy codec driver
3 * Copyright 2016 Google Inc. 4 * Copyright 2016 Google Inc.
4 * Copyright 2016 Linaro Ltd. 5 * Copyright 2016 Linaro Ltd.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h
index 6fb064c69a36..161b37c8ef17 100644
--- a/drivers/staging/greybus/audio_codec.h
+++ b/drivers/staging/greybus/audio_codec.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus audio driver 3 * Greybus audio driver
3 * Copyright 2015 Google Inc. 4 * Copyright 2015 Google Inc.
4 * Copyright 2015 Linaro Ltd. 5 * Copyright 2015 Linaro Ltd.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#ifndef __LINUX_GBAUDIO_CODEC_H 8#ifndef __LINUX_GBAUDIO_CODEC_H
diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c
index 7884d8482dc0..8894f1c87d48 100644
--- a/drivers/staging/greybus/audio_gb.c
+++ b/drivers/staging/greybus/audio_gb.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Audio Device Class Protocol helpers 3 * Greybus Audio Device Class Protocol helpers
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include "greybus.h" 8#include "greybus.h"
diff --git a/drivers/staging/greybus/audio_manager.c b/drivers/staging/greybus/audio_manager.c
index aa6508b44fab..d44b070d8862 100644
--- a/drivers/staging/greybus/audio_manager.c
+++ b/drivers/staging/greybus/audio_manager.c
@@ -1,16 +1,15 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include <linux/string.h> 8#include <linux/string.h>
10#include <linux/sysfs.h> 9#include <linux/sysfs.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/rwlock.h> 12#include <linux/spinlock.h>
14#include <linux/idr.h> 13#include <linux/idr.h>
15 14
16#include "audio_manager.h" 15#include "audio_manager.h"
diff --git a/drivers/staging/greybus/audio_manager.h b/drivers/staging/greybus/audio_manager.h
index 5ab8f5e0ed3f..dcb1a20f5ff1 100644
--- a/drivers/staging/greybus/audio_manager.h
+++ b/drivers/staging/greybus/audio_manager.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#ifndef _GB_AUDIO_MANAGER_H_ 8#ifndef _GB_AUDIO_MANAGER_H_
diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
index adc16977452d..52342e832e3b 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include <linux/slab.h> 8#include <linux/slab.h>
diff --git a/drivers/staging/greybus/audio_manager_private.h b/drivers/staging/greybus/audio_manager_private.h
index 079ce953c256..9d9b58fc54c4 100644
--- a/drivers/staging/greybus/audio_manager_private.h
+++ b/drivers/staging/greybus/audio_manager_private.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#ifndef _GB_AUDIO_MANAGER_PRIVATE_H_ 8#ifndef _GB_AUDIO_MANAGER_PRIVATE_H_
diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c
index 34ebd147052f..283fbed0c8ed 100644
--- a/drivers/staging/greybus/audio_manager_sysfs.c
+++ b/drivers/staging/greybus/audio_manager_sysfs.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2015-2016 Google Inc. 5 * Copyright 2015-2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include <linux/string.h> 8#include <linux/string.h>
diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c
index 094c3be79b33..d065334efa23 100644
--- a/drivers/staging/greybus/audio_module.c
+++ b/drivers/staging/greybus/audio_module.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus audio driver 3 * Greybus audio driver
3 * Copyright 2015 Google Inc. 4 * Copyright 2015 Google Inc.
4 * Copyright 2015 Linaro Ltd. 5 * Copyright 2015 Linaro Ltd.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 07fac3948f3a..de4b1b2b12f3 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus audio driver 3 * Greybus audio driver
3 * Copyright 2015-2016 Google Inc. 4 * Copyright 2015-2016 Google Inc.
4 * Copyright 2015-2016 Linaro Ltd. 5 * Copyright 2015-2016 Linaro Ltd.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include "audio_codec.h" 8#include "audio_codec.h"
diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c
index 6c5dcb1c226b..16cc65e1472b 100644
--- a/drivers/staging/greybus/authentication.c
+++ b/drivers/staging/greybus/authentication.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Component Authentication Protocol (CAP) Driver. 3 * Greybus Component Authentication Protocol (CAP) Driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include "greybus.h" 9#include "greybus.h"
diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
index 06df0ce03150..e85ffae85dff 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * BOOTROM Greybus driver. 3 * BOOTROM Greybus driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/firmware.h> 9#include <linux/firmware.h>
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c
index d2ef57d090be..81c018da1248 100644
--- a/drivers/staging/greybus/bundle.c
+++ b/drivers/staging/greybus/bundle.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus bundles 3 * Greybus bundles
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include "greybus.h" 9#include "greybus.h"
diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 0c3491def96c..ffcfd43802cc 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus bundles 3 * Greybus bundles
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __BUNDLE_H 9#ifndef __BUNDLE_H
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index a64517eabff4..f13f16b63d7e 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Camera protocol driver. 3 * Greybus Camera protocol driver.
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/debugfs.h> 9#include <linux/debugfs.h>
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 2cf64640e8ec..2103168b585e 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus connections 3 * Greybus connections
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/workqueue.h> 9#include <linux/workqueue.h>
diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h
index 4d9f4c64176c..ec3f1d3ef3b9 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus connections 3 * Greybus connections
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __CONNECTION_H 9#ifndef __CONNECTION_H
diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c
index 5b30be30a3a4..35f945a12b11 100644
--- a/drivers/staging/greybus/control.c
+++ b/drivers/staging/greybus/control.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus CPort control protocol. 3 * Greybus CPort control protocol.
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/control.h b/drivers/staging/greybus/control.h
index 4dcaec8b9cfe..643ddb9e0f92 100644
--- a/drivers/staging/greybus/control.h
+++ b/drivers/staging/greybus/control.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus CPort control protocol 3 * Greybus CPort control protocol
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __CONTROL_H 9#ifndef __CONTROL_H
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c
index ba761905b790..dafa430d176e 100644
--- a/drivers/staging/greybus/core.c
+++ b/drivers/staging/greybus/core.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus "Core" 3 * Greybus "Core"
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/greybus/debugfs.c b/drivers/staging/greybus/debugfs.c
index a9d4d3da99a0..56e20c30feb5 100644
--- a/drivers/staging/greybus/debugfs.c
+++ b/drivers/staging/greybus/debugfs.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus debugfs code 3 * Greybus debugfs code
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/debugfs.h> 9#include <linux/debugfs.h>
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index f7b24e0eaa6f..b082d81833a0 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus "AP" USB driver for "ES2" controller chips 3 * Greybus "AP" USB driver for "ES2" controller chips
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9#include <linux/kthread.h> 8#include <linux/kthread.h>
10#include <linux/sizes.h> 9#include <linux/sizes.h>
@@ -761,6 +760,7 @@ static int check_urb_status(struct urb *urb)
761 case -EOVERFLOW: 760 case -EOVERFLOW:
762 dev_err(dev, "%s: overflow actual length is %d\n", 761 dev_err(dev, "%s: overflow actual length is %d\n",
763 __func__, urb->actual_length); 762 __func__, urb->actual_length);
763 /* fall through */
764 case -ECONNRESET: 764 case -ECONNRESET:
765 case -ENOENT: 765 case -ENOENT:
766 case -ESHUTDOWN: 766 case -ESHUTDOWN:
diff --git a/drivers/staging/greybus/firmware.h b/drivers/staging/greybus/firmware.h
index f4f0db1cefe8..946221307ef6 100644
--- a/drivers/staging/greybus/firmware.h
+++ b/drivers/staging/greybus/firmware.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Firmware Management Header 3 * Greybus Firmware Management Header
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __FIRMWARE_H 9#ifndef __FIRMWARE_H
diff --git a/drivers/staging/greybus/fw-core.c b/drivers/staging/greybus/fw-core.c
index 454a98957ba5..388866d92f5b 100644
--- a/drivers/staging/greybus/fw-core.c
+++ b/drivers/staging/greybus/fw-core.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Firmware Core Bundle Driver. 3 * Greybus Firmware Core Bundle Driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 9
diff --git a/drivers/staging/greybus/fw-download.c b/drivers/staging/greybus/fw-download.c
index 8a1a413c6cb3..d3b7cccbc10d 100644
--- a/drivers/staging/greybus/fw-download.c
+++ b/drivers/staging/greybus/fw-download.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Firmware Download Protocol Driver. 3 * Greybus Firmware Download Protocol Driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/firmware.h> 9#include <linux/firmware.h>
diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c
index 3cd6cf0a656b..71aec14f8181 100644
--- a/drivers/staging/greybus/fw-management.c
+++ b/drivers/staging/greybus/fw-management.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Firmware Management Protocol Driver. 3 * Greybus Firmware Management Protocol Driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/cdev.h> 9#include <linux/cdev.h>
diff --git a/drivers/staging/greybus/gb-camera.h b/drivers/staging/greybus/gb-camera.h
index d45dabc5b367..ee293e461fc3 100644
--- a/drivers/staging/greybus/gb-camera.h
+++ b/drivers/staging/greybus/gb-camera.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Camera protocol driver. 3 * Greybus Camera protocol driver.
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8#ifndef __GB_CAMERA_H 7#ifndef __GB_CAMERA_H
9#define __GB_CAMERA_H 8#define __GB_CAMERA_H
diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
index 80c1da8224e6..6cb85c3d3572 100644
--- a/drivers/staging/greybus/gbphy.c
+++ b/drivers/staging/greybus/gbphy.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Bridged-Phy Bus driver 3 * Greybus Bridged-Phy Bus driver
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/greybus/gbphy.h b/drivers/staging/greybus/gbphy.h
index 8ee68055ccc4..99463489d7d6 100644
--- a/drivers/staging/greybus/gbphy.h
+++ b/drivers/staging/greybus/gbphy.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Bridged-Phy Bus driver 3 * Greybus Bridged-Phy Bus driver
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#ifndef __GBPHY_H 8#ifndef __GBPHY_H
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index ee5f998b174f..b1d4698019a1 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPIO Greybus driver. 3 * GPIO Greybus driver.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index c9bb93f23927..d03ddb7c9df0 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus driver and device API 3 * Greybus driver and device API
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __LINUX_GREYBUS_H 9#ifndef __LINUX_GREYBUS_H
diff --git a/drivers/staging/greybus/greybus_authentication.h b/drivers/staging/greybus/greybus_authentication.h
index 4784ed98e8a3..03ea9615b217 100644
--- a/drivers/staging/greybus/greybus_authentication.h
+++ b/drivers/staging/greybus/greybus_authentication.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * Greybus Component Authentication User Header 3 * Greybus Component Authentication User Header
3 * 4 *
diff --git a/drivers/staging/greybus/greybus_firmware.h b/drivers/staging/greybus/greybus_firmware.h
index 277a2acce6fd..b58281a63ba4 100644
--- a/drivers/staging/greybus/greybus_firmware.h
+++ b/drivers/staging/greybus/greybus_firmware.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * Greybus Firmware Management User Header 3 * Greybus Firmware Management User Header
3 * 4 *
diff --git a/drivers/staging/greybus/greybus_manifest.h b/drivers/staging/greybus/greybus_manifest.h
index d135945cefe1..2cec5cf7a846 100644
--- a/drivers/staging/greybus/greybus_manifest.h
+++ b/drivers/staging/greybus/greybus_manifest.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus manifest definition 3 * Greybus manifest definition
3 * 4 *
diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h
index b1be0b0af464..9bd7b6dfb476 100644
--- a/drivers/staging/greybus/greybus_protocols.h
+++ b/drivers/staging/greybus/greybus_protocols.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or 3 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license. 4 * redistributing this file, you may do so under either license.
diff --git a/drivers/staging/greybus/greybus_trace.h b/drivers/staging/greybus/greybus_trace.h
index f8feae4dc3b5..7b5e2c6b1f6b 100644
--- a/drivers/staging/greybus/greybus_trace.h
+++ b/drivers/staging/greybus/greybus_trace.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus driver and device API 3 * Greybus driver and device API
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9#undef TRACE_SYSTEM 8#undef TRACE_SYSTEM
10#define TRACE_SYSTEM greybus 9#define TRACE_SYSTEM greybus
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c
index 185ae3fa10fd..969f86697673 100644
--- a/drivers/staging/greybus/hd.c
+++ b/drivers/staging/greybus/hd.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Host Device 3 * Greybus Host Device
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/hd.h b/drivers/staging/greybus/hd.h
index e7927bb1761c..6cf024a20a58 100644
--- a/drivers/staging/greybus/hd.h
+++ b/drivers/staging/greybus/hd.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Host Device 3 * Greybus Host Device
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __HD_H 9#ifndef __HD_H
diff --git a/drivers/staging/greybus/hid.c b/drivers/staging/greybus/hid.c
index 465101bbab69..04053ff075a6 100644
--- a/drivers/staging/greybus/hid.c
+++ b/drivers/staging/greybus/hid.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * HID class driver for the Greybus. 3 * HID class driver for the Greybus.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/bitops.h> 9#include <linux/bitops.h>
diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c
index c2a50087000c..58a37deb6579 100644
--- a/drivers/staging/greybus/i2c.c
+++ b/drivers/staging/greybus/i2c.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * I2C bridge driver for the Greybus "generic" I2C module. 3 * I2C bridge driver for the Greybus "generic" I2C module.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 71e5cc234e78..d7b5b89a2f40 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus interface code 3 * Greybus interface code
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/delay.h> 9#include <linux/delay.h>
diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h
index bd31b8c18d5b..1c00c5bb3ec9 100644
--- a/drivers/staging/greybus/interface.h
+++ b/drivers/staging/greybus/interface.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Interface Block code 3 * Greybus Interface Block code
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __INTERFACE_H 9#ifndef __INTERFACE_H
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 3f4148c92308..010ae1e9c7fb 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Lights protocol driver. 3 * Greybus Lights protocol driver.
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -925,6 +924,8 @@ static void __gb_lights_led_unregister(struct gb_channel *channel)
925 return; 924 return;
926 925
927 led_classdev_unregister(cdev); 926 led_classdev_unregister(cdev);
927 kfree(cdev->name);
928 cdev->name = NULL;
928 channel->led = NULL; 929 channel->led = NULL;
929} 930}
930 931
@@ -998,11 +999,7 @@ static int gb_lights_channel_config(struct gb_light *light,
998 999
999 light->has_flash = true; 1000 light->has_flash = true;
1000 1001
1001 ret = gb_lights_channel_flash_config(channel); 1002 return gb_lights_channel_flash_config(channel);
1002 if (ret < 0)
1003 return ret;
1004
1005 return ret;
1006} 1003}
1007 1004
1008static int gb_lights_light_config(struct gb_lights *glights, u8 id) 1005static int gb_lights_light_config(struct gb_lights *glights, u8 id)
diff --git a/drivers/staging/greybus/log.c b/drivers/staging/greybus/log.c
index 5c5bedaf69a6..15a88574dbb0 100644
--- a/drivers/staging/greybus/log.c
+++ b/drivers/staging/greybus/log.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus driver for the log protocol 3 * Greybus driver for the log protocol
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 08e255884206..42f6f3de967c 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Loopback bridge driver for the Greybus loopback module. 3 * Loopback bridge driver for the Greybus loopback module.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -58,12 +57,7 @@ static struct gb_loopback_device gb_dev;
58struct gb_loopback_async_operation { 57struct gb_loopback_async_operation {
59 struct gb_loopback *gb; 58 struct gb_loopback *gb;
60 struct gb_operation *operation; 59 struct gb_operation *operation;
61 struct timeval ts; 60 ktime_t ts;
62 struct timer_list timer;
63 struct list_head entry;
64 struct work_struct work;
65 struct kref kref;
66 bool pending;
67 int (*completion)(struct gb_loopback_async_operation *op_async); 61 int (*completion)(struct gb_loopback_async_operation *op_async);
68}; 62};
69 63
@@ -72,7 +66,6 @@ struct gb_loopback {
72 66
73 struct dentry *file; 67 struct dentry *file;
74 struct kfifo kfifo_lat; 68 struct kfifo kfifo_lat;
75 struct kfifo kfifo_ts;
76 struct mutex mutex; 69 struct mutex mutex;
77 struct task_struct *task; 70 struct task_struct *task;
78 struct list_head entry; 71 struct list_head entry;
@@ -82,7 +75,7 @@ struct gb_loopback {
82 atomic_t outstanding_operations; 75 atomic_t outstanding_operations;
83 76
84 /* Per connection stats */ 77 /* Per connection stats */
85 struct timeval ts; 78 ktime_t ts;
86 struct gb_loopback_stats latency; 79 struct gb_loopback_stats latency;
87 struct gb_loopback_stats throughput; 80 struct gb_loopback_stats throughput;
88 struct gb_loopback_stats requests_per_second; 81 struct gb_loopback_stats requests_per_second;
@@ -262,7 +255,6 @@ static void gb_loopback_check_attr(struct gb_loopback *gb)
262 gb->iteration_max, kfifo_depth); 255 gb->iteration_max, kfifo_depth);
263 } 256 }
264 kfifo_reset_out(&gb->kfifo_lat); 257 kfifo_reset_out(&gb->kfifo_lat);
265 kfifo_reset_out(&gb->kfifo_ts);
266 258
267 switch (gb->type) { 259 switch (gb->type) {
268 case GB_LOOPBACK_TYPE_PING: 260 case GB_LOOPBACK_TYPE_PING:
@@ -377,21 +369,9 @@ static u64 __gb_loopback_calc_latency(u64 t1, u64 t2)
377 return NSEC_PER_DAY - t2 + t1; 369 return NSEC_PER_DAY - t2 + t1;
378} 370}
379 371
380static u64 gb_loopback_calc_latency(struct timeval *ts, struct timeval *te) 372static u64 gb_loopback_calc_latency(ktime_t ts, ktime_t te)
381{
382 u64 t1, t2;
383
384 t1 = timeval_to_ns(ts);
385 t2 = timeval_to_ns(te);
386
387 return __gb_loopback_calc_latency(t1, t2);
388}
389
390static void gb_loopback_push_latency_ts(struct gb_loopback *gb,
391 struct timeval *ts, struct timeval *te)
392{ 373{
393 kfifo_in(&gb->kfifo_ts, (unsigned char *)ts, sizeof(*ts)); 374 return __gb_loopback_calc_latency(ktime_to_ns(ts), ktime_to_ns(te));
394 kfifo_in(&gb->kfifo_ts, (unsigned char *)te, sizeof(*te));
395} 375}
396 376
397static int gb_loopback_operation_sync(struct gb_loopback *gb, int type, 377static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
@@ -399,10 +379,10 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
399 void *response, int response_size) 379 void *response, int response_size)
400{ 380{
401 struct gb_operation *operation; 381 struct gb_operation *operation;
402 struct timeval ts, te; 382 ktime_t ts, te;
403 int ret; 383 int ret;
404 384
405 do_gettimeofday(&ts); 385 ts = ktime_get();
406 operation = gb_operation_create(gb->connection, type, request_size, 386 operation = gb_operation_create(gb->connection, type, request_size,
407 response_size, GFP_KERNEL); 387 response_size, GFP_KERNEL);
408 if (!operation) 388 if (!operation)
@@ -430,11 +410,10 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
430 } 410 }
431 } 411 }
432 412
433 do_gettimeofday(&te); 413 te = ktime_get();
434 414
435 /* Calculate the total time the message took */ 415 /* Calculate the total time the message took */
436 gb_loopback_push_latency_ts(gb, &ts, &te); 416 gb->elapsed_nsecs = gb_loopback_calc_latency(ts, te);
437 gb->elapsed_nsecs = gb_loopback_calc_latency(&ts, &te);
438 417
439out_put_operation: 418out_put_operation:
440 gb_operation_put(operation); 419 gb_operation_put(operation);
@@ -442,56 +421,6 @@ out_put_operation:
442 return ret; 421 return ret;
443} 422}
444 423
445static void __gb_loopback_async_operation_destroy(struct kref *kref)
446{
447 struct gb_loopback_async_operation *op_async;
448
449 op_async = container_of(kref, struct gb_loopback_async_operation, kref);
450
451 list_del(&op_async->entry);
452 if (op_async->operation)
453 gb_operation_put(op_async->operation);
454 atomic_dec(&op_async->gb->outstanding_operations);
455 wake_up(&op_async->gb->wq_completion);
456 kfree(op_async);
457}
458
459static void gb_loopback_async_operation_get(struct gb_loopback_async_operation
460 *op_async)
461{
462 kref_get(&op_async->kref);
463}
464
465static void gb_loopback_async_operation_put(struct gb_loopback_async_operation
466 *op_async)
467{
468 unsigned long flags;
469
470 spin_lock_irqsave(&gb_dev.lock, flags);
471 kref_put(&op_async->kref, __gb_loopback_async_operation_destroy);
472 spin_unlock_irqrestore(&gb_dev.lock, flags);
473}
474
475static struct gb_loopback_async_operation *
476 gb_loopback_operation_find(u16 id)
477{
478 struct gb_loopback_async_operation *op_async;
479 bool found = false;
480 unsigned long flags;
481
482 spin_lock_irqsave(&gb_dev.lock, flags);
483 list_for_each_entry(op_async, &gb_dev.list_op_async, entry) {
484 if (op_async->operation->id == id) {
485 gb_loopback_async_operation_get(op_async);
486 found = true;
487 break;
488 }
489 }
490 spin_unlock_irqrestore(&gb_dev.lock, flags);
491
492 return found ? op_async : NULL;
493}
494
495static void gb_loopback_async_wait_all(struct gb_loopback *gb) 424static void gb_loopback_async_wait_all(struct gb_loopback *gb)
496{ 425{
497 wait_event(gb->wq_completion, 426 wait_event(gb->wq_completion,
@@ -502,87 +431,42 @@ static void gb_loopback_async_operation_callback(struct gb_operation *operation)
502{ 431{
503 struct gb_loopback_async_operation *op_async; 432 struct gb_loopback_async_operation *op_async;
504 struct gb_loopback *gb; 433 struct gb_loopback *gb;
505 struct timeval te; 434 ktime_t te;
506 bool err = false; 435 int result;
507
508 do_gettimeofday(&te);
509 op_async = gb_loopback_operation_find(operation->id);
510 if (!op_async)
511 return;
512 436
437 te = ktime_get();
438 result = gb_operation_result(operation);
439 op_async = gb_operation_get_data(operation);
513 gb = op_async->gb; 440 gb = op_async->gb;
441
514 mutex_lock(&gb->mutex); 442 mutex_lock(&gb->mutex);
515 443
516 if (!op_async->pending || gb_operation_result(operation)) { 444 if (!result && op_async->completion)
517 err = true; 445 result = op_async->completion(op_async);
446
447 if (!result) {
448 gb->elapsed_nsecs = gb_loopback_calc_latency(op_async->ts, te);
518 } else { 449 } else {
519 if (op_async->completion) 450 gb->error++;
520 if (op_async->completion(op_async)) 451 if (result == -ETIMEDOUT)
521 err = true; 452 gb->requests_timedout++;
522 } 453 }
523 454
524 if (!err) { 455 gb->iteration_count++;
525 gb_loopback_push_latency_ts(gb, &op_async->ts, &te); 456 gb_loopback_calculate_stats(gb, result);
526 gb->elapsed_nsecs = gb_loopback_calc_latency(&op_async->ts,
527 &te);
528 }
529 457
530 if (op_async->pending) {
531 if (err)
532 gb->error++;
533 gb->iteration_count++;
534 op_async->pending = false;
535 del_timer_sync(&op_async->timer);
536 gb_loopback_async_operation_put(op_async);
537 gb_loopback_calculate_stats(gb, err);
538 }
539 mutex_unlock(&gb->mutex); 458 mutex_unlock(&gb->mutex);
540 459
541 dev_dbg(&gb->connection->bundle->dev, "complete operation %d\n", 460 dev_dbg(&gb->connection->bundle->dev, "complete operation %d\n",
542 operation->id); 461 operation->id);
543 462
544 gb_loopback_async_operation_put(op_async); 463 /* Wake up waiters */
545} 464 atomic_dec(&op_async->gb->outstanding_operations);
546 465 wake_up(&gb->wq_completion);
547static void gb_loopback_async_operation_work(struct work_struct *work)
548{
549 struct gb_loopback *gb;
550 struct gb_operation *operation;
551 struct gb_loopback_async_operation *op_async;
552
553 op_async = container_of(work, struct gb_loopback_async_operation, work);
554 gb = op_async->gb;
555 operation = op_async->operation;
556
557 mutex_lock(&gb->mutex);
558 if (op_async->pending) {
559 gb->requests_timedout++;
560 gb->error++;
561 gb->iteration_count++;
562 op_async->pending = false;
563 gb_loopback_async_operation_put(op_async);
564 gb_loopback_calculate_stats(gb, true);
565 }
566 mutex_unlock(&gb->mutex);
567
568 dev_dbg(&gb->connection->bundle->dev, "timeout operation %d\n",
569 operation->id);
570
571 gb_operation_cancel(operation, -ETIMEDOUT);
572 gb_loopback_async_operation_put(op_async);
573}
574
575static void gb_loopback_async_operation_timeout(unsigned long data)
576{
577 struct gb_loopback_async_operation *op_async;
578 u16 id = data;
579 466
580 op_async = gb_loopback_operation_find(id); 467 /* Release resources */
581 if (!op_async) { 468 gb_operation_put(operation);
582 pr_err("operation %d not found - time out ?\n", id); 469 kfree(op_async);
583 return;
584 }
585 schedule_work(&op_async->work);
586} 470}
587 471
588static int gb_loopback_async_operation(struct gb_loopback *gb, int type, 472static int gb_loopback_async_operation(struct gb_loopback *gb, int type,
@@ -593,15 +477,11 @@ static int gb_loopback_async_operation(struct gb_loopback *gb, int type,
593 struct gb_loopback_async_operation *op_async; 477 struct gb_loopback_async_operation *op_async;
594 struct gb_operation *operation; 478 struct gb_operation *operation;
595 int ret; 479 int ret;
596 unsigned long flags;
597 480
598 op_async = kzalloc(sizeof(*op_async), GFP_KERNEL); 481 op_async = kzalloc(sizeof(*op_async), GFP_KERNEL);
599 if (!op_async) 482 if (!op_async)
600 return -ENOMEM; 483 return -ENOMEM;
601 484
602 INIT_WORK(&op_async->work, gb_loopback_async_operation_work);
603 kref_init(&op_async->kref);
604
605 operation = gb_operation_create(gb->connection, type, request_size, 485 operation = gb_operation_create(gb->connection, type, request_size,
606 response_size, GFP_KERNEL); 486 response_size, GFP_KERNEL);
607 if (!operation) { 487 if (!operation) {
@@ -612,35 +492,24 @@ static int gb_loopback_async_operation(struct gb_loopback *gb, int type,
612 if (request_size) 492 if (request_size)
613 memcpy(operation->request->payload, request, request_size); 493 memcpy(operation->request->payload, request, request_size);
614 494
495 gb_operation_set_data(operation, op_async);
496
615 op_async->gb = gb; 497 op_async->gb = gb;
616 op_async->operation = operation; 498 op_async->operation = operation;
617 op_async->completion = completion; 499 op_async->completion = completion;
618 500
619 spin_lock_irqsave(&gb_dev.lock, flags); 501 op_async->ts = ktime_get();
620 list_add_tail(&op_async->entry, &gb_dev.list_op_async);
621 spin_unlock_irqrestore(&gb_dev.lock, flags);
622 502
623 do_gettimeofday(&op_async->ts);
624 op_async->pending = true;
625 atomic_inc(&gb->outstanding_operations); 503 atomic_inc(&gb->outstanding_operations);
626 mutex_lock(&gb->mutex);
627 ret = gb_operation_request_send(operation, 504 ret = gb_operation_request_send(operation,
628 gb_loopback_async_operation_callback, 505 gb_loopback_async_operation_callback,
629 0, 506 jiffies_to_msecs(gb->jiffy_timeout),
630 GFP_KERNEL); 507 GFP_KERNEL);
631 if (ret) 508 if (ret) {
632 goto error; 509 atomic_dec(&gb->outstanding_operations);
633 510 gb_operation_put(operation);
634 setup_timer(&op_async->timer, gb_loopback_async_operation_timeout, 511 kfree(op_async);
635 (unsigned long)operation->id); 512 }
636 op_async->timer.expires = jiffies + gb->jiffy_timeout;
637 add_timer(&op_async->timer);
638
639 goto done;
640error:
641 gb_loopback_async_operation_put(op_async);
642done:
643 mutex_unlock(&gb->mutex);
644 return ret; 513 return ret;
645} 514}
646 515
@@ -854,7 +723,7 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb)
854 /* Should be initialized at least once per transaction set */ 723 /* Should be initialized at least once per transaction set */
855 gb->apbridge_latency_ts = 0; 724 gb->apbridge_latency_ts = 0;
856 gb->gbphy_latency_ts = 0; 725 gb->gbphy_latency_ts = 0;
857 memset(&gb->ts, 0, sizeof(struct timeval)); 726 gb->ts = ktime_set(0, 0);
858} 727}
859 728
860static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val) 729static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val)
@@ -937,15 +806,15 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb, bool error)
937{ 806{
938 u64 nlat; 807 u64 nlat;
939 u32 lat; 808 u32 lat;
940 struct timeval te; 809 ktime_t te;
941 810
942 if (!error) { 811 if (!error) {
943 gb->requests_completed++; 812 gb->requests_completed++;
944 gb_loopback_calculate_latency_stats(gb); 813 gb_loopback_calculate_latency_stats(gb);
945 } 814 }
946 815
947 do_gettimeofday(&te); 816 te = ktime_get();
948 nlat = gb_loopback_calc_latency(&gb->ts, &te); 817 nlat = gb_loopback_calc_latency(gb->ts, te);
949 if (nlat >= NSEC_PER_SEC || gb->iteration_count == gb->iteration_max) { 818 if (nlat >= NSEC_PER_SEC || gb->iteration_count == gb->iteration_max) {
950 lat = gb_loopback_nsec_to_usec_latency(nlat); 819 lat = gb_loopback_nsec_to_usec_latency(nlat);
951 820
@@ -1029,9 +898,8 @@ static int gb_loopback_fn(void *data)
1029 size = gb->size; 898 size = gb->size;
1030 us_wait = gb->us_wait; 899 us_wait = gb->us_wait;
1031 type = gb->type; 900 type = gb->type;
1032 if (gb->ts.tv_usec == 0 && gb->ts.tv_sec == 0) 901 if (ktime_to_ns(gb->ts) == 0)
1033 do_gettimeofday(&gb->ts); 902 gb->ts = ktime_get();
1034 mutex_unlock(&gb->mutex);
1035 903
1036 /* Else operations to perform */ 904 /* Else operations to perform */
1037 if (gb->async) { 905 if (gb->async) {
@@ -1042,8 +910,10 @@ static int gb_loopback_fn(void *data)
1042 else if (type == GB_LOOPBACK_TYPE_SINK) 910 else if (type == GB_LOOPBACK_TYPE_SINK)
1043 error = gb_loopback_async_sink(gb, size); 911 error = gb_loopback_async_sink(gb, size);
1044 912
1045 if (error) 913 if (error) {
1046 gb->error++; 914 gb->error++;
915 gb->iteration_count++;
916 }
1047 } else { 917 } else {
1048 /* We are effectively single threaded here */ 918 /* We are effectively single threaded here */
1049 if (type == GB_LOOPBACK_TYPE_PING) 919 if (type == GB_LOOPBACK_TYPE_PING)
@@ -1059,6 +929,7 @@ static int gb_loopback_fn(void *data)
1059 gb_loopback_calculate_stats(gb, !!error); 929 gb_loopback_calculate_stats(gb, !!error);
1060 } 930 }
1061 gb->send_count++; 931 gb->send_count++;
932 mutex_unlock(&gb->mutex);
1062 933
1063 if (us_wait) { 934 if (us_wait) {
1064 if (us_wait < 20000) 935 if (us_wait < 20000)
@@ -1241,18 +1112,12 @@ static int gb_loopback_probe(struct gb_bundle *bundle,
1241 retval = -ENOMEM; 1112 retval = -ENOMEM;
1242 goto out_conn; 1113 goto out_conn;
1243 } 1114 }
1244 if (kfifo_alloc(&gb->kfifo_ts, kfifo_depth * sizeof(struct timeval) * 2,
1245 GFP_KERNEL)) {
1246 retval = -ENOMEM;
1247 goto out_kfifo0;
1248 }
1249
1250 /* Fork worker thread */ 1115 /* Fork worker thread */
1251 mutex_init(&gb->mutex); 1116 mutex_init(&gb->mutex);
1252 gb->task = kthread_run(gb_loopback_fn, gb, "gb_loopback"); 1117 gb->task = kthread_run(gb_loopback_fn, gb, "gb_loopback");
1253 if (IS_ERR(gb->task)) { 1118 if (IS_ERR(gb->task)) {
1254 retval = PTR_ERR(gb->task); 1119 retval = PTR_ERR(gb->task);
1255 goto out_kfifo1; 1120 goto out_kfifo;
1256 } 1121 }
1257 1122
1258 spin_lock_irqsave(&gb_dev.lock, flags); 1123 spin_lock_irqsave(&gb_dev.lock, flags);
@@ -1266,9 +1131,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle,
1266 1131
1267 return 0; 1132 return 0;
1268 1133
1269out_kfifo1: 1134out_kfifo:
1270 kfifo_free(&gb->kfifo_ts);
1271out_kfifo0:
1272 kfifo_free(&gb->kfifo_lat); 1135 kfifo_free(&gb->kfifo_lat);
1273out_conn: 1136out_conn:
1274 device_unregister(dev); 1137 device_unregister(dev);
@@ -1302,7 +1165,6 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle)
1302 kthread_stop(gb->task); 1165 kthread_stop(gb->task);
1303 1166
1304 kfifo_free(&gb->kfifo_lat); 1167 kfifo_free(&gb->kfifo_lat);
1305 kfifo_free(&gb->kfifo_ts);
1306 gb_connection_latency_tag_disable(gb->connection); 1168 gb_connection_latency_tag_disable(gb->connection);
1307 debugfs_remove(gb->file); 1169 debugfs_remove(gb->file);
1308 1170
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c
index 7b903770a684..08db49264f2b 100644
--- a/drivers/staging/greybus/manifest.c
+++ b/drivers/staging/greybus/manifest.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus manifest parsing 3 * Greybus manifest parsing
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include "greybus.h" 9#include "greybus.h"
diff --git a/drivers/staging/greybus/manifest.h b/drivers/staging/greybus/manifest.h
index d96428407cd7..f3c95a255631 100644
--- a/drivers/staging/greybus/manifest.h
+++ b/drivers/staging/greybus/manifest.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus manifest parsing 3 * Greybus manifest parsing
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __MANIFEST_H 9#ifndef __MANIFEST_H
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index 660b4674a76f..b785382192de 100644
--- a/drivers/staging/greybus/module.c
+++ b/drivers/staging/greybus/module.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Module code 3 * Greybus Module code
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include "greybus.h" 9#include "greybus.h"
diff --git a/drivers/staging/greybus/module.h b/drivers/staging/greybus/module.h
index 88a97ce04243..b1ebcc6636db 100644
--- a/drivers/staging/greybus/module.h
+++ b/drivers/staging/greybus/module.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Module code 3 * Greybus Module code
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 * Copyright 2016 Linaro Ltd. 6 * Copyright 2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __MODULE_H 9#ifndef __MODULE_H
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index 3023012808d9..609332b3e15b 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h
index 7529f01b2529..40b7b02fff88 100644
--- a/drivers/staging/greybus/operation.h
+++ b/drivers/staging/greybus/operation.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus operations 3 * Greybus operations
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __OPERATION_H 9#ifndef __OPERATION_H
@@ -105,6 +104,8 @@ struct gb_operation {
105 104
106 int active; 105 int active;
107 struct list_head links; /* connection->operations */ 106 struct list_head links; /* connection->operations */
107
108 void *private;
108}; 109};
109 110
110static inline bool 111static inline bool
@@ -206,6 +207,17 @@ static inline int gb_operation_unidirectional(struct gb_connection *connection,
206 request, request_size, GB_OPERATION_TIMEOUT_DEFAULT); 207 request, request_size, GB_OPERATION_TIMEOUT_DEFAULT);
207} 208}
208 209
210static inline void *gb_operation_get_data(struct gb_operation *operation)
211{
212 return operation->private;
213}
214
215static inline void gb_operation_set_data(struct gb_operation *operation,
216 void *data)
217{
218 operation->private = data;
219}
220
209int gb_operation_init(void); 221int gb_operation_init(void);
210void gb_operation_exit(void); 222void gb_operation_exit(void);
211 223
diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
index 20cac20518d7..0529e5628c24 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Power Supply driver for a Greybus module. 3 * Power Supply driver for a Greybus module.
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/pwm.c b/drivers/staging/greybus/pwm.c
index f0404bc37123..4a6d394b6c44 100644
--- a/drivers/staging/greybus/pwm.c
+++ b/drivers/staging/greybus/pwm.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * PWM Greybus driver. 3 * PWM Greybus driver.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
index 729d25811568..838acbe84ca0 100644
--- a/drivers/staging/greybus/raw.c
+++ b/drivers/staging/greybus/raw.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus driver for the Raw protocol 3 * Greybus driver for the Raw protocol
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c
index 101ca5097fc9..38e85033fc4b 100644
--- a/drivers/staging/greybus/sdio.c
+++ b/drivers/staging/greybus/sdio.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SD/MMC Greybus driver. 3 * SD/MMC Greybus driver.
3 * 4 *
4 * Copyright 2014-2015 Google Inc. 5 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd. 6 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/greybus/spi.c b/drivers/staging/greybus/spi.c
index c893552b5c0b..47d896992b35 100644
--- a/drivers/staging/greybus/spi.c
+++ b/drivers/staging/greybus/spi.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SPI bridge PHY driver. 3 * SPI bridge PHY driver.
3 * 4 *
4 * Copyright 2014-2016 Google Inc. 5 * Copyright 2014-2016 Google Inc.
5 * Copyright 2014-2016 Linaro Ltd. 6 * Copyright 2014-2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
index e97b19148497..2e07c6b41334 100644
--- a/drivers/staging/greybus/spilib.c
+++ b/drivers/staging/greybus/spilib.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus SPI library 3 * Greybus SPI library
3 * 4 *
4 * Copyright 2014-2016 Google Inc. 5 * Copyright 2014-2016 Google Inc.
5 * Copyright 2014-2016 Linaro Ltd. 6 * Copyright 2014-2016 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/bitops.h> 9#include <linux/bitops.h>
@@ -544,12 +543,15 @@ int gb_spilib_master_init(struct gb_connection *connection, struct device *dev,
544 543
545 return 0; 544 return 0;
546 545
547exit_spi_unregister:
548 spi_unregister_master(master);
549exit_spi_put: 546exit_spi_put:
550 spi_master_put(master); 547 spi_master_put(master);
551 548
552 return ret; 549 return ret;
550
551exit_spi_unregister:
552 spi_unregister_master(master);
553
554 return ret;
553} 555}
554EXPORT_SYMBOL_GPL(gb_spilib_master_init); 556EXPORT_SYMBOL_GPL(gb_spilib_master_init);
555 557
@@ -558,7 +560,6 @@ void gb_spilib_master_exit(struct gb_connection *connection)
558 struct spi_master *master = gb_connection_get_data(connection); 560 struct spi_master *master = gb_connection_get_data(connection);
559 561
560 spi_unregister_master(master); 562 spi_unregister_master(master);
561 spi_master_put(master);
562} 563}
563EXPORT_SYMBOL_GPL(gb_spilib_master_exit); 564EXPORT_SYMBOL_GPL(gb_spilib_master_exit);
564 565
diff --git a/drivers/staging/greybus/spilib.h b/drivers/staging/greybus/spilib.h
index cb6092578a92..043d4d32c3ee 100644
--- a/drivers/staging/greybus/spilib.h
+++ b/drivers/staging/greybus/spilib.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus SPI library header 3 * Greybus SPI library header
3 * 4 *
diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c
index 516f827e5ed9..a874fed761a1 100644
--- a/drivers/staging/greybus/svc.c
+++ b/drivers/staging/greybus/svc.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SVC Greybus driver. 3 * SVC Greybus driver.
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/debugfs.h> 9#include <linux/debugfs.h>
diff --git a/drivers/staging/greybus/svc.h b/drivers/staging/greybus/svc.h
index 226c2a396fc8..ad01783bac9c 100644
--- a/drivers/staging/greybus/svc.h
+++ b/drivers/staging/greybus/svc.h
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus SVC code 3 * Greybus SVC code
3 * 4 *
4 * Copyright 2015 Google Inc. 5 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd. 6 * Copyright 2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#ifndef __SVC_H 9#ifndef __SVC_H
diff --git a/drivers/staging/greybus/svc_watchdog.c b/drivers/staging/greybus/svc_watchdog.c
index 779fbea5d4ba..7868ad8211c5 100644
--- a/drivers/staging/greybus/svc_watchdog.c
+++ b/drivers/staging/greybus/svc_watchdog.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SVC Greybus "watchdog" driver. 3 * SVC Greybus "watchdog" driver.
3 * 4 *
4 * Copyright 2016 Google Inc. 5 * Copyright 2016 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */ 6 */
8 7
9#include <linux/delay.h> 8#include <linux/delay.h>
diff --git a/drivers/staging/greybus/tools/lbtest b/drivers/staging/greybus/tools/lbtest
index d7353f1a2a6f..47c481239e98 100755
--- a/drivers/staging/greybus/tools/lbtest
+++ b/drivers/staging/greybus/tools/lbtest
@@ -1,4 +1,5 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# SPDX-License-Identifier: BSD-3-Clause
2 3
3# Copyright (c) 2015 Google, Inc. 4# Copyright (c) 2015 Google, Inc.
4# Copyright (c) 2015 Linaro, Ltd. 5# Copyright (c) 2015 Linaro, Ltd.
diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
index fbe589fca840..c51610ce24af 100644
--- a/drivers/staging/greybus/tools/loopback_test.c
+++ b/drivers/staging/greybus/tools/loopback_test.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: BSD-3-Clause
1/* 2/*
2 * Loopback test application 3 * Loopback test application
3 * 4 *
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index c6d01b800d3c..8a006323c3c1 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * UART driver for the Greybus "generic" UART module. 3 * UART driver for the Greybus "generic" UART module.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 * 7 *
7 * Released under the GPLv2 only.
8 *
9 * Heavily based on drivers/usb/class/cdc-acm.c and 8 * Heavily based on drivers/usb/class/cdc-acm.c and
10 * drivers/usb/serial/usb-serial.c. 9 * drivers/usb/serial/usb-serial.c.
11 */ 10 */
diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c
index f93a76d02de6..1c246c73a085 100644
--- a/drivers/staging/greybus/usb.c
+++ b/drivers/staging/greybus/usb.c
@@ -1,11 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB host driver for the Greybus "generic" USB module. 3 * USB host driver for the Greybus "generic" USB module.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 *
9 */ 7 */
10#include <linux/kernel.h> 8#include <linux/kernel.h>
11#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/staging/greybus/vibrator.c b/drivers/staging/greybus/vibrator.c
index 5cd8a50d41ad..3e5dedeacd5c 100644
--- a/drivers/staging/greybus/vibrator.c
+++ b/drivers/staging/greybus/vibrator.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Greybus Vibrator protocol driver. 3 * Greybus Vibrator protocol driver.
3 * 4 *
4 * Copyright 2014 Google Inc. 5 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd. 6 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */ 7 */
9 8
10#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
index bcbdc7340b55..fa8b27e091a2 100644
--- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
+++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
@@ -106,7 +106,7 @@ static int readmagic_bitstream(u8 *bitdata, int *offset)
106 read_bitstream(bitdata, buf, offset, 13); 106 read_bitstream(bitdata, buf, offset, 13);
107 r = memcmp(buf, bits_magic, 13); 107 r = memcmp(buf, bits_magic, 13);
108 if (r) { 108 if (r) {
109 pr_err("error: corrupted header"); 109 pr_err("error: corrupted header\n");
110 return -EINVAL; 110 return -EINVAL;
111 } 111 }
112 pr_info("bitstream file magic number Ok\n"); 112 pr_info("bitstream file magic number Ok\n");
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 54ef0deed28f..ec42544a46aa 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -26,9 +26,6 @@ Then fill in the following:
26 pointer to a structure with elements that tend to be fixed for 26 pointer to a structure with elements that tend to be fixed for
27 large sets of different parts supported by a given driver. 27 large sets of different parts supported by a given driver.
28 This contains: 28 This contains:
29 * info->driver_module:
30 Set to THIS_MODULE. Used to ensure correct ownership
31 of various resources allocate by the core.
32 * info->event_attrs: 29 * info->event_attrs:
33 Attributes used to enable / disable hardware events. 30 Attributes used to enable / disable hardware events.
34 * info->attrs: 31 * info->attrs:
diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt
index 7c0e505e4f04..299a1add98bf 100644
--- a/drivers/staging/iio/Documentation/trigger.txt
+++ b/drivers/staging/iio/Documentation/trigger.txt
@@ -10,10 +10,6 @@ struct iio_trig *trig = iio_trigger_alloc("<trigger format string>", ...);
10allocates a trigger structure. The key elements to then fill in within 10allocates a trigger structure. The key elements to then fill in within
11a driver are: 11a driver are:
12 12
13trig->owner
14 Typically set to THIS_MODULE. Used to ensure correct
15 ownership of core allocated resources.
16
17trig->set_trigger_state: 13trig->set_trigger_state:
18 Function that enables / disables the underlying source of the trigger. 14 Function that enables / disables the underlying source of the trigger.
19 15
diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c
index fbc240663621..2ebd27536216 100644
--- a/drivers/staging/iio/accel/adis16201.c
+++ b/drivers/staging/iio/accel/adis16201.c
@@ -284,7 +284,6 @@ static const struct iio_info adis16201_info = {
284 .read_raw = adis16201_read_raw, 284 .read_raw = adis16201_read_raw,
285 .write_raw = adis16201_write_raw, 285 .write_raw = adis16201_write_raw,
286 .update_scan_mode = adis_update_scan_mode, 286 .update_scan_mode = adis_update_scan_mode,
287 .driver_module = THIS_MODULE,
288}; 287};
289 288
290static const char * const adis16201_status_error_msgs[] = { 289static const char * const adis16201_status_error_msgs[] = {
diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c
index 4e3fa7592d3f..b3e4571340ab 100644
--- a/drivers/staging/iio/accel/adis16203.c
+++ b/drivers/staging/iio/accel/adis16203.c
@@ -232,7 +232,6 @@ static const struct iio_info adis16203_info = {
232 .read_raw = adis16203_read_raw, 232 .read_raw = adis16203_read_raw,
233 .write_raw = adis16203_write_raw, 233 .write_raw = adis16203_write_raw,
234 .update_scan_mode = adis_update_scan_mode, 234 .update_scan_mode = adis_update_scan_mode,
235 .driver_module = THIS_MODULE,
236}; 235};
237 236
238static const char * const adis16203_status_error_msgs[] = { 237static const char * const adis16203_status_error_msgs[] = {
diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c
index 8485c024e3f5..7fcef9a2590a 100644
--- a/drivers/staging/iio/accel/adis16209.c
+++ b/drivers/staging/iio/accel/adis16209.c
@@ -285,7 +285,6 @@ static const struct iio_info adis16209_info = {
285 .read_raw = adis16209_read_raw, 285 .read_raw = adis16209_read_raw,
286 .write_raw = adis16209_write_raw, 286 .write_raw = adis16209_write_raw,
287 .update_scan_mode = adis_update_scan_mode, 287 .update_scan_mode = adis_update_scan_mode,
288 .driver_module = THIS_MODULE,
289}; 288};
290 289
291static const char * const adis16209_status_error_msgs[] = { 290static const char * const adis16209_status_error_msgs[] = {
diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c
index 109cd94b5ac3..fff6d99089cc 100644
--- a/drivers/staging/iio/accel/adis16240.c
+++ b/drivers/staging/iio/accel/adis16240.c
@@ -361,7 +361,6 @@ static const struct iio_info adis16240_info = {
361 .read_raw = adis16240_read_raw, 361 .read_raw = adis16240_read_raw,
362 .write_raw = adis16240_write_raw, 362 .write_raw = adis16240_write_raw,
363 .update_scan_mode = adis_update_scan_mode, 363 .update_scan_mode = adis_update_scan_mode,
364 .driver_module = THIS_MODULE,
365}; 364};
366 365
367static const char * const adis16240_status_error_msgs[] = { 366static const char * const adis16240_status_error_msgs[] = {
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 6150d2780e22..cadfb96734ed 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -162,6 +162,7 @@ struct ad7192_state {
162 u32 scale_avail[8][2]; 162 u32 scale_avail[8][2];
163 u8 gpocon; 163 u8 gpocon;
164 u8 devid; 164 u8 devid;
165 struct mutex lock; /* protect sensor state */
165 166
166 struct ad_sigma_delta sd; 167 struct ad_sigma_delta sd;
167}; 168};
@@ -461,10 +462,10 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
461 case IIO_CHAN_INFO_SCALE: 462 case IIO_CHAN_INFO_SCALE:
462 switch (chan->type) { 463 switch (chan->type) {
463 case IIO_VOLTAGE: 464 case IIO_VOLTAGE:
464 mutex_lock(&indio_dev->mlock); 465 mutex_lock(&st->lock);
465 *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; 466 *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0];
466 *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; 467 *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1];
467 mutex_unlock(&indio_dev->mlock); 468 mutex_unlock(&st->lock);
468 return IIO_VAL_INT_PLUS_NANO; 469 return IIO_VAL_INT_PLUS_NANO;
469 case IIO_TEMP: 470 case IIO_TEMP:
470 *val = 0; 471 *val = 0;
@@ -508,6 +509,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
508 switch (mask) { 509 switch (mask) {
509 case IIO_CHAN_INFO_SCALE: 510 case IIO_CHAN_INFO_SCALE:
510 ret = -EINVAL; 511 ret = -EINVAL;
512 mutex_lock(&st->lock);
511 for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) 513 for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++)
512 if (val2 == st->scale_avail[i][1]) { 514 if (val2 == st->scale_avail[i][1]) {
513 ret = 0; 515 ret = 0;
@@ -521,6 +523,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
521 ad7192_calibrate_all(st); 523 ad7192_calibrate_all(st);
522 break; 524 break;
523 } 525 }
526 mutex_unlock(&st->lock);
524 break; 527 break;
525 case IIO_CHAN_INFO_SAMP_FREQ: 528 case IIO_CHAN_INFO_SAMP_FREQ:
526 if (!val) { 529 if (!val) {
@@ -567,7 +570,6 @@ static const struct iio_info ad7192_info = {
567 .write_raw_get_fmt = ad7192_write_raw_get_fmt, 570 .write_raw_get_fmt = ad7192_write_raw_get_fmt,
568 .attrs = &ad7192_attribute_group, 571 .attrs = &ad7192_attribute_group,
569 .validate_trigger = ad_sd_validate_trigger, 572 .validate_trigger = ad_sd_validate_trigger,
570 .driver_module = THIS_MODULE,
571}; 573};
572 574
573static const struct iio_info ad7195_info = { 575static const struct iio_info ad7195_info = {
@@ -576,7 +578,6 @@ static const struct iio_info ad7195_info = {
576 .write_raw_get_fmt = ad7192_write_raw_get_fmt, 578 .write_raw_get_fmt = ad7192_write_raw_get_fmt,
577 .attrs = &ad7195_attribute_group, 579 .attrs = &ad7195_attribute_group,
578 .validate_trigger = ad_sd_validate_trigger, 580 .validate_trigger = ad_sd_validate_trigger,
579 .driver_module = THIS_MODULE,
580}; 581};
581 582
582static const struct iio_chan_spec ad7192_channels[] = { 583static const struct iio_chan_spec ad7192_channels[] = {
@@ -632,6 +633,8 @@ static int ad7192_probe(struct spi_device *spi)
632 633
633 st = iio_priv(indio_dev); 634 st = iio_priv(indio_dev);
634 635
636 mutex_init(&st->lock);
637
635 st->avdd = devm_regulator_get(&spi->dev, "avdd"); 638 st->avdd = devm_regulator_get(&spi->dev, "avdd");
636 if (IS_ERR(st->avdd)) 639 if (IS_ERR(st->avdd))
637 return PTR_ERR(st->avdd); 640 return PTR_ERR(st->avdd);
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index f85dde9805e0..b736275c10f5 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -828,7 +828,6 @@ static const struct iio_info ad7280_info = {
828 .read_raw = ad7280_read_raw, 828 .read_raw = ad7280_read_raw,
829 .event_attrs = &ad7280_event_attrs_group, 829 .event_attrs = &ad7280_event_attrs_group,
830 .attrs = &ad7280_attrs_group, 830 .attrs = &ad7280_attrs_group,
831 .driver_module = THIS_MODULE,
832}; 831};
833 832
834static const struct ad7280_platform_data ad7793_default_pdata = { 833static const struct ad7280_platform_data ad7793_default_pdata = {
diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c
index 18f5f139117e..25b9fcd5e3a4 100644
--- a/drivers/staging/iio/adc/ad7606.c
+++ b/drivers/staging/iio/adc/ad7606.c
@@ -373,26 +373,22 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
373}; 373};
374 374
375static const struct iio_info ad7606_info_no_os_or_range = { 375static const struct iio_info ad7606_info_no_os_or_range = {
376 .driver_module = THIS_MODULE,
377 .read_raw = &ad7606_read_raw, 376 .read_raw = &ad7606_read_raw,
378}; 377};
379 378
380static const struct iio_info ad7606_info_os_and_range = { 379static const struct iio_info ad7606_info_os_and_range = {
381 .driver_module = THIS_MODULE,
382 .read_raw = &ad7606_read_raw, 380 .read_raw = &ad7606_read_raw,
383 .write_raw = &ad7606_write_raw, 381 .write_raw = &ad7606_write_raw,
384 .attrs = &ad7606_attribute_group_os_and_range, 382 .attrs = &ad7606_attribute_group_os_and_range,
385}; 383};
386 384
387static const struct iio_info ad7606_info_os = { 385static const struct iio_info ad7606_info_os = {
388 .driver_module = THIS_MODULE,
389 .read_raw = &ad7606_read_raw, 386 .read_raw = &ad7606_read_raw,
390 .write_raw = &ad7606_write_raw, 387 .write_raw = &ad7606_write_raw,
391 .attrs = &ad7606_attribute_group_os, 388 .attrs = &ad7606_attribute_group_os,
392}; 389};
393 390
394static const struct iio_info ad7606_info_range = { 391static const struct iio_info ad7606_info_range = {
395 .driver_module = THIS_MODULE,
396 .read_raw = &ad7606_read_raw, 392 .read_raw = &ad7606_read_raw,
397 .write_raw = &ad7606_write_raw, 393 .write_raw = &ad7606_write_raw,
398 .attrs = &ad7606_attribute_group_range, 394 .attrs = &ad7606_attribute_group_range,
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6eba8a..a7797af579b9 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -155,7 +155,6 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
155 155
156static const struct iio_info ad7780_info = { 156static const struct iio_info ad7780_info = {
157 .read_raw = ad7780_read_raw, 157 .read_raw = ad7780_read_raw,
158 .driver_module = THIS_MODULE,
159}; 158};
160 159
161static int ad7780_probe(struct spi_device *spi) 160static int ad7780_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 17d280581e24..bfe180a475ee 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -335,7 +335,6 @@ static const struct attribute_group ad7816_event_attribute_group = {
335static const struct iio_info ad7816_info = { 335static const struct iio_info ad7816_info = {
336 .attrs = &ad7816_attribute_group, 336 .attrs = &ad7816_attribute_group,
337 .event_attrs = &ad7816_event_attribute_group, 337 .event_attrs = &ad7816_event_attribute_group,
338 .driver_module = THIS_MODULE,
339}; 338};
340 339
341/* 340/*
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index b2bce26499f5..2d33632c00e8 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -2087,13 +2087,11 @@ EXPORT_SYMBOL_GPL(adt7316_pm_ops);
2087static const struct iio_info adt7316_info = { 2087static const struct iio_info adt7316_info = {
2088 .attrs = &adt7316_attribute_group, 2088 .attrs = &adt7316_attribute_group,
2089 .event_attrs = &adt7316_event_attribute_group, 2089 .event_attrs = &adt7316_event_attribute_group,
2090 .driver_module = THIS_MODULE,
2091}; 2090};
2092 2091
2093static const struct iio_info adt7516_info = { 2092static const struct iio_info adt7516_info = {
2094 .attrs = &adt7516_attribute_group, 2093 .attrs = &adt7516_attribute_group,
2095 .event_attrs = &adt7516_event_attribute_group, 2094 .event_attrs = &adt7516_event_attribute_group,
2096 .driver_module = THIS_MODULE,
2097}; 2095};
2098 2096
2099/* 2097/*
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index a6f249e9c1e1..2fe916c48848 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -569,7 +569,6 @@ static const struct attribute_group ad7150_event_attribute_group = {
569 569
570static const struct iio_info ad7150_info = { 570static const struct iio_info ad7150_info = {
571 .event_attrs = &ad7150_event_attribute_group, 571 .event_attrs = &ad7150_event_attribute_group,
572 .driver_module = THIS_MODULE,
573 .read_raw = &ad7150_read_raw, 572 .read_raw = &ad7150_read_raw,
574 .read_event_config = &ad7150_read_event_config, 573 .read_event_config = &ad7150_read_event_config,
575 .write_event_config = &ad7150_write_event_config, 574 .write_event_config = &ad7150_write_event_config,
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
index ff10d1f0a7e4..61377ca444de 100644
--- a/drivers/staging/iio/cdc/ad7152.c
+++ b/drivers/staging/iio/cdc/ad7152.c
@@ -441,7 +441,6 @@ static const struct iio_info ad7152_info = {
441 .read_raw = ad7152_read_raw, 441 .read_raw = ad7152_read_raw,
442 .write_raw = ad7152_write_raw, 442 .write_raw = ad7152_write_raw,
443 .write_raw_get_fmt = ad7152_write_raw_get_fmt, 443 .write_raw_get_fmt = ad7152_write_raw_get_fmt,
444 .driver_module = THIS_MODULE,
445}; 444};
446 445
447static const struct iio_chan_spec ad7152_channels[] = { 446static const struct iio_chan_spec ad7152_channels[] = {
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index cdcb4fccf3fe..a124853a05f0 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -667,7 +667,6 @@ static const struct iio_info ad7746_info = {
667 .attrs = &ad7746_attribute_group, 667 .attrs = &ad7746_attribute_group,
668 .read_raw = ad7746_read_raw, 668 .read_raw = ad7746_read_raw,
669 .write_raw = ad7746_write_raw, 669 .write_raw = ad7746_write_raw,
670 .driver_module = THIS_MODULE,
671}; 670};
672 671
673/* 672/*
diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 6da46ede7ee0..c73eff1f8d73 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -290,7 +290,6 @@ static const struct attribute_group ad9832_attribute_group = {
290 290
291static const struct iio_info ad9832_info = { 291static const struct iio_info ad9832_info = {
292 .attrs = &ad9832_attribute_group, 292 .attrs = &ad9832_attribute_group,
293 .driver_module = THIS_MODULE,
294}; 293};
295 294
296static int ad9832_probe(struct spi_device *spi) 295static int ad9832_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 995acdd7c942..4c6d4043903e 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -381,12 +381,10 @@ static const struct attribute_group ad9833_attribute_group = {
381 381
382static const struct iio_info ad9834_info = { 382static const struct iio_info ad9834_info = {
383 .attrs = &ad9834_attribute_group, 383 .attrs = &ad9834_attribute_group,
384 .driver_module = THIS_MODULE,
385}; 384};
386 385
387static const struct iio_info ad9833_info = { 386static const struct iio_info ad9833_info = {
388 .attrs = &ad9833_attribute_group, 387 .attrs = &ad9833_attribute_group,
389 .driver_module = THIS_MODULE,
390}; 388};
391 389
392static int ad9834_probe(struct spi_device *spi) 390static int ad9834_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c
index 967524583d8a..4e7630caf7d3 100644
--- a/drivers/staging/iio/gyro/adis16060_core.c
+++ b/drivers/staging/iio/gyro/adis16060_core.c
@@ -103,7 +103,6 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
103 103
104static const struct iio_info adis16060_info = { 104static const struct iio_info adis16060_info = {
105 .read_raw = adis16060_read_raw, 105 .read_raw = adis16060_read_raw,
106 .driver_module = THIS_MODULE,
107}; 106};
108 107
109static const struct iio_chan_spec adis16060_channels[] = { 108static const struct iio_chan_spec adis16060_channels[] = {
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 3d539eeb0e26..2b28fb9c0048 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -575,7 +575,6 @@ out:
575static const struct iio_info ad5933_info = { 575static const struct iio_info ad5933_info = {
576 .read_raw = ad5933_read_raw, 576 .read_raw = ad5933_read_raw,
577 .attrs = &ad5933_attribute_group, 577 .attrs = &ad5933_attribute_group,
578 .driver_module = THIS_MODULE,
579}; 578};
580 579
581static int ad5933_ring_preenable(struct iio_dev *indio_dev) 580static int ad5933_ring_preenable(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 786e93f16ce9..42ed9c015aaf 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -15,112 +15,112 @@
15 * more details. 15 * more details.
16 */ 16 */
17 17
18#include <linux/kernel.h>
19#include <linux/i2c.h>
20#include <linux/errno.h>
21#include <linux/delay.h> 18#include <linux/delay.h>
22#include <linux/mutex.h> 19#include <linux/errno.h>
20#include <linux/i2c.h>
23#include <linux/interrupt.h> 21#include <linux/interrupt.h>
24#include <linux/slab.h> 22#include <linux/kernel.h>
25#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mutex.h>
25#include <linux/slab.h>
26#include <linux/iio/events.h> 26#include <linux/iio/events.h>
27#include <linux/iio/iio.h> 27#include <linux/iio/iio.h>
28#include <linux/iio/sysfs.h> 28#include <linux/iio/sysfs.h>
29#include "tsl2x7x.h" 29#include "tsl2x7x.h"
30 30
31/* Cal defs*/ 31/* Cal defs*/
32#define PROX_STAT_CAL 0 32#define PROX_STAT_CAL 0
33#define PROX_STAT_SAMP 1 33#define PROX_STAT_SAMP 1
34#define MAX_SAMPLES_CAL 200 34#define MAX_SAMPLES_CAL 200
35 35
36/* TSL2X7X Device ID */ 36/* TSL2X7X Device ID */
37#define TRITON_ID 0x00 37#define TRITON_ID 0x00
38#define SWORDFISH_ID 0x30 38#define SWORDFISH_ID 0x30
39#define HALIBUT_ID 0x20 39#define HALIBUT_ID 0x20
40 40
41/* Lux calculation constants */ 41/* Lux calculation constants */
42#define TSL2X7X_LUX_CALC_OVER_FLOW 65535 42#define TSL2X7X_LUX_CALC_OVER_FLOW 65535
43 43
44/* TAOS Register definitions - note: 44/* TAOS Register definitions - note:
45 * depending on device, some of these register are not used and the 45 * depending on device, some of these register are not used and the
46 * register address is benign. 46 * register address is benign.
47 */ 47 */
48/* 2X7X register offsets */ 48/* 2X7X register offsets */
49#define TSL2X7X_MAX_CONFIG_REG 16 49#define TSL2X7X_MAX_CONFIG_REG 16
50 50
51/* Device Registers and Masks */ 51/* Device Registers and Masks */
52#define TSL2X7X_CNTRL 0x00 52#define TSL2X7X_CNTRL 0x00
53#define TSL2X7X_ALS_TIME 0X01 53#define TSL2X7X_ALS_TIME 0X01
54#define TSL2X7X_PRX_TIME 0x02 54#define TSL2X7X_PRX_TIME 0x02
55#define TSL2X7X_WAIT_TIME 0x03 55#define TSL2X7X_WAIT_TIME 0x03
56#define TSL2X7X_ALS_MINTHRESHLO 0X04 56#define TSL2X7X_ALS_MINTHRESHLO 0X04
57#define TSL2X7X_ALS_MINTHRESHHI 0X05 57#define TSL2X7X_ALS_MINTHRESHHI 0X05
58#define TSL2X7X_ALS_MAXTHRESHLO 0X06 58#define TSL2X7X_ALS_MAXTHRESHLO 0X06
59#define TSL2X7X_ALS_MAXTHRESHHI 0X07 59#define TSL2X7X_ALS_MAXTHRESHHI 0X07
60#define TSL2X7X_PRX_MINTHRESHLO 0X08 60#define TSL2X7X_PRX_MINTHRESHLO 0X08
61#define TSL2X7X_PRX_MINTHRESHHI 0X09 61#define TSL2X7X_PRX_MINTHRESHHI 0X09
62#define TSL2X7X_PRX_MAXTHRESHLO 0X0A 62#define TSL2X7X_PRX_MAXTHRESHLO 0X0A
63#define TSL2X7X_PRX_MAXTHRESHHI 0X0B 63#define TSL2X7X_PRX_MAXTHRESHHI 0X0B
64#define TSL2X7X_PERSISTENCE 0x0C 64#define TSL2X7X_PERSISTENCE 0x0C
65#define TSL2X7X_PRX_CONFIG 0x0D 65#define TSL2X7X_PRX_CONFIG 0x0D
66#define TSL2X7X_PRX_COUNT 0x0E 66#define TSL2X7X_PRX_COUNT 0x0E
67#define TSL2X7X_GAIN 0x0F 67#define TSL2X7X_GAIN 0x0F
68#define TSL2X7X_NOTUSED 0x10 68#define TSL2X7X_NOTUSED 0x10
69#define TSL2X7X_REVID 0x11 69#define TSL2X7X_REVID 0x11
70#define TSL2X7X_CHIPID 0x12 70#define TSL2X7X_CHIPID 0x12
71#define TSL2X7X_STATUS 0x13 71#define TSL2X7X_STATUS 0x13
72#define TSL2X7X_ALS_CHAN0LO 0x14 72#define TSL2X7X_ALS_CHAN0LO 0x14
73#define TSL2X7X_ALS_CHAN0HI 0x15 73#define TSL2X7X_ALS_CHAN0HI 0x15
74#define TSL2X7X_ALS_CHAN1LO 0x16 74#define TSL2X7X_ALS_CHAN1LO 0x16
75#define TSL2X7X_ALS_CHAN1HI 0x17 75#define TSL2X7X_ALS_CHAN1HI 0x17
76#define TSL2X7X_PRX_LO 0x18 76#define TSL2X7X_PRX_LO 0x18
77#define TSL2X7X_PRX_HI 0x19 77#define TSL2X7X_PRX_HI 0x19
78 78
79/* tsl2X7X cmd reg masks */ 79/* tsl2X7X cmd reg masks */
80#define TSL2X7X_CMD_REG 0x80 80#define TSL2X7X_CMD_REG 0x80
81#define TSL2X7X_CMD_SPL_FN 0x60 81#define TSL2X7X_CMD_SPL_FN 0x60
82 82
83#define TSL2X7X_CMD_PROX_INT_CLR 0X05 83#define TSL2X7X_CMD_PROX_INT_CLR 0X05
84#define TSL2X7X_CMD_ALS_INT_CLR 0x06 84#define TSL2X7X_CMD_ALS_INT_CLR 0x06
85#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07 85#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07
86 86
87/* tsl2X7X cntrl reg masks */ 87/* tsl2X7X cntrl reg masks */
88#define TSL2X7X_CNTL_ADC_ENBL 0x02 88#define TSL2X7X_CNTL_ADC_ENBL 0x02
89#define TSL2X7X_CNTL_PWR_ON 0x01 89#define TSL2X7X_CNTL_PWR_ON 0x01
90 90
91/* tsl2X7X status reg masks */ 91/* tsl2X7X status reg masks */
92#define TSL2X7X_STA_ADC_VALID 0x01 92#define TSL2X7X_STA_ADC_VALID 0x01
93#define TSL2X7X_STA_PRX_VALID 0x02 93#define TSL2X7X_STA_PRX_VALID 0x02
94#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID |\ 94#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID | \
95 TSL2X7X_STA_PRX_VALID) 95 TSL2X7X_STA_PRX_VALID)
96#define TSL2X7X_STA_ALS_INTR 0x10 96#define TSL2X7X_STA_ALS_INTR 0x10
97#define TSL2X7X_STA_PRX_INTR 0x20 97#define TSL2X7X_STA_PRX_INTR 0x20
98 98
99/* tsl2X7X cntrl reg masks */ 99/* tsl2X7X cntrl reg masks */
100#define TSL2X7X_CNTL_REG_CLEAR 0x00 100#define TSL2X7X_CNTL_REG_CLEAR 0x00
101#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20 101#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20
102#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10 102#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10
103#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08 103#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08
104#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04 104#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04
105#define TSL2X7X_CNTL_PWRON 0x01 105#define TSL2X7X_CNTL_PWRON 0x01
106#define TSL2X7X_CNTL_ALSPON_ENBL 0x03 106#define TSL2X7X_CNTL_ALSPON_ENBL 0x03
107#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13 107#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13
108#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F 108#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F
109#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F 109#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F
110 110
111/*Prox diode to use */ 111/*Prox diode to use */
112#define TSL2X7X_DIODE0 0x10 112#define TSL2X7X_DIODE0 0x10
113#define TSL2X7X_DIODE1 0x20 113#define TSL2X7X_DIODE1 0x20
114#define TSL2X7X_DIODE_BOTH 0x30 114#define TSL2X7X_DIODE_BOTH 0x30
115 115
116/* LED Power */ 116/* LED Power */
117#define TSL2X7X_mA100 0x00 117#define TSL2X7X_100_mA 0x00
118#define TSL2X7X_mA50 0x40 118#define TSL2X7X_50_mA 0x40
119#define TSL2X7X_mA25 0x80 119#define TSL2X7X_25_mA 0x80
120#define TSL2X7X_mA13 0xD0 120#define TSL2X7X_13_mA 0xD0
121#define TSL2X7X_MAX_TIMER_CNT (0xFF) 121#define TSL2X7X_MAX_TIMER_CNT 0xFF
122 122
123#define TSL2X7X_MIN_ITIME 3 123#define TSL2X7X_MIN_ITIME 3
124 124
125/* TAOS txx2x7x Device family members */ 125/* TAOS txx2x7x Device family members */
126enum { 126enum {
@@ -142,11 +142,6 @@ enum {
142 TSL2X7X_CHIP_SUSPENDED = 2 142 TSL2X7X_CHIP_SUSPENDED = 2
143}; 143};
144 144
145struct tsl2x7x_parse_result {
146 int integer;
147 int fract;
148};
149
150/* Per-device data */ 145/* Per-device data */
151struct tsl2x7x_als_info { 146struct tsl2x7x_als_info {
152 u16 als_ch0; 147 u16 als_ch0;
@@ -174,7 +169,7 @@ struct tsl2X7X_chip {
174 struct i2c_client *client; 169 struct i2c_client *client;
175 u16 prox_data; 170 u16 prox_data;
176 struct tsl2x7x_als_info als_cur_info; 171 struct tsl2x7x_als_info als_cur_info;
177 struct tsl2x7x_settings tsl2x7x_settings; 172 struct tsl2x7x_settings settings;
178 struct tsl2X7X_platform_data *pdata; 173 struct tsl2X7X_platform_data *pdata;
179 int als_time_scale; 174 int als_time_scale;
180 int als_saturation; 175 int als_saturation;
@@ -192,25 +187,25 @@ struct tsl2X7X_chip {
192}; 187};
193 188
194/* Different devices require different coefficents */ 189/* Different devices require different coefficents */
195static const struct tsl2x7x_lux tsl2x71_lux_table[] = { 190static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
196 { 14461, 611, 1211 }, 191 { 14461, 611, 1211 },
197 { 18540, 352, 623 }, 192 { 18540, 352, 623 },
198 { 0, 0, 0 }, 193 { 0, 0, 0 },
199}; 194};
200 195
201static const struct tsl2x7x_lux tmd2x71_lux_table[] = { 196static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
202 { 11635, 115, 256 }, 197 { 11635, 115, 256 },
203 { 15536, 87, 179 }, 198 { 15536, 87, 179 },
204 { 0, 0, 0 }, 199 { 0, 0, 0 },
205}; 200};
206 201
207static const struct tsl2x7x_lux tsl2x72_lux_table[] = { 202static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
208 { 14013, 466, 917 }, 203 { 14013, 466, 917 },
209 { 18222, 310, 552 }, 204 { 18222, 310, 552 },
210 { 0, 0, 0 }, 205 { 0, 0, 0 },
211}; 206};
212 207
213static const struct tsl2x7x_lux tmd2x72_lux_table[] = { 208static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
214 { 13218, 130, 262 }, 209 { 13218, 130, 262 },
215 { 17592, 92, 169 }, 210 { 17592, 92, 169 },
216 { 0, 0, 0 }, 211 { 0, 0, 0 },
@@ -248,14 +243,14 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
248 .prox_pulse_count = 8 243 .prox_pulse_count = 8
249}; 244};
250 245
251static const s16 tsl2X7X_als_gainadj[] = { 246static const s16 tsl2x7x_als_gain[] = {
252 1, 247 1,
253 8, 248 8,
254 16, 249 16,
255 120 250 120
256}; 251};
257 252
258static const s16 tsl2X7X_prx_gainadj[] = { 253static const s16 tsl2x7x_prx_gain[] = {
259 1, 254 1,
260 2, 255 2,
261 4, 256 4,
@@ -353,9 +348,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
353 348
354 /* clear any existing interrupt status */ 349 /* clear any existing interrupt status */
355 ret = i2c_smbus_write_byte(chip->client, 350 ret = i2c_smbus_write_byte(chip->client,
356 (TSL2X7X_CMD_REG | 351 TSL2X7X_CMD_REG |
357 TSL2X7X_CMD_SPL_FN | 352 TSL2X7X_CMD_SPL_FN |
358 TSL2X7X_CMD_ALS_INT_CLR)); 353 TSL2X7X_CMD_ALS_INT_CLR);
359 if (ret < 0) { 354 if (ret < 0) {
360 dev_err(&chip->client->dev, 355 dev_err(&chip->client->dev,
361 "i2c_write_command failed - err = %d\n", ret); 356 "i2c_write_command failed - err = %d\n", ret);
@@ -369,7 +364,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
369 chip->als_cur_info.als_ch0 = ch0; 364 chip->als_cur_info.als_ch0 = ch0;
370 chip->als_cur_info.als_ch1 = ch1; 365 chip->als_cur_info.als_ch1 = ch1;
371 366
372 if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) { 367 if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
373 lux = TSL2X7X_LUX_CALC_OVER_FLOW; 368 lux = TSL2X7X_LUX_CALC_OVER_FLOW;
374 goto return_max; 369 goto return_max;
375 } 370 }
@@ -389,11 +384,10 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
389 if (p->ratio == 0) { 384 if (p->ratio == 0) {
390 lux = 0; 385 lux = 0;
391 } else { 386 } else {
392 ch0lux = DIV_ROUND_UP(ch0 * p->ch0, 387 lux = DIV_ROUND_UP(ch0 * p->ch0,
393 tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); 388 tsl2x7x_als_gain[chip->settings.als_gain]) -
394 ch1lux = DIV_ROUND_UP(ch1 * p->ch1, 389 DIV_ROUND_UP(ch1 * p->ch1,
395 tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); 390 tsl2x7x_als_gain[chip->settings.als_gain]);
396 lux = ch0lux - ch1lux;
397 } 391 }
398 392
399 /* note: lux is 31 bit max at this point */ 393 /* note: lux is 31 bit max at this point */
@@ -419,7 +413,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
419 */ 413 */
420 414
421 lux64 = lux; 415 lux64 = lux;
422 lux64 = lux64 * chip->tsl2x7x_settings.als_gain_trim; 416 lux64 = lux64 * chip->settings.als_gain_trim;
423 lux64 >>= 8; 417 lux64 >>= 8;
424 lux = lux64; 418 lux = lux64;
425 lux = (lux + 500) / 1000; 419 lux = (lux + 500) / 1000;
@@ -472,7 +466,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
472 case tmd2771: 466 case tmd2771:
473 if (!(ret & TSL2X7X_STA_ADC_VALID)) 467 if (!(ret & TSL2X7X_STA_ADC_VALID))
474 goto prox_poll_err; 468 goto prox_poll_err;
475 break; 469 break;
476 case tsl2572: 470 case tsl2572:
477 case tsl2672: 471 case tsl2672:
478 case tmd2672: 472 case tmd2672:
@@ -480,7 +474,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
480 case tmd2772: 474 case tmd2772:
481 if (!(ret & TSL2X7X_STA_PRX_VALID)) 475 if (!(ret & TSL2X7X_STA_PRX_VALID))
482 goto prox_poll_err; 476 goto prox_poll_err;
483 break; 477 break;
484 } 478 }
485 479
486 for (i = 0; i < 2; i++) { 480 for (i = 0; i < 2; i++) {
@@ -514,12 +508,10 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
514{ 508{
515 /* If Operational settings defined elsewhere.. */ 509 /* If Operational settings defined elsewhere.. */
516 if (chip->pdata && chip->pdata->platform_default_settings) 510 if (chip->pdata && chip->pdata->platform_default_settings)
517 memcpy(&chip->tsl2x7x_settings, 511 memcpy(&chip->settings, chip->pdata->platform_default_settings,
518 chip->pdata->platform_default_settings,
519 sizeof(tsl2x7x_default_settings)); 512 sizeof(tsl2x7x_default_settings));
520 else 513 else
521 memcpy(&chip->tsl2x7x_settings, 514 memcpy(&chip->settings, &tsl2x7x_default_settings,
522 &tsl2x7x_default_settings,
523 sizeof(tsl2x7x_default_settings)); 515 sizeof(tsl2x7x_default_settings));
524 516
525 /* Load up the proper lux table. */ 517 /* Load up the proper lux table. */
@@ -529,8 +521,8 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
529 sizeof(chip->pdata->platform_lux_table)); 521 sizeof(chip->pdata->platform_lux_table));
530 else 522 else
531 memcpy(chip->tsl2x7x_device_lux, 523 memcpy(chip->tsl2x7x_device_lux,
532 (struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id], 524 tsl2x7x_default_lux_table_group[chip->id],
533 MAX_DEFAULT_TABLE_BYTES); 525 TSL2X7X_DEFAULT_TABLE_BYTES);
534} 526}
535 527
536/** 528/**
@@ -542,9 +534,7 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
542static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev) 534static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
543{ 535{
544 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 536 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
545 int gain_trim_val; 537 int ret, lux_val;
546 int ret;
547 int lux_val;
548 538
549 ret = i2c_smbus_read_byte_data(chip->client, 539 ret = i2c_smbus_read_byte_data(chip->client,
550 TSL2X7X_CMD_REG | TSL2X7X_CNTRL); 540 TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
@@ -575,16 +565,16 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
575 return lux_val; 565 return lux_val;
576 } 566 }
577 567
578 gain_trim_val = ((chip->tsl2x7x_settings.als_cal_target) 568 ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) /
579 * chip->tsl2x7x_settings.als_gain_trim) / lux_val; 569 lux_val;
580 if ((gain_trim_val < 250) || (gain_trim_val > 4000)) 570 if (ret < 250 || ret > 4000)
581 return -ERANGE; 571 return -ERANGE;
582 572
583 chip->tsl2x7x_settings.als_gain_trim = gain_trim_val; 573 chip->settings.als_gain_trim = ret;
584 dev_info(&chip->client->dev, 574 dev_info(&chip->client->dev,
585 "%s als_calibrate completed\n", chip->client->name); 575 "%s als_calibrate completed\n", chip->client->name);
586 576
587 return (int)gain_trim_val; 577 return ret;
588} 578}
589 579
590static int tsl2x7x_chip_on(struct iio_dev *indio_dev) 580static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
@@ -602,34 +592,30 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
602 chip->pdata->power_on(indio_dev); 592 chip->pdata->power_on(indio_dev);
603 593
604 /* Non calculated parameters */ 594 /* Non calculated parameters */
605 chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = 595 chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
606 chip->tsl2x7x_settings.prx_time; 596 chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
607 chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = 597 chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
608 chip->tsl2x7x_settings.wait_time;
609 chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] =
610 chip->tsl2x7x_settings.prox_config;
611 598
612 chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] = 599 chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
613 (chip->tsl2x7x_settings.als_thresh_low) & 0xFF; 600 (chip->settings.als_thresh_low) & 0xFF;
614 chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] = 601 chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] =
615 (chip->tsl2x7x_settings.als_thresh_low >> 8) & 0xFF; 602 (chip->settings.als_thresh_low >> 8) & 0xFF;
616 chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] = 603 chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] =
617 (chip->tsl2x7x_settings.als_thresh_high) & 0xFF; 604 (chip->settings.als_thresh_high) & 0xFF;
618 chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] = 605 chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] =
619 (chip->tsl2x7x_settings.als_thresh_high >> 8) & 0xFF; 606 (chip->settings.als_thresh_high >> 8) & 0xFF;
620 chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = 607 chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = chip->settings.persistence;
621 chip->tsl2x7x_settings.persistence;
622 608
623 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = 609 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
624 chip->tsl2x7x_settings.prox_pulse_count; 610 chip->settings.prox_pulse_count;
625 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = 611 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
626 (chip->tsl2x7x_settings.prox_thres_low) & 0xFF; 612 (chip->settings.prox_thres_low) & 0xFF;
627 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] = 613 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
628 (chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF; 614 (chip->settings.prox_thres_low >> 8) & 0xFF;
629 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = 615 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
630 (chip->tsl2x7x_settings.prox_thres_high) & 0xFF; 616 (chip->settings.prox_thres_high) & 0xFF;
631 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] = 617 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
632 (chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF; 618 (chip->settings.prox_thres_high >> 8) & 0xFF;
633 619
634 /* and make sure we're not already on */ 620 /* and make sure we're not already on */
635 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { 621 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
@@ -639,7 +625,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
639 } 625 }
640 626
641 /* determine als integration register */ 627 /* determine als integration register */
642 als_count = (chip->tsl2x7x_settings.als_time * 100 + 135) / 270; 628 als_count = (chip->settings.als_time * 100 + 135) / 270;
643 if (!als_count) 629 if (!als_count)
644 als_count = 1; /* ensure at least one cycle */ 630 als_count = 1; /* ensure at least one cycle */
645 631
@@ -649,9 +635,9 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
649 635
650 /* Set the gain based on tsl2x7x_settings struct */ 636 /* Set the gain based on tsl2x7x_settings struct */
651 chip->tsl2x7x_config[TSL2X7X_GAIN] = 637 chip->tsl2x7x_config[TSL2X7X_GAIN] =
652 chip->tsl2x7x_settings.als_gain | 638 chip->settings.als_gain |
653 (TSL2X7X_mA100 | TSL2X7X_DIODE1) 639 (TSL2X7X_100_mA | TSL2X7X_DIODE1) |
654 | ((chip->tsl2x7x_settings.prox_gain) << 2); 640 (chip->settings.prox_gain << 2);
655 641
656 /* set chip struct re scaling and saturation */ 642 /* set chip struct re scaling and saturation */
657 chip->als_saturation = als_count * 922; /* 90% of full scale */ 643 chip->als_saturation = als_count * 922; /* 90% of full scale */
@@ -706,18 +692,18 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
706 692
707 chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING; 693 chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
708 694
709 if (chip->tsl2x7x_settings.interrupts_en != 0) { 695 if (chip->settings.interrupts_en != 0) {
710 dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n"); 696 dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n");
711 697
712 reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL; 698 reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL;
713 if ((chip->tsl2x7x_settings.interrupts_en == 0x20) || 699 if (chip->settings.interrupts_en == 0x20 ||
714 (chip->tsl2x7x_settings.interrupts_en == 0x30)) 700 chip->settings.interrupts_en == 0x30)
715 reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL; 701 reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL;
716 702
717 reg_val |= chip->tsl2x7x_settings.interrupts_en; 703 reg_val |= chip->settings.interrupts_en;
718 ret = i2c_smbus_write_byte_data(chip->client, 704 ret = i2c_smbus_write_byte_data(chip->client,
719 (TSL2X7X_CMD_REG | 705 TSL2X7X_CMD_REG | TSL2X7X_CNTRL,
720 TSL2X7X_CNTRL), reg_val); 706 reg_val);
721 if (ret < 0) 707 if (ret < 0)
722 dev_err(&chip->client->dev, 708 dev_err(&chip->client->dev,
723 "%s: failed in tsl2x7x_IOCTL_INT_SET.\n", 709 "%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
@@ -766,8 +752,7 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
766 * put device back into proper state, and unlock 752 * put device back into proper state, and unlock
767 * resource. 753 * resource.
768 */ 754 */
769static 755static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
770int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
771{ 756{
772 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 757 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
773 int device_status = chip->tsl2x7x_chip_status; 758 int device_status = chip->tsl2x7x_chip_status;
@@ -791,9 +776,8 @@ unlock:
791 return ret; 776 return ret;
792} 777}
793 778
794static 779static void tsl2x7x_prox_calculate(int *data, int length,
795void tsl2x7x_prox_calculate(int *data, int length, 780 struct tsl2x7x_prox_stat *statP)
796 struct tsl2x7x_prox_stat *statP)
797{ 781{
798 int i; 782 int i;
799 int sample_sum; 783 int sample_sum;
@@ -837,25 +821,25 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
837 u8 tmp_irq_settings; 821 u8 tmp_irq_settings;
838 u8 current_state = chip->tsl2x7x_chip_status; 822 u8 current_state = chip->tsl2x7x_chip_status;
839 823
840 if (chip->tsl2x7x_settings.prox_max_samples_cal > MAX_SAMPLES_CAL) { 824 if (chip->settings.prox_max_samples_cal > MAX_SAMPLES_CAL) {
841 dev_err(&chip->client->dev, 825 dev_err(&chip->client->dev,
842 "max prox samples cal is too big: %d\n", 826 "max prox samples cal is too big: %d\n",
843 chip->tsl2x7x_settings.prox_max_samples_cal); 827 chip->settings.prox_max_samples_cal);
844 chip->tsl2x7x_settings.prox_max_samples_cal = MAX_SAMPLES_CAL; 828 chip->settings.prox_max_samples_cal = MAX_SAMPLES_CAL;
845 } 829 }
846 830
847 /* have to stop to change settings */ 831 /* have to stop to change settings */
848 tsl2x7x_chip_off(indio_dev); 832 tsl2x7x_chip_off(indio_dev);
849 833
850 /* Enable proximity detection save just in case prox not wanted yet*/ 834 /* Enable proximity detection save just in case prox not wanted yet*/
851 tmp_irq_settings = chip->tsl2x7x_settings.interrupts_en; 835 tmp_irq_settings = chip->settings.interrupts_en;
852 chip->tsl2x7x_settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL; 836 chip->settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL;
853 837
854 /*turn on device if not already on*/ 838 /*turn on device if not already on*/
855 tsl2x7x_chip_on(indio_dev); 839 tsl2x7x_chip_on(indio_dev);
856 840
857 /*gather the samples*/ 841 /*gather the samples*/
858 for (i = 0; i < chip->tsl2x7x_settings.prox_max_samples_cal; i++) { 842 for (i = 0; i < chip->settings.prox_max_samples_cal; i++) {
859 usleep_range(15000, 17500); 843 usleep_range(15000, 17500);
860 tsl2x7x_get_prox(indio_dev); 844 tsl2x7x_get_prox(indio_dev);
861 prox_history[i] = chip->prox_data; 845 prox_history[i] = chip->prox_data;
@@ -866,25 +850,25 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
866 tsl2x7x_chip_off(indio_dev); 850 tsl2x7x_chip_off(indio_dev);
867 calP = &prox_stat_data[PROX_STAT_CAL]; 851 calP = &prox_stat_data[PROX_STAT_CAL];
868 tsl2x7x_prox_calculate(prox_history, 852 tsl2x7x_prox_calculate(prox_history,
869 chip->tsl2x7x_settings.prox_max_samples_cal, 853 chip->settings.prox_max_samples_cal, calP);
870 calP); 854 chip->settings.prox_thres_high = (calP->max << 1) - calP->mean;
871 chip->tsl2x7x_settings.prox_thres_high = (calP->max << 1) - calP->mean;
872 855
873 dev_info(&chip->client->dev, " cal min=%d mean=%d max=%d\n", 856 dev_info(&chip->client->dev, " cal min=%d mean=%d max=%d\n",
874 calP->min, calP->mean, calP->max); 857 calP->min, calP->mean, calP->max);
875 dev_info(&chip->client->dev, 858 dev_info(&chip->client->dev,
876 "%s proximity threshold set to %d\n", 859 "%s proximity threshold set to %d\n",
877 chip->client->name, chip->tsl2x7x_settings.prox_thres_high); 860 chip->client->name, chip->settings.prox_thres_high);
878 861
879 /* back to the way they were */ 862 /* back to the way they were */
880 chip->tsl2x7x_settings.interrupts_en = tmp_irq_settings; 863 chip->settings.interrupts_en = tmp_irq_settings;
881 if (current_state == TSL2X7X_CHIP_WORKING) 864 if (current_state == TSL2X7X_CHIP_WORKING)
882 tsl2x7x_chip_on(indio_dev); 865 tsl2x7x_chip_on(indio_dev);
883} 866}
884 867
885static ssize_t in_illuminance0_calibscale_available_show(struct device *dev, 868static ssize_t
886 struct device_attribute *attr, 869in_illuminance0_calibscale_available_show(struct device *dev,
887 char *buf) 870 struct device_attribute *attr,
871 char *buf)
888{ 872{
889 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); 873 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
890 874
@@ -900,69 +884,23 @@ static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
900 return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120"); 884 return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
901} 885}
902 886
903static ssize_t in_proximity0_calibscale_available_show(struct device *dev, 887static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
904 struct device_attribute *attr,
905 char *buf)
906{
907 return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
908}
909
910static ssize_t in_illuminance0_integration_time_show(struct device *dev,
911 struct device_attribute *attr,
912 char *buf)
913{
914 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
915 int y, z;
916
917 y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
918 z = y * TSL2X7X_MIN_ITIME;
919 y /= 1000;
920 z %= 1000;
921
922 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
923}
924
925static ssize_t in_illuminance0_integration_time_store(struct device *dev,
926 struct device_attribute *attr,
927 const char *buf, size_t len)
928{
929 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
930 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
931 struct tsl2x7x_parse_result result;
932 int ret;
933
934 ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
935 if (ret)
936 return ret;
937
938 result.fract /= 3;
939 chip->tsl2x7x_settings.als_time =
940 TSL2X7X_MAX_TIMER_CNT - (u8)result.fract;
941
942 dev_info(&chip->client->dev, "%s: als time = %d",
943 __func__, chip->tsl2x7x_settings.als_time);
944
945 tsl2x7x_invoke_change(indio_dev);
946
947 return IIO_VAL_INT_PLUS_MICRO;
948}
949 888
950static IIO_CONST_ATTR(in_illuminance0_integration_time_available, 889static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
951 ".00272 - .696"); 890 ".00272 - .696");
952 891
953static ssize_t in_illuminance0_target_input_show(struct device *dev, 892static ssize_t in_illuminance0_target_input_show(struct device *dev,
954 struct device_attribute *attr, 893 struct device_attribute *attr,
955 char *buf) 894 char *buf)
956{ 895{
957 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); 896 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
958 897
959 return snprintf(buf, PAGE_SIZE, "%d\n", 898 return snprintf(buf, PAGE_SIZE, "%d\n", chip->settings.als_cal_target);
960 chip->tsl2x7x_settings.als_cal_target);
961} 899}
962 900
963static ssize_t in_illuminance0_target_input_store(struct device *dev, 901static ssize_t in_illuminance0_target_input_store(struct device *dev,
964 struct device_attribute *attr, 902 struct device_attribute *attr,
965 const char *buf, size_t len) 903 const char *buf, size_t len)
966{ 904{
967 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 905 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
968 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 906 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
@@ -973,7 +911,7 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
973 return -EINVAL; 911 return -EINVAL;
974 912
975 if (value) 913 if (value)
976 chip->tsl2x7x_settings.als_cal_target = value; 914 chip->settings.als_cal_target = value;
977 915
978 ret = tsl2x7x_invoke_change(indio_dev); 916 ret = tsl2x7x_invoke_change(indio_dev);
979 if (ret < 0) 917 if (ret < 0)
@@ -982,111 +920,9 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
982 return len; 920 return len;
983} 921}
984 922
985/* persistence settings */
986static ssize_t in_intensity0_thresh_period_show(struct device *dev,
987 struct device_attribute *attr,
988 char *buf)
989{
990 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
991 int y, z, filter_delay;
992
993 /* Determine integration time */
994 y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
995 z = y * TSL2X7X_MIN_ITIME;
996 filter_delay = z * (chip->tsl2x7x_settings.persistence & 0x0F);
997 y = filter_delay / 1000;
998 z = filter_delay % 1000;
999
1000 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
1001}
1002
1003static ssize_t in_intensity0_thresh_period_store(struct device *dev,
1004 struct device_attribute *attr,
1005 const char *buf, size_t len)
1006{
1007 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1008 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
1009 struct tsl2x7x_parse_result result;
1010 int y, z, filter_delay;
1011 int ret;
1012
1013 ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
1014 if (ret)
1015 return ret;
1016
1017 y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
1018 z = y * TSL2X7X_MIN_ITIME;
1019
1020 filter_delay =
1021 DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
1022
1023 chip->tsl2x7x_settings.persistence &= 0xF0;
1024 chip->tsl2x7x_settings.persistence |= (filter_delay & 0x0F);
1025
1026 dev_info(&chip->client->dev, "%s: als persistence = %d",
1027 __func__, filter_delay);
1028
1029 ret = tsl2x7x_invoke_change(indio_dev);
1030 if (ret < 0)
1031 return ret;
1032
1033 return IIO_VAL_INT_PLUS_MICRO;
1034}
1035
1036static ssize_t in_proximity0_thresh_period_show(struct device *dev,
1037 struct device_attribute *attr,
1038 char *buf)
1039{
1040 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
1041 int y, z, filter_delay;
1042
1043 /* Determine integration time */
1044 y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1;
1045 z = y * TSL2X7X_MIN_ITIME;
1046 filter_delay = z * ((chip->tsl2x7x_settings.persistence & 0xF0) >> 4);
1047 y = filter_delay / 1000;
1048 z = filter_delay % 1000;
1049
1050 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
1051}
1052
1053static ssize_t in_proximity0_thresh_period_store(struct device *dev,
1054 struct device_attribute *attr,
1055 const char *buf, size_t len)
1056{
1057 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1058 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
1059 struct tsl2x7x_parse_result result;
1060 int y, z, filter_delay;
1061 int ret;
1062
1063 ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
1064 if (ret)
1065 return ret;
1066
1067 y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1;
1068 z = y * TSL2X7X_MIN_ITIME;
1069
1070 filter_delay =
1071 DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
1072
1073 chip->tsl2x7x_settings.persistence &= 0x0F;
1074 chip->tsl2x7x_settings.persistence |= ((filter_delay << 4) & 0xF0);
1075
1076 dev_info(&chip->client->dev, "%s: prox persistence = %d",
1077 __func__, filter_delay);
1078
1079 ret = tsl2x7x_invoke_change(indio_dev);
1080 if (ret < 0)
1081 return ret;
1082
1083
1084 return IIO_VAL_INT_PLUS_MICRO;
1085}
1086
1087static ssize_t in_illuminance0_calibrate_store(struct device *dev, 923static ssize_t in_illuminance0_calibrate_store(struct device *dev,
1088 struct device_attribute *attr, 924 struct device_attribute *attr,
1089 const char *buf, size_t len) 925 const char *buf, size_t len)
1090{ 926{
1091 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 927 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1092 bool value; 928 bool value;
@@ -1106,14 +942,14 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
1106} 942}
1107 943
1108static ssize_t in_illuminance0_lux_table_show(struct device *dev, 944static ssize_t in_illuminance0_lux_table_show(struct device *dev,
1109 struct device_attribute *attr, 945 struct device_attribute *attr,
1110 char *buf) 946 char *buf)
1111{ 947{
1112 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); 948 struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
1113 int i = 0; 949 int i = 0;
1114 int offset = 0; 950 int offset = 0;
1115 951
1116 while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) { 952 while (i < TSL2X7X_MAX_LUX_TABLE_SIZE) {
1117 offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,", 953 offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,",
1118 chip->tsl2x7x_device_lux[i].ratio, 954 chip->tsl2x7x_device_lux[i].ratio,
1119 chip->tsl2x7x_device_lux[i].ch0, 955 chip->tsl2x7x_device_lux[i].ch0,
@@ -1134,8 +970,8 @@ static ssize_t in_illuminance0_lux_table_show(struct device *dev,
1134} 970}
1135 971
1136static ssize_t in_illuminance0_lux_table_store(struct device *dev, 972static ssize_t in_illuminance0_lux_table_store(struct device *dev,
1137 struct device_attribute *attr, 973 struct device_attribute *attr,
1138 const char *buf, size_t len) 974 const char *buf, size_t len)
1139{ 975{
1140 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 976 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1141 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 977 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
@@ -1176,8 +1012,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
1176} 1012}
1177 1013
1178static ssize_t in_proximity0_calibrate_store(struct device *dev, 1014static ssize_t in_proximity0_calibrate_store(struct device *dev,
1179 struct device_attribute *attr, 1015 struct device_attribute *attr,
1180 const char *buf, size_t len) 1016 const char *buf, size_t len)
1181{ 1017{
1182 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 1018 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1183 bool value; 1019 bool value;
@@ -1205,9 +1041,9 @@ static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev,
1205 int ret; 1041 int ret;
1206 1042
1207 if (chan->type == IIO_INTENSITY) 1043 if (chan->type == IIO_INTENSITY)
1208 ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x10); 1044 ret = !!(chip->settings.interrupts_en & 0x10);
1209 else 1045 else
1210 ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x20); 1046 ret = !!(chip->settings.interrupts_en & 0x20);
1211 1047
1212 return ret; 1048 return ret;
1213} 1049}
@@ -1223,14 +1059,14 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
1223 1059
1224 if (chan->type == IIO_INTENSITY) { 1060 if (chan->type == IIO_INTENSITY) {
1225 if (val) 1061 if (val)
1226 chip->tsl2x7x_settings.interrupts_en |= 0x10; 1062 chip->settings.interrupts_en |= 0x10;
1227 else 1063 else
1228 chip->tsl2x7x_settings.interrupts_en &= 0x20; 1064 chip->settings.interrupts_en &= 0x20;
1229 } else { 1065 } else {
1230 if (val) 1066 if (val)
1231 chip->tsl2x7x_settings.interrupts_en |= 0x20; 1067 chip->settings.interrupts_en |= 0x20;
1232 else 1068 else
1233 chip->tsl2x7x_settings.interrupts_en &= 0x10; 1069 chip->settings.interrupts_en &= 0x10;
1234 } 1070 }
1235 1071
1236 ret = tsl2x7x_invoke_change(indio_dev); 1072 ret = tsl2x7x_invoke_change(indio_dev);
@@ -1248,18 +1084,19 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
1248 int val, int val2) 1084 int val, int val2)
1249{ 1085{
1250 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1086 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
1251 int ret = -EINVAL; 1087 int ret = -EINVAL, y, z, filter_delay;
1088 u8 time;
1252 1089
1253 switch (info) { 1090 switch (info) {
1254 case IIO_EV_INFO_VALUE: 1091 case IIO_EV_INFO_VALUE:
1255 if (chan->type == IIO_INTENSITY) { 1092 if (chan->type == IIO_INTENSITY) {
1256 switch (dir) { 1093 switch (dir) {
1257 case IIO_EV_DIR_RISING: 1094 case IIO_EV_DIR_RISING:
1258 chip->tsl2x7x_settings.als_thresh_high = val; 1095 chip->settings.als_thresh_high = val;
1259 ret = 0; 1096 ret = 0;
1260 break; 1097 break;
1261 case IIO_EV_DIR_FALLING: 1098 case IIO_EV_DIR_FALLING:
1262 chip->tsl2x7x_settings.als_thresh_low = val; 1099 chip->settings.als_thresh_low = val;
1263 ret = 0; 1100 ret = 0;
1264 break; 1101 break;
1265 default: 1102 default:
@@ -1268,11 +1105,11 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
1268 } else { 1105 } else {
1269 switch (dir) { 1106 switch (dir) {
1270 case IIO_EV_DIR_RISING: 1107 case IIO_EV_DIR_RISING:
1271 chip->tsl2x7x_settings.prox_thres_high = val; 1108 chip->settings.prox_thres_high = val;
1272 ret = 0; 1109 ret = 0;
1273 break; 1110 break;
1274 case IIO_EV_DIR_FALLING: 1111 case IIO_EV_DIR_FALLING:
1275 chip->tsl2x7x_settings.prox_thres_low = val; 1112 chip->settings.prox_thres_low = val;
1276 ret = 0; 1113 ret = 0;
1277 break; 1114 break;
1278 default: 1115 default:
@@ -1280,6 +1117,33 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
1280 } 1117 }
1281 } 1118 }
1282 break; 1119 break;
1120 case IIO_EV_INFO_PERIOD:
1121 if (chan->type == IIO_INTENSITY)
1122 time = chip->settings.als_time;
1123 else
1124 time = chip->settings.prx_time;
1125
1126 y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
1127 z = y * TSL2X7X_MIN_ITIME;
1128
1129 filter_delay = DIV_ROUND_UP((val * 1000) + val2, z);
1130
1131 if (chan->type == IIO_INTENSITY) {
1132 chip->settings.persistence &= 0xF0;
1133 chip->settings.persistence |=
1134 (filter_delay & 0x0F);
1135 dev_info(&chip->client->dev, "%s: ALS persistence = %d",
1136 __func__, filter_delay);
1137 } else {
1138 chip->settings.persistence &= 0x0F;
1139 chip->settings.persistence |=
1140 ((filter_delay << 4) & 0xF0);
1141 dev_info(&chip->client->dev,
1142 "%s: Proximity persistence = %d",
1143 __func__, filter_delay);
1144 }
1145 ret = 0;
1146 break;
1283 default: 1147 default:
1284 break; 1148 break;
1285 } 1149 }
@@ -1298,18 +1162,19 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
1298 int *val, int *val2) 1162 int *val, int *val2)
1299{ 1163{
1300 struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1164 struct tsl2X7X_chip *chip = iio_priv(indio_dev);
1301 int ret = -EINVAL; 1165 int ret = -EINVAL, filter_delay, mult;
1166 u8 time;
1302 1167
1303 switch (info) { 1168 switch (info) {
1304 case IIO_EV_INFO_VALUE: 1169 case IIO_EV_INFO_VALUE:
1305 if (chan->type == IIO_INTENSITY) { 1170 if (chan->type == IIO_INTENSITY) {
1306 switch (dir) { 1171 switch (dir) {
1307 case IIO_EV_DIR_RISING: 1172 case IIO_EV_DIR_RISING:
1308 *val = chip->tsl2x7x_settings.als_thresh_high; 1173 *val = chip->settings.als_thresh_high;
1309 ret = IIO_VAL_INT; 1174 ret = IIO_VAL_INT;
1310 break; 1175 break;
1311 case IIO_EV_DIR_FALLING: 1176 case IIO_EV_DIR_FALLING:
1312 *val = chip->tsl2x7x_settings.als_thresh_low; 1177 *val = chip->settings.als_thresh_low;
1313 ret = IIO_VAL_INT; 1178 ret = IIO_VAL_INT;
1314 break; 1179 break;
1315 default: 1180 default:
@@ -1318,11 +1183,11 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
1318 } else { 1183 } else {
1319 switch (dir) { 1184 switch (dir) {
1320 case IIO_EV_DIR_RISING: 1185 case IIO_EV_DIR_RISING:
1321 *val = chip->tsl2x7x_settings.prox_thres_high; 1186 *val = chip->settings.prox_thres_high;
1322 ret = IIO_VAL_INT; 1187 ret = IIO_VAL_INT;
1323 break; 1188 break;
1324 case IIO_EV_DIR_FALLING: 1189 case IIO_EV_DIR_FALLING:
1325 *val = chip->tsl2x7x_settings.prox_thres_low; 1190 *val = chip->settings.prox_thres_low;
1326 ret = IIO_VAL_INT; 1191 ret = IIO_VAL_INT;
1327 break; 1192 break;
1328 default: 1193 default:
@@ -1330,6 +1195,23 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
1330 } 1195 }
1331 } 1196 }
1332 break; 1197 break;
1198 case IIO_EV_INFO_PERIOD:
1199 if (chan->type == IIO_INTENSITY) {
1200 time = chip->settings.als_time;
1201 mult = chip->settings.persistence & 0x0F;
1202 } else {
1203 time = chip->settings.prx_time;
1204 mult = (chip->settings.persistence & 0xF0) >> 4;
1205 }
1206
1207 /* Determine integration time */
1208 *val = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
1209 *val2 = *val * TSL2X7X_MIN_ITIME;
1210 filter_delay = *val2 * mult;
1211 *val = filter_delay / 1000;
1212 *val2 = filter_delay % 1000;
1213 ret = IIO_VAL_INT_PLUS_MICRO;
1214 break;
1333 default: 1215 default:
1334 break; 1216 break;
1335 } 1217 }
@@ -1379,18 +1261,20 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
1379 break; 1261 break;
1380 case IIO_CHAN_INFO_CALIBSCALE: 1262 case IIO_CHAN_INFO_CALIBSCALE:
1381 if (chan->type == IIO_LIGHT) 1263 if (chan->type == IIO_LIGHT)
1382 *val = 1264 *val = tsl2x7x_als_gain[chip->settings.als_gain];
1383 tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain];
1384 else 1265 else
1385 *val = 1266 *val = tsl2x7x_prx_gain[chip->settings.prox_gain];
1386 tsl2X7X_prx_gainadj[chip->tsl2x7x_settings.prox_gain];
1387 ret = IIO_VAL_INT; 1267 ret = IIO_VAL_INT;
1388 break; 1268 break;
1389 case IIO_CHAN_INFO_CALIBBIAS: 1269 case IIO_CHAN_INFO_CALIBBIAS:
1390 *val = chip->tsl2x7x_settings.als_gain_trim; 1270 *val = chip->settings.als_gain_trim;
1391 ret = IIO_VAL_INT; 1271 ret = IIO_VAL_INT;
1392 break; 1272 break;
1393 1273 case IIO_CHAN_INFO_INT_TIME:
1274 *val = (TSL2X7X_MAX_TIMER_CNT - chip->settings.als_time) + 1;
1275 *val2 = ((*val * TSL2X7X_MIN_ITIME) % 1000) / 1000;
1276 ret = IIO_VAL_INT_PLUS_MICRO;
1277 break;
1394 default: 1278 default:
1395 ret = -EINVAL; 1279 ret = -EINVAL;
1396 } 1280 }
@@ -1411,13 +1295,13 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1411 if (chan->type == IIO_INTENSITY) { 1295 if (chan->type == IIO_INTENSITY) {
1412 switch (val) { 1296 switch (val) {
1413 case 1: 1297 case 1:
1414 chip->tsl2x7x_settings.als_gain = 0; 1298 chip->settings.als_gain = 0;
1415 break; 1299 break;
1416 case 8: 1300 case 8:
1417 chip->tsl2x7x_settings.als_gain = 1; 1301 chip->settings.als_gain = 1;
1418 break; 1302 break;
1419 case 16: 1303 case 16:
1420 chip->tsl2x7x_settings.als_gain = 2; 1304 chip->settings.als_gain = 2;
1421 break; 1305 break;
1422 case 120: 1306 case 120:
1423 switch (chip->id) { 1307 switch (chip->id) {
@@ -1428,7 +1312,7 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1428 case tmd2772: 1312 case tmd2772:
1429 return -EINVAL; 1313 return -EINVAL;
1430 } 1314 }
1431 chip->tsl2x7x_settings.als_gain = 3; 1315 chip->settings.als_gain = 3;
1432 break; 1316 break;
1433 case 128: 1317 case 128:
1434 switch (chip->id) { 1318 switch (chip->id) {
@@ -1439,7 +1323,7 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1439 case tmd2771: 1323 case tmd2771:
1440 return -EINVAL; 1324 return -EINVAL;
1441 } 1325 }
1442 chip->tsl2x7x_settings.als_gain = 3; 1326 chip->settings.als_gain = 3;
1443 break; 1327 break;
1444 default: 1328 default:
1445 return -EINVAL; 1329 return -EINVAL;
@@ -1447,16 +1331,16 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1447 } else { 1331 } else {
1448 switch (val) { 1332 switch (val) {
1449 case 1: 1333 case 1:
1450 chip->tsl2x7x_settings.prox_gain = 0; 1334 chip->settings.prox_gain = 0;
1451 break; 1335 break;
1452 case 2: 1336 case 2:
1453 chip->tsl2x7x_settings.prox_gain = 1; 1337 chip->settings.prox_gain = 1;
1454 break; 1338 break;
1455 case 4: 1339 case 4:
1456 chip->tsl2x7x_settings.prox_gain = 2; 1340 chip->settings.prox_gain = 2;
1457 break; 1341 break;
1458 case 8: 1342 case 8:
1459 chip->tsl2x7x_settings.prox_gain = 3; 1343 chip->settings.prox_gain = 3;
1460 break; 1344 break;
1461 default: 1345 default:
1462 return -EINVAL; 1346 return -EINVAL;
@@ -1464,9 +1348,15 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1464 } 1348 }
1465 break; 1349 break;
1466 case IIO_CHAN_INFO_CALIBBIAS: 1350 case IIO_CHAN_INFO_CALIBBIAS:
1467 chip->tsl2x7x_settings.als_gain_trim = val; 1351 chip->settings.als_gain_trim = val;
1468 break; 1352 break;
1353 case IIO_CHAN_INFO_INT_TIME:
1354 chip->settings.als_time =
1355 TSL2X7X_MAX_TIMER_CNT - (val2 / TSL2X7X_MIN_ITIME);
1469 1356
1357 dev_info(&chip->client->dev, "%s: als time = %d",
1358 __func__, chip->settings.als_time);
1359 break;
1470 default: 1360 default:
1471 return -EINVAL; 1361 return -EINVAL;
1472 } 1362 }
@@ -1474,12 +1364,8 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
1474 return tsl2x7x_invoke_change(indio_dev); 1364 return tsl2x7x_invoke_change(indio_dev);
1475} 1365}
1476 1366
1477static DEVICE_ATTR_RO(in_proximity0_calibscale_available);
1478
1479static DEVICE_ATTR_RO(in_illuminance0_calibscale_available); 1367static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
1480 1368
1481static DEVICE_ATTR_RW(in_illuminance0_integration_time);
1482
1483static DEVICE_ATTR_RW(in_illuminance0_target_input); 1369static DEVICE_ATTR_RW(in_illuminance0_target_input);
1484 1370
1485static DEVICE_ATTR_WO(in_illuminance0_calibrate); 1371static DEVICE_ATTR_WO(in_illuminance0_calibrate);
@@ -1488,10 +1374,6 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
1488 1374
1489static DEVICE_ATTR_RW(in_illuminance0_lux_table); 1375static DEVICE_ATTR_RW(in_illuminance0_lux_table);
1490 1376
1491static DEVICE_ATTR_RW(in_intensity0_thresh_period);
1492
1493static DEVICE_ATTR_RW(in_proximity0_thresh_period);
1494
1495/* Use the default register values to identify the Taos device */ 1377/* Use the default register values to identify the Taos device */
1496static int tsl2x7x_device_id(int *id, int target) 1378static int tsl2x7x_device_id(int *id, int target)
1497{ 1379{
@@ -1559,7 +1441,6 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
1559 1441
1560static struct attribute *tsl2x7x_ALS_device_attrs[] = { 1442static struct attribute *tsl2x7x_ALS_device_attrs[] = {
1561 &dev_attr_in_illuminance0_calibscale_available.attr, 1443 &dev_attr_in_illuminance0_calibscale_available.attr,
1562 &dev_attr_in_illuminance0_integration_time.attr,
1563 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, 1444 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
1564 &dev_attr_in_illuminance0_target_input.attr, 1445 &dev_attr_in_illuminance0_target_input.attr,
1565 &dev_attr_in_illuminance0_calibrate.attr, 1446 &dev_attr_in_illuminance0_calibrate.attr,
@@ -1574,49 +1455,31 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
1574 1455
1575static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = { 1456static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
1576 &dev_attr_in_illuminance0_calibscale_available.attr, 1457 &dev_attr_in_illuminance0_calibscale_available.attr,
1577 &dev_attr_in_illuminance0_integration_time.attr,
1578 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, 1458 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
1579 &dev_attr_in_illuminance0_target_input.attr, 1459 &dev_attr_in_illuminance0_target_input.attr,
1580 &dev_attr_in_illuminance0_calibrate.attr, 1460 &dev_attr_in_illuminance0_calibrate.attr,
1581 &dev_attr_in_illuminance0_lux_table.attr, 1461 &dev_attr_in_illuminance0_lux_table.attr,
1582 &dev_attr_in_proximity0_calibrate.attr, 1462 &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
1583 NULL 1463 NULL
1584}; 1464};
1585 1465
1586static struct attribute *tsl2x7x_PRX2_device_attrs[] = { 1466static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
1587 &dev_attr_in_proximity0_calibrate.attr, 1467 &dev_attr_in_proximity0_calibrate.attr,
1588 &dev_attr_in_proximity0_calibscale_available.attr, 1468 &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
1589 NULL 1469 NULL
1590}; 1470};
1591 1471
1592static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = { 1472static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
1593 &dev_attr_in_illuminance0_calibscale_available.attr, 1473 &dev_attr_in_illuminance0_calibscale_available.attr,
1594 &dev_attr_in_illuminance0_integration_time.attr,
1595 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, 1474 &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
1596 &dev_attr_in_illuminance0_target_input.attr, 1475 &dev_attr_in_illuminance0_target_input.attr,
1597 &dev_attr_in_illuminance0_calibrate.attr, 1476 &dev_attr_in_illuminance0_calibrate.attr,
1598 &dev_attr_in_illuminance0_lux_table.attr, 1477 &dev_attr_in_illuminance0_lux_table.attr,
1599 &dev_attr_in_proximity0_calibrate.attr, 1478 &dev_attr_in_proximity0_calibrate.attr,
1600 &dev_attr_in_proximity0_calibscale_available.attr, 1479 &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
1601 NULL 1480 NULL
1602}; 1481};
1603 1482
1604static struct attribute *tsl2X7X_ALS_event_attrs[] = {
1605 &dev_attr_in_intensity0_thresh_period.attr,
1606 NULL,
1607};
1608
1609static struct attribute *tsl2X7X_PRX_event_attrs[] = {
1610 &dev_attr_in_proximity0_thresh_period.attr,
1611 NULL,
1612};
1613
1614static struct attribute *tsl2X7X_ALSPRX_event_attrs[] = {
1615 &dev_attr_in_intensity0_thresh_period.attr,
1616 &dev_attr_in_proximity0_thresh_period.attr,
1617 NULL,
1618};
1619
1620static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = { 1483static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
1621 [ALS] = { 1484 [ALS] = {
1622 .attrs = tsl2x7x_ALS_device_attrs, 1485 .attrs = tsl2x7x_ALS_device_attrs,
@@ -1635,26 +1498,9 @@ static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
1635 }, 1498 },
1636}; 1499};
1637 1500
1638static const struct attribute_group tsl2X7X_event_attr_group_tbl[] = {
1639 [ALS] = {
1640 .attrs = tsl2X7X_ALS_event_attrs,
1641 .name = "events",
1642 },
1643 [PRX] = {
1644 .attrs = tsl2X7X_PRX_event_attrs,
1645 .name = "events",
1646 },
1647 [ALSPRX] = {
1648 .attrs = tsl2X7X_ALSPRX_event_attrs,
1649 .name = "events",
1650 },
1651};
1652
1653static const struct iio_info tsl2X7X_device_info[] = { 1501static const struct iio_info tsl2X7X_device_info[] = {
1654 [ALS] = { 1502 [ALS] = {
1655 .attrs = &tsl2X7X_device_attr_group_tbl[ALS], 1503 .attrs = &tsl2X7X_device_attr_group_tbl[ALS],
1656 .event_attrs = &tsl2X7X_event_attr_group_tbl[ALS],
1657 .driver_module = THIS_MODULE,
1658 .read_raw = &tsl2x7x_read_raw, 1504 .read_raw = &tsl2x7x_read_raw,
1659 .write_raw = &tsl2x7x_write_raw, 1505 .write_raw = &tsl2x7x_write_raw,
1660 .read_event_value = &tsl2x7x_read_event_value, 1506 .read_event_value = &tsl2x7x_read_event_value,
@@ -1664,8 +1510,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
1664 }, 1510 },
1665 [PRX] = { 1511 [PRX] = {
1666 .attrs = &tsl2X7X_device_attr_group_tbl[PRX], 1512 .attrs = &tsl2X7X_device_attr_group_tbl[PRX],
1667 .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
1668 .driver_module = THIS_MODULE,
1669 .read_raw = &tsl2x7x_read_raw, 1513 .read_raw = &tsl2x7x_read_raw,
1670 .write_raw = &tsl2x7x_write_raw, 1514 .write_raw = &tsl2x7x_write_raw,
1671 .read_event_value = &tsl2x7x_read_event_value, 1515 .read_event_value = &tsl2x7x_read_event_value,
@@ -1675,8 +1519,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
1675 }, 1519 },
1676 [ALSPRX] = { 1520 [ALSPRX] = {
1677 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX], 1521 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
1678 .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
1679 .driver_module = THIS_MODULE,
1680 .read_raw = &tsl2x7x_read_raw, 1522 .read_raw = &tsl2x7x_read_raw,
1681 .write_raw = &tsl2x7x_write_raw, 1523 .write_raw = &tsl2x7x_write_raw,
1682 .read_event_value = &tsl2x7x_read_event_value, 1524 .read_event_value = &tsl2x7x_read_event_value,
@@ -1686,8 +1528,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
1686 }, 1528 },
1687 [PRX2] = { 1529 [PRX2] = {
1688 .attrs = &tsl2X7X_device_attr_group_tbl[PRX2], 1530 .attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
1689 .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
1690 .driver_module = THIS_MODULE,
1691 .read_raw = &tsl2x7x_read_raw, 1531 .read_raw = &tsl2x7x_read_raw,
1692 .write_raw = &tsl2x7x_write_raw, 1532 .write_raw = &tsl2x7x_write_raw,
1693 .read_event_value = &tsl2x7x_read_event_value, 1533 .read_event_value = &tsl2x7x_read_event_value,
@@ -1697,8 +1537,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
1697 }, 1537 },
1698 [ALSPRX2] = { 1538 [ALSPRX2] = {
1699 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2], 1539 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
1700 .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
1701 .driver_module = THIS_MODULE,
1702 .read_raw = &tsl2x7x_read_raw, 1540 .read_raw = &tsl2x7x_read_raw,
1703 .write_raw = &tsl2x7x_write_raw, 1541 .write_raw = &tsl2x7x_write_raw,
1704 .read_event_value = &tsl2x7x_read_event_value, 1542 .read_event_value = &tsl2x7x_read_event_value,
@@ -1719,6 +1557,10 @@ static const struct iio_event_spec tsl2x7x_events[] = {
1719 .dir = IIO_EV_DIR_FALLING, 1557 .dir = IIO_EV_DIR_FALLING,
1720 .mask_separate = BIT(IIO_EV_INFO_VALUE) | 1558 .mask_separate = BIT(IIO_EV_INFO_VALUE) |
1721 BIT(IIO_EV_INFO_ENABLE), 1559 BIT(IIO_EV_INFO_ENABLE),
1560 }, {
1561 .type = IIO_EV_TYPE_THRESH,
1562 .dir = IIO_EV_DIR_EITHER,
1563 .mask_separate = BIT(IIO_EV_INFO_PERIOD),
1722 }, 1564 },
1723}; 1565};
1724 1566
@@ -1729,7 +1571,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
1729 .type = IIO_LIGHT, 1571 .type = IIO_LIGHT,
1730 .indexed = 1, 1572 .indexed = 1,
1731 .channel = 0, 1573 .channel = 0,
1732 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), 1574 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
1575 BIT(IIO_CHAN_INFO_INT_TIME),
1733 }, { 1576 }, {
1734 .type = IIO_INTENSITY, 1577 .type = IIO_INTENSITY,
1735 .indexed = 1, 1578 .indexed = 1,
@@ -1768,7 +1611,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
1768 .type = IIO_LIGHT, 1611 .type = IIO_LIGHT,
1769 .indexed = 1, 1612 .indexed = 1,
1770 .channel = 0, 1613 .channel = 0,
1771 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) 1614 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
1615 BIT(IIO_CHAN_INFO_INT_TIME),
1772 }, { 1616 }, {
1773 .type = IIO_INTENSITY, 1617 .type = IIO_INTENSITY,
1774 .indexed = 1, 1618 .indexed = 1,
@@ -1816,7 +1660,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
1816 .type = IIO_LIGHT, 1660 .type = IIO_LIGHT,
1817 .indexed = 1, 1661 .indexed = 1,
1818 .channel = 0, 1662 .channel = 0,
1819 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), 1663 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
1664 BIT(IIO_CHAN_INFO_INT_TIME),
1820 }, { 1665 }, {
1821 .type = IIO_INTENSITY, 1666 .type = IIO_INTENSITY,
1822 .indexed = 1, 1667 .indexed = 1,
@@ -1874,7 +1719,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
1874 return -EINVAL; 1719 return -EINVAL;
1875 } 1720 }
1876 1721
1877 ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL)); 1722 ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
1878 if (ret < 0) { 1723 if (ret < 0) {
1879 dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n", 1724 dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n",
1880 ret); 1725 ret);
@@ -1982,7 +1827,7 @@ static int tsl2x7x_remove(struct i2c_client *client)
1982 return 0; 1827 return 0;
1983} 1828}
1984 1829
1985static struct i2c_device_id tsl2x7x_idtable[] = { 1830static const struct i2c_device_id tsl2x7x_idtable[] = {
1986 { "tsl2571", tsl2571 }, 1831 { "tsl2571", tsl2571 },
1987 { "tsl2671", tsl2671 }, 1832 { "tsl2671", tsl2671 },
1988 { "tmd2671", tmd2671 }, 1833 { "tmd2671", tmd2671 },
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index ecae92211216..df00f2ec1719 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -23,18 +23,19 @@
23#define __TSL2X7X_H 23#define __TSL2X7X_H
24#include <linux/pm.h> 24#include <linux/pm.h>
25 25
26/* Max number of segments allowable in LUX table */
27#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
28#define MAX_DEFAULT_TABLE_BYTES (sizeof(int) * TSL2X7X_MAX_LUX_TABLE_SIZE)
29
30struct iio_dev;
31
32struct tsl2x7x_lux { 26struct tsl2x7x_lux {
33 unsigned int ratio; 27 unsigned int ratio;
34 unsigned int ch0; 28 unsigned int ch0;
35 unsigned int ch1; 29 unsigned int ch1;
36}; 30};
37 31
32/* Max number of segments allowable in LUX table */
33#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
34/* The default LUX tables all have 3 elements. */
35#define TSL2X7X_DEF_LUX_TABLE_SZ 3
36#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
37 TSL2X7X_DEF_LUX_TABLE_SZ)
38
38/** 39/**
39 * struct tsl2x7x_default_settings - power on defaults unless 40 * struct tsl2x7x_default_settings - power on defaults unless
40 * overridden by platform data. 41 * overridden by platform data.
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
index ce26abdeab92..c44eb577dc35 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -80,7 +80,7 @@
80 * @us: actual spi_device 80 * @us: actual spi_device
81 * @tx: transmit buffer 81 * @tx: transmit buffer
82 * @rx: receive buffer 82 * @rx: receive buffer
83 * @buf_lock: mutex to protect tx and rx 83 * @buf_lock: mutex to protect tx, rx and write frequency
84 **/ 84 **/
85struct ade7753_state { 85struct ade7753_state {
86 struct spi_device *us; 86 struct spi_device *us;
@@ -107,6 +107,19 @@ static int ade7753_spi_write_reg_8(struct device *dev,
107 return ret; 107 return ret;
108} 108}
109 109
110static int __ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
111 u16 value)
112{
113 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
114 struct ade7753_state *st = iio_priv(indio_dev);
115
116 st->tx[0] = ADE7753_WRITE_REG(reg_address);
117 st->tx[1] = (value >> 8) & 0xFF;
118 st->tx[2] = value & 0xFF;
119
120 return spi_write(st->us, st->tx, 3);
121}
122
110static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address, 123static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
111 u16 value) 124 u16 value)
112{ 125{
@@ -115,10 +128,7 @@ static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
115 struct ade7753_state *st = iio_priv(indio_dev); 128 struct ade7753_state *st = iio_priv(indio_dev);
116 129
117 mutex_lock(&st->buf_lock); 130 mutex_lock(&st->buf_lock);
118 st->tx[0] = ADE7753_WRITE_REG(reg_address); 131 ret = __ade7753_spi_write_reg_16(dev, reg_address, value);
119 st->tx[1] = (value >> 8) & 0xFF;
120 st->tx[2] = value & 0xFF;
121 ret = spi_write(st->us, st->tx, 3);
122 mutex_unlock(&st->buf_lock); 132 mutex_unlock(&st->buf_lock);
123 133
124 return ret; 134 return ret;
@@ -483,7 +493,7 @@ static ssize_t ade7753_write_frequency(struct device *dev,
483 if (!val) 493 if (!val)
484 return -EINVAL; 494 return -EINVAL;
485 495
486 mutex_lock(&indio_dev->mlock); 496 mutex_lock(&st->buf_lock);
487 497
488 t = 27900 / val; 498 t = 27900 / val;
489 if (t > 0) 499 if (t > 0)
@@ -501,10 +511,10 @@ static ssize_t ade7753_write_frequency(struct device *dev,
501 reg &= ~(3 << 11); 511 reg &= ~(3 << 11);
502 reg |= t << 11; 512 reg |= t << 11;
503 513
504 ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg); 514 ret = __ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
505 515
506out: 516out:
507 mutex_unlock(&indio_dev->mlock); 517 mutex_unlock(&st->buf_lock);
508 518
509 return ret ? ret : len; 519 return ret ? ret : len;
510} 520}
@@ -561,7 +571,6 @@ static const struct attribute_group ade7753_attribute_group = {
561 571
562static const struct iio_info ade7753_info = { 572static const struct iio_info ade7753_info = {
563 .attrs = &ade7753_attribute_group, 573 .attrs = &ade7753_attribute_group,
564 .driver_module = THIS_MODULE,
565}; 574};
566 575
567static int ade7753_probe(struct spi_device *spi) 576static int ade7753_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
index be0df3fe4230..3a1e342d75fb 100644
--- a/drivers/staging/iio/meter/ade7754.c
+++ b/drivers/staging/iio/meter/ade7754.c
@@ -601,7 +601,6 @@ static const struct attribute_group ade7754_attribute_group = {
601 601
602static const struct iio_info ade7754_info = { 602static const struct iio_info ade7754_info = {
603 .attrs = &ade7754_attribute_group, 603 .attrs = &ade7754_attribute_group,
604 .driver_module = THIS_MODULE,
605}; 604};
606 605
607static int ade7754_probe(struct spi_device *spi) 606static int ade7754_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
index 40498af4dc46..7b7ffe5ed186 100644
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ b/drivers/staging/iio/meter/ade7758_core.c
@@ -827,7 +827,6 @@ static const struct iio_info ade7758_info = {
827 .attrs = &ade7758_attribute_group, 827 .attrs = &ade7758_attribute_group,
828 .read_raw = &ade7758_read_raw, 828 .read_raw = &ade7758_read_raw,
829 .write_raw = &ade7758_write_raw, 829 .write_raw = &ade7758_write_raw,
830 .driver_module = THIS_MODULE,
831}; 830};
832 831
833static int ade7758_probe(struct spi_device *spi) 832static int ade7758_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
index 5b35a7f08f4f..1f0d1a0cf889 100644
--- a/drivers/staging/iio/meter/ade7758_trigger.c
+++ b/drivers/staging/iio/meter/ade7758_trigger.c
@@ -53,7 +53,6 @@ static int ade7758_trig_try_reen(struct iio_trigger *trig)
53} 53}
54 54
55static const struct iio_trigger_ops ade7758_trigger_ops = { 55static const struct iio_trigger_ops ade7758_trigger_ops = {
56 .owner = THIS_MODULE,
57 .set_trigger_state = &ade7758_data_rdy_trigger_set_state, 56 .set_trigger_state = &ade7758_data_rdy_trigger_set_state,
58 .try_reenable = &ade7758_trig_try_reen, 57 .try_reenable = &ade7758_trig_try_reen,
59}; 58};
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
index 1691760339da..d99cf508d8d0 100644
--- a/drivers/staging/iio/meter/ade7759.c
+++ b/drivers/staging/iio/meter/ade7759.c
@@ -60,7 +60,7 @@
60/** 60/**
61 * struct ade7759_state - device instance specific data 61 * struct ade7759_state - device instance specific data
62 * @us: actual spi_device 62 * @us: actual spi_device
63 * @buf_lock: mutex to protect tx and rx 63 * @buf_lock: mutex to protect tx and rx and write frequency
64 * @tx: transmit buffer 64 * @tx: transmit buffer
65 * @rx: receive buffer 65 * @rx: receive buffer
66 **/ 66 **/
@@ -89,19 +89,30 @@ static int ade7759_spi_write_reg_8(struct device *dev,
89 return ret; 89 return ret;
90} 90}
91 91
92static int ade7759_spi_write_reg_16(struct device *dev, 92/*Unlocked version of ade7759_spi_write_reg_16 function */
93static int __ade7759_spi_write_reg_16(struct device *dev,
93 u8 reg_address, 94 u8 reg_address,
94 u16 value) 95 u16 value)
95{ 96{
96 int ret;
97 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 97 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
98 struct ade7759_state *st = iio_priv(indio_dev); 98 struct ade7759_state *st = iio_priv(indio_dev);
99 99
100 mutex_lock(&st->buf_lock);
101 st->tx[0] = ADE7759_WRITE_REG(reg_address); 100 st->tx[0] = ADE7759_WRITE_REG(reg_address);
102 st->tx[1] = (value >> 8) & 0xFF; 101 st->tx[1] = (value >> 8) & 0xFF;
103 st->tx[2] = value & 0xFF; 102 st->tx[2] = value & 0xFF;
104 ret = spi_write(st->us, st->tx, 3); 103 return spi_write(st->us, st->tx, 3);
104}
105
106static int ade7759_spi_write_reg_16(struct device *dev,
107 u8 reg_address,
108 u16 value)
109{
110 int ret;
111 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
112 struct ade7759_state *st = iio_priv(indio_dev);
113
114 mutex_lock(&st->buf_lock);
115 ret = __ade7759_spi_write_reg_16(dev, reg_address, value);
105 mutex_unlock(&st->buf_lock); 116 mutex_unlock(&st->buf_lock);
106 117
107 return ret; 118 return ret;
@@ -172,7 +183,7 @@ static int ade7759_spi_read_reg_40(struct device *dev,
172 reg_address); 183 reg_address);
173 goto error_ret; 184 goto error_ret;
174 } 185 }
175 *val = ((u64)st->rx[1] << 32) | (st->rx[2] << 24) | 186 *val = ((u64)st->rx[1] << 32) | ((u64)st->rx[2] << 24) |
176 (st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5]; 187 (st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5];
177 188
178error_ret: 189error_ret:
@@ -429,7 +440,7 @@ static ssize_t ade7759_write_frequency(struct device *dev,
429 if (!val) 440 if (!val)
430 return -EINVAL; 441 return -EINVAL;
431 442
432 mutex_lock(&indio_dev->mlock); 443 mutex_lock(&st->buf_lock);
433 444
434 t = 27900 / val; 445 t = 27900 / val;
435 if (t > 0) 446 if (t > 0)
@@ -447,10 +458,10 @@ static ssize_t ade7759_write_frequency(struct device *dev,
447 reg &= ~(3 << 13); 458 reg &= ~(3 << 13);
448 reg |= t << 13; 459 reg |= t << 13;
449 460
450 ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg); 461 ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
451 462
452out: 463out:
453 mutex_unlock(&indio_dev->mlock); 464 mutex_unlock(&st->buf_lock);
454 465
455 return ret ? ret : len; 466 return ret ? ret : len;
456} 467}
@@ -493,7 +504,6 @@ static const struct attribute_group ade7759_attribute_group = {
493 504
494static const struct iio_info ade7759_info = { 505static const struct iio_info ade7759_info = {
495 .attrs = &ade7759_attribute_group, 506 .attrs = &ade7759_attribute_group,
496 .driver_module = THIS_MODULE,
497}; 507};
498 508
499static int ade7759_probe(struct spi_device *spi) 509static int ade7759_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c
index 70612da64a8b..90d07cdca4b8 100644
--- a/drivers/staging/iio/meter/ade7854.c
+++ b/drivers/staging/iio/meter/ade7854.c
@@ -530,7 +530,6 @@ static const struct attribute_group ade7854_attribute_group = {
530 530
531static const struct iio_info ade7854_info = { 531static const struct iio_info ade7854_info = {
532 .attrs = &ade7854_attribute_group, 532 .attrs = &ade7854_attribute_group,
533 .driver_module = THIS_MODULE,
534}; 533};
535 534
536int ade7854_probe(struct iio_dev *indio_dev, struct device *dev) 535int ade7854_probe(struct iio_dev *indio_dev, struct device *dev)
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c
index a37e199225f4..aa62c64e9bc4 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -98,7 +98,6 @@ static const struct iio_chan_spec ad2s1200_channels[] = {
98 98
99static const struct iio_info ad2s1200_info = { 99static const struct iio_info ad2s1200_info = {
100 .read_raw = ad2s1200_read_raw, 100 .read_raw = ad2s1200_read_raw,
101 .driver_module = THIS_MODULE,
102}; 101};
103 102
104static int ad2s1200_probe(struct spi_device *spi) 103static int ad2s1200_probe(struct spi_device *spi)
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 3e00df74b18c..f8baab061eba 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -638,7 +638,6 @@ error_ret:
638static const struct iio_info ad2s1210_info = { 638static const struct iio_info ad2s1210_info = {
639 .read_raw = ad2s1210_read_raw, 639 .read_raw = ad2s1210_read_raw,
640 .attrs = &ad2s1210_attribute_group, 640 .attrs = &ad2s1210_attribute_group,
641 .driver_module = THIS_MODULE,
642}; 641};
643 642
644static int ad2s1210_setup_gpios(struct ad2s1210_state *st) 643static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index b2270908f26f..59586947a936 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -48,7 +48,6 @@ error_ret:
48 48
49static const struct iio_info ad2s90_info = { 49static const struct iio_info ad2s90_info = {
50 .read_raw = ad2s90_read_raw, 50 .read_raw = ad2s90_read_raw,
51 .driver_module = THIS_MODULE,
52}; 51};
53 52
54static const struct iio_chan_spec ad2s90_chan = { 53static const struct iio_chan_spec ad2s90_chan = {
diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index 4e0b4eedb53d..d80dcf82eba9 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -172,7 +172,6 @@ static int iio_bfin_tmr_get_number(int irq)
172} 172}
173 173
174static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = { 174static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = {
175 .owner = THIS_MODULE,
176 .set_trigger_state = iio_bfin_tmr_set_state, 175 .set_trigger_state = iio_bfin_tmr_set_state,
177}; 176};
178 177
diff --git a/drivers/staging/irda/drivers/ali-ircc.c b/drivers/staging/irda/drivers/ali-ircc.c
index 35f198d83701..589cd01797f4 100644
--- a/drivers/staging/irda/drivers/ali-ircc.c
+++ b/drivers/staging/irda/drivers/ali-ircc.c
@@ -1876,8 +1876,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1876 self->stamp = ktime_get(); 1876 self->stamp = ktime_get();
1877 1877
1878 skb = dev_alloc_skb(len+1); 1878 skb = dev_alloc_skb(len+1);
1879 if (skb == NULL) 1879 if (!skb) {
1880 {
1881 self->netdev->stats.rx_dropped++; 1880 self->netdev->stats.rx_dropped++;
1882 1881
1883 return FALSE; 1882 return FALSE;
diff --git a/drivers/staging/irda/drivers/au1k_ir.c b/drivers/staging/irda/drivers/au1k_ir.c
index be4ea6aa57a9..73e3e4b041bf 100644
--- a/drivers/staging/irda/drivers/au1k_ir.c
+++ b/drivers/staging/irda/drivers/au1k_ir.c
@@ -290,8 +290,7 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed)
290 while (irda_read(aup, IR_STATUS) & (IR_RX_STATUS | IR_TX_STATUS)) { 290 while (irda_read(aup, IR_STATUS) & (IR_RX_STATUS | IR_TX_STATUS)) {
291 msleep(20); 291 msleep(20);
292 if (!timeout--) { 292 if (!timeout--) {
293 printk(KERN_ERR "%s: rx/tx disable timeout\n", 293 netdev_err(dev, "rx/tx disable timeout\n");
294 dev->name);
295 break; 294 break;
296 } 295 }
297 } 296 }
@@ -349,7 +348,7 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed)
349 IR_RX_ENABLE); 348 IR_RX_ENABLE);
350 break; 349 break;
351 default: 350 default:
352 printk(KERN_ERR "%s unsupported speed %x\n", dev->name, speed); 351 netdev_err(dev, "unsupported speed %x\n", speed);
353 ret = -EINVAL; 352 ret = -EINVAL;
354 break; 353 break;
355 } 354 }
@@ -361,18 +360,18 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed)
361 irda_write(aup, IR_RING_PROMPT, 0); 360 irda_write(aup, IR_RING_PROMPT, 0);
362 361
363 if (control & (1 << 14)) { 362 if (control & (1 << 14)) {
364 printk(KERN_ERR "%s: configuration error\n", dev->name); 363 netdev_err(dev, "configuration error\n");
365 } else { 364 } else {
366 if (control & (1 << 11)) 365 if (control & (1 << 11))
367 printk(KERN_DEBUG "%s Valid SIR config\n", dev->name); 366 netdev_debug(dev, "Valid SIR config\n");
368 if (control & (1 << 12)) 367 if (control & (1 << 12))
369 printk(KERN_DEBUG "%s Valid MIR config\n", dev->name); 368 netdev_debug(dev, "Valid MIR config\n");
370 if (control & (1 << 13)) 369 if (control & (1 << 13))
371 printk(KERN_DEBUG "%s Valid FIR config\n", dev->name); 370 netdev_debug(dev, "Valid FIR config\n");
372 if (control & (1 << 10)) 371 if (control & (1 << 10))
373 printk(KERN_DEBUG "%s TX enabled\n", dev->name); 372 netdev_debug(dev, "TX enabled\n");
374 if (control & (1 << 9)) 373 if (control & (1 << 9))
375 printk(KERN_DEBUG "%s RX enabled\n", dev->name); 374 netdev_debug(dev, "RX enabled\n");
376 } 375 }
377 376
378 return ret; 377 return ret;
@@ -584,23 +583,21 @@ static int au1k_irda_start(struct net_device *dev)
584 583
585 retval = au1k_init(dev); 584 retval = au1k_init(dev);
586 if (retval) { 585 if (retval) {
587 printk(KERN_ERR "%s: error in au1k_init\n", dev->name); 586 netdev_err(dev, "error in au1k_init\n");
588 return retval; 587 return retval;
589 } 588 }
590 589
591 retval = request_irq(aup->irq_tx, &au1k_irda_interrupt, 0, 590 retval = request_irq(aup->irq_tx, &au1k_irda_interrupt, 0,
592 dev->name, dev); 591 dev->name, dev);
593 if (retval) { 592 if (retval) {
594 printk(KERN_ERR "%s: unable to get IRQ %d\n", 593 netdev_err(dev, "unable to get IRQ %d\n", dev->irq);
595 dev->name, dev->irq);
596 return retval; 594 return retval;
597 } 595 }
598 retval = request_irq(aup->irq_rx, &au1k_irda_interrupt, 0, 596 retval = request_irq(aup->irq_rx, &au1k_irda_interrupt, 0,
599 dev->name, dev); 597 dev->name, dev);
600 if (retval) { 598 if (retval) {
601 free_irq(aup->irq_tx, dev); 599 free_irq(aup->irq_tx, dev);
602 printk(KERN_ERR "%s: unable to get IRQ %d\n", 600 netdev_err(dev, "unable to get IRQ %d\n", dev->irq);
603 dev->name, dev->irq);
604 return retval; 601 return retval;
605 } 602 }
606 603
@@ -673,12 +670,12 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
673 flags = ptxd->flags; 670 flags = ptxd->flags;
674 671
675 if (flags & AU_OWN) { 672 if (flags & AU_OWN) {
676 printk(KERN_DEBUG "%s: tx_full\n", dev->name); 673 netdev_debug(dev, "tx_full\n");
677 netif_stop_queue(dev); 674 netif_stop_queue(dev);
678 aup->tx_full = 1; 675 aup->tx_full = 1;
679 return 1; 676 return 1;
680 } else if (((aup->tx_head + 1) & (NUM_IR_DESC - 1)) == aup->tx_tail) { 677 } else if (((aup->tx_head + 1) & (NUM_IR_DESC - 1)) == aup->tx_tail) {
681 printk(KERN_DEBUG "%s: tx_full\n", dev->name); 678 netdev_debug(dev, "tx_full\n");
682 netif_stop_queue(dev); 679 netif_stop_queue(dev);
683 aup->tx_full = 1; 680 aup->tx_full = 1;
684 return 1; 681 return 1;
@@ -688,7 +685,7 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
688 685
689#if 0 686#if 0
690 if (irda_read(aup, IR_RX_BYTE_CNT) != 0) { 687 if (irda_read(aup, IR_RX_BYTE_CNT) != 0) {
691 printk(KERN_DEBUG "tx warning: rx byte cnt %x\n", 688 netdev_debug(dev, "tx warning: rx byte cnt %x\n",
692 irda_read(aup, IR_RX_BYTE_CNT)); 689 irda_read(aup, IR_RX_BYTE_CNT));
693 } 690 }
694#endif 691#endif
@@ -726,7 +723,7 @@ static void au1k_tx_timeout(struct net_device *dev)
726 u32 speed; 723 u32 speed;
727 struct au1k_private *aup = netdev_priv(dev); 724 struct au1k_private *aup = netdev_priv(dev);
728 725
729 printk(KERN_ERR "%s: tx timeout\n", dev->name); 726 netdev_err(dev, "tx timeout\n");
730 speed = aup->speed; 727 speed = aup->speed;
731 aup->speed = 0; 728 aup->speed = 0;
732 au1k_irda_set_speed(dev, speed); 729 au1k_irda_set_speed(dev, speed);
@@ -751,8 +748,7 @@ static int au1k_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
751 ret = au1k_irda_set_speed(dev, 748 ret = au1k_irda_set_speed(dev,
752 rq->ifr_baudrate); 749 rq->ifr_baudrate);
753 else { 750 else {
754 printk(KERN_ERR "%s ioctl: !netif_running\n", 751 netdev_err(dev, "ioctl: !netif_running\n");
755 dev->name);
756 ret = 0; 752 ret = 0;
757 } 753 }
758 } 754 }
@@ -868,7 +864,7 @@ out3:
868out2: 864out2:
869 kfree(aup->rx_buff.head); 865 kfree(aup->rx_buff.head);
870out1: 866out1:
871 printk(KERN_ERR "au1k_irda_net_init() failed. Returns %d\n", retval); 867 netdev_err(dev, "au1k_irda_net_init() failed. Returns %d\n");
872 return retval; 868 return retval;
873} 869}
874 870
@@ -934,7 +930,7 @@ static int au1k_irda_probe(struct platform_device *pdev)
934 930
935 platform_set_drvdata(pdev, dev); 931 platform_set_drvdata(pdev, dev);
936 932
937 printk(KERN_INFO "IrDA: Registered device %s\n", dev->name); 933 netdev_info(dev, "IrDA: Registered device\n");
938 return 0; 934 return 0;
939 935
940out4: 936out4:
diff --git a/drivers/staging/irda/drivers/bfin_sir.c b/drivers/staging/irda/drivers/bfin_sir.c
index 3151b580dbd6..59e409b68349 100644
--- a/drivers/staging/irda/drivers/bfin_sir.c
+++ b/drivers/staging/irda/drivers/bfin_sir.c
@@ -22,6 +22,8 @@ static int max_rate = 57600;
22static int max_rate = 115200; 22static int max_rate = 115200;
23#endif 23#endif
24 24
25static void bfin_sir_rx_dma_timeout(struct timer_list *t);
26
25static void turnaround_delay(int mtt) 27static void turnaround_delay(int mtt)
26{ 28{
27 long ticks; 29 long ticks;
@@ -57,7 +59,7 @@ static void bfin_sir_init_ports(struct bfin_sir_port *sp, struct platform_device
57 sp->clk = get_sclk(); 59 sp->clk = get_sclk();
58#ifdef CONFIG_SIR_BFIN_DMA 60#ifdef CONFIG_SIR_BFIN_DMA
59 sp->tx_done = 1; 61 sp->tx_done = 1;
60 init_timer(&(sp->rx_dma_timer)); 62 timer_setup(&sp->rx_dma_timer, bfin_sir_rx_dma_timeout, 0);
61#endif 63#endif
62} 64}
63 65
@@ -317,10 +319,12 @@ static void bfin_sir_dma_rx_chars(struct net_device *dev)
317 async_unwrap_char(dev, &self->stats, &self->rx_buff, port->rx_dma_buf.buf[i]); 319 async_unwrap_char(dev, &self->stats, &self->rx_buff, port->rx_dma_buf.buf[i]);
318} 320}
319 321
320void bfin_sir_rx_dma_timeout(struct net_device *dev) 322static void bfin_sir_rx_dma_timeout(struct timer_list *t)
321{ 323{
324 struct bfin_sir_port *port = from_timer(port, t, rx_dma_timer);
325 struct net_device *dev = port->dev;
322 struct bfin_sir_self *self = netdev_priv(dev); 326 struct bfin_sir_self *self = netdev_priv(dev);
323 struct bfin_sir_port *port = self->sir_port; 327
324 int x_pos, pos; 328 int x_pos, pos;
325 unsigned long flags; 329 unsigned long flags;
326 330
@@ -405,8 +409,6 @@ static int bfin_sir_startup(struct bfin_sir_port *port, struct net_device *dev)
405 set_dma_start_addr(port->rx_dma_channel, (unsigned long)port->rx_dma_buf.buf); 409 set_dma_start_addr(port->rx_dma_channel, (unsigned long)port->rx_dma_buf.buf);
406 enable_dma(port->rx_dma_channel); 410 enable_dma(port->rx_dma_channel);
407 411
408 port->rx_dma_timer.data = (unsigned long)(dev);
409 port->rx_dma_timer.function = (void *)bfin_sir_rx_dma_timeout;
410 412
411#else 413#else
412 414
diff --git a/drivers/staging/irda/drivers/esi-sir.c b/drivers/staging/irda/drivers/esi-sir.c
index 019a3e848bcb..eb7aa6430bea 100644
--- a/drivers/staging/irda/drivers/esi-sir.c
+++ b/drivers/staging/irda/drivers/esi-sir.c
@@ -1,5 +1,5 @@
1/********************************************************************* 1/*********************************************************************
2 * 2 *
3 * Filename: esi.c 3 * Filename: esi.c
4 * Version: 1.6 4 * Version: 1.6
5 * Description: Driver for the Extended Systems JetEye PC dongle 5 * Description: Driver for the Extended Systems JetEye PC dongle
@@ -8,25 +8,25 @@
8 * Created at: Sat Feb 21 18:54:38 1998 8 * Created at: Sat Feb 21 18:54:38 1998
9 * Modified at: Sun Oct 27 22:01:04 2002 9 * Modified at: Sun Oct 27 22:01:04 2002
10 * Modified by: Martin Diehl <mad@mdiehl.de> 10 * Modified by: Martin Diehl <mad@mdiehl.de>
11 * 11 *
12 * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>, 12 * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>, 13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
14 * Copyright (c) 2002 Martin Diehl, <mad@mdiehl.de>, 14 * Copyright (c) 2002 Martin Diehl, <mad@mdiehl.de>,
15 * All Rights Reserved. 15 * All Rights Reserved.
16 * 16 *
17 * This program is free software; you can redistribute it and/or 17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as 18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of 19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version. 20 * the License, or (at your option) any later version.
21 * 21 *
22 * This program is distributed in the hope that it will be useful, 22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 * 26 *
27 * You should have received a copy of the GNU General Public License 27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, see <http://www.gnu.org/licenses/>. 28 * along with this program; if not, see <http://www.gnu.org/licenses/>.
29 * 29 *
30 ********************************************************************/ 30 ********************************************************************/
31 31
32#include <linux/module.h> 32#include <linux/module.h>
@@ -97,7 +97,7 @@ static int esi_change_speed(struct sir_dev *dev, unsigned speed)
97{ 97{
98 int ret = 0; 98 int ret = 0;
99 int dtr, rts; 99 int dtr, rts;
100 100
101 switch (speed) { 101 switch (speed) {
102 case 19200: 102 case 19200:
103 dtr = TRUE; 103 dtr = TRUE;
diff --git a/drivers/staging/irda/drivers/irda-usb.c b/drivers/staging/irda/drivers/irda-usb.c
index 723e49bc4baa..bda6bdc6c70b 100644
--- a/drivers/staging/irda/drivers/irda-usb.c
+++ b/drivers/staging/irda/drivers/irda-usb.c
@@ -117,7 +117,7 @@ static void irda_usb_close(struct irda_usb_cb *self);
117static void speed_bulk_callback(struct urb *urb); 117static void speed_bulk_callback(struct urb *urb);
118static void write_bulk_callback(struct urb *urb); 118static void write_bulk_callback(struct urb *urb);
119static void irda_usb_receive(struct urb *urb); 119static void irda_usb_receive(struct urb *urb);
120static void irda_usb_rx_defer_expired(unsigned long data); 120static void irda_usb_rx_defer_expired(struct timer_list *t);
121static int irda_usb_net_open(struct net_device *dev); 121static int irda_usb_net_open(struct net_device *dev);
122static int irda_usb_net_close(struct net_device *dev); 122static int irda_usb_net_close(struct net_device *dev);
123static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 123static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -334,9 +334,9 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
334 urb->transfer_flags = 0; 334 urb->transfer_flags = 0;
335 335
336 /* Irq disabled -> GFP_ATOMIC */ 336 /* Irq disabled -> GFP_ATOMIC */
337 if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) { 337 ret = usb_submit_urb(urb, GFP_ATOMIC);
338 if (ret)
338 net_warn_ratelimited("%s(), failed Speed URB\n", __func__); 339 net_warn_ratelimited("%s(), failed Speed URB\n", __func__);
339 }
340} 340}
341 341
342/*------------------------------------------------------------------*/ 342/*------------------------------------------------------------------*/
@@ -846,8 +846,7 @@ static void irda_usb_receive(struct urb *urb)
846 * hot unplug of the dongle... 846 * hot unplug of the dongle...
847 * Lowest effective timer is 10ms... 847 * Lowest effective timer is 10ms...
848 * Jean II */ 848 * Jean II */
849 self->rx_defer_timer.function = irda_usb_rx_defer_expired; 849 self->rx_defer_timer_urb = urb;
850 self->rx_defer_timer.data = (unsigned long) urb;
851 mod_timer(&self->rx_defer_timer, 850 mod_timer(&self->rx_defer_timer,
852 jiffies + msecs_to_jiffies(10)); 851 jiffies + msecs_to_jiffies(10));
853 852
@@ -953,20 +952,13 @@ done:
953 * In case of errors, we want the USB layer to have time to recover. 952 * In case of errors, we want the USB layer to have time to recover.
954 * Now, it is time to resubmit ouur Rx URB... 953 * Now, it is time to resubmit ouur Rx URB...
955 */ 954 */
956static void irda_usb_rx_defer_expired(unsigned long data) 955static void irda_usb_rx_defer_expired(struct timer_list *t)
957{ 956{
958 struct urb *urb = (struct urb *) data; 957 struct irda_usb_cb *self = from_timer(self, t, rx_defer_timer);
958 struct urb *urb = self->rx_defer_timer_urb;
959 struct sk_buff *skb = (struct sk_buff *) urb->context; 959 struct sk_buff *skb = (struct sk_buff *) urb->context;
960 struct irda_usb_cb *self;
961 struct irda_skb_cb *cb;
962 struct urb *next_urb; 960 struct urb *next_urb;
963 961
964 /* Find ourselves */
965 cb = (struct irda_skb_cb *) skb->cb;
966 IRDA_ASSERT(cb != NULL, return;);
967 self = (struct irda_usb_cb *) cb->context;
968 IRDA_ASSERT(self != NULL, return;);
969
970 /* Same stuff as when Rx is done, see above... */ 962 /* Same stuff as when Rx is done, see above... */
971 next_urb = self->idle_rx_urb; 963 next_urb = self->idle_rx_urb;
972 urb->context = NULL; 964 urb->context = NULL;
@@ -1622,7 +1614,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1622 self = netdev_priv(net); 1614 self = netdev_priv(net);
1623 self->netdev = net; 1615 self->netdev = net;
1624 spin_lock_init(&self->lock); 1616 spin_lock_init(&self->lock);
1625 init_timer(&self->rx_defer_timer); 1617 timer_setup(&self->rx_defer_timer, irda_usb_rx_defer_expired, 0);
1626 1618
1627 self->capability = id->driver_info; 1619 self->capability = id->driver_info;
1628 self->needspatch = ((self->capability & IUC_STIR421X) != 0); 1620 self->needspatch = ((self->capability & IUC_STIR421X) != 0);
diff --git a/drivers/staging/irda/drivers/irda-usb.h b/drivers/staging/irda/drivers/irda-usb.h
index 8ac389fa9348..56ee8c16c5e2 100644
--- a/drivers/staging/irda/drivers/irda-usb.h
+++ b/drivers/staging/irda/drivers/irda-usb.h
@@ -170,5 +170,6 @@ struct irda_usb_cb {
170 int needspatch; /* device needs firmware patch */ 170 int needspatch; /* device needs firmware patch */
171 171
172 struct timer_list rx_defer_timer; /* Wait for Rx error to clear */ 172 struct timer_list rx_defer_timer; /* Wait for Rx error to clear */
173 struct urb *rx_defer_timer_urb; /* URB attached to rx_defer_timer */
173}; 174};
174 175
diff --git a/drivers/staging/irda/drivers/mcs7780.c b/drivers/staging/irda/drivers/mcs7780.c
index c3f0b254b344..d52e9f4b9770 100644
--- a/drivers/staging/irda/drivers/mcs7780.c
+++ b/drivers/staging/irda/drivers/mcs7780.c
@@ -605,19 +605,22 @@ static int mcs_speed_change(struct mcs_cb *mcs)
605 if (mcs->new_speed <= 115200) { 605 if (mcs->new_speed <= 115200) {
606 rval &= ~MCS_FIR; 606 rval &= ~MCS_FIR;
607 607
608 if ((rst = (mcs->speed > 115200))) 608 rst = mcs->speed > 115200;
609 if (rst)
609 mcs_set_reg(mcs, MCS_MINRXPW_REG, 0); 610 mcs_set_reg(mcs, MCS_MINRXPW_REG, 0);
610 611
611 } else if (mcs->new_speed <= 1152000) { 612 } else if (mcs->new_speed <= 1152000) {
612 rval &= ~MCS_FIR; 613 rval &= ~MCS_FIR;
613 614
614 if ((rst = !(mcs->speed == 576000 || mcs->speed == 1152000))) 615 rst = !(mcs->speed == 576000 || mcs->speed == 1152000);
616 if (rst)
615 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); 617 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5);
616 618
617 } else { 619 } else {
618 rval |= MCS_FIR; 620 rval |= MCS_FIR;
619 621
620 if ((rst = (mcs->speed != 4000000))) 622 rst = mcs->speed != 4000000;
623 if (rst)
621 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); 624 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5);
622 625
623 } 626 }
diff --git a/drivers/staging/irda/drivers/vlsi_ir.c b/drivers/staging/irda/drivers/vlsi_ir.c
index 6638784c082e..3dff3c55ddf5 100644
--- a/drivers/staging/irda/drivers/vlsi_ir.c
+++ b/drivers/staging/irda/drivers/vlsi_ir.c
@@ -170,10 +170,10 @@ static void vlsi_proc_pdev(struct seq_file *seq, struct pci_dev *pdev)
170 seq_printf(seq, "pci-power-state: %u\n", (unsigned) pdev->current_state); 170 seq_printf(seq, "pci-power-state: %u\n", (unsigned) pdev->current_state);
171 seq_printf(seq, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n", 171 seq_printf(seq, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
172 pdev->irq, (unsigned)pci_resource_start(pdev, 0), (unsigned long long)pdev->dma_mask); 172 pdev->irq, (unsigned)pci_resource_start(pdev, 0), (unsigned long long)pdev->dma_mask);
173 seq_printf(seq, "hw registers: "); 173 seq_puts(seq, "hw registers: ");
174 for (i = 0; i < 0x20; i++) 174 for (i = 0; i < 0x20; i++)
175 seq_printf(seq, "%02x", (unsigned)inb((iobase+i))); 175 seq_printf(seq, "%02x", (unsigned)inb((iobase+i)));
176 seq_printf(seq, "\n"); 176 seq_putc(seq, '\n');
177} 177}
178 178
179static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) 179static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
@@ -193,7 +193,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
193 if (!netif_running(ndev)) 193 if (!netif_running(ndev))
194 return; 194 return;
195 195
196 seq_printf(seq, "\nhw-state:\n"); 196 seq_puts(seq, "\nhw-state:\n");
197 pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte); 197 pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte);
198 seq_printf(seq, "IRMISC:%s%s%s uart%s", 198 seq_printf(seq, "IRMISC:%s%s%s uart%s",
199 (byte&IRMISC_IRRAIL) ? " irrail" : "", 199 (byte&IRMISC_IRRAIL) ? " irrail" : "",
@@ -274,7 +274,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
274 word = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK; 274 word = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
275 seq_printf(seq, "RCVBCNT: rx-fifo filling level = %u\n", word); 275 seq_printf(seq, "RCVBCNT: rx-fifo filling level = %u\n", word);
276 276
277 seq_printf(seq, "\nsw-state:\n"); 277 seq_puts(seq, "\nsw-state:\n");
278 seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud, 278 seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud,
279 (idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR")); 279 (idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR"));
280 sec = div_s64_rem(ktime_us_delta(ktime_get(), idev->last_rx), 280 sec = div_s64_rem(ktime_us_delta(ktime_get(), idev->last_rx),
@@ -305,10 +305,10 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r)
305 t = atomic_read(&r->tail) & r->mask; 305 t = atomic_read(&r->tail) & r->mask;
306 seq_printf(seq, "head = %d / tail = %d ", h, t); 306 seq_printf(seq, "head = %d / tail = %d ", h, t);
307 if (h == t) 307 if (h == t)
308 seq_printf(seq, "(empty)\n"); 308 seq_puts(seq, "(empty)\n");
309 else { 309 else {
310 if (((t+1)&r->mask) == h) 310 if (((t+1)&r->mask) == h)
311 seq_printf(seq, "(full)\n"); 311 seq_puts(seq, "(full)\n");
312 else 312 else
313 seq_printf(seq, "(level = %d)\n", ((unsigned)(t-h) & r->mask)); 313 seq_printf(seq, "(level = %d)\n", ((unsigned)(t-h) & r->mask));
314 rd = &r->rd[h]; 314 rd = &r->rd[h];
@@ -355,13 +355,13 @@ static int vlsi_seq_show(struct seq_file *seq, void *v)
355 seq_printf(seq, "\nPCI controller down - resume_ok = %d\n", 355 seq_printf(seq, "\nPCI controller down - resume_ok = %d\n",
356 idev->resume_ok); 356 idev->resume_ok);
357 if (netif_running(ndev) && idev->rx_ring && idev->tx_ring) { 357 if (netif_running(ndev) && idev->rx_ring && idev->tx_ring) {
358 seq_printf(seq, "\n--------- RX ring -----------\n\n"); 358 seq_puts(seq, "\n--------- RX ring -----------\n\n");
359 vlsi_proc_ring(seq, idev->rx_ring); 359 vlsi_proc_ring(seq, idev->rx_ring);
360 seq_printf(seq, "\n--------- TX ring -----------\n\n"); 360 seq_puts(seq, "\n--------- TX ring -----------\n\n");
361 vlsi_proc_ring(seq, idev->tx_ring); 361 vlsi_proc_ring(seq, idev->tx_ring);
362 } 362 }
363 } 363 }
364 seq_printf(seq, "\n"); 364 seq_putc(seq, '\n');
365 spin_unlock_irqrestore(&idev->lock, flags); 365 spin_unlock_irqrestore(&idev->lock, flags);
366 366
367 return 0; 367 return 0;
diff --git a/drivers/staging/irda/include/net/irda/irlmp_event.h b/drivers/staging/irda/include/net/irda/irlmp_event.h
index 9e4ec17a7449..a1a082fe384e 100644
--- a/drivers/staging/irda/include/net/irda/irlmp_event.h
+++ b/drivers/staging/irda/include/net/irda/irlmp_event.h
@@ -82,9 +82,9 @@ typedef enum {
82extern const char *const irlmp_state[]; 82extern const char *const irlmp_state[];
83extern const char *const irlsap_state[]; 83extern const char *const irlsap_state[];
84 84
85void irlmp_watchdog_timer_expired(void *data); 85void irlmp_watchdog_timer_expired(struct timer_list *t);
86void irlmp_discovery_timer_expired(void *data); 86void irlmp_discovery_timer_expired(struct timer_list *t);
87void irlmp_idle_timer_expired(void *data); 87void irlmp_idle_timer_expired(struct timer_list *t);
88 88
89void irlmp_do_lap_event(struct lap_cb *self, IRLMP_EVENT event, 89void irlmp_do_lap_event(struct lap_cb *self, IRLMP_EVENT event,
90 struct sk_buff *skb); 90 struct sk_buff *skb);
diff --git a/drivers/staging/irda/include/net/irda/qos.h b/drivers/staging/irda/include/net/irda/qos.h
index 05a5a249956f..a0315b50ac27 100644
--- a/drivers/staging/irda/include/net/irda/qos.h
+++ b/drivers/staging/irda/include/net/irda/qos.h
@@ -58,23 +58,23 @@
58#define IR_16000000 0x02 58#define IR_16000000 0x02
59 59
60/* Quality of Service information */ 60/* Quality of Service information */
61typedef struct { 61struct qos_value {
62 __u32 value; 62 __u32 value;
63 __u16 bits; /* LSB is first byte, MSB is second byte */ 63 __u16 bits; /* LSB is first byte, MSB is second byte */
64} qos_value_t; 64};
65 65
66struct qos_info { 66struct qos_info {
67 magic_t magic; 67 magic_t magic;
68 68
69 qos_value_t baud_rate; /* IR_11520O | ... */ 69 struct qos_value baud_rate; /* IR_11520O | ... */
70 qos_value_t max_turn_time; 70 struct qos_value max_turn_time;
71 qos_value_t data_size; 71 struct qos_value data_size;
72 qos_value_t window_size; 72 struct qos_value window_size;
73 qos_value_t additional_bofs; 73 struct qos_value additional_bofs;
74 qos_value_t min_turn_time; 74 struct qos_value min_turn_time;
75 qos_value_t link_disc_time; 75 struct qos_value link_disc_time;
76 76
77 qos_value_t power; 77 struct qos_value power;
78}; 78};
79 79
80extern int sysctl_max_baud_rate; 80extern int sysctl_max_baud_rate;
diff --git a/drivers/staging/irda/include/net/irda/timer.h b/drivers/staging/irda/include/net/irda/timer.h
index d784f242cf7b..a6635f0afae9 100644
--- a/drivers/staging/irda/include/net/irda/timer.h
+++ b/drivers/staging/irda/include/net/irda/timer.h
@@ -72,14 +72,11 @@ struct lap_cb;
72 72
73#define WATCHDOG_TIMEOUT (20*HZ) /* 20 sec */ 73#define WATCHDOG_TIMEOUT (20*HZ) /* 20 sec */
74 74
75typedef void (*TIMER_CALLBACK)(void *); 75static inline void irda_start_timer(struct timer_list *ptimer, int timeout,
76 76 void (*callback)(struct timer_list *))
77static inline void irda_start_timer(struct timer_list *ptimer, int timeout,
78 void* data, TIMER_CALLBACK callback)
79{ 77{
80 ptimer->function = (void (*)(unsigned long)) callback; 78 ptimer->function = (TIMER_FUNC_TYPE) callback;
81 ptimer->data = (unsigned long) data; 79
82
83 /* Set new value for timer (update or add timer). 80 /* Set new value for timer (update or add timer).
84 * We use mod_timer() because it's more efficient and also 81 * We use mod_timer() because it's more efficient and also
85 * safer with respect to race conditions - Jean II */ 82 * safer with respect to race conditions - Jean II */
diff --git a/drivers/staging/irda/net/af_irda.c b/drivers/staging/irda/net/af_irda.c
index 23fa7c8b09a5..b82a47b9ef0b 100644
--- a/drivers/staging/irda/net/af_irda.c
+++ b/drivers/staging/irda/net/af_irda.c
@@ -429,11 +429,11 @@ static void irda_selective_discovery_indication(discinfo_t *discovery,
429 * We were waiting for a node to be discovered, but nothing has come up 429 * We were waiting for a node to be discovered, but nothing has come up
430 * so far. Wake up the user and tell him that we failed... 430 * so far. Wake up the user and tell him that we failed...
431 */ 431 */
432static void irda_discovery_timeout(u_long priv) 432static void irda_discovery_timeout(struct timer_list *t)
433{ 433{
434 struct irda_sock *self; 434 struct irda_sock *self;
435 435
436 self = (struct irda_sock *) priv; 436 self = from_timer(self, t, watchdog);
437 BUG_ON(self == NULL); 437 BUG_ON(self == NULL);
438 438
439 /* Nothing for the caller */ 439 /* Nothing for the caller */
@@ -2505,8 +2505,7 @@ bed:
2505 2505
2506 /* Set watchdog timer to expire in <val> ms. */ 2506 /* Set watchdog timer to expire in <val> ms. */
2507 self->errno = 0; 2507 self->errno = 0;
2508 setup_timer(&self->watchdog, irda_discovery_timeout, 2508 timer_setup(&self->watchdog, irda_discovery_timeout, 0);
2509 (unsigned long)self);
2510 mod_timer(&self->watchdog, 2509 mod_timer(&self->watchdog,
2511 jiffies + msecs_to_jiffies(val)); 2510 jiffies + msecs_to_jiffies(val));
2512 2511
diff --git a/drivers/staging/irda/net/discovery.c b/drivers/staging/irda/net/discovery.c
index 364d70aed068..1e54954a4081 100644
--- a/drivers/staging/irda/net/discovery.c
+++ b/drivers/staging/irda/net/discovery.c
@@ -179,7 +179,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force)
179 /* Create the client specific buffer */ 179 /* Create the client specific buffer */
180 n = HASHBIN_GET_SIZE(log); 180 n = HASHBIN_GET_SIZE(log);
181 buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); 181 buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC);
182 if (buffer == NULL) { 182 if (!buffer) {
183 spin_unlock_irqrestore(&log->hb_spinlock, flags); 183 spin_unlock_irqrestore(&log->hb_spinlock, flags);
184 return; 184 return;
185 } 185 }
@@ -291,7 +291,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn,
291 /* Create the client specific buffer */ 291 /* Create the client specific buffer */
292 n = HASHBIN_GET_SIZE(log); 292 n = HASHBIN_GET_SIZE(log);
293 buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); 293 buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC);
294 if (buffer == NULL) { 294 if (!buffer) {
295 spin_unlock_irqrestore(&log->hb_spinlock, flags); 295 spin_unlock_irqrestore(&log->hb_spinlock, flags);
296 return NULL; 296 return NULL;
297 } 297 }
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c b/drivers/staging/irda/net/ircomm/ircomm_tty.c
index ec157c3419b5..473abfaffe7b 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
@@ -395,7 +395,7 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
395 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED; 395 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
396 396
397 /* Init some important stuff */ 397 /* Init some important stuff */
398 init_timer(&self->watchdog_timer); 398 timer_setup(&self->watchdog_timer, NULL, 0);
399 spin_lock_init(&self->spinlock); 399 spin_lock_init(&self->spinlock);
400 400
401 /* 401 /*
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c b/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
index 0a411019c098..e2d5ce8ba0db 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
@@ -52,7 +52,7 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
52 struct ias_value *value, void *priv); 52 struct ias_value *value, void *priv);
53static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self, 53static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
54 int timeout); 54 int timeout);
55static void ircomm_tty_watchdog_timer_expired(void *data); 55static void ircomm_tty_watchdog_timer_expired(struct timer_list *timer);
56 56
57static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, 57static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
58 IRCOMM_TTY_EVENT event, 58 IRCOMM_TTY_EVENT event,
@@ -587,7 +587,7 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
587 IRDA_ASSERT(self != NULL, return;); 587 IRDA_ASSERT(self != NULL, return;);
588 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 588 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
589 589
590 irda_start_timer(&self->watchdog_timer, timeout, (void *) self, 590 irda_start_timer(&self->watchdog_timer, timeout,
591 ircomm_tty_watchdog_timer_expired); 591 ircomm_tty_watchdog_timer_expired);
592} 592}
593 593
@@ -597,9 +597,9 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
597 * Called when the connect procedure have taken to much time. 597 * Called when the connect procedure have taken to much time.
598 * 598 *
599 */ 599 */
600static void ircomm_tty_watchdog_timer_expired(void *data) 600static void ircomm_tty_watchdog_timer_expired(struct timer_list *t)
601{ 601{
602 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data; 602 struct ircomm_tty_cb *self = from_timer(self, t, watchdog_timer);
603 603
604 IRDA_ASSERT(self != NULL, return;); 604 IRDA_ASSERT(self != NULL, return;);
605 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 605 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
diff --git a/drivers/staging/irda/net/irda_device.c b/drivers/staging/irda/net/irda_device.c
index 890b90d055d5..682b4eea15e0 100644
--- a/drivers/staging/irda/net/irda_device.c
+++ b/drivers/staging/irda/net/irda_device.c
@@ -54,29 +54,30 @@
54 54
55static void __irda_task_delete(struct irda_task *task); 55static void __irda_task_delete(struct irda_task *task);
56 56
57static hashbin_t *dongles = NULL; 57static hashbin_t *dongles;
58static hashbin_t *tasks = NULL; 58static hashbin_t *tasks;
59 59
60static void irda_task_timer_expired(void *data); 60static void irda_task_timer_expired(struct timer_list *timer);
61 61
62int __init irda_device_init( void) 62int __init irda_device_init(void)
63{ 63{
64 dongles = hashbin_new(HB_NOLOCK); 64 dongles = hashbin_new(HB_NOLOCK);
65 if (dongles == NULL) { 65 if (!dongles) {
66 net_warn_ratelimited("IrDA: Can't allocate dongles hashbin!\n"); 66 net_warn_ratelimited("IrDA: Can't allocate dongles hashbin!\n");
67 return -ENOMEM; 67 return -ENOMEM;
68 } 68 }
69 spin_lock_init(&dongles->hb_spinlock); 69 spin_lock_init(&dongles->hb_spinlock);
70 70
71 tasks = hashbin_new(HB_LOCK); 71 tasks = hashbin_new(HB_LOCK);
72 if (tasks == NULL) { 72 if (!tasks) {
73 net_warn_ratelimited("IrDA: Can't allocate tasks hashbin!\n"); 73 net_warn_ratelimited("IrDA: Can't allocate tasks hashbin!\n");
74 hashbin_delete(dongles, NULL); 74 hashbin_delete(dongles, NULL);
75 return -ENOMEM; 75 return -ENOMEM;
76 } 76 }
77 77
78 /* We no longer initialise the driver ourselves here, we let 78 /* We no longer initialise the driver ourselves here, we let
79 * the system do it for us... - Jean II */ 79 * the system do it for us... - Jean II
80 */
80 81
81 return 0; 82 return 0;
82} 83}
@@ -84,6 +85,7 @@ int __init irda_device_init( void)
84static void leftover_dongle(void *arg) 85static void leftover_dongle(void *arg)
85{ 86{
86 struct dongle_reg *reg = arg; 87 struct dongle_reg *reg = arg;
88
87 net_warn_ratelimited("IrDA: Dongle type %x not unregistered\n", 89 net_warn_ratelimited("IrDA: Dongle type %x not unregistered\n",
88 reg->type); 90 reg->type);
89} 91}
@@ -107,7 +109,7 @@ void irda_device_set_media_busy(struct net_device *dev, int status)
107 109
108 pr_debug("%s(%s)\n", __func__, status ? "TRUE" : "FALSE"); 110 pr_debug("%s(%s)\n", __func__, status ? "TRUE" : "FALSE");
109 111
110 self = (struct irlap_cb *) dev->atalk_ptr; 112 self = (struct irlap_cb *)dev->atalk_ptr;
111 113
112 /* Some drivers may enable the receive interrupt before calling 114 /* Some drivers may enable the receive interrupt before calling
113 * irlap_open(), or they may disable the receive interrupt 115 * irlap_open(), or they may disable the receive interrupt
@@ -115,7 +117,8 @@ void irda_device_set_media_busy(struct net_device *dev, int status)
115 * The IrDA stack is protected from this in irlap_driver_rcv(). 117 * The IrDA stack is protected from this in irlap_driver_rcv().
116 * However, the driver calls directly the wrapper, that calls 118 * However, the driver calls directly the wrapper, that calls
117 * us directly. Make sure we protect ourselves. 119 * us directly. Make sure we protect ourselves.
118 * Jean II */ 120 * Jean II
121 */
119 if (!self || self->magic != LAP_MAGIC) 122 if (!self || self->magic != LAP_MAGIC)
120 return; 123 return;
121 124
@@ -133,7 +136,6 @@ void irda_device_set_media_busy(struct net_device *dev, int status)
133} 136}
134EXPORT_SYMBOL(irda_device_set_media_busy); 137EXPORT_SYMBOL(irda_device_set_media_busy);
135 138
136
137/* 139/*
138 * Function irda_device_is_receiving (dev) 140 * Function irda_device_is_receiving (dev)
139 * 141 *
@@ -169,7 +171,7 @@ static void __irda_task_delete(struct irda_task *task)
169static void irda_task_delete(struct irda_task *task) 171static void irda_task_delete(struct irda_task *task)
170{ 172{
171 /* Unregister task */ 173 /* Unregister task */
172 hashbin_remove(tasks, (long) task, NULL); 174 hashbin_remove(tasks, (long)task, NULL);
173 175
174 __irda_task_delete(task); 176 __irda_task_delete(task);
175} 177}
@@ -231,7 +233,7 @@ static int irda_task_kick(struct irda_task *task)
231 } 233 }
232 irda_task_delete(task); 234 irda_task_delete(task);
233 } else if (timeout > 0) { 235 } else if (timeout > 0) {
234 irda_start_timer(&task->timer, timeout, (void *) task, 236 irda_start_timer(&task->timer, timeout,
235 irda_task_timer_expired); 237 irda_task_timer_expired);
236 finished = FALSE; 238 finished = FALSE;
237 } else { 239 } else {
@@ -249,11 +251,9 @@ static int irda_task_kick(struct irda_task *task)
249 * Task time has expired. We now try to execute task (again), and restart 251 * Task time has expired. We now try to execute task (again), and restart
250 * the timer if the task has not finished yet 252 * the timer if the task has not finished yet
251 */ 253 */
252static void irda_task_timer_expired(void *data) 254static void irda_task_timer_expired(struct timer_list *t)
253{ 255{
254 struct irda_task *task; 256 struct irda_task *task = from_timer(task, t, timer);
255
256 task = data;
257 257
258 irda_task_kick(task); 258 irda_task_kick(task);
259} 259}
@@ -280,8 +280,8 @@ static void irda_device_setup(struct net_device *dev)
280 280
281/* 281/*
282 * Funciton alloc_irdadev 282 * Funciton alloc_irdadev
283 * Allocates and sets up an IRDA device in a manner similar to 283 * Allocates and sets up an IRDA device in a manner similar to
284 * alloc_etherdev. 284 * alloc_etherdev.
285 */ 285 */
286struct net_device *alloc_irdadev(int sizeof_priv) 286struct net_device *alloc_irdadev(int sizeof_priv)
287{ 287{
diff --git a/drivers/staging/irda/net/iriap.c b/drivers/staging/irda/net/iriap.c
index 1138eaf5c682..d64192e9db8b 100644
--- a/drivers/staging/irda/net/iriap.c
+++ b/drivers/staging/irda/net/iriap.c
@@ -76,12 +76,12 @@ static void iriap_connect_confirm(void *instance, void *sap,
76static int iriap_data_indication(void *instance, void *sap, 76static int iriap_data_indication(void *instance, void *sap,
77 struct sk_buff *skb); 77 struct sk_buff *skb);
78 78
79static void iriap_watchdog_timer_expired(void *data); 79static void iriap_watchdog_timer_expired(struct timer_list *t);
80 80
81static inline void iriap_start_watchdog_timer(struct iriap_cb *self, 81static inline void iriap_start_watchdog_timer(struct iriap_cb *self,
82 int timeout) 82 int timeout)
83{ 83{
84 irda_start_timer(&self->watchdog_timer, timeout, self, 84 irda_start_timer(&self->watchdog_timer, timeout,
85 iriap_watchdog_timer_expired); 85 iriap_watchdog_timer_expired);
86} 86}
87 87
@@ -199,7 +199,7 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
199 * we connect, so this must have a sane value... Jean II */ 199 * we connect, so this must have a sane value... Jean II */
200 self->max_header_size = LMP_MAX_HEADER; 200 self->max_header_size = LMP_MAX_HEADER;
201 201
202 init_timer(&self->watchdog_timer); 202 timer_setup(&self->watchdog_timer, NULL, 0);
203 203
204 hashbin_insert(iriap, (irda_queue_t *) self, (long) self, NULL); 204 hashbin_insert(iriap, (irda_queue_t *) self, (long) self, NULL);
205 205
@@ -946,9 +946,9 @@ void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb)
946 * Query has taken too long time, so abort 946 * Query has taken too long time, so abort
947 * 947 *
948 */ 948 */
949static void iriap_watchdog_timer_expired(void *data) 949static void iriap_watchdog_timer_expired(struct timer_list *t)
950{ 950{
951 struct iriap_cb *self = (struct iriap_cb *) data; 951 struct iriap_cb *self = from_timer(self, t, watchdog_timer);
952 952
953 IRDA_ASSERT(self != NULL, return;); 953 IRDA_ASSERT(self != NULL, return;);
954 IRDA_ASSERT(self->magic == IAS_MAGIC, return;); 954 IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
diff --git a/drivers/staging/irda/net/irlan/irlan_client.c b/drivers/staging/irda/net/irlan/irlan_client.c
index c5837a40c78e..0b65e80849ae 100644
--- a/drivers/staging/irda/net/irlan/irlan_client.c
+++ b/drivers/staging/irda/net/irlan/irlan_client.c
@@ -68,9 +68,9 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
68 char *value, int val_len); 68 char *value, int val_len);
69static void irlan_client_open_ctrl_tsap(struct irlan_cb *self); 69static void irlan_client_open_ctrl_tsap(struct irlan_cb *self);
70 70
71static void irlan_client_kick_timer_expired(void *data) 71static void irlan_client_kick_timer_expired(struct timer_list *t)
72{ 72{
73 struct irlan_cb *self = (struct irlan_cb *) data; 73 struct irlan_cb *self = from_timer(self, t, client.kick_timer);
74 74
75 IRDA_ASSERT(self != NULL, return;); 75 IRDA_ASSERT(self != NULL, return;);
76 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 76 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@@ -89,7 +89,7 @@ static void irlan_client_kick_timer_expired(void *data)
89 89
90static void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout) 90static void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout)
91{ 91{
92 irda_start_timer(&self->client.kick_timer, timeout, (void *) self, 92 irda_start_timer(&self->client.kick_timer, timeout,
93 irlan_client_kick_timer_expired); 93 irlan_client_kick_timer_expired);
94} 94}
95 95
diff --git a/drivers/staging/irda/net/irlan/irlan_common.c b/drivers/staging/irda/net/irlan/irlan_common.c
index 481bbc2a4349..fdcd7147007d 100644
--- a/drivers/staging/irda/net/irlan/irlan_common.c
+++ b/drivers/staging/irda/net/irlan/irlan_common.c
@@ -228,8 +228,8 @@ static struct irlan_cb __init *irlan_open(__u32 saddr, __u32 daddr)
228 228
229 self->media = MEDIA_802_3; 229 self->media = MEDIA_802_3;
230 self->disconnect_reason = LM_USER_REQUEST; 230 self->disconnect_reason = LM_USER_REQUEST;
231 init_timer(&self->watchdog_timer); 231 timer_setup(&self->watchdog_timer, NULL, 0);
232 init_timer(&self->client.kick_timer); 232 timer_setup(&self->client.kick_timer, NULL, 0);
233 init_waitqueue_head(&self->open_wait); 233 init_waitqueue_head(&self->open_wait);
234 234
235 skb_queue_head_init(&self->client.txq); 235 skb_queue_head_init(&self->client.txq);
diff --git a/drivers/staging/irda/net/irlap.c b/drivers/staging/irda/net/irlap.c
index 1cde711bcab5..d7d894423b4f 100644
--- a/drivers/staging/irda/net/irlap.c
+++ b/drivers/staging/irda/net/irlap.c
@@ -148,14 +148,14 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
148 /* Copy to the driver */ 148 /* Copy to the driver */
149 memcpy(dev->dev_addr, &self->saddr, 4); 149 memcpy(dev->dev_addr, &self->saddr, 4);
150 150
151 init_timer(&self->slot_timer); 151 timer_setup(&self->slot_timer, NULL, 0);
152 init_timer(&self->query_timer); 152 timer_setup(&self->query_timer, NULL, 0);
153 init_timer(&self->discovery_timer); 153 timer_setup(&self->discovery_timer, NULL, 0);
154 init_timer(&self->final_timer); 154 timer_setup(&self->final_timer, NULL, 0);
155 init_timer(&self->poll_timer); 155 timer_setup(&self->poll_timer, NULL, 0);
156 init_timer(&self->wd_timer); 156 timer_setup(&self->wd_timer, NULL, 0);
157 init_timer(&self->backoff_timer); 157 timer_setup(&self->backoff_timer, NULL, 0);
158 init_timer(&self->media_busy_timer); 158 timer_setup(&self->media_busy_timer, NULL, 0);
159 159
160 irlap_apply_default_connection_parameters(self); 160 irlap_apply_default_connection_parameters(self);
161 161
diff --git a/drivers/staging/irda/net/irlap_event.c b/drivers/staging/irda/net/irlap_event.c
index 0e1b4d79f745..634188b07e0a 100644
--- a/drivers/staging/irda/net/irlap_event.c
+++ b/drivers/staging/irda/net/irlap_event.c
@@ -163,9 +163,9 @@ static int (*state[])(struct irlap_cb *self, IRLAP_EVENT event,
163 * Poll timer has expired. Normally we must now send a RR frame to the 163 * Poll timer has expired. Normally we must now send a RR frame to the
164 * remote device 164 * remote device
165 */ 165 */
166static void irlap_poll_timer_expired(void *data) 166static void irlap_poll_timer_expired(struct timer_list *t)
167{ 167{
168 struct irlap_cb *self = (struct irlap_cb *) data; 168 struct irlap_cb *self = from_timer(self, t, poll_timer);
169 169
170 IRDA_ASSERT(self != NULL, return;); 170 IRDA_ASSERT(self != NULL, return;);
171 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 171 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -222,7 +222,7 @@ static void irlap_start_poll_timer(struct irlap_cb *self, int timeout)
222 if (timeout == 0) 222 if (timeout == 0)
223 irlap_do_event(self, POLL_TIMER_EXPIRED, NULL, NULL); 223 irlap_do_event(self, POLL_TIMER_EXPIRED, NULL, NULL);
224 else 224 else
225 irda_start_timer(&self->poll_timer, timeout, self, 225 irda_start_timer(&self->poll_timer, timeout,
226 irlap_poll_timer_expired); 226 irlap_poll_timer_expired);
227} 227}
228 228
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 43964594aa12..34355061ab0b 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -109,7 +109,7 @@ int __init irlmp_init(void)
109 irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */ 109 irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */
110 strcpy(sysctl_devname, "Linux"); 110 strcpy(sysctl_devname, "Linux");
111 111
112 init_timer(&irlmp->discovery_timer); 112 timer_setup(&irlmp->discovery_timer, NULL, 0);
113 113
114 /* Do discovery every 3 seconds, conditionally */ 114 /* Do discovery every 3 seconds, conditionally */
115 if (sysctl_discovery) 115 if (sysctl_discovery)
@@ -185,7 +185,7 @@ struct lsap_cb *irlmp_open_lsap(__u8 slsap_sel, notify_t *notify, __u8 pid)
185 self->dlsap_sel = LSAP_ANY; 185 self->dlsap_sel = LSAP_ANY;
186 /* self->connected = FALSE; -> already NULL via memset() */ 186 /* self->connected = FALSE; -> already NULL via memset() */
187 187
188 init_timer(&self->watchdog_timer); 188 timer_setup(&self->watchdog_timer, NULL, 0);
189 189
190 self->notify = *notify; 190 self->notify = *notify;
191 191
@@ -311,7 +311,7 @@ void irlmp_register_link(struct irlap_cb *irlap, __u32 saddr, notify_t *notify)
311 311
312 lap->lap_state = LAP_STANDBY; 312 lap->lap_state = LAP_STANDBY;
313 313
314 init_timer(&lap->idle_timer); 314 timer_setup(&lap->idle_timer, NULL, 0);
315 315
316 /* 316 /*
317 * Insert into queue of LMP links 317 * Insert into queue of LMP links
@@ -655,7 +655,7 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
655 /* Not everything is the same */ 655 /* Not everything is the same */
656 new->notify.instance = instance; 656 new->notify.instance = instance;
657 657
658 init_timer(&new->watchdog_timer); 658 timer_setup(&new->watchdog_timer, NULL, 0);
659 659
660 hashbin_insert(irlmp->unconnected_lsaps, (irda_queue_t *) new, 660 hashbin_insert(irlmp->unconnected_lsaps, (irda_queue_t *) new,
661 (long) new, NULL); 661 (long) new, NULL);
diff --git a/drivers/staging/irda/net/irlmp_event.c b/drivers/staging/irda/net/irlmp_event.c
index e306cf2c1e04..ddad0994b6dc 100644
--- a/drivers/staging/irda/net/irlmp_event.c
+++ b/drivers/staging/irda/net/irlmp_event.c
@@ -165,7 +165,7 @@ void irlmp_do_lap_event(struct lap_cb *self, IRLMP_EVENT event,
165 (*lap_state[self->lap_state]) (self, event, skb); 165 (*lap_state[self->lap_state]) (self, event, skb);
166} 166}
167 167
168void irlmp_discovery_timer_expired(void *data) 168void irlmp_discovery_timer_expired(struct timer_list *t)
169{ 169{
170 /* We always cleanup the log (active & passive discovery) */ 170 /* We always cleanup the log (active & passive discovery) */
171 irlmp_do_expiry(); 171 irlmp_do_expiry();
@@ -176,9 +176,9 @@ void irlmp_discovery_timer_expired(void *data)
176 irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout * HZ); 176 irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout * HZ);
177} 177}
178 178
179void irlmp_watchdog_timer_expired(void *data) 179void irlmp_watchdog_timer_expired(struct timer_list *t)
180{ 180{
181 struct lsap_cb *self = (struct lsap_cb *) data; 181 struct lsap_cb *self = from_timer(self, t, watchdog_timer);
182 182
183 IRDA_ASSERT(self != NULL, return;); 183 IRDA_ASSERT(self != NULL, return;);
184 IRDA_ASSERT(self->magic == LMP_LSAP_MAGIC, return;); 184 IRDA_ASSERT(self->magic == LMP_LSAP_MAGIC, return;);
@@ -186,9 +186,9 @@ void irlmp_watchdog_timer_expired(void *data)
186 irlmp_do_lsap_event(self, LM_WATCHDOG_TIMEOUT, NULL); 186 irlmp_do_lsap_event(self, LM_WATCHDOG_TIMEOUT, NULL);
187} 187}
188 188
189void irlmp_idle_timer_expired(void *data) 189void irlmp_idle_timer_expired(struct timer_list *t)
190{ 190{
191 struct lap_cb *self = (struct lap_cb *) data; 191 struct lap_cb *self = from_timer(self, t, idle_timer);
192 192
193 IRDA_ASSERT(self != NULL, return;); 193 IRDA_ASSERT(self != NULL, return;);
194 IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;); 194 IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
diff --git a/drivers/staging/irda/net/irqueue.c b/drivers/staging/irda/net/irqueue.c
index 160dc89335e2..14291cbc4097 100644
--- a/drivers/staging/irda/net/irqueue.c
+++ b/drivers/staging/irda/net/irqueue.c
@@ -217,7 +217,8 @@ static __u32 hash( const char* name)
217 217
218 while(*name) { 218 while(*name) {
219 h = (h<<4) + *name++; 219 h = (h<<4) + *name++;
220 if ((g = (h & 0xf0000000))) 220 g = h & 0xf0000000;
221 if (g)
221 h ^=g>>24; 222 h ^=g>>24;
222 h &=~g; 223 h &=~g;
223 } 224 }
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/irda/net/irttp.c
index b6ab41d5b3a3..741a94f39b4e 100644
--- a/drivers/staging/irda/net/irttp.c
+++ b/drivers/staging/irda/net/irttp.c
@@ -62,7 +62,6 @@ static void irttp_run_rx_queue(struct tsap_cb *self);
62static void irttp_flush_queues(struct tsap_cb *self); 62static void irttp_flush_queues(struct tsap_cb *self);
63static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb); 63static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb);
64static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self); 64static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self);
65static void irttp_todo_expired(unsigned long data);
66static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, 65static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
67 int get); 66 int get);
68 67
@@ -160,9 +159,9 @@ static inline void irttp_start_todo_timer(struct tsap_cb *self, int timeout)
160 * killed (need user context), and we can't guarantee that here... 159 * killed (need user context), and we can't guarantee that here...
161 * Jean II 160 * Jean II
162 */ 161 */
163static void irttp_todo_expired(unsigned long data) 162static void irttp_todo_expired(struct timer_list *t)
164{ 163{
165 struct tsap_cb *self = (struct tsap_cb *) data; 164 struct tsap_cb *self = from_timer(self, t, todo_timer);
166 165
167 /* Check that we still exist */ 166 /* Check that we still exist */
168 if (!self || self->magic != TTP_TSAP_MAGIC) 167 if (!self || self->magic != TTP_TSAP_MAGIC)
@@ -374,7 +373,7 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
374static void irttp_init_tsap(struct tsap_cb *tsap) 373static void irttp_init_tsap(struct tsap_cb *tsap)
375{ 374{
376 spin_lock_init(&tsap->lock); 375 spin_lock_init(&tsap->lock);
377 init_timer(&tsap->todo_timer); 376 timer_setup(&tsap->todo_timer, irttp_todo_expired, 0);
378 377
379 skb_queue_head_init(&tsap->rx_queue); 378 skb_queue_head_init(&tsap->rx_queue);
380 skb_queue_head_init(&tsap->tx_queue); 379 skb_queue_head_init(&tsap->tx_queue);
@@ -410,10 +409,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
410 /* Initialize internal objects */ 409 /* Initialize internal objects */
411 irttp_init_tsap(self); 410 irttp_init_tsap(self);
412 411
413 /* Initialise todo timer */
414 self->todo_timer.data = (unsigned long) self;
415 self->todo_timer.function = &irttp_todo_expired;
416
417 /* Initialize callbacks for IrLMP to use */ 412 /* Initialize callbacks for IrLMP to use */
418 irda_notify_init(&ttp_notify); 413 irda_notify_init(&ttp_notify);
419 ttp_notify.connect_confirm = irttp_connect_confirm; 414 ttp_notify.connect_confirm = irttp_connect_confirm;
diff --git a/drivers/staging/irda/net/timer.c b/drivers/staging/irda/net/timer.c
index f2280f73b057..cf00c0d848aa 100644
--- a/drivers/staging/irda/net/timer.c
+++ b/drivers/staging/irda/net/timer.c
@@ -34,16 +34,16 @@
34 34
35extern int sysctl_slot_timeout; 35extern int sysctl_slot_timeout;
36 36
37static void irlap_slot_timer_expired(void* data); 37static void irlap_slot_timer_expired(struct timer_list *t);
38static void irlap_query_timer_expired(void* data); 38static void irlap_query_timer_expired(struct timer_list *t);
39static void irlap_final_timer_expired(void* data); 39static void irlap_final_timer_expired(struct timer_list *t);
40static void irlap_wd_timer_expired(void* data); 40static void irlap_wd_timer_expired(struct timer_list *t);
41static void irlap_backoff_timer_expired(void* data); 41static void irlap_backoff_timer_expired(struct timer_list *t);
42static void irlap_media_busy_expired(void* data); 42static void irlap_media_busy_expired(struct timer_list *t);
43 43
44void irlap_start_slot_timer(struct irlap_cb *self, int timeout) 44void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
45{ 45{
46 irda_start_timer(&self->slot_timer, timeout, (void *) self, 46 irda_start_timer(&self->slot_timer, timeout,
47 irlap_slot_timer_expired); 47 irlap_slot_timer_expired);
48} 48}
49 49
@@ -66,32 +66,32 @@ void irlap_start_query_timer(struct irlap_cb *self, int S, int s)
66 /* Set or re-set the timer. We reset the timer for each received 66 /* Set or re-set the timer. We reset the timer for each received
67 * discovery query, which allow us to automatically adjust to 67 * discovery query, which allow us to automatically adjust to
68 * the speed of the peer discovery (faster or slower). Jean II */ 68 * the speed of the peer discovery (faster or slower). Jean II */
69 irda_start_timer( &self->query_timer, timeout, (void *) self, 69 irda_start_timer(&self->query_timer, timeout,
70 irlap_query_timer_expired); 70 irlap_query_timer_expired);
71} 71}
72 72
73void irlap_start_final_timer(struct irlap_cb *self, int timeout) 73void irlap_start_final_timer(struct irlap_cb *self, int timeout)
74{ 74{
75 irda_start_timer(&self->final_timer, timeout, (void *) self, 75 irda_start_timer(&self->final_timer, timeout,
76 irlap_final_timer_expired); 76 irlap_final_timer_expired);
77} 77}
78 78
79void irlap_start_wd_timer(struct irlap_cb *self, int timeout) 79void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
80{ 80{
81 irda_start_timer(&self->wd_timer, timeout, (void *) self, 81 irda_start_timer(&self->wd_timer, timeout,
82 irlap_wd_timer_expired); 82 irlap_wd_timer_expired);
83} 83}
84 84
85void irlap_start_backoff_timer(struct irlap_cb *self, int timeout) 85void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
86{ 86{
87 irda_start_timer(&self->backoff_timer, timeout, (void *) self, 87 irda_start_timer(&self->backoff_timer, timeout,
88 irlap_backoff_timer_expired); 88 irlap_backoff_timer_expired);
89} 89}
90 90
91void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout) 91void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout)
92{ 92{
93 irda_start_timer(&self->media_busy_timer, timeout, 93 irda_start_timer(&self->media_busy_timer, timeout,
94 (void *) self, irlap_media_busy_expired); 94 irlap_media_busy_expired);
95} 95}
96 96
97void irlap_stop_mbusy_timer(struct irlap_cb *self) 97void irlap_stop_mbusy_timer(struct irlap_cb *self)
@@ -110,19 +110,19 @@ void irlap_stop_mbusy_timer(struct irlap_cb *self)
110 110
111void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) 111void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout)
112{ 112{
113 irda_start_timer(&self->watchdog_timer, timeout, (void *) self, 113 irda_start_timer(&self->watchdog_timer, timeout,
114 irlmp_watchdog_timer_expired); 114 irlmp_watchdog_timer_expired);
115} 115}
116 116
117void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) 117void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout)
118{ 118{
119 irda_start_timer(&self->discovery_timer, timeout, (void *) self, 119 irda_start_timer(&self->discovery_timer, timeout,
120 irlmp_discovery_timer_expired); 120 irlmp_discovery_timer_expired);
121} 121}
122 122
123void irlmp_start_idle_timer(struct lap_cb *self, int timeout) 123void irlmp_start_idle_timer(struct lap_cb *self, int timeout)
124{ 124{
125 irda_start_timer(&self->idle_timer, timeout, (void *) self, 125 irda_start_timer(&self->idle_timer, timeout,
126 irlmp_idle_timer_expired); 126 irlmp_idle_timer_expired);
127} 127}
128 128
@@ -138,9 +138,9 @@ void irlmp_stop_idle_timer(struct lap_cb *self)
138 * IrLAP slot timer has expired 138 * IrLAP slot timer has expired
139 * 139 *
140 */ 140 */
141static void irlap_slot_timer_expired(void *data) 141static void irlap_slot_timer_expired(struct timer_list *t)
142{ 142{
143 struct irlap_cb *self = (struct irlap_cb *) data; 143 struct irlap_cb *self = from_timer(self, t, slot_timer);
144 144
145 IRDA_ASSERT(self != NULL, return;); 145 IRDA_ASSERT(self != NULL, return;);
146 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 146 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -154,9 +154,9 @@ static void irlap_slot_timer_expired(void *data)
154 * IrLAP query timer has expired 154 * IrLAP query timer has expired
155 * 155 *
156 */ 156 */
157static void irlap_query_timer_expired(void *data) 157static void irlap_query_timer_expired(struct timer_list *t)
158{ 158{
159 struct irlap_cb *self = (struct irlap_cb *) data; 159 struct irlap_cb *self = from_timer(self, t, query_timer);
160 160
161 IRDA_ASSERT(self != NULL, return;); 161 IRDA_ASSERT(self != NULL, return;);
162 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 162 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -170,9 +170,9 @@ static void irlap_query_timer_expired(void *data)
170 * 170 *
171 * 171 *
172 */ 172 */
173static void irlap_final_timer_expired(void *data) 173static void irlap_final_timer_expired(struct timer_list *t)
174{ 174{
175 struct irlap_cb *self = (struct irlap_cb *) data; 175 struct irlap_cb *self = from_timer(self, t, final_timer);
176 176
177 IRDA_ASSERT(self != NULL, return;); 177 IRDA_ASSERT(self != NULL, return;);
178 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 178 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -186,9 +186,9 @@ static void irlap_final_timer_expired(void *data)
186 * 186 *
187 * 187 *
188 */ 188 */
189static void irlap_wd_timer_expired(void *data) 189static void irlap_wd_timer_expired(struct timer_list *t)
190{ 190{
191 struct irlap_cb *self = (struct irlap_cb *) data; 191 struct irlap_cb *self = from_timer(self, t, wd_timer);
192 192
193 IRDA_ASSERT(self != NULL, return;); 193 IRDA_ASSERT(self != NULL, return;);
194 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 194 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -202,9 +202,9 @@ static void irlap_wd_timer_expired(void *data)
202 * 202 *
203 * 203 *
204 */ 204 */
205static void irlap_backoff_timer_expired(void *data) 205static void irlap_backoff_timer_expired(struct timer_list *t)
206{ 206{
207 struct irlap_cb *self = (struct irlap_cb *) data; 207 struct irlap_cb *self = from_timer(self, t, backoff_timer);
208 208
209 IRDA_ASSERT(self != NULL, return;); 209 IRDA_ASSERT(self != NULL, return;);
210 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 210 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -218,9 +218,9 @@ static void irlap_backoff_timer_expired(void *data)
218 * 218 *
219 * 219 *
220 */ 220 */
221static void irlap_media_busy_expired(void *data) 221static void irlap_media_busy_expired(struct timer_list *t)
222{ 222{
223 struct irlap_cb *self = (struct irlap_cb *) data; 223 struct irlap_cb *self = from_timer(self, t, media_busy_timer);
224 224
225 IRDA_ASSERT(self != NULL, return;); 225 IRDA_ASSERT(self != NULL, return;);
226 226
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 0f9348ba5d84..880085e2f24a 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -114,7 +114,7 @@ int ks_wlan_update_phy_information(struct ks_wlan_private *priv)
114} 114}
115 115
116static 116static
117void ks_wlan_update_phyinfo_timeout(unsigned long ptr) 117void ks_wlan_update_phyinfo_timeout(struct timer_list *unused)
118{ 118{
119 DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); 119 DPRINTK(4, "in_interrupt = %ld\n", in_interrupt());
120 atomic_set(&update_phyinfo, 0); 120 atomic_set(&update_phyinfo, 0);
@@ -473,13 +473,16 @@ static int ks_wlan_set_rate(struct net_device *dev,
473 priv->reg.rate_set.body[3] = 473 priv->reg.rate_set.body[3] =
474 TX_RATE_11M; 474 TX_RATE_11M;
475 i++; 475 i++;
476 /* fall through */
476 case 5500000: 477 case 5500000:
477 priv->reg.rate_set.body[2] = TX_RATE_5M; 478 priv->reg.rate_set.body[2] = TX_RATE_5M;
478 i++; 479 i++;
480 /* fall through */
479 case 2000000: 481 case 2000000:
480 priv->reg.rate_set.body[1] = 482 priv->reg.rate_set.body[1] =
481 TX_RATE_2M | BASIC_RATE; 483 TX_RATE_2M | BASIC_RATE;
482 i++; 484 i++;
485 /* fall through */
483 case 1000000: 486 case 1000000:
484 priv->reg.rate_set.body[0] = 487 priv->reg.rate_set.body[0] =
485 TX_RATE_1M | BASIC_RATE; 488 TX_RATE_1M | BASIC_RATE;
@@ -535,14 +538,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
535 priv->reg.rate_set.body[11] = 538 priv->reg.rate_set.body[11] =
536 TX_RATE_54M; 539 TX_RATE_54M;
537 i++; 540 i++;
541 /* fall through */
538 case 48000000: 542 case 48000000:
539 priv->reg.rate_set.body[10] = 543 priv->reg.rate_set.body[10] =
540 TX_RATE_48M; 544 TX_RATE_48M;
541 i++; 545 i++;
546 /* fall through */
542 case 36000000: 547 case 36000000:
543 priv->reg.rate_set.body[9] = 548 priv->reg.rate_set.body[9] =
544 TX_RATE_36M; 549 TX_RATE_36M;
545 i++; 550 i++;
551 /* fall through */
546 case 24000000: 552 case 24000000:
547 case 18000000: 553 case 18000000:
548 case 12000000: 554 case 12000000:
@@ -619,14 +625,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
619 TX_RATE_6M | BASIC_RATE; 625 TX_RATE_6M | BASIC_RATE;
620 i++; 626 i++;
621 } 627 }
628 /* fall through */
622 case 5500000: 629 case 5500000:
623 priv->reg.rate_set.body[2] = 630 priv->reg.rate_set.body[2] =
624 TX_RATE_5M | BASIC_RATE; 631 TX_RATE_5M | BASIC_RATE;
625 i++; 632 i++;
633 /* fall through */
626 case 2000000: 634 case 2000000:
627 priv->reg.rate_set.body[1] = 635 priv->reg.rate_set.body[1] =
628 TX_RATE_2M | BASIC_RATE; 636 TX_RATE_2M | BASIC_RATE;
629 i++; 637 i++;
638 /* fall through */
630 case 1000000: 639 case 1000000:
631 priv->reg.rate_set.body[0] = 640 priv->reg.rate_set.body[0] =
632 TX_RATE_1M | BASIC_RATE; 641 TX_RATE_1M | BASIC_RATE;
@@ -2010,6 +2019,7 @@ static int ks_wlan_set_mlme(struct net_device *dev,
2010 case IW_MLME_DEAUTH: 2019 case IW_MLME_DEAUTH:
2011 if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) 2020 if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
2012 return 0; 2021 return 0;
2022 /* fall through */
2013 case IW_MLME_DISASSOC: 2023 case IW_MLME_DISASSOC:
2014 mode = 1; 2024 mode = 1;
2015 return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); 2025 return ks_wlan_set_stop_request(dev, NULL, &mode, NULL);
@@ -2941,8 +2951,7 @@ int ks_wlan_net_start(struct net_device *dev)
2941 2951
2942 /* phy information update timer */ 2952 /* phy information update timer */
2943 atomic_set(&update_phyinfo, 0); 2953 atomic_set(&update_phyinfo, 0);
2944 setup_timer(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 2954 timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
2945 (unsigned long)priv);
2946 2955
2947 /* dummy address set */ 2956 /* dummy address set */
2948 memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); 2957 memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 1ea27c9e3708..3cb3f086148e 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index b48e2f093bcc..6ad8867e5451 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 6d8752a368fa..6d132f941281 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index 3f773a4a344b..e5c156e9d907 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* GPL HEADER START 2/* GPL HEADER START
2 * 3 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index e7c37415a0c7..1b98f0953afb 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index fedb46dff696..d6fc3164e7e7 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index 0cc2fc465c1a..5a27220cc608 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
index 8c75d5075590..d4c5965c43b1 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index 709771d27f89..2f4ff595fac9 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 41795d9b3b9b..1191764c431a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 008da4497bda..9699646decb9 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h
index 2accd9a85472..fc780f608e57 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index fa0808d2953b..30e333af8d0d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index dd0cd0442b86..854c84358ab4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 709e1ce98d8d..aece13698eb4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h
index 9c37f3e4b134..31fcd33171b4 100644
--- a/drivers/staging/lustre/include/linux/lnet/api.h
+++ b/drivers/staging/lustre/include/linux/lnet/api.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index e0968ab8d95e..c1626726fa05 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index eea3b8e5e406..cfe8ee424e94 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -160,9 +161,9 @@ struct lnet_libmd {
160 } md_iov; 161 } md_iov;
161}; 162};
162 163
163#define LNET_MD_FLAG_ZOMBIE (1 << 0) 164#define LNET_MD_FLAG_ZOMBIE BIT(0)
164#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) 165#define LNET_MD_FLAG_AUTO_UNLINK BIT(1)
165#define LNET_MD_FLAG_ABORTED (1 << 2) 166#define LNET_MD_FLAG_ABORTED BIT(2)
166 167
167struct lnet_test_peer { 168struct lnet_test_peer {
168 /* info about peers we are trying to fail */ 169 /* info about peers we are trying to fail */
@@ -287,9 +288,9 @@ struct lnet_ni {
287 * of old LNet, so there shouldn't be any compatibility issue 288 * of old LNet, so there shouldn't be any compatibility issue
288 */ 289 */
289#define LNET_PING_FEAT_INVAL (0) /* no feature */ 290#define LNET_PING_FEAT_INVAL (0) /* no feature */
290#define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */ 291#define LNET_PING_FEAT_BASE BIT(0) /* just a ping */
291#define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */ 292#define LNET_PING_FEAT_NI_STATUS BIT(1) /* return NI status */
292#define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */ 293#define LNET_PING_FEAT_RTE_DISABLED BIT(2) /* Routing enabled */
293 294
294#define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \ 295#define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \
295 LNET_PING_FEAT_NI_STATUS) 296 LNET_PING_FEAT_NI_STATUS)
@@ -440,23 +441,21 @@ struct lnet_rtrbuf {
440 441
441enum lnet_match_flags { 442enum lnet_match_flags {
442 /* Didn't match anything */ 443 /* Didn't match anything */
443 LNET_MATCHMD_NONE = (1 << 0), 444 LNET_MATCHMD_NONE = BIT(0),
444 /* Matched OK */ 445 /* Matched OK */
445 LNET_MATCHMD_OK = (1 << 1), 446 LNET_MATCHMD_OK = BIT(1),
446 /* Must be discarded */ 447 /* Must be discarded */
447 LNET_MATCHMD_DROP = (1 << 2), 448 LNET_MATCHMD_DROP = BIT(2),
448 /* match and buffer is exhausted */ 449 /* match and buffer is exhausted */
449 LNET_MATCHMD_EXHAUSTED = (1 << 3), 450 LNET_MATCHMD_EXHAUSTED = BIT(3),
450 /* match or drop */ 451 /* match or drop */
451 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP), 452 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
452}; 453};
453 454
454/* Options for lnet_portal::ptl_options */ 455/* Options for lnet_portal::ptl_options */
455#define LNET_PTL_LAZY (1 << 0) 456#define LNET_PTL_LAZY BIT(0)
456#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */ 457#define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */
457#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, 458#define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */
458 * request portal
459 */
460 459
461/* parameter for matching operations (GET, PUT) */ 460/* parameter for matching operations (GET, PUT) */
462struct lnet_match_info { 461struct lnet_match_info {
diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h
index 553fb64b3e80..6bd1bca190a3 100644
--- a/drivers/staging/lustre/include/linux/lnet/socklnd.h
+++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 64763aacda57..8024843521ab 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index a1e994a1cc84..171eced213f8 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 8fc191d99927..40e3af5d8b04 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index 3fe4d4858eba..a71b765215ad 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index fbbd8a5489e9..f8ea523863ba 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -176,12 +177,9 @@ struct ksock_peer *
176ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id) 177ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id)
177{ 178{
178 struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); 179 struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
179 struct list_head *tmp;
180 struct ksock_peer *peer; 180 struct ksock_peer *peer;
181 181
182 list_for_each(tmp, peer_list) { 182 list_for_each_entry(peer, peer_list, ksnp_list) {
183 peer = list_entry(tmp, struct ksock_peer, ksnp_list);
184
185 LASSERT(!peer->ksnp_closing); 183 LASSERT(!peer->ksnp_closing);
186 184
187 if (peer->ksnp_ni != ni) 185 if (peer->ksnp_ni != ni)
@@ -453,7 +451,6 @@ int
453ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr, 451ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
454 int port) 452 int port)
455{ 453{
456 struct list_head *tmp;
457 struct ksock_peer *peer; 454 struct ksock_peer *peer;
458 struct ksock_peer *peer2; 455 struct ksock_peer *peer2;
459 struct ksock_route *route; 456 struct ksock_route *route;
@@ -491,9 +488,7 @@ ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
491 } 488 }
492 489
493 route2 = NULL; 490 route2 = NULL;
494 list_for_each(tmp, &peer->ksnp_routes) { 491 list_for_each_entry(route2, &peer->ksnp_routes, ksnr_list) {
495 route2 = list_entry(tmp, struct ksock_route, ksnr_list);
496
497 if (route2->ksnr_ipaddr == ipaddr) 492 if (route2->ksnr_ipaddr == ipaddr)
498 break; 493 break;
499 494
@@ -1854,12 +1849,10 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
1854 1849
1855 peer = ksocknal_find_peer_locked(ni, id); 1850 peer = ksocknal_find_peer_locked(ni, id);
1856 if (peer) { 1851 if (peer) {
1857 struct list_head *tmp;
1858 struct ksock_conn *conn; 1852 struct ksock_conn *conn;
1859 int bufnob; 1853 int bufnob;
1860 1854
1861 list_for_each(tmp, &peer->ksnp_conns) { 1855 list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) {
1862 conn = list_entry(tmp, struct ksock_conn, ksnc_list);
1863 bufnob = conn->ksnc_sock->sk->sk_wmem_queued; 1856 bufnob = conn->ksnc_sock->sk->sk_wmem_queued;
1864 1857
1865 if (bufnob < conn->ksnc_tx_bufnob) { 1858 if (bufnob < conn->ksnc_tx_bufnob) {
@@ -2316,7 +2309,7 @@ ksocknal_base_shutdown(void)
2316 switch (ksocknal_data.ksnd_init) { 2309 switch (ksocknal_data.ksnd_init) {
2317 default: 2310 default:
2318 LASSERT(0); 2311 LASSERT(0);
2319 2312 /* fall through */
2320 case SOCKNAL_INIT_ALL: 2313 case SOCKNAL_INIT_ALL:
2321 case SOCKNAL_INIT_DATA: 2314 case SOCKNAL_INIT_DATA:
2322 LASSERT(ksocknal_data.ksnd_peers); 2315 LASSERT(ksocknal_data.ksnd_peers);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index e6428c4b7aec..35a7b396def4 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 6b38d5a8fe92..a5f2ecb966fa 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index 9c328dc6537b..970140f09258 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
index fc7eec83ac07..5663a4ca94d4 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
index 84be9a518190..d827f770e831 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
index 1ab394c1fabc..551c45bf4108 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c b/drivers/staging/lustre/lnet/libcfs/fail.c
index 24f4701a7a1e..5d501beeb622 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c
index 49a04a2b4ec4..f4f67d2b301e 100644
--- a/drivers/staging/lustre/lnet/libcfs/hash.c
+++ b/drivers/staging/lustre/lnet/libcfs/hash.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 2ddd09a83cd0..e3a4c67a66b5 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
index 77fd3d06cde9..f6a0040f4ab1 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c b/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
index 1a0c7cad5983..df93d8f77ea2 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
index 333e47febf87..bcac5074bf80 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 2da051c0d251..51823ce71773 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
index db0572733712..2e5d311d2438 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* GPL HEADER START 2/* GPL HEADER START
2 * 3 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
index 55663390b608..80072b2a443c 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* GPL HEADER START 2/* GPL HEADER START
2 * 3 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
index d0b3aa80cfa6..5616e9ea1450 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c
index 528d49794881..1d8949f1a4fa 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
index 972677bdf6bc..0092166af258 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
index 3f5dec153571..963df0ef4afb 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This program is free software; you can redistribute it and/or modify 3 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 only, 4 * it under the terms of the GNU General Public License version 2 only,
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index 435722175cce..b5746230ab31 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c
index 4e331e71083d..6f92ea272186 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
index 16a3ae791bb6..7928d7182634 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 6aed98fc9688..4ead55920e79 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/prng.c b/drivers/staging/lustre/lnet/libcfs/prng.c
index 963ef4ae93b1..f47cf67a92e3 100644
--- a/drivers/staging/lustre/lnet/libcfs/prng.c
+++ b/drivers/staging/lustre/lnet/libcfs/prng.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index f916b475e767..da2844f37edf 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index c3547cd4c72c..a29d6eb3a785 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c
index 038ed8c52107..6a05d9bab8dc 100644
--- a/drivers/staging/lustre/lnet/libcfs/workitem.c
+++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index be2823f8eb02..ee85cab6f437 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index ad835035fffa..7caff290c146 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 26841a7b6213..0cf0f4f99435 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c
index 6b446a51eeac..daf744277003 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index a0aef4b9bce3..ac5b9593d597 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c
index f52a5e8ed386..dd5d3cf6d3e2 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-me.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-me.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index bc0779c02d97..27848cd69564 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
index d04875e3956f..c72ef05b2420 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 5946848a7846..8ae93bf6fd1b 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 7d0add0c0de3..539a26444f31 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c
index 80c06f4b0c8d..7456b989e451 100644
--- a/drivers/staging/lustre/lnet/lnet/lo.c
+++ b/drivers/staging/lustre/lnet/lnet/lo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
index 7d12a7fb36a4..c0c4723f72fd 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 03f3d18a1a29..3c83aa31e2c2 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -629,6 +630,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
629 case LNET_CREDIT_OK: 630 case LNET_CREDIT_OK:
630 lnet_ni_recv(ni, msg->msg_private, msg, 0, 631 lnet_ni_recv(ni, msg->msg_private, msg, 0,
631 0, msg->msg_len, msg->msg_len); 632 0, msg->msg_len, msg->msg_len);
633 /* fall through */
632 case LNET_CREDIT_WAIT: 634 case LNET_CREDIT_WAIT:
633 continue; 635 continue;
634 default: /* failures */ 636 default: /* failures */
diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c
index 7bd1e6f389aa..05b120c2d45a 100644
--- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
+++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 4d55df8ff74e..5e94ad349454 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 3df101bafd9f..88283ca3f860 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
@@ -222,15 +223,12 @@ struct lnet_remotenet *
222lnet_find_net_locked(__u32 net) 223lnet_find_net_locked(__u32 net)
223{ 224{
224 struct lnet_remotenet *rnet; 225 struct lnet_remotenet *rnet;
225 struct list_head *tmp;
226 struct list_head *rn_list; 226 struct list_head *rn_list;
227 227
228 LASSERT(!the_lnet.ln_shutdown); 228 LASSERT(!the_lnet.ln_shutdown);
229 229
230 rn_list = lnet_net2rnethash(net); 230 rn_list = lnet_net2rnethash(net);
231 list_for_each(tmp, rn_list) { 231 list_for_each_entry(rnet, rn_list, lrn_list) {
232 rnet = list_entry(tmp, struct lnet_remotenet, lrn_list);
233
234 if (rnet->lrn_net == net) 232 if (rnet->lrn_net == net)
235 return rnet; 233 return rnet;
236 } 234 }
@@ -243,7 +241,6 @@ static void lnet_shuffle_seed(void)
243 __u32 lnd_type, seed[2]; 241 __u32 lnd_type, seed[2];
244 struct timespec64 ts; 242 struct timespec64 ts;
245 struct lnet_ni *ni; 243 struct lnet_ni *ni;
246 struct list_head *tmp;
247 244
248 if (seeded) 245 if (seeded)
249 return; 246 return;
@@ -254,8 +251,7 @@ static void lnet_shuffle_seed(void)
254 * Nodes with small feet have little entropy 251 * Nodes with small feet have little entropy
255 * the NID for this node gives the most entropy in the low bits 252 * the NID for this node gives the most entropy in the low bits
256 */ 253 */
257 list_for_each(tmp, &the_lnet.ln_nis) { 254 list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
258 ni = list_entry(tmp, struct lnet_ni, ni_list);
259 lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); 255 lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid));
260 256
261 if (lnd_type != LOLND) 257 if (lnd_type != LOLND)
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 4a994d113c7d..d32d653edcb0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
index f8b9175f08d4..f1ee219bc8f3 100644
--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c
index 9619ecbf8bdf..082c0afacf23 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -151,6 +152,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
151 152
152 case LST_OPC_BATCHSRV: 153 case LST_OPC_BATCHSRV:
153 client = 0; 154 client = 0;
155 /* fall through */
154 case LST_OPC_BATCHCLI: 156 case LST_OPC_BATCHCLI:
155 if (!name) 157 if (!name)
156 goto out; 158 goto out;
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 196d23c10921..6a0f770e0e24 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h
index 239323679baa..374a5f31ef6f 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 289b202c3b36..a2662638d599 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h
index 143eae9b8d71..3933ed4cca93 100644
--- a/drivers/staging/lustre/lnet/selftest/console.h
+++ b/drivers/staging/lustre/lnet/selftest/console.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index ef27bfffc230..fe889607ff3f 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c
index b5d556fa48ab..1d44d912f014 100644
--- a/drivers/staging/lustre/lnet/selftest/module.c
+++ b/drivers/staging/lustre/lnet/selftest/module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -57,10 +58,13 @@ lnet_selftest_exit(void)
57 switch (lst_init_step) { 58 switch (lst_init_step) {
58 case LST_INIT_CONSOLE: 59 case LST_INIT_CONSOLE:
59 lstcon_console_fini(); 60 lstcon_console_fini();
61 /* fall through */
60 case LST_INIT_FW: 62 case LST_INIT_FW:
61 sfw_shutdown(); 63 sfw_shutdown();
64 /* fall through */
62 case LST_INIT_RPC: 65 case LST_INIT_RPC:
63 srpc_shutdown(); 66 srpc_shutdown();
67 /* fall through */
64 case LST_INIT_WI_TEST: 68 case LST_INIT_WI_TEST:
65 for (i = 0; 69 for (i = 0;
66 i < cfs_cpt_number(lnet_cpt_table()); i++) { 70 i < cfs_cpt_number(lnet_cpt_table()); i++) {
@@ -72,7 +76,7 @@ lnet_selftest_exit(void)
72 sizeof(lst_sched_test[0]) * 76 sizeof(lst_sched_test[0]) *
73 cfs_cpt_number(lnet_cpt_table())); 77 cfs_cpt_number(lnet_cpt_table()));
74 lst_sched_test = NULL; 78 lst_sched_test = NULL;
75 79 /* fall through */
76 case LST_INIT_WI_SERIAL: 80 case LST_INIT_WI_SERIAL:
77 cfs_wi_sched_destroy(lst_sched_serial); 81 cfs_wi_sched_destroy(lst_sched_serial);
78 lst_sched_serial = NULL; 82 lst_sched_serial = NULL;
diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
index 9653ac6fd619..f54bd630dbf8 100644
--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c
index 77c222cca230..ab7e8a8e58b8 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1037,6 +1038,7 @@ srpc_handle_rpc(struct swi_workitem *wi)
1037 ev->ev_status = rc; 1038 ev->ev_status = rc;
1038 } 1039 }
1039 } 1040 }
1041 /* fall through */
1040 case SWI_STATE_BULK_STARTED: 1042 case SWI_STATE_BULK_STARTED:
1041 LASSERT(!rpc->srpc_bulk || ev->ev_fired); 1043 LASSERT(!rpc->srpc_bulk || ev->ev_fired);
1042 1044
@@ -1237,7 +1239,8 @@ srpc_send_rpc(struct swi_workitem *wi)
1237 break; 1239 break;
1238 1240
1239 wi->swi_state = SWI_STATE_REQUEST_SENT; 1241 wi->swi_state = SWI_STATE_REQUEST_SENT;
1240 /* perhaps more events, fall thru */ 1242 /* perhaps more events */
1243 /* fall through */
1241 case SWI_STATE_REQUEST_SENT: { 1244 case SWI_STATE_REQUEST_SENT: {
1242 enum srpc_msg_type type = srpc_service2reply(rpc->crpc_service); 1245 enum srpc_msg_type type = srpc_service2reply(rpc->crpc_service);
1243 1246
@@ -1269,6 +1272,7 @@ srpc_send_rpc(struct swi_workitem *wi)
1269 1272
1270 wi->swi_state = SWI_STATE_REPLY_RECEIVED; 1273 wi->swi_state = SWI_STATE_REPLY_RECEIVED;
1271 } 1274 }
1275 /* fall through */
1272 case SWI_STATE_REPLY_RECEIVED: 1276 case SWI_STATE_REPLY_RECEIVED:
1273 if (do_bulk && !rpc->crpc_bulkev.ev_fired) 1277 if (do_bulk && !rpc->crpc_bulkev.ev_fired)
1274 break; 1278 break;
@@ -1448,6 +1452,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
1448 srpc_data.rpc_counters.rpcs_sent++; 1452 srpc_data.rpc_counters.rpcs_sent++;
1449 spin_unlock(&srpc_data.rpc_glock); 1453 spin_unlock(&srpc_data.rpc_glock);
1450 } 1454 }
1455 /* fall through */
1451 case SRPC_REPLY_RCVD: 1456 case SRPC_REPLY_RCVD:
1452 case SRPC_BULK_REQ_RCVD: 1457 case SRPC_BULK_REQ_RCVD:
1453 crpc = rpcev->ev_data; 1458 crpc = rpcev->ev_data;
@@ -1570,7 +1575,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
1570 1575
1571 if (!ev->unlinked) 1576 if (!ev->unlinked)
1572 break; /* wait for final event */ 1577 break; /* wait for final event */
1573 1578 /* fall through */
1574 case SRPC_BULK_PUT_SENT: 1579 case SRPC_BULK_PUT_SENT:
1575 if (!ev->status && ev->type != LNET_EVENT_UNLINK) { 1580 if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
1576 spin_lock(&srpc_data.rpc_glock); 1581 spin_lock(&srpc_data.rpc_glock);
@@ -1582,6 +1587,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
1582 1587
1583 spin_unlock(&srpc_data.rpc_glock); 1588 spin_unlock(&srpc_data.rpc_glock);
1584 } 1589 }
1590 /* fall through */
1585 case SRPC_REPLY_SENT: 1591 case SRPC_REPLY_SENT:
1586 srpc = rpcev->ev_data; 1592 srpc = rpcev->ev_data;
1587 scd = srpc->srpc_scd; 1593 scd = srpc->srpc_scd;
@@ -1674,14 +1680,14 @@ srpc_shutdown(void)
1674 spin_unlock(&srpc_data.rpc_glock); 1680 spin_unlock(&srpc_data.rpc_glock);
1675 1681
1676 stt_shutdown(); 1682 stt_shutdown();
1677 1683 /* fall through */
1678 case SRPC_STATE_EQ_INIT: 1684 case SRPC_STATE_EQ_INIT:
1679 rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL); 1685 rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
1680 rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL); 1686 rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
1681 LASSERT(!rc); 1687 LASSERT(!rc);
1682 rc = LNetEQFree(srpc_data.rpc_lnet_eq); 1688 rc = LNetEQFree(srpc_data.rpc_lnet_eq);
1683 LASSERT(!rc); /* the EQ should have no user by now */ 1689 LASSERT(!rc); /* the EQ should have no user by now */
1684 1690 /* fall through */
1685 case SRPC_STATE_NI_INIT: 1691 case SRPC_STATE_NI_INIT:
1686 LNetNIFini(); 1692 LNetNIFini();
1687 } 1693 }
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h
index 7bb442a8e698..465b5b534423 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.h
+++ b/drivers/staging/lustre/lnet/selftest/rpc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
index 7adad4302dcf..8c10f0f149d5 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 2fe692df19d0..ab125a8524c5 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h
index 441d6d6b4f8e..7f0ef9bd0cda 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.h
+++ b/drivers/staging/lustre/lnet/selftest/timer.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h
index f48ab9d21428..b7b8f900df8e 100644
--- a/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c
index c21a5f5b7621..9577da33e666 100644
--- a/drivers/staging/lustre/lustre/fid/fid_lib.c
+++ b/drivers/staging/lustre/lustre/fid/fid_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c
index ba736239243c..009c2367f74e 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -279,7 +280,8 @@ int seq_client_alloc_fid(const struct lu_env *env,
279 *fid = seq->lcs_fid; 280 *fid = seq->lcs_fid;
280 mutex_unlock(&seq->lcs_mutex); 281 mutex_unlock(&seq->lcs_mutex);
281 282
282 CDEBUG(D_INFO, "%s: Allocated FID " DFID "\n", seq->lcs_name, PFID(fid)); 283 CDEBUG(D_INFO,
284 "%s: Allocated FID " DFID "\n", seq->lcs_name, PFID(fid));
283 return rc; 285 return rc;
284} 286}
285EXPORT_SYMBOL(seq_client_alloc_fid); 287EXPORT_SYMBOL(seq_client_alloc_fid);
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 1a269fbc4b47..083419f77697 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index b723ece02eff..7d6a7106c0a5 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h
index fe6f278a7d9f..b5e3abaa508a 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
index 5b180830eec0..068c364adda8 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -425,7 +426,8 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds,
425 target = fld_client_get_target(fld, seq); 426 target = fld_client_get_target(fld, seq);
426 LASSERT(target); 427 LASSERT(target);
427 428
428 CDEBUG(D_INFO, "%s: Lookup fld entry (seq: %#llx) on target %s (idx %llu)\n", 429 CDEBUG(D_INFO,
430 "%s: Lookup fld entry (seq: %#llx) on target %s (idx %llu)\n",
429 fld->lcf_name, seq, fld_target_name(target), target->ft_idx); 431 fld->lcf_name, seq, fld_target_name(target), target->ft_idx);
430 432
431 res.lsr_start = seq; 433 res.lsr_start = seq;
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 6cae803fc8d2..1a6a76110c3e 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 9ba184b6017f..90419dca2e1e 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h
index a4d7280e1fa4..7d119c1a0469 100644
--- a/drivers/staging/lustre/lustre/include/interval_tree.h
+++ b/drivers/staging/lustre/lustre/include/interval_tree.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/llog_swab.h b/drivers/staging/lustre/lustre/include/llog_swab.h
index 925271db4554..0433b79efdcb 100644
--- a/drivers/staging/lustre/lustre/include/llog_swab.h
+++ b/drivers/staging/lustre/lustre/include/llog_swab.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 98d6b1364c21..835a729dd8d0 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 4f213c408cfa..34e35fbff978 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1130,7 +1131,7 @@ struct lu_context_key {
1130 { \ 1131 { \
1131 type *value; \ 1132 type *value; \
1132 \ 1133 \
1133 BUILD_BUG_ON(PAGE_SIZE < sizeof(*value)); \ 1134 BUILD_BUG_ON(sizeof(*value) > PAGE_SIZE); \
1134 \ 1135 \
1135 value = kzalloc(sizeof(*value), GFP_NOFS); \ 1136 value = kzalloc(sizeof(*value), GFP_NOFS); \
1136 if (!value) \ 1137 if (!value) \
@@ -1303,8 +1304,6 @@ struct lu_buf {
1303 size_t lb_len; 1304 size_t lb_len;
1304}; 1305};
1305 1306
1306#define DLUBUF "(%p %zu)"
1307#define PLUBUF(buf) (buf)->lb_buf, (buf)->lb_len
1308/** 1307/**
1309 * One-time initializers, called at obdclass module initialization, not 1308 * One-time initializers, called at obdclass module initialization, not
1310 * exported. 1309 * exported.
diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h
index f7dfd83951ee..ad0c24d29ffa 100644
--- a/drivers/staging/lustre/lustre/include/lu_ref.h
+++ b/drivers/staging/lustre/lustre/include/lu_ref.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
3 * Use is subject to license terms. 4 * Use is subject to license terms.
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h
index 9786f6caaade..35ff61ce4e9d 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 69bfd6a6e0f9..9f488e605083 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h
index 0be6a534f712..721a81f923e3 100644
--- a/drivers/staging/lustre/lustre/include/lustre_debug.h
+++ b/drivers/staging/lustre/lustre/include/lustre_debug.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h
index 2d862b32265b..8f1a22527006 100644
--- a/drivers/staging/lustre/lustre/include/lustre_disk.h
+++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 13c3d2fd31a8..e0b17052b2ea 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
index 11331ae81d58..53db031c4c8c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* -*- buffer-read-only: t -*- vi: set ro: 2/* -*- buffer-read-only: t -*- vi: set ro:
2 * 3 *
3 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -136,7 +137,8 @@
136#define ldlm_clear_cancel_on_block(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 23) 137#define ldlm_clear_cancel_on_block(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 23)
137 138
138/** 139/**
139 * measure lock contention and return -EUSERS if locking contention is high */ 140 * measure lock contention and return -EUSERS if locking contention is high
141 */
140#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL /* bit 30 */ 142#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL /* bit 30 */
141#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG((_l), 1ULL << 30) 143#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG((_l), 1ULL << 30)
142#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG((_l), 1ULL << 30) 144#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG((_l), 1ULL << 30)
@@ -144,7 +146,8 @@
144 146
145/** 147/**
146 * These are flags that are mapped into the flags and ASTs of blocking 148 * These are flags that are mapped into the flags and ASTs of blocking
147 * locks Add FL_DISCARD to blocking ASTs */ 149 * locks Add FL_DISCARD to blocking ASTs
150 */
148#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL /* bit 31 */ 151#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL /* bit 31 */
149#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG((_l), 1ULL << 31) 152#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG((_l), 1ULL << 31)
150#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG((_l), 1ULL << 31) 153#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG((_l), 1ULL << 31)
diff --git a/drivers/staging/lustre/lustre/include/lustre_errno.h b/drivers/staging/lustre/lustre/include/lustre_errno.h
index 35aefa2cdad1..59fbb9f47ff1 100644
--- a/drivers/staging/lustre/lustre/include/lustre_errno.h
+++ b/drivers/staging/lustre/lustre/include/lustre_errno.h
@@ -70,16 +70,14 @@
70#define LUSTRE_EROFS 30 /* Read-only file system */ 70#define LUSTRE_EROFS 30 /* Read-only file system */
71#define LUSTRE_EMLINK 31 /* Too many links */ 71#define LUSTRE_EMLINK 31 /* Too many links */
72#define LUSTRE_EPIPE 32 /* Broken pipe */ 72#define LUSTRE_EPIPE 32 /* Broken pipe */
73#define LUSTRE_EDOM 33 /* Math argument out of domain of 73#define LUSTRE_EDOM 33 /* Math argument out of func domain */
74 func */
75#define LUSTRE_ERANGE 34 /* Math result not representable */ 74#define LUSTRE_ERANGE 34 /* Math result not representable */
76#define LUSTRE_EDEADLK 35 /* Resource deadlock would occur */ 75#define LUSTRE_EDEADLK 35 /* Resource deadlock would occur */
77#define LUSTRE_ENAMETOOLONG 36 /* File name too long */ 76#define LUSTRE_ENAMETOOLONG 36 /* File name too long */
78#define LUSTRE_ENOLCK 37 /* No record locks available */ 77#define LUSTRE_ENOLCK 37 /* No record locks available */
79#define LUSTRE_ENOSYS 38 /* Function not implemented */ 78#define LUSTRE_ENOSYS 38 /* Function not implemented */
80#define LUSTRE_ENOTEMPTY 39 /* Directory not empty */ 79#define LUSTRE_ENOTEMPTY 39 /* Directory not empty */
81#define LUSTRE_ELOOP 40 /* Too many symbolic links 80#define LUSTRE_ELOOP 40 /* Too many symbolic links found */
82 encountered */
83#define LUSTRE_ENOMSG 42 /* No message of desired type */ 81#define LUSTRE_ENOMSG 42 /* No message of desired type */
84#define LUSTRE_EIDRM 43 /* Identifier removed */ 82#define LUSTRE_EIDRM 43 /* Identifier removed */
85#define LUSTRE_ECHRNG 44 /* Channel number out of range */ 83#define LUSTRE_ECHRNG 44 /* Channel number out of range */
@@ -112,23 +110,17 @@
112#define LUSTRE_EMULTIHOP 72 /* Multihop attempted */ 110#define LUSTRE_EMULTIHOP 72 /* Multihop attempted */
113#define LUSTRE_EDOTDOT 73 /* RFS specific error */ 111#define LUSTRE_EDOTDOT 73 /* RFS specific error */
114#define LUSTRE_EBADMSG 74 /* Not a data message */ 112#define LUSTRE_EBADMSG 74 /* Not a data message */
115#define LUSTRE_EOVERFLOW 75 /* Value too large for defined data 113#define LUSTRE_EOVERFLOW 75 /* Value too large for data type */
116 type */
117#define LUSTRE_ENOTUNIQ 76 /* Name not unique on network */ 114#define LUSTRE_ENOTUNIQ 76 /* Name not unique on network */
118#define LUSTRE_EBADFD 77 /* File descriptor in bad state */ 115#define LUSTRE_EBADFD 77 /* File descriptor in bad state */
119#define LUSTRE_EREMCHG 78 /* Remote address changed */ 116#define LUSTRE_EREMCHG 78 /* Remote address changed */
120#define LUSTRE_ELIBACC 79 /* Can not access a needed shared 117#define LUSTRE_ELIBACC 79 /* Can't access needed shared library */
121 library */ 118#define LUSTRE_ELIBBAD 80 /* Access corrupted shared library */
122#define LUSTRE_ELIBBAD 80 /* Accessing a corrupted shared
123 library */
124#define LUSTRE_ELIBSCN 81 /* .lib section in a.out corrupted */ 119#define LUSTRE_ELIBSCN 81 /* .lib section in a.out corrupted */
125#define LUSTRE_ELIBMAX 82 /* Attempting to link in too many shared 120#define LUSTRE_ELIBMAX 82 /* Trying to link too many libraries */
126 libraries */ 121#define LUSTRE_ELIBEXEC 83 /* Cannot exec a shared lib directly */
127#define LUSTRE_ELIBEXEC 83 /* Cannot exec a shared library
128 directly */
129#define LUSTRE_EILSEQ 84 /* Illegal byte sequence */ 122#define LUSTRE_EILSEQ 84 /* Illegal byte sequence */
130#define LUSTRE_ERESTART 85 /* Interrupted system call should be 123#define LUSTRE_ERESTART 85 /* Restart interrupted system call */
131 restarted */
132#define LUSTRE_ESTRPIPE 86 /* Streams pipe error */ 124#define LUSTRE_ESTRPIPE 86 /* Streams pipe error */
133#define LUSTRE_EUSERS 87 /* Too many users */ 125#define LUSTRE_EUSERS 87 /* Too many users */
134#define LUSTRE_ENOTSOCK 88 /* Socket operation on non-socket */ 126#define LUSTRE_ENOTSOCK 88 /* Socket operation on non-socket */
@@ -138,26 +130,20 @@
138#define LUSTRE_ENOPROTOOPT 92 /* Protocol not available */ 130#define LUSTRE_ENOPROTOOPT 92 /* Protocol not available */
139#define LUSTRE_EPROTONOSUPPORT 93 /* Protocol not supported */ 131#define LUSTRE_EPROTONOSUPPORT 93 /* Protocol not supported */
140#define LUSTRE_ESOCKTNOSUPPORT 94 /* Socket type not supported */ 132#define LUSTRE_ESOCKTNOSUPPORT 94 /* Socket type not supported */
141#define LUSTRE_EOPNOTSUPP 95 /* Operation not supported on transport 133#define LUSTRE_EOPNOTSUPP 95 /* Operation not supported */
142 endpoint */
143#define LUSTRE_EPFNOSUPPORT 96 /* Protocol family not supported */ 134#define LUSTRE_EPFNOSUPPORT 96 /* Protocol family not supported */
144#define LUSTRE_EAFNOSUPPORT 97 /* Address family not supported by 135#define LUSTRE_EAFNOSUPPORT 97 /* Address family not supported */
145 protocol */
146#define LUSTRE_EADDRINUSE 98 /* Address already in use */ 136#define LUSTRE_EADDRINUSE 98 /* Address already in use */
147#define LUSTRE_EADDRNOTAVAIL 99 /* Cannot assign requested address */ 137#define LUSTRE_EADDRNOTAVAIL 99 /* Cannot assign requested address */
148#define LUSTRE_ENETDOWN 100 /* Network is down */ 138#define LUSTRE_ENETDOWN 100 /* Network is down */
149#define LUSTRE_ENETUNREACH 101 /* Network is unreachable */ 139#define LUSTRE_ENETUNREACH 101 /* Network is unreachable */
150#define LUSTRE_ENETRESET 102 /* Network dropped connection because of 140#define LUSTRE_ENETRESET 102 /* Network connection drop for reset */
151 reset */
152#define LUSTRE_ECONNABORTED 103 /* Software caused connection abort */ 141#define LUSTRE_ECONNABORTED 103 /* Software caused connection abort */
153#define LUSTRE_ECONNRESET 104 /* Connection reset by peer */ 142#define LUSTRE_ECONNRESET 104 /* Connection reset by peer */
154#define LUSTRE_ENOBUFS 105 /* No buffer space available */ 143#define LUSTRE_ENOBUFS 105 /* No buffer space available */
155#define LUSTRE_EISCONN 106 /* Transport endpoint is already 144#define LUSTRE_EISCONN 106 /* Transport endpoint is connected */
156 connected */ 145#define LUSTRE_ENOTCONN 107 /* Transport endpoint not connected */
157#define LUSTRE_ENOTCONN 107 /* Transport endpoint is not 146#define LUSTRE_ESHUTDOWN 108 /* Cannot send after shutdown */
158 connected */
159#define LUSTRE_ESHUTDOWN 108 /* Cannot send after transport endpoint
160 shutdown */
161#define LUSTRE_ETOOMANYREFS 109 /* Too many references: cannot splice */ 147#define LUSTRE_ETOOMANYREFS 109 /* Too many references: cannot splice */
162#define LUSTRE_ETIMEDOUT 110 /* Connection timed out */ 148#define LUSTRE_ETIMEDOUT 110 /* Connection timed out */
163#define LUSTRE_ECONNREFUSED 111 /* Connection refused */ 149#define LUSTRE_ECONNREFUSED 111 /* Connection refused */
@@ -185,8 +171,7 @@
185#define LUSTRE_ERESTARTNOINTR 513 171#define LUSTRE_ERESTARTNOINTR 513
186#define LUSTRE_ERESTARTNOHAND 514 /* restart if no handler.. */ 172#define LUSTRE_ERESTARTNOHAND 514 /* restart if no handler.. */
187#define LUSTRE_ENOIOCTLCMD 515 /* No ioctl command */ 173#define LUSTRE_ENOIOCTLCMD 515 /* No ioctl command */
188#define LUSTRE_ERESTART_RESTARTBLOCK 516 /* restart by calling 174#define LUSTRE_ERESTART_RESTARTBLOCK 516 /* restart via sys_restart_syscall */
189 sys_restart_syscall */
190#define LUSTRE_EBADHANDLE 521 /* Illegal NFS file handle */ 175#define LUSTRE_EBADHANDLE 521 /* Illegal NFS file handle */
191#define LUSTRE_ENOTSYNC 522 /* Update synchronization mismatch */ 176#define LUSTRE_ENOTSYNC 522 /* Update synchronization mismatch */
192#define LUSTRE_EBADCOOKIE 523 /* Cookie is stale */ 177#define LUSTRE_EBADCOOKIE 523 /* Cookie is stale */
@@ -194,10 +179,8 @@
194#define LUSTRE_ETOOSMALL 525 /* Buffer or request is too small */ 179#define LUSTRE_ETOOSMALL 525 /* Buffer or request is too small */
195#define LUSTRE_ESERVERFAULT 526 /* An untranslatable error occurred */ 180#define LUSTRE_ESERVERFAULT 526 /* An untranslatable error occurred */
196#define LUSTRE_EBADTYPE 527 /* Type not supported by server */ 181#define LUSTRE_EBADTYPE 527 /* Type not supported by server */
197#define LUSTRE_EJUKEBOX 528 /* Request initiated, but will not 182#define LUSTRE_EJUKEBOX 528 /* Request won't finish until timeout */
198 complete before timeout */ 183#define LUSTRE_EIOCBQUEUED 529 /* iocb queued await completion event */
199#define LUSTRE_EIOCBQUEUED 529 /* iocb queued, will get completion
200 event */
201#define LUSTRE_EIOCBRETRY 530 /* iocb queued, will trigger a retry */ 184#define LUSTRE_EIOCBRETRY 530 /* iocb queued, will trigger a retry */
202 185
203/* 186/*
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 3631a69a5c6f..66ac9dc7302a 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h
index e0f2b8295775..d19c7a27ee48 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fid.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fid.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h
index 6125eb0d3395..4055bbd24c55 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h b/drivers/staging/lustre/lustre/include/lustre_ha.h
index dec1e99d594d..cbd68985ada9 100644
--- a/drivers/staging/lustre/lustre/include/lustre_ha.h
+++ b/drivers/staging/lustre/lustre/include/lustre_ha.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index d49932628f32..c48c97362cf6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
index d71d0473a4eb..ea158e0630e2 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h
index ed2b6c674109..519e94fc089d 100644
--- a/drivers/staging/lustre/lustre/include/lustre_intent.h
+++ b/drivers/staging/lustre/lustre/include/lustre_intent.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
index f1899a3d7a40..2b3fa8430185 100644
--- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h
index 81b9cbffc050..ca1dce15337e 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_linkea.h b/drivers/staging/lustre/lustre/include/lustre_linkea.h
index 3ff008fee13d..03db1511bfd3 100644
--- a/drivers/staging/lustre/lustre/include/lustre_linkea.h
+++ b/drivers/staging/lustre/lustre/include/lustre_linkea.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_lmv.h b/drivers/staging/lustre/lustre/include/lustre_lmv.h
index 98a82be2037f..f4298e5f7543 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lmv.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lmv.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
index 24a7777424f6..07f4e600386b 100644
--- a/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h
index c0c44974cb1c..007e1ec3f0f4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_mdc.h
+++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h
index c424e1239fd5..6937546f1d46 100644
--- a/drivers/staging/lustre/lustre/include/lustre_mds.h
+++ b/drivers/staging/lustre/lustre/include/lustre_mds.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index c6d1646f102a..3ff5de4770e8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_nrs.h b/drivers/staging/lustre/lustre/include/lustre_nrs.h
index 51f45f7776df..ffa7317da35b 100644
--- a/drivers/staging/lustre/lustre/include/lustre_nrs.h
+++ b/drivers/staging/lustre/lustre/include/lustre_nrs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h b/drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h
index 3b5418eac6c4..b70d97d4acbb 100644
--- a/drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h
+++ b/drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_obdo.h b/drivers/staging/lustre/lustre/include/lustre_obdo.h
index 53379f861161..d67dcbb84f18 100644
--- a/drivers/staging/lustre/lustre/include/lustre_obdo.h
+++ b/drivers/staging/lustre/lustre/include/lustre_obdo.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
index 5842cb18b49e..ce28ed5c1ef8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index cd62ccd53e2c..213d0a01adcf 100644
--- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h
+++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h
index 03a970bcac55..a40f706a53a1 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/lustre_swab.h b/drivers/staging/lustre/lustre/include/lustre_swab.h
index 765e923c2fc9..9d786bbe7f3f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_swab.h
+++ b/drivers/staging/lustre/lustre/include/lustre_swab.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index a986737ec010..4368f4e9f208 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h
index cda3d2808d2f..e5f7bb20415d 100644
--- a/drivers/staging/lustre/lustre/include/obd_cksum.h
+++ b/drivers/staging/lustre/lustre/include/obd_cksum.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 976005a1e0b2..67c535c5aa98 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index aea193a882a2..3f4fe290f6ea 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/include/seq_range.h b/drivers/staging/lustre/lustre/include/seq_range.h
index d7175485944d..9450da728160 100644
--- a/drivers/staging/lustre/lustre/include/seq_range.h
+++ b/drivers/staging/lustre/lustre/include/seq_range.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c
index 19e285dd2ee1..8df7a4463c21 100644
--- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c
+++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c
index 57fd84effdfa..0662cec14b81 100644
--- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index 2cc6dc2b281f..fac9d19d50b6 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -207,7 +208,8 @@ void ldlm_extent_add_lock(struct ldlm_resource *res,
207 continue; 208 continue;
208 if (ldlm_extent_overlap(&lck->l_req_extent, 209 if (ldlm_extent_overlap(&lck->l_req_extent,
209 &lock->l_req_extent)) { 210 &lock->l_req_extent)) {
210 CDEBUG(D_ERROR, "granting conflicting lock %p %p\n", 211 CDEBUG(D_ERROR,
212 "granting conflicting lock %p %p\n",
211 lck, lock); 213 lck, lock);
212 ldlm_resource_dump(D_ERROR, res); 214 ldlm_resource_dump(D_ERROR, res);
213 LBUG(); 215 LBUG();
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index cb826e9e840e..657ab95091a0 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -59,17 +60,6 @@
59#include <linux/list.h> 60#include <linux/list.h>
60#include "ldlm_internal.h" 61#include "ldlm_internal.h"
61 62
62/**
63 * list_for_remaining_safe - iterate over the remaining entries in a list
64 * and safeguard against removal of a list entry.
65 * \param pos the &struct list_head to use as a loop counter. pos MUST
66 * have been initialized prior to using it in this macro.
67 * \param n another &struct list_head to use as temporary storage
68 * \param head the head for your list.
69 */
70#define list_for_remaining_safe(pos, n, head) \
71 for (n = pos->next; pos != (head); pos = n, n = pos->next)
72
73static inline int 63static inline int
74ldlm_same_flock_owner(struct ldlm_lock *lock, struct ldlm_lock *new) 64ldlm_same_flock_owner(struct ldlm_lock *lock, struct ldlm_lock *new)
75{ 65{
@@ -88,24 +78,23 @@ ldlm_flocks_overlap(struct ldlm_lock *lock, struct ldlm_lock *new)
88} 78}
89 79
90static inline void 80static inline void
91ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode, __u64 flags) 81ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
92{ 82{
93 LDLM_DEBUG(lock, "%s(mode: %d, flags: 0x%llx)", 83 LDLM_DEBUG(lock, "%s(mode: %d)",
94 __func__, mode, flags); 84 __func__, mode);
95 85
96 /* Safe to not lock here, since it should be empty anyway */ 86 /* Safe to not lock here, since it should be empty anyway */
97 LASSERT(hlist_unhashed(&lock->l_exp_flock_hash)); 87 LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
98 88
99 list_del_init(&lock->l_res_link); 89 list_del_init(&lock->l_res_link);
100 if (flags == LDLM_FL_WAIT_NOREPROC) {
101 /* client side - set a flag to prevent sending a CANCEL */
102 lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_CBPENDING;
103 90
104 /* when reaching here, it is under lock_res_and_lock(). Thus, 91 /* client side - set a flag to prevent sending a CANCEL */
105 * need call the nolock version of ldlm_lock_decref_internal 92 lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_CBPENDING;
106 */ 93
107 ldlm_lock_decref_internal_nolock(lock, mode); 94 /* when reaching here, it is under lock_res_and_lock(). Thus,
108 } 95 * need call the nolock version of ldlm_lock_decref_internal
96 */
97 ldlm_lock_decref_internal_nolock(lock, mode);
109 98
110 ldlm_lock_destroy_nolock(lock); 99 ldlm_lock_destroy_nolock(lock);
111} 100}
@@ -121,129 +110,45 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode, __u64 flags)
121 * It is also responsible for splitting a lock if a portion of the lock 110 * It is also responsible for splitting a lock if a portion of the lock
122 * is released. 111 * is released.
123 * 112 *
124 * If \a first_enq is 0 (ie, called from ldlm_reprocess_queue):
125 * - blocking ASTs have already been sent
126 *
127 * If \a first_enq is 1 (ie, called from ldlm_lock_enqueue):
128 * - blocking ASTs have not been sent yet, so list of conflicting locks
129 * would be collected and ASTs sent.
130 */ 113 */
131static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, 114static int ldlm_process_flock_lock(struct ldlm_lock *req)
132 int first_enq, enum ldlm_error *err,
133 struct list_head *work_list)
134{ 115{
135 struct ldlm_resource *res = req->l_resource; 116 struct ldlm_resource *res = req->l_resource;
136 struct ldlm_namespace *ns = ldlm_res_to_ns(res); 117 struct ldlm_namespace *ns = ldlm_res_to_ns(res);
137 struct list_head *tmp; 118 struct ldlm_lock *tmp;
138 struct list_head *ownlocks = NULL; 119 struct ldlm_lock *lock;
139 struct ldlm_lock *lock = NULL;
140 struct ldlm_lock *new = req; 120 struct ldlm_lock *new = req;
141 struct ldlm_lock *new2 = NULL; 121 struct ldlm_lock *new2 = NULL;
142 enum ldlm_mode mode = req->l_req_mode; 122 enum ldlm_mode mode = req->l_req_mode;
143 int added = (mode == LCK_NL); 123 int added = (mode == LCK_NL);
144 int overlaps = 0;
145 int splitted = 0; 124 int splitted = 0;
146 const struct ldlm_callback_suite null_cbs = { }; 125 const struct ldlm_callback_suite null_cbs = { };
147 126
148 CDEBUG(D_DLMTRACE, 127 CDEBUG(D_DLMTRACE,
149 "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", 128 "owner %llu pid %u mode %u start %llu end %llu\n",
150 *flags, new->l_policy_data.l_flock.owner, 129 new->l_policy_data.l_flock.owner,
151 new->l_policy_data.l_flock.pid, mode, 130 new->l_policy_data.l_flock.pid, mode,
152 req->l_policy_data.l_flock.start, 131 req->l_policy_data.l_flock.start,
153 req->l_policy_data.l_flock.end); 132 req->l_policy_data.l_flock.end);
154 133
155 *err = ELDLM_OK;
156
157 /* No blocking ASTs are sent to the clients for 134 /* No blocking ASTs are sent to the clients for
158 * Posix file & record locks 135 * Posix file & record locks
159 */ 136 */
160 req->l_blocking_ast = NULL; 137 req->l_blocking_ast = NULL;
161 138
162reprocess: 139reprocess:
163 if ((*flags == LDLM_FL_WAIT_NOREPROC) || (mode == LCK_NL)) { 140 /* This loop determines where this processes locks start
164 /* This loop determines where this processes locks start 141 * in the resource lr_granted list.
165 * in the resource lr_granted list. 142 */
166 */ 143 list_for_each_entry(lock, &res->lr_granted, l_res_link)
167 list_for_each(tmp, &res->lr_granted) { 144 if (ldlm_same_flock_owner(lock, req))
168 lock = list_entry(tmp, struct ldlm_lock, 145 break;
169 l_res_link);
170 if (ldlm_same_flock_owner(lock, req)) {
171 ownlocks = tmp;
172 break;
173 }
174 }
175 } else {
176 int reprocess_failed = 0;
177
178 lockmode_verify(mode);
179
180 /* This loop determines if there are existing locks
181 * that conflict with the new lock request.
182 */
183 list_for_each(tmp, &res->lr_granted) {
184 lock = list_entry(tmp, struct ldlm_lock,
185 l_res_link);
186
187 if (ldlm_same_flock_owner(lock, req)) {
188 if (!ownlocks)
189 ownlocks = tmp;
190 continue;
191 }
192
193 /* locks are compatible, overlap doesn't matter */
194 if (lockmode_compat(lock->l_granted_mode, mode))
195 continue;
196
197 if (!ldlm_flocks_overlap(lock, req))
198 continue;
199
200 if (!first_enq) {
201 reprocess_failed = 1;
202 continue;
203 }
204
205 if (*flags & LDLM_FL_BLOCK_NOWAIT) {
206 ldlm_flock_destroy(req, mode, *flags);
207 *err = -EAGAIN;
208 return LDLM_ITER_STOP;
209 }
210
211 if (*flags & LDLM_FL_TEST_LOCK) {
212 ldlm_flock_destroy(req, mode, *flags);
213 req->l_req_mode = lock->l_granted_mode;
214 req->l_policy_data.l_flock.pid =
215 lock->l_policy_data.l_flock.pid;
216 req->l_policy_data.l_flock.start =
217 lock->l_policy_data.l_flock.start;
218 req->l_policy_data.l_flock.end =
219 lock->l_policy_data.l_flock.end;
220 *flags |= LDLM_FL_LOCK_CHANGED;
221 return LDLM_ITER_STOP;
222 }
223
224 ldlm_resource_add_lock(res, &res->lr_waiting, req);
225 *flags |= LDLM_FL_BLOCK_GRANTED;
226 return LDLM_ITER_STOP;
227 }
228 if (reprocess_failed)
229 return LDLM_ITER_CONTINUE;
230 }
231
232 if (*flags & LDLM_FL_TEST_LOCK) {
233 ldlm_flock_destroy(req, mode, *flags);
234 req->l_req_mode = LCK_NL;
235 *flags |= LDLM_FL_LOCK_CHANGED;
236 return LDLM_ITER_STOP;
237 }
238 146
239 /* Scan the locks owned by this process that overlap this request. 147 /* Scan the locks owned by this process to find the insertion point
148 * (as locks are ordered), and to handle overlaps.
240 * We may have to merge or split existing locks. 149 * We may have to merge or split existing locks.
241 */ 150 */
242 if (!ownlocks) 151 list_for_each_entry_safe_from(lock, tmp, &res->lr_granted, l_res_link) {
243 ownlocks = &res->lr_granted;
244
245 list_for_remaining_safe(ownlocks, tmp, &res->lr_granted) {
246 lock = list_entry(ownlocks, struct ldlm_lock, l_res_link);
247 152
248 if (!ldlm_same_flock_owner(lock, new)) 153 if (!ldlm_same_flock_owner(lock, new))
249 break; 154 break;
@@ -283,7 +188,7 @@ reprocess:
283 } 188 }
284 189
285 if (added) { 190 if (added) {
286 ldlm_flock_destroy(lock, mode, *flags); 191 ldlm_flock_destroy(lock, mode);
287 } else { 192 } else {
288 new = lock; 193 new = lock;
289 added = 1; 194 added = 1;
@@ -299,8 +204,6 @@ reprocess:
299 lock->l_policy_data.l_flock.start) 204 lock->l_policy_data.l_flock.start)
300 break; 205 break;
301 206
302 ++overlaps;
303
304 if (new->l_policy_data.l_flock.start <= 207 if (new->l_policy_data.l_flock.start <=
305 lock->l_policy_data.l_flock.start) { 208 lock->l_policy_data.l_flock.start) {
306 if (new->l_policy_data.l_flock.end < 209 if (new->l_policy_data.l_flock.end <
@@ -309,7 +212,7 @@ reprocess:
309 new->l_policy_data.l_flock.end + 1; 212 new->l_policy_data.l_flock.end + 1;
310 break; 213 break;
311 } 214 }
312 ldlm_flock_destroy(lock, lock->l_req_mode, *flags); 215 ldlm_flock_destroy(lock, lock->l_req_mode);
313 continue; 216 continue;
314 } 217 }
315 if (new->l_policy_data.l_flock.end >= 218 if (new->l_policy_data.l_flock.end >=
@@ -340,9 +243,7 @@ reprocess:
340 NULL, 0, LVB_T_NONE); 243 NULL, 0, LVB_T_NONE);
341 lock_res_and_lock(req); 244 lock_res_and_lock(req);
342 if (IS_ERR(new2)) { 245 if (IS_ERR(new2)) {
343 ldlm_flock_destroy(req, lock->l_granted_mode, 246 ldlm_flock_destroy(req, lock->l_granted_mode);
344 *flags);
345 *err = PTR_ERR(new2);
346 return LDLM_ITER_STOP; 247 return LDLM_ITER_STOP;
347 } 248 }
348 goto reprocess; 249 goto reprocess;
@@ -371,12 +272,11 @@ reprocess:
371 &new2->l_remote_handle, 272 &new2->l_remote_handle,
372 &new2->l_exp_hash); 273 &new2->l_exp_hash);
373 } 274 }
374 if (*flags == LDLM_FL_WAIT_NOREPROC) 275 ldlm_lock_addref_internal_nolock(new2,
375 ldlm_lock_addref_internal_nolock(new2, 276 lock->l_granted_mode);
376 lock->l_granted_mode);
377 277
378 /* insert new2 at lock */ 278 /* insert new2 at lock */
379 ldlm_resource_add_lock(res, ownlocks, new2); 279 ldlm_resource_add_lock(res, &lock->l_res_link, new2);
380 LDLM_LOCK_RELEASE(new2); 280 LDLM_LOCK_RELEASE(new2);
381 break; 281 break;
382 } 282 }
@@ -390,17 +290,12 @@ reprocess:
390 290
391 if (!added) { 291 if (!added) {
392 list_del_init(&req->l_res_link); 292 list_del_init(&req->l_res_link);
393 /* insert new lock before ownlocks in list. */ 293 /* insert new lock before "lock", which might be the
394 ldlm_resource_add_lock(res, ownlocks, req); 294 * next lock for this owner, or might be the first
395 } 295 * lock for the next owner, or might not be a lock at
396 296 * all, but instead points at the head of the list
397 if (*flags != LDLM_FL_WAIT_NOREPROC) {
398 /* The only one possible case for client-side calls flock
399 * policy function is ldlm_flock_completion_ast inside which
400 * carries LDLM_FL_WAIT_NOREPROC flag.
401 */ 297 */
402 CERROR("Illegal parameter for client-side-only module.\n"); 298 ldlm_resource_add_lock(res, &lock->l_res_link, req);
403 LBUG();
404 } 299 }
405 300
406 /* In case we're reprocessing the requested lock we can't destroy 301 /* In case we're reprocessing the requested lock we can't destroy
@@ -409,7 +304,7 @@ reprocess:
409 * could be freed before the completion AST can be sent. 304 * could be freed before the completion AST can be sent.
410 */ 305 */
411 if (added) 306 if (added)
412 ldlm_flock_destroy(req, mode, *flags); 307 ldlm_flock_destroy(req, mode);
413 308
414 ldlm_resource_dump(D_INFO, res); 309 ldlm_resource_dump(D_INFO, res);
415 return LDLM_ITER_CONTINUE; 310 return LDLM_ITER_CONTINUE;
@@ -417,7 +312,6 @@ reprocess:
417 312
418struct ldlm_flock_wait_data { 313struct ldlm_flock_wait_data {
419 struct ldlm_lock *fwd_lock; 314 struct ldlm_lock *fwd_lock;
420 int fwd_generation;
421}; 315};
422 316
423static void 317static void
@@ -448,12 +342,9 @@ int
448ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) 342ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
449{ 343{
450 struct file_lock *getlk = lock->l_ast_data; 344 struct file_lock *getlk = lock->l_ast_data;
451 struct obd_device *obd; 345 struct ldlm_flock_wait_data fwd;
452 struct obd_import *imp = NULL; 346 struct l_wait_info lwi;
453 struct ldlm_flock_wait_data fwd; 347 int rc = 0;
454 struct l_wait_info lwi;
455 enum ldlm_error err;
456 int rc = 0;
457 348
458 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT2, 4); 349 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT2, 4);
459 if (OBD_FAIL_PRECHECK(OBD_FAIL_LDLM_CP_CB_WAIT3)) { 350 if (OBD_FAIL_PRECHECK(OBD_FAIL_LDLM_CP_CB_WAIT3)) {
@@ -479,20 +370,9 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
479 return 0; 370 return 0;
480 } 371 }
481 372
482 LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, sleeping"); 373 LDLM_DEBUG(lock,
374 "client-side enqueue returned a blocked lock, sleeping");
483 fwd.fwd_lock = lock; 375 fwd.fwd_lock = lock;
484 obd = class_exp2obd(lock->l_conn_export);
485
486 /* if this is a local lock, there is no import */
487 if (obd)
488 imp = obd->u.cli.cl_import;
489
490 if (imp) {
491 spin_lock(&imp->imp_lock);
492 fwd.fwd_generation = imp->imp_generation;
493 spin_unlock(&imp->imp_lock);
494 }
495
496 lwi = LWI_TIMEOUT_INTR(0, NULL, ldlm_flock_interrupted_wait, &fwd); 376 lwi = LWI_TIMEOUT_INTR(0, NULL, ldlm_flock_interrupted_wait, &fwd);
497 377
498 /* Go to sleep until the lock is granted. */ 378 /* Go to sleep until the lock is granted. */
@@ -561,10 +441,11 @@ granted:
561 mode = lock->l_granted_mode; 441 mode = lock->l_granted_mode;
562 442
563 if (ldlm_is_flock_deadlock(lock)) { 443 if (ldlm_is_flock_deadlock(lock)) {
564 LDLM_DEBUG(lock, "client-side enqueue deadlock received"); 444 LDLM_DEBUG(lock,
445 "client-side enqueue deadlock received");
565 rc = -EDEADLK; 446 rc = -EDEADLK;
566 } 447 }
567 ldlm_flock_destroy(lock, mode, LDLM_FL_WAIT_NOREPROC); 448 ldlm_flock_destroy(lock, mode);
568 unlock_res_and_lock(lock); 449 unlock_res_and_lock(lock);
569 450
570 /* Need to wake up the waiter if we were evicted */ 451 /* Need to wake up the waiter if we were evicted */
@@ -585,7 +466,7 @@ granted:
585 * in the lock changes we can decref the appropriate refcount. 466 * in the lock changes we can decref the appropriate refcount.
586 */ 467 */
587 LASSERT(ldlm_is_test_lock(lock)); 468 LASSERT(ldlm_is_test_lock(lock));
588 ldlm_flock_destroy(lock, getlk->fl_type, LDLM_FL_WAIT_NOREPROC); 469 ldlm_flock_destroy(lock, getlk->fl_type);
589 switch (lock->l_granted_mode) { 470 switch (lock->l_granted_mode) {
590 case LCK_PR: 471 case LCK_PR:
591 getlk->fl_type = F_RDLCK; 472 getlk->fl_type = F_RDLCK;
@@ -600,12 +481,10 @@ granted:
600 getlk->fl_start = (loff_t)lock->l_policy_data.l_flock.start; 481 getlk->fl_start = (loff_t)lock->l_policy_data.l_flock.start;
601 getlk->fl_end = (loff_t)lock->l_policy_data.l_flock.end; 482 getlk->fl_end = (loff_t)lock->l_policy_data.l_flock.end;
602 } else { 483 } else {
603 __u64 noreproc = LDLM_FL_WAIT_NOREPROC;
604
605 /* We need to reprocess the lock to do merges or splits 484 /* We need to reprocess the lock to do merges or splits
606 * with existing locks owned by this process. 485 * with existing locks owned by this process.
607 */ 486 */
608 ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); 487 ldlm_process_flock_lock(lock);
609 } 488 }
610 unlock_res_and_lock(lock); 489 unlock_res_and_lock(lock);
611 return rc; 490 return rc;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
index fcb6e44bd319..2926208cdfa1 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 36808dbe8790..bc33ca100620 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -88,7 +89,7 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client);
88/* ldlm_request.c */ 89/* ldlm_request.c */
89/* Cancel lru flag, it indicates we cancel aged locks. */ 90/* Cancel lru flag, it indicates we cancel aged locks. */
90enum { 91enum {
91 LDLM_LRU_FLAG_AGED = BIT(0), /* Cancel aged locks (non lru resize). */ 92 LDLM_LRU_FLAG_AGED = BIT(0), /* Cancel old non-LRU resize locks */
92 LDLM_LRU_FLAG_PASSED = BIT(1), /* Cancel passed number of locks. */ 93 LDLM_LRU_FLAG_PASSED = BIT(1), /* Cancel passed number of locks. */
93 LDLM_LRU_FLAG_SHRINK = BIT(2), /* Cancel locks from shrinker. */ 94 LDLM_LRU_FLAG_SHRINK = BIT(2), /* Cancel locks from shrinker. */
94 LDLM_LRU_FLAG_LRUR = BIT(3), /* Cancel locks from lru resize. */ 95 LDLM_LRU_FLAG_LRUR = BIT(3), /* Cancel locks from lru resize. */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index 22600c2a73ea..9efd26ec59dd 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b5d84f3f6071..7cb61e2e7d3b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1035,7 +1036,8 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list)
1035 ldlm_extent_add_lock(res, lock); 1036 ldlm_extent_add_lock(res, lock);
1036 } else if (res->lr_type == LDLM_FLOCK) { 1037 } else if (res->lr_type == LDLM_FLOCK) {
1037 /* 1038 /*
1038 * We should not add locks to granted list in the following cases: 1039 * We should not add locks to granted list in
1040 * the following cases:
1039 * - this is an UNLOCK but not a real lock; 1041 * - this is an UNLOCK but not a real lock;
1040 * - this is a TEST lock; 1042 * - this is a TEST lock;
1041 * - this is a F_CANCELLK lock (async flock has req_mode == 0) 1043 * - this is a F_CANCELLK lock (async flock has req_mode == 0)
@@ -2051,13 +2053,16 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2051 libcfs_debug_vmsg2(msgdata, fmt, args, 2053 libcfs_debug_vmsg2(msgdata, fmt, args,
2052 " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", 2054 " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
2053 lock, 2055 lock,
2054 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), 2056 lock->l_handle.h_cookie,
2057 atomic_read(&lock->l_refc),
2055 lock->l_readers, lock->l_writers, 2058 lock->l_readers, lock->l_writers,
2056 ldlm_lockname[lock->l_granted_mode], 2059 ldlm_lockname[lock->l_granted_mode],
2057 ldlm_lockname[lock->l_req_mode], 2060 ldlm_lockname[lock->l_req_mode],
2058 lock->l_flags, nid, lock->l_remote_handle.cookie, 2061 lock->l_flags, nid,
2062 lock->l_remote_handle.cookie,
2059 exp ? atomic_read(&exp->exp_refcount) : -99, 2063 exp ? atomic_read(&exp->exp_refcount) : -99,
2060 lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); 2064 lock->l_pid, lock->l_callback_timeout,
2065 lock->l_lvb_type);
2061 va_end(args); 2066 va_end(args);
2062 return; 2067 return;
2063 } 2068 }
@@ -2067,7 +2072,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2067 libcfs_debug_vmsg2(msgdata, fmt, args, 2072 libcfs_debug_vmsg2(msgdata, fmt, args,
2068 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", 2073 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
2069 ldlm_lock_to_ns_name(lock), lock, 2074 ldlm_lock_to_ns_name(lock), lock,
2070 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), 2075 lock->l_handle.h_cookie,
2076 atomic_read(&lock->l_refc),
2071 lock->l_readers, lock->l_writers, 2077 lock->l_readers, lock->l_writers,
2072 ldlm_lockname[lock->l_granted_mode], 2078 ldlm_lockname[lock->l_granted_mode],
2073 ldlm_lockname[lock->l_req_mode], 2079 ldlm_lockname[lock->l_req_mode],
@@ -2076,8 +2082,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2076 ldlm_typename[resource->lr_type], 2082 ldlm_typename[resource->lr_type],
2077 lock->l_policy_data.l_extent.start, 2083 lock->l_policy_data.l_extent.start,
2078 lock->l_policy_data.l_extent.end, 2084 lock->l_policy_data.l_extent.end,
2079 lock->l_req_extent.start, lock->l_req_extent.end, 2085 lock->l_req_extent.start,
2080 lock->l_flags, nid, lock->l_remote_handle.cookie, 2086 lock->l_req_extent.end,
2087 lock->l_flags, nid,
2088 lock->l_remote_handle.cookie,
2081 exp ? atomic_read(&exp->exp_refcount) : -99, 2089 exp ? atomic_read(&exp->exp_refcount) : -99,
2082 lock->l_pid, lock->l_callback_timeout, 2090 lock->l_pid, lock->l_callback_timeout,
2083 lock->l_lvb_type); 2091 lock->l_lvb_type);
@@ -2087,7 +2095,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2087 libcfs_debug_vmsg2(msgdata, fmt, args, 2095 libcfs_debug_vmsg2(msgdata, fmt, args,
2088 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", 2096 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n",
2089 ldlm_lock_to_ns_name(lock), lock, 2097 ldlm_lock_to_ns_name(lock), lock,
2090 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), 2098 lock->l_handle.h_cookie,
2099 atomic_read(&lock->l_refc),
2091 lock->l_readers, lock->l_writers, 2100 lock->l_readers, lock->l_writers,
2092 ldlm_lockname[lock->l_granted_mode], 2101 ldlm_lockname[lock->l_granted_mode],
2093 ldlm_lockname[lock->l_req_mode], 2102 ldlm_lockname[lock->l_req_mode],
@@ -2097,7 +2106,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2097 lock->l_policy_data.l_flock.pid, 2106 lock->l_policy_data.l_flock.pid,
2098 lock->l_policy_data.l_flock.start, 2107 lock->l_policy_data.l_flock.start,
2099 lock->l_policy_data.l_flock.end, 2108 lock->l_policy_data.l_flock.end,
2100 lock->l_flags, nid, lock->l_remote_handle.cookie, 2109 lock->l_flags, nid,
2110 lock->l_remote_handle.cookie,
2101 exp ? atomic_read(&exp->exp_refcount) : -99, 2111 exp ? atomic_read(&exp->exp_refcount) : -99,
2102 lock->l_pid, lock->l_callback_timeout); 2112 lock->l_pid, lock->l_callback_timeout);
2103 break; 2113 break;
@@ -2115,7 +2125,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2115 lock->l_policy_data.l_inodebits.bits, 2125 lock->l_policy_data.l_inodebits.bits,
2116 atomic_read(&resource->lr_refcount), 2126 atomic_read(&resource->lr_refcount),
2117 ldlm_typename[resource->lr_type], 2127 ldlm_typename[resource->lr_type],
2118 lock->l_flags, nid, lock->l_remote_handle.cookie, 2128 lock->l_flags, nid,
2129 lock->l_remote_handle.cookie,
2119 exp ? atomic_read(&exp->exp_refcount) : -99, 2130 exp ? atomic_read(&exp->exp_refcount) : -99,
2120 lock->l_pid, lock->l_callback_timeout, 2131 lock->l_pid, lock->l_callback_timeout,
2121 lock->l_lvb_type); 2132 lock->l_lvb_type);
@@ -2133,7 +2144,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
2133 PLDLMRES(resource), 2144 PLDLMRES(resource),
2134 atomic_read(&resource->lr_refcount), 2145 atomic_read(&resource->lr_refcount),
2135 ldlm_typename[resource->lr_type], 2146 ldlm_typename[resource->lr_type],
2136 lock->l_flags, nid, lock->l_remote_handle.cookie, 2147 lock->l_flags, nid,
2148 lock->l_remote_handle.cookie,
2137 exp ? atomic_read(&exp->exp_refcount) : -99, 2149 exp ? atomic_read(&exp->exp_refcount) : -99,
2138 lock->l_pid, lock->l_callback_timeout, 2150 lock->l_pid, lock->l_callback_timeout,
2139 lock->l_lvb_type); 2151 lock->l_lvb_type);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index e2707336586c..2d5a2c932ddc 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -184,7 +185,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
184 LASSERT(lock->l_lvb_data); 185 LASSERT(lock->l_lvb_data);
185 186
186 if (unlikely(lock->l_lvb_len < lvb_len)) { 187 if (unlikely(lock->l_lvb_len < lvb_len)) {
187 LDLM_ERROR(lock, "Replied LVB is larger than expectation, expected = %d, replied = %d", 188 LDLM_ERROR(lock,
189 "Replied LVB is larger than expectation, expected = %d, replied = %d",
188 lock->l_lvb_len, lvb_len); 190 lock->l_lvb_len, lvb_len);
189 rc = -EINVAL; 191 rc = -EINVAL;
190 goto out; 192 goto out;
@@ -598,7 +600,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
598 600
599 lock = ldlm_handle2lock_long(&dlm_req->lock_handle[0], 0); 601 lock = ldlm_handle2lock_long(&dlm_req->lock_handle[0], 0);
600 if (!lock) { 602 if (!lock) {
601 CDEBUG(D_DLMTRACE, "callback on lock %#llx - lock disappeared\n", 603 CDEBUG(D_DLMTRACE,
604 "callback on lock %#llx - lock disappeared\n",
602 dlm_req->lock_handle[0].cookie); 605 dlm_req->lock_handle[0].cookie);
603 rc = ldlm_callback_reply(req, -EINVAL); 606 rc = ldlm_callback_reply(req, -EINVAL);
604 ldlm_callback_errmsg(req, "Operate with invalid parameter", rc, 607 ldlm_callback_errmsg(req, "Operate with invalid parameter", rc,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
index 1ca605fe25ff..33b5a3f96fcb 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index d77bf0baa84f..da65d00a7811 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -386,7 +387,8 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl)
386 pl->pl_recalc_period; 387 pl->pl_recalc_period;
387 if (recalc_interval_sec <= 0) { 388 if (recalc_interval_sec <= 0) {
388 /* DEBUG: should be re-removed after LU-4536 is fixed */ 389 /* DEBUG: should be re-removed after LU-4536 is fixed */
389 CDEBUG(D_DLMTRACE, "%s: Negative interval(%ld), too short period(%ld)\n", 390 CDEBUG(D_DLMTRACE,
391 "%s: Negative interval(%ld), too short period(%ld)\n",
390 pl->pl_name, (long)recalc_interval_sec, 392 pl->pl_name, (long)recalc_interval_sec,
391 (long)pl->pl_recalc_period); 393 (long)pl->pl_recalc_period);
392 394
@@ -415,7 +417,8 @@ static int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask)
415 lprocfs_counter_add(pl->pl_stats, 417 lprocfs_counter_add(pl->pl_stats,
416 LDLM_POOL_SHRINK_FREED_STAT, 418 LDLM_POOL_SHRINK_FREED_STAT,
417 cancel); 419 cancel);
418 CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, shrunk %d\n", 420 CDEBUG(D_DLMTRACE,
421 "%s: request to shrink %d locks, shrunk %d\n",
419 pl->pl_name, nr, cancel); 422 pl->pl_name, nr, cancel);
420 } 423 }
421 } 424 }
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index f3bf238d0748..02ea14c9b089 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -121,7 +122,8 @@ static int ldlm_expired_completion_wait(void *data)
121 if (!lock->l_conn_export) { 122 if (!lock->l_conn_export) {
122 static unsigned long next_dump, last_dump; 123 static unsigned long next_dump, last_dump;
123 124
124 LDLM_ERROR(lock, "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep", 125 LDLM_ERROR(lock,
126 "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep",
125 (s64)lock->l_last_activity, 127 (s64)lock->l_last_activity,
126 (s64)(ktime_get_real_seconds() - 128 (s64)(ktime_get_real_seconds() -
127 lock->l_last_activity)); 129 lock->l_last_activity));
@@ -139,7 +141,8 @@ static int ldlm_expired_completion_wait(void *data)
139 obd = lock->l_conn_export->exp_obd; 141 obd = lock->l_conn_export->exp_obd;
140 imp = obd->u.cli.cl_import; 142 imp = obd->u.cli.cl_import;
141 ptlrpc_fail_import(imp, lwd->lwd_conn_cnt); 143 ptlrpc_fail_import(imp, lwd->lwd_conn_cnt);
142 LDLM_ERROR(lock, "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s", 144 LDLM_ERROR(lock,
145 "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s",
143 (s64)lock->l_last_activity, 146 (s64)lock->l_last_activity,
144 (s64)(ktime_get_real_seconds() - lock->l_last_activity), 147 (s64)(ktime_get_real_seconds() - lock->l_last_activity),
145 obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); 148 obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
@@ -218,7 +221,8 @@ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
218 return ldlm_completion_tail(lock, data); 221 return ldlm_completion_tail(lock, data);
219 } 222 }
220 223
221 LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, going forward"); 224 LDLM_DEBUG(lock,
225 "client-side enqueue returned a blocked lock, going forward");
222 return 0; 226 return 0;
223} 227}
224EXPORT_SYMBOL(ldlm_completion_ast_async); 228EXPORT_SYMBOL(ldlm_completion_ast_async);
@@ -264,7 +268,8 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
264 return 0; 268 return 0;
265 } 269 }
266 270
267 LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, sleeping"); 271 LDLM_DEBUG(lock,
272 "client-side enqueue returned a blocked lock, sleeping");
268 273
269noreproc: 274noreproc:
270 275
@@ -414,7 +419,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
414 rc = size; 419 rc = size;
415 goto cleanup; 420 goto cleanup;
416 } else if (unlikely(size > lvb_len)) { 421 } else if (unlikely(size > lvb_len)) {
417 LDLM_ERROR(lock, "Replied LVB is larger than expectation, expected = %d, replied = %d", 422 LDLM_ERROR(lock,
423 "Replied LVB is larger than expectation, expected = %d, replied = %d",
418 lvb_len, size); 424 lvb_len, size);
419 rc = -EINVAL; 425 rc = -EINVAL;
420 goto cleanup; 426 goto cleanup;
@@ -473,8 +479,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
473 479
474 if (!ldlm_res_eq(&reply->lock_desc.l_resource.lr_name, 480 if (!ldlm_res_eq(&reply->lock_desc.l_resource.lr_name,
475 &lock->l_resource->lr_name)) { 481 &lock->l_resource->lr_name)) {
476 CDEBUG(D_INFO, "remote intent success, locking " DLDLMRES 482 CDEBUG(D_INFO,
477 " instead of " DLDLMRES "\n", 483 "remote intent success, locking " DLDLMRES " instead of " DLDLMRES "\n",
478 PLDLMRES(&reply->lock_desc.l_resource), 484 PLDLMRES(&reply->lock_desc.l_resource),
479 PLDLMRES(lock->l_resource)); 485 PLDLMRES(lock->l_resource));
480 486
@@ -850,7 +856,8 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock)
850 unlock_res_and_lock(lock); 856 unlock_res_and_lock(lock);
851 857
852 if (local_only) { 858 if (local_only) {
853 CDEBUG(D_DLMTRACE, "not sending request (at caller's instruction)\n"); 859 CDEBUG(D_DLMTRACE,
860 "not sending request (at caller's instruction)\n");
854 rc = LDLM_FL_LOCAL_ONLY; 861 rc = LDLM_FL_LOCAL_ONLY;
855 } 862 }
856 ldlm_lock_cancel(lock); 863 ldlm_lock_cancel(lock);
@@ -963,7 +970,8 @@ static int ldlm_cli_cancel_req(struct obd_export *exp,
963 970
964 rc = ptlrpc_queue_wait(req); 971 rc = ptlrpc_queue_wait(req);
965 if (rc == LUSTRE_ESTALE) { 972 if (rc == LUSTRE_ESTALE) {
966 CDEBUG(D_DLMTRACE, "client/server (nid %s) out of sync -- not fatal\n", 973 CDEBUG(D_DLMTRACE,
974 "client/server (nid %s) out of sync -- not fatal\n",
967 libcfs_nid2str(req->rq_import-> 975 libcfs_nid2str(req->rq_import->
968 imp_connection->c_peer.nid)); 976 imp_connection->c_peer.nid));
969 rc = 0; 977 rc = 0;
@@ -1175,6 +1183,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, struct ldlm_lock *lock,
1175 case LDLM_IBITS: 1183 case LDLM_IBITS:
1176 if (ns->ns_cancel && ns->ns_cancel(lock) != 0) 1184 if (ns->ns_cancel && ns->ns_cancel(lock) != 0)
1177 break; 1185 break;
1186 /* fall through */
1178 default: 1187 default:
1179 result = LDLM_POLICY_SKIP_LOCK; 1188 result = LDLM_POLICY_SKIP_LOCK;
1180 lock_res_and_lock(lock); 1189 lock_res_and_lock(lock);
@@ -1363,13 +1372,14 @@ ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags)
1363 * flags & LDLM_LRU_FLAG_LRUR - use LRU resize policy (SLV from server) to 1372 * flags & LDLM_LRU_FLAG_LRUR - use LRU resize policy (SLV from server) to
1364 * cancel not more than \a count locks; 1373 * cancel not more than \a count locks;
1365 * 1374 *
1366 * flags & LDLM_LRU_FLAG_PASSED - cancel \a count number of old locks (located at 1375 * flags & LDLM_LRU_FLAG_PASSED - cancel \a count number of old locks (located
1367 * the beginning of LRU list); 1376 * at the beginning of LRU list);
1368 * 1377 *
1369 * flags & LDLM_LRU_FLAG_SHRINK - cancel not more than \a count locks according to 1378 * flags & LDLM_LRU_FLAG_SHRINK - cancel not more than \a count locks according
1370 * memory pressure policy function; 1379 * to memory pressure policy function;
1371 * 1380 *
1372 * flags & LDLM_LRU_FLAG_AGED - cancel \a count locks according to "aged policy". 1381 * flags & LDLM_LRU_FLAG_AGED - cancel \a count locks according to
1382 * "aged policy".
1373 * 1383 *
1374 * flags & LDLM_LRU_FLAG_NO_WAIT - cancel as many unused locks as possible 1384 * flags & LDLM_LRU_FLAG_NO_WAIT - cancel as many unused locks as possible
1375 * (typically before replaying locks) w/o 1385 * (typically before replaying locks) w/o
@@ -1383,7 +1393,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
1383 ldlm_cancel_lru_policy_t pf; 1393 ldlm_cancel_lru_policy_t pf;
1384 struct ldlm_lock *lock, *next; 1394 struct ldlm_lock *lock, *next;
1385 int added = 0, unused, remained; 1395 int added = 0, unused, remained;
1386 int no_wait = flags & (LDLM_LRU_FLAG_NO_WAIT | LDLM_LRU_FLAG_LRUR_NO_WAIT); 1396 int no_wait = flags &
1397 (LDLM_LRU_FLAG_NO_WAIT | LDLM_LRU_FLAG_LRUR_NO_WAIT);
1387 1398
1388 spin_lock(&ns->ns_lock); 1399 spin_lock(&ns->ns_lock);
1389 unused = ns->ns_nr_unused; 1400 unused = ns->ns_nr_unused;
@@ -2034,7 +2045,8 @@ static void ldlm_cancel_unused_locks_for_replay(struct ldlm_namespace *ns)
2034 int canceled; 2045 int canceled;
2035 LIST_HEAD(cancels); 2046 LIST_HEAD(cancels);
2036 2047
2037 CDEBUG(D_DLMTRACE, "Dropping as many unused locks as possible before replay for namespace %s (%d)\n", 2048 CDEBUG(D_DLMTRACE,
2049 "Dropping as many unused locks as possible before replay for namespace %s (%d)\n",
2038 ldlm_ns_name(ns), ns->ns_nr_unused); 2050 ldlm_ns_name(ns), ns->ns_nr_unused);
2039 2051
2040 /* We don't need to care whether or not LRU resize is enabled 2052 /* We don't need to care whether or not LRU resize is enabled
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index c2ddf7312571..2689ffdf10e3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1358,7 +1359,8 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res)
1358 LDLM_DEBUG_LIMIT(level, lock, "###"); 1359 LDLM_DEBUG_LIMIT(level, lock, "###");
1359 if (!(level & D_CANTMASK) && 1360 if (!(level & D_CANTMASK) &&
1360 ++granted > ldlm_dump_granted_max) { 1361 ++granted > ldlm_dump_granted_max) {
1361 CDEBUG(level, "only dump %d granted locks to avoid DDOS.\n", 1362 CDEBUG(level,
1363 "only dump %d granted locks to avoid DDOS.\n",
1362 granted); 1364 granted);
1363 break; 1365 break;
1364 } 1366 }
diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c
index 3670fcaf373f..549369739d80 100644
--- a/drivers/staging/lustre/lustre/llite/dcache.c
+++ b/drivers/staging/lustre/lustre/llite/dcache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -141,7 +142,8 @@ void ll_intent_drop_lock(struct lookup_intent *it)
141 142
142 handle.cookie = it->it_lock_handle; 143 handle.cookie = it->it_lock_handle;
143 144
144 CDEBUG(D_DLMTRACE, "releasing lock with cookie %#llx from it %p\n", 145 CDEBUG(D_DLMTRACE,
146 "releasing lock with cookie %#llx from it %p\n",
145 handle.cookie, it); 147 handle.cookie, it);
146 ldlm_lock_decref(&handle, it->it_lock_mode); 148 ldlm_lock_decref(&handle, it->it_lock_mode);
147 149
@@ -152,7 +154,8 @@ void ll_intent_drop_lock(struct lookup_intent *it)
152 if (it->it_remote_lock_mode != 0) { 154 if (it->it_remote_lock_mode != 0) {
153 handle.cookie = it->it_remote_lock_handle; 155 handle.cookie = it->it_remote_lock_handle;
154 156
155 CDEBUG(D_DLMTRACE, "releasing remote lock with cookie%#llx from it %p\n", 157 CDEBUG(D_DLMTRACE,
158 "releasing remote lock with cookie%#llx from it %p\n",
156 handle.cookie, it); 159 handle.cookie, it);
157 ldlm_lock_decref(&handle, 160 ldlm_lock_decref(&handle,
158 it->it_remote_lock_mode); 161 it->it_remote_lock_mode);
@@ -185,7 +188,8 @@ void ll_invalidate_aliases(struct inode *inode)
185 188
186 spin_lock(&inode->i_lock); 189 spin_lock(&inode->i_lock);
187 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { 190 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
188 CDEBUG(D_DENTRY, "dentry in drop %pd (%p) parent %p inode %p flags %d\n", 191 CDEBUG(D_DENTRY,
192 "dentry in drop %pd (%p) parent %p inode %p flags %d\n",
189 dentry, dentry, dentry->d_parent, 193 dentry, dentry, dentry->d_parent,
190 d_inode(dentry), dentry->d_flags); 194 d_inode(dentry), dentry->d_flags);
191 195
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 1db3e7f345c5..5b2e47c246f3 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -303,7 +304,8 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
303 struct md_op_data *op_data; 304 struct md_op_data *op_data;
304 int rc; 305 int rc;
305 306
306 CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p) pos/size %lu/%llu 32bit_api %d\n", 307 CDEBUG(D_VFSTRACE,
308 "VFS Op:inode=" DFID "(%p) pos/size %lu/%llu 32bit_api %d\n",
307 PFID(ll_inode2fid(inode)), inode, (unsigned long)pos, 309 PFID(ll_inode2fid(inode)), inode, (unsigned long)pos,
308 i_size_read(inode), api32); 310 i_size_read(inode), api32);
309 311
@@ -502,7 +504,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
502 break; 504 break;
503 } 505 }
504 default: { 506 default: {
505 CDEBUG(D_IOCTL, "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", 507 CDEBUG(D_IOCTL,
508 "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n",
506 lump->lmm_magic, LOV_USER_MAGIC_V1, 509 lump->lmm_magic, LOV_USER_MAGIC_V1,
507 LOV_USER_MAGIC_V3); 510 LOV_USER_MAGIC_V3);
508 return -EINVAL; 511 return -EINVAL;
@@ -732,10 +735,10 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy)
732 rc = ll_data_version(inode, &data_version, LL_DV_RD_FLUSH); 735 rc = ll_data_version(inode, &data_version, LL_DV_RD_FLUSH);
733 iput(inode); 736 iput(inode);
734 if (rc != 0) { 737 if (rc != 0) {
735 CDEBUG(D_HSM, "Could not read file data version of " 738 CDEBUG(D_HSM,
736 DFID " (rc = %d). Archive request (%#llx) could not be done.\n", 739 "Could not read file data version of " DFID " (rc = %d). Archive request (%#llx) could not be done.\n",
737 PFID(&copy->hc_hai.hai_fid), rc, 740 PFID(&copy->hc_hai.hai_fid), rc,
738 copy->hc_hai.hai_cookie); 741 copy->hc_hai.hai_cookie);
739 hpk.hpk_flags |= HP_FLAG_RETRY; 742 hpk.hpk_flags |= HP_FLAG_RETRY;
740 /* hpk_errval must be >= 0 */ 743 /* hpk_errval must be >= 0 */
741 hpk.hpk_errval = -rc; 744 hpk.hpk_errval = -rc;
@@ -816,7 +819,8 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy)
816 rc = ll_data_version(inode, &data_version, LL_DV_RD_FLUSH); 819 rc = ll_data_version(inode, &data_version, LL_DV_RD_FLUSH);
817 iput(inode); 820 iput(inode);
818 if (rc) { 821 if (rc) {
819 CDEBUG(D_HSM, "Could not read file data version. Request could not be confirmed.\n"); 822 CDEBUG(D_HSM,
823 "Could not read file data version. Request could not be confirmed.\n");
820 if (hpk.hpk_errval == 0) 824 if (hpk.hpk_errval == 0)
821 hpk.hpk_errval = -rc; 825 hpk.hpk_errval = -rc;
822 goto progress; 826 goto progress;
@@ -832,8 +836,7 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy)
832 */ 836 */
833 if ((copy->hc_hai.hai_action == HSMA_ARCHIVE) && 837 if ((copy->hc_hai.hai_action == HSMA_ARCHIVE) &&
834 (copy->hc_data_version != data_version)) { 838 (copy->hc_data_version != data_version)) {
835 CDEBUG(D_HSM, "File data version mismatched. File content was changed during archiving. " 839 CDEBUG(D_HSM, "File data version mismatched. File content was changed during archiving. " DFID ", start:%#llx current:%#llx\n",
836 DFID ", start:%#llx current:%#llx\n",
837 PFID(&copy->hc_hai.hai_fid), 840 PFID(&copy->hc_hai.hai_fid),
838 copy->hc_data_version, data_version); 841 copy->hc_data_version, data_version);
839 /* File was changed, send error to cdt. Do not ask for 842 /* File was changed, send error to cdt. Do not ask for
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index be665454f407..2d6e64dea266 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -386,8 +387,8 @@ static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize,
386 ll_finish_md_op_data(op_data); 387 ll_finish_md_op_data(op_data);
387 if (rc == -ESTALE) { 388 if (rc == -ESTALE) {
388 /* reason for keep own exit path - don`t flood log 389 /* reason for keep own exit path - don`t flood log
389 * with messages with -ESTALE errors. 390 * with messages with -ESTALE errors.
390 */ 391 */
391 if (!it_disposition(itp, DISP_OPEN_OPEN) || 392 if (!it_disposition(itp, DISP_OPEN_OPEN) ||
392 it_open_error(DISP_OPEN_OPEN, itp)) 393 it_open_error(DISP_OPEN_OPEN, itp))
393 goto out; 394 goto out;
@@ -605,7 +606,8 @@ restart:
605 * to get file with different fid. 606 * to get file with different fid.
606 */ 607 */
607 it->it_flags |= MDS_OPEN_LOCK | MDS_OPEN_BY_FID; 608 it->it_flags |= MDS_OPEN_LOCK | MDS_OPEN_BY_FID;
608 rc = ll_intent_file_open(file->f_path.dentry, NULL, 0, it); 609 rc = ll_intent_file_open(file->f_path.dentry,
610 NULL, 0, it);
609 if (rc) 611 if (rc)
610 goto out_openerr; 612 goto out_openerr;
611 613
@@ -1119,7 +1121,8 @@ out:
1119 cl_io_fini(env, io); 1121 cl_io_fini(env, io);
1120 1122
1121 if ((!rc || rc == -ENODATA) && count > 0 && io->ci_need_restart) { 1123 if ((!rc || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
1122 CDEBUG(D_VFSTRACE, "%s: restart %s from %lld, count:%zu, result: %zd\n", 1124 CDEBUG(D_VFSTRACE,
1125 "%s: restart %s from %lld, count:%zu, result: %zd\n",
1123 file_dentry(file)->d_name.name, 1126 file_dentry(file)->d_name.name,
1124 iot == CIT_READ ? "read" : "write", 1127 iot == CIT_READ ? "read" : "write",
1125 *ppos, count, result); 1128 *ppos, count, result);
@@ -3455,7 +3458,8 @@ out:
3455 if (rc == 0) 3458 if (rc == 0)
3456 rc = -EAGAIN; 3459 rc = -EAGAIN;
3457 3460
3458 CDEBUG(D_INODE, "%s: file=" DFID " waiting layout return: %d.\n", 3461 CDEBUG(D_INODE,
3462 "%s: file=" DFID " waiting layout return: %d.\n",
3459 ll_get_fsname(inode->i_sb, NULL, 0), 3463 ll_get_fsname(inode->i_sb, NULL, 0),
3460 PFID(&lli->lli_fid), rc); 3464 PFID(&lli->lli_fid), rc);
3461 } 3465 }
diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c
index 34c2cfecf4b8..c43ac574274c 100644
--- a/drivers/staging/lustre/lustre/llite/glimpse.c
+++ b/drivers/staging/lustre/lustre/llite/glimpse.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index d2392e4c6872..df5c0c0ae703 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
index 422f410d95c1..a246b955306e 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 0287c751e1cd..b133fd00c08c 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -84,7 +85,7 @@ struct ll_dentry_data {
84 85
85struct ll_getname_data { 86struct ll_getname_data {
86 struct dir_context ctx; 87 struct dir_context ctx;
87 char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ 88 char *lgd_name; /* points to buffer with NAME_MAX+1 size */
88 struct lu_fid lgd_fid; /* target fid we are looking for */ 89 struct lu_fid lgd_fid; /* target fid we are looking for */
89 int lgd_found; /* inode matched? */ 90 int lgd_found; /* inode matched? */
90}; 91};
@@ -392,7 +393,8 @@ enum stats_track_type {
392#define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */ 393#define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */
393#define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */ 394#define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */
394#define LL_SBI_ALWAYS_PING 0x200000 /* always ping even if server 395#define LL_SBI_ALWAYS_PING 0x200000 /* always ping even if server
395 * suppress_pings */ 396 * suppress_pings
397 */
396 398
397#define LL_SBI_FLAGS { \ 399#define LL_SBI_FLAGS { \
398 "nolck", \ 400 "nolck", \
@@ -637,7 +639,8 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
637#if BITS_PER_LONG == 32 639#if BITS_PER_LONG == 32
638 return 1; 640 return 1;
639#elif defined(CONFIG_COMPAT) 641#elif defined(CONFIG_COMPAT)
640 return unlikely(in_compat_syscall() || (sbi->ll_flags & LL_SBI_32BIT_API)); 642 return unlikely(in_compat_syscall() ||
643 (sbi->ll_flags & LL_SBI_32BIT_API));
641#else 644#else
642 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API); 645 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
643#endif 646#endif
@@ -1065,7 +1068,7 @@ struct ll_statahead_info {
1065 * hidden entries 1068 * hidden entries
1066 */ 1069 */
1067 sai_agl_valid:1,/* AGL is valid for the dir */ 1070 sai_agl_valid:1,/* AGL is valid for the dir */
1068 sai_in_readpage:1;/* statahead is in readdir() */ 1071 sai_in_readpage:1;/* statahead in readdir() */
1069 wait_queue_head_t sai_waitq; /* stat-ahead wait queue */ 1072 wait_queue_head_t sai_waitq; /* stat-ahead wait queue */
1070 struct ptlrpc_thread sai_thread; /* stat-ahead thread */ 1073 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
1071 struct ptlrpc_thread sai_agl_thread; /* AGL thread */ 1074 struct ptlrpc_thread sai_agl_thread; /* AGL thread */
@@ -1198,7 +1201,7 @@ typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
1198 * Return value: 1201 * Return value:
1199 * A magic pointer will be returned if success; 1202 * A magic pointer will be returned if success;
1200 * otherwise, NULL will be returned. 1203 * otherwise, NULL will be returned.
1201 * */ 1204 */
1202void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd); 1205void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
1203void ll_iocontrol_unregister(void *magic); 1206void ll_iocontrol_unregister(void *magic);
1204 1207
@@ -1261,7 +1264,8 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,
1261 1264
1262 handle.cookie = it->it_lock_handle; 1265 handle.cookie = it->it_lock_handle;
1263 1266
1264 CDEBUG(D_DLMTRACE, "setting l_data to inode " DFID "%p for lock %#llx\n", 1267 CDEBUG(D_DLMTRACE,
1268 "setting l_data to inode " DFID "%p for lock %#llx\n",
1265 PFID(ll_inode2fid(inode)), inode, handle.cookie); 1269 PFID(ll_inode2fid(inode)), inode, handle.cookie);
1266 1270
1267 md_set_lock_data(exp, &handle, inode, &it->it_lock_bits); 1271 md_set_lock_data(exp, &handle, inode, &it->it_lock_bits);
@@ -1284,7 +1288,8 @@ static inline int d_lustre_invalid(const struct dentry *dentry)
1284 */ 1288 */
1285static inline void d_lustre_invalidate(struct dentry *dentry, int nested) 1289static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1286{ 1290{
1287 CDEBUG(D_DENTRY, "invalidate dentry %pd (%p) parent %p inode %p refc %d\n", 1291 CDEBUG(D_DENTRY,
1292 "invalidate dentry %pd (%p) parent %p inode %p refc %d\n",
1288 dentry, dentry, 1293 dentry, dentry,
1289 dentry->d_parent, d_inode(dentry), d_count(dentry)); 1294 dentry->d_parent, d_inode(dentry), d_count(dentry));
1290 1295
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 25393e3a0fe8..65ac5128f005 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -231,7 +232,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
231 err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, 232 err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid,
232 data, NULL); 233 data, NULL);
233 if (err == -EBUSY) { 234 if (err == -EBUSY) {
234 LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", 235 LCONSOLE_ERROR_MSG(0x14f,
236 "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n",
235 md); 237 md);
236 goto out; 238 goto out;
237 } else if (err) { 239 } else if (err) {
@@ -279,7 +281,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
279 } 281 }
280 obd_connect_flags2str(buf, PAGE_SIZE, 282 obd_connect_flags2str(buf, PAGE_SIZE,
281 valid ^ CLIENT_CONNECT_MDT_REQD, ","); 283 valid ^ CLIENT_CONNECT_MDT_REQD, ",");
282 LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n", 284 LCONSOLE_ERROR_MSG(0x170,
285 "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n",
283 sbi->ll_md_exp->exp_obd->obd_name, buf); 286 sbi->ll_md_exp->exp_obd->obd_name, buf);
284 kfree(buf); 287 kfree(buf);
285 err = -EPROTO; 288 err = -EPROTO;
@@ -380,7 +383,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
380 if (sbi->ll_flags & LL_SBI_ALWAYS_PING) 383 if (sbi->ll_flags & LL_SBI_ALWAYS_PING)
381 data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS; 384 data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS;
382 385
383 CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d\n", 386 CDEBUG(D_RPCTRACE,
387 "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d\n",
384 data->ocd_connect_flags, 388 data->ocd_connect_flags,
385 data->ocd_version, data->ocd_grant); 389 data->ocd_version, data->ocd_grant);
386 390
@@ -392,7 +396,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
392 err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, 396 err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data,
393 NULL); 397 NULL);
394 if (err == -EBUSY) { 398 if (err == -EBUSY) {
395 LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", 399 LCONSOLE_ERROR_MSG(0x150,
400 "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n",
396 dt); 401 dt);
397 goto out_md; 402 goto out_md;
398 } else if (err) { 403 } else if (err) {
@@ -915,7 +920,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
915 /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ 920 /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */
916 lprof = class_get_profile(profilenm); 921 lprof = class_get_profile(profilenm);
917 if (!lprof) { 922 if (!lprof) {
918 LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n", 923 LCONSOLE_ERROR_MSG(0x156,
924 "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n",
919 profilenm); 925 profilenm);
920 err = -EINVAL; 926 err = -EINVAL;
921 goto out_free; 927 goto out_free;
@@ -1042,7 +1048,8 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock)
1042 } else { 1048 } else {
1043 inode = lock->l_resource->lr_lvb_inode; 1049 inode = lock->l_resource->lr_lvb_inode;
1044 LDLM_DEBUG_LIMIT(inode->i_state & I_FREEING ? D_INFO : 1050 LDLM_DEBUG_LIMIT(inode->i_state & I_FREEING ? D_INFO :
1045 D_WARNING, lock, "lr_lvb_inode %p is bogus: magic %08x", 1051 D_WARNING, lock,
1052 "lr_lvb_inode %p is bogus: magic %08x",
1046 lock->l_resource->lr_lvb_inode, 1053 lock->l_resource->lr_lvb_inode,
1047 lli->lli_inode_magic); 1054 lli->lli_inode_magic);
1048 inode = NULL; 1055 inode = NULL;
@@ -1744,7 +1751,8 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
1744 } 1751 }
1745 if (body->mbo_valid & OBD_MD_FLMTIME) { 1752 if (body->mbo_valid & OBD_MD_FLMTIME) {
1746 if (body->mbo_mtime > LTIME_S(inode->i_mtime)) { 1753 if (body->mbo_mtime > LTIME_S(inode->i_mtime)) {
1747 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %llu\n", 1754 CDEBUG(D_INODE,
1755 "setting ino %lu mtime from %lu to %llu\n",
1748 inode->i_ino, LTIME_S(inode->i_mtime), 1756 inode->i_ino, LTIME_S(inode->i_mtime),
1749 body->mbo_mtime); 1757 body->mbo_mtime);
1750 LTIME_S(inode->i_mtime) = body->mbo_mtime; 1758 LTIME_S(inode->i_mtime) = body->mbo_mtime;
@@ -2254,7 +2262,8 @@ int ll_process_config(struct lustre_cfg *lcfg)
2254 return -EINVAL; 2262 return -EINVAL;
2255 sb = (void *)x; 2263 sb = (void *)x;
2256 /* This better be a real Lustre superblock! */ 2264 /* This better be a real Lustre superblock! */
2257 LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == LMD_MAGIC); 2265 LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic ==
2266 LMD_MAGIC);
2258 2267
2259 /* Note we have not called client_common_fill_super yet, so 2268 /* Note we have not called client_common_fill_super yet, so
2260 * proc fns must be able to handle that! 2269 * proc fns must be able to handle that!
@@ -2571,8 +2580,9 @@ static int ll_linkea_decode(struct linkea_data *ldata, unsigned int linkno,
2571 * 2580 *
2572 * \param[in] file - File descriptor against which to perform the operation 2581 * \param[in] file - File descriptor against which to perform the operation
2573 * \param[in,out] arg - User-filled structure containing the linkno to operate 2582 * \param[in,out] arg - User-filled structure containing the linkno to operate
2574 * on and the available size. It is eventually filled with 2583 * on and the available size. It is eventually filled
2575 * the requested information or left untouched on error 2584 * with the requested information or left untouched on
2585 * error
2576 * 2586 *
2577 * \retval - 0 on success 2587 * \retval - 0 on success
2578 * \retval - Appropriate negative error code on failure 2588 * \retval - Appropriate negative error code on failure
diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index ccc7ae15a943..c0533bd6f352 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -208,7 +209,8 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
208 */ 209 */
209 unlock_page(vmpage); 210 unlock_page(vmpage);
210 211
211 CDEBUG(D_MMAP, "Race on page_mkwrite %p/%lu, page has been written out, retry.\n", 212 CDEBUG(D_MMAP,
213 "Race on page_mkwrite %p/%lu, page has been written out, retry.\n",
212 vmpage, vmpage->index); 214 vmpage, vmpage->index);
213 215
214 *retry = true; 216 *retry = true;
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index e50c637fab54..a6a1d80c711a 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -127,7 +128,8 @@ struct lustre_nfs_fid {
127}; 128};
128 129
129static struct dentry * 130static struct dentry *
130ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *parent) 131ll_iget_for_nfs(struct super_block *sb,
132 struct lu_fid *fid, struct lu_fid *parent)
131{ 133{
132 struct inode *inode; 134 struct inode *inode;
133 struct dentry *result; 135 struct dentry *result;
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index e3bd2d18eac5..644bea2f9d37 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 5cc2b3255207..a2687f46a16d 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -204,7 +205,8 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
204 205
205 if (!fid_res_name_eq(ll_inode2fid(inode), 206 if (!fid_res_name_eq(ll_inode2fid(inode),
206 &lock->l_resource->lr_name)) { 207 &lock->l_resource->lr_name)) {
207 LDLM_ERROR(lock, "data mismatch with object " DFID "(%p)", 208 LDLM_ERROR(lock,
209 "data mismatch with object " DFID "(%p)",
208 PFID(ll_inode2fid(inode)), inode); 210 PFID(ll_inode2fid(inode)), inode);
209 LBUG(); 211 LBUG();
210 } 212 }
@@ -289,7 +291,8 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
289 * we have to invalidate the negative children 291 * we have to invalidate the negative children
290 * on master inode 292 * on master inode
291 */ 293 */
292 CDEBUG(D_INODE, "Invalidate s" DFID " m" DFID "\n", 294 CDEBUG(D_INODE,
295 "Invalidate s" DFID " m" DFID "\n",
293 PFID(ll_inode2fid(inode)), 296 PFID(ll_inode2fid(inode)),
294 PFID(&lli->lli_pfid)); 297 PFID(&lli->lli_pfid));
295 298
@@ -736,7 +739,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
736 739
737 *opened |= FILE_CREATED; 740 *opened |= FILE_CREATED;
738 } 741 }
739 if (d_really_is_positive(dentry) && it_disposition(it, DISP_OPEN_OPEN)) { 742 if (d_really_is_positive(dentry) &&
743 it_disposition(it, DISP_OPEN_OPEN)) {
740 /* Open dentry. */ 744 /* Open dentry. */
741 if (S_ISFIFO(d_inode(dentry)->i_mode)) { 745 if (S_ISFIFO(d_inode(dentry)->i_mode)) {
742 /* We cannot call open here as it might 746 /* We cannot call open here as it might
@@ -949,7 +953,9 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild,
949 953
950 switch (mode & S_IFMT) { 954 switch (mode & S_IFMT) {
951 case 0: 955 case 0:
952 mode |= S_IFREG; /* for mode = 0 case, fallthrough */ 956 mode |= S_IFREG;
957 /* for mode = 0 case */
958 /* fall through */
953 case S_IFREG: 959 case S_IFREG:
954 case S_IFCHR: 960 case S_IFCHR:
955 case S_IFBLK: 961 case S_IFBLK:
@@ -980,7 +986,8 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry,
980{ 986{
981 int rc; 987 int rc;
982 988
983 CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p), flags=%u, excl=%d\n", 989 CDEBUG(D_VFSTRACE,
990 "VFS Op:name=%pd, dir=" DFID "(%p), flags=%u, excl=%d\n",
984 dentry, PFID(ll_inode2fid(dir)), dir, mode, want_excl); 991 dentry, PFID(ll_inode2fid(dir)), dir, mode, want_excl);
985 992
986 rc = ll_mknod(dir, dentry, mode, 0); 993 rc = ll_mknod(dir, dentry, mode, 0);
@@ -1101,7 +1108,8 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
1101 struct md_op_data *op_data; 1108 struct md_op_data *op_data;
1102 int err; 1109 int err;
1103 1110
1104 CDEBUG(D_VFSTRACE, "VFS Op: inode=" DFID "(%p), dir=" DFID "(%p), target=%pd\n", 1111 CDEBUG(D_VFSTRACE,
1112 "VFS Op: inode=" DFID "(%p), dir=" DFID "(%p), target=%pd\n",
1105 PFID(ll_inode2fid(src)), src, PFID(ll_inode2fid(dir)), dir, 1113 PFID(ll_inode2fid(src)), src, PFID(ll_inode2fid(dir)), dir,
1106 new_dentry); 1114 new_dentry);
1107 1115
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c b/drivers/staging/lustre/lustre/llite/range_lock.c
index a32598bacdfb..cc9565f6bfe2 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.c
+++ b/drivers/staging/lustre/lustre/llite/range_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.h b/drivers/staging/lustre/lustre/llite/range_lock.h
index 1e1519b1e006..38b2be4e378f 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.h
+++ b/drivers/staging/lustre/lustre/llite/range_lock.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
index e72090572bcc..3e008ce7275d 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -297,7 +298,8 @@ stride_pg_count(pgoff_t st_off, unsigned long st_len, unsigned long st_pgs,
297 else 298 else
298 pg_count = start_left + st_pgs * (end - start - 1) + end_left; 299 pg_count = start_left + st_pgs * (end - start - 1) + end_left;
299 300
300 CDEBUG(D_READA, "st_off %lu, st_len %lu st_pgs %lu off %lu length %lu pgcount %lu\n", 301 CDEBUG(D_READA,
302 "st_off %lu, st_len %lu st_pgs %lu off %lu length %lu pgcount %lu\n",
301 st_off, st_len, st_pgs, off, length, pg_count); 303 st_off, st_len, st_pgs, off, length, pg_count);
302 304
303 return pg_count; 305 return pg_count;
@@ -404,7 +406,8 @@ ll_read_ahead_pages(const struct lu_env *env, struct cl_io *io,
404 * forward read-ahead, it will be fixed when backward 406 * forward read-ahead, it will be fixed when backward
405 * read-ahead is implemented 407 * read-ahead is implemented
406 */ 408 */
407 LASSERTF(page_idx >= ria->ria_stoff, "Invalid page_idx %lu rs %lu re %lu ro %lu rl %lu rp %lu\n", 409 LASSERTF(page_idx >= ria->ria_stoff,
410 "Invalid page_idx %lu rs %lu re %lu ro %lu rl %lu rp %lu\n",
408 page_idx, 411 page_idx,
409 ria->ria_start, ria->ria_end, ria->ria_stoff, 412 ria->ria_start, ria->ria_end, ria->ria_stoff,
410 ria->ria_length, ria->ria_pages); 413 ria->ria_length, ria->ria_pages);
@@ -669,8 +672,9 @@ static void ras_stride_increase_window(struct ll_readahead_state *ras,
669 unsigned long stride_len; 672 unsigned long stride_len;
670 673
671 LASSERT(ras->ras_stride_length > 0); 674 LASSERT(ras->ras_stride_length > 0);
672 LASSERTF(ras->ras_window_start + ras->ras_window_len 675 LASSERTF(ras->ras_window_start + ras->ras_window_len >=
673 >= ras->ras_stride_offset, "window_start %lu, window_len %lu stride_offset %lu\n", 676 ras->ras_stride_offset,
677 "window_start %lu, window_len %lu stride_offset %lu\n",
674 ras->ras_window_start, 678 ras->ras_window_start,
675 ras->ras_window_len, ras->ras_stride_offset); 679 ras->ras_window_len, ras->ras_stride_offset);
676 680
@@ -766,7 +770,8 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
766 PAGE_SHIFT; 770 PAGE_SHIFT;
767 771
768 CDEBUG(D_READA, "kmsp %llu mwp %lu mp %lu\n", kms_pages, 772 CDEBUG(D_READA, "kmsp %llu mwp %lu mp %lu\n", kms_pages,
769 ra->ra_max_read_ahead_whole_pages, ra->ra_max_pages_per_file); 773 ra->ra_max_read_ahead_whole_pages,
774 ra->ra_max_pages_per_file);
770 775
771 if (kms_pages && 776 if (kms_pages &&
772 kms_pages <= ra->ra_max_read_ahead_whole_pages) { 777 kms_pages <= ra->ra_max_read_ahead_whole_pages) {
@@ -884,7 +889,8 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
884 889
885 /* The initial ras_window_len is set to the request size. To avoid 890 /* The initial ras_window_len is set to the request size. To avoid
886 * uselessly reading and discarding pages for random IO the window is 891 * uselessly reading and discarding pages for random IO the window is
887 * only increased once per consecutive request received. */ 892 * only increased once per consecutive request received.
893 */
888 if ((ras->ras_consecutive_requests > 1 || stride_detect) && 894 if ((ras->ras_consecutive_requests > 1 || stride_detect) &&
889 !ras->ras_request_index) 895 !ras->ras_request_index)
890 ras_increase_window(inode, ras, ra); 896 ras_increase_window(inode, ras, ra);
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index 3619cd8bb5f3..722e5ea1af5f 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index ea9d59f07b78..90c7324575e4 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1082,7 +1083,8 @@ static int ll_statahead_thread(void *arg)
1082 struct ll_inode_info *clli; 1083 struct ll_inode_info *clli;
1083 1084
1084 clli = list_entry(sai->sai_agls.next, 1085 clli = list_entry(sai->sai_agls.next,
1085 struct ll_inode_info, lli_agl_list); 1086 struct ll_inode_info,
1087 lli_agl_list);
1086 list_del_init(&clli->lli_agl_list); 1088 list_del_init(&clli->lli_agl_list);
1087 spin_unlock(&lli->lli_agl_lock); 1089 spin_unlock(&lli->lli_agl_lock);
1088 1090
diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c
index 0da4af81b830..0bda111a096e 100644
--- a/drivers/staging/lustre/lustre/llite/super25.c
+++ b/drivers/staging/lustre/lustre/llite/super25.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -88,7 +89,8 @@ static int __init lustre_init(void)
88 struct timespec64 ts; 89 struct timespec64 ts;
89 int i, rc, seed[2]; 90 int i, rc, seed[2];
90 91
91 BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) != LUSTRE_VOLATILE_HDR_LEN + 1); 92 BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) !=
93 LUSTRE_VOLATILE_HDR_LEN + 1);
92 94
93 /* print an address of _any_ initialized kernel symbol from this 95 /* print an address of _any_ initialized kernel symbol from this
94 * module, to allow debugging with gdb that doesn't support data 96 * module, to allow debugging with gdb that doesn't support data
diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c
index 3cd33483afaf..0690fdbf49f5 100644
--- a/drivers/staging/lustre/lustre/llite/symlink.c
+++ b/drivers/staging/lustre/lustre/llite/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index f9d9a161bd4e..8ccc8b799c02 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
index adce0ff4ae44..02ea5161d635 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
index c83853fa1bb4..bfae98e82d6f 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c
index e522f7c00617..4b6c7143bd2c 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_lock.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c
index 3953750b334e..05ad3b322a29 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_object.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c
index 687c0c79d621..6eb0565ddc22 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_page.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 0be55623bac4..532384c91447 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c
index 80ee3920481a..dbf9be2eebd4 100644
--- a/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -364,7 +364,8 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
364 } 364 }
365 365
366 if (oit->it_status < 0) { 366 if (oit->it_status < 0) {
367 CDEBUG(D_CACHE, "getxattr intent returned %d for fid " DFID "\n", 367 CDEBUG(D_CACHE,
368 "getxattr intent returned %d for fid " DFID "\n",
368 oit->it_status, PFID(ll_inode2fid(inode))); 369 oit->it_status, PFID(ll_inode2fid(inode)));
369 rc = oit->it_status; 370 rc = oit->it_status;
370 /* xattr data is so large that we don't want to cache it */ 371 /* xattr data is so large that we don't want to cache it */
diff --git a/drivers/staging/lustre/lustre/llite/xattr_security.c b/drivers/staging/lustre/lustre/llite/xattr_security.c
index 391fb25ac31d..93ec07531ac7 100644
--- a/drivers/staging/lustre/lustre/llite/xattr_security.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c
index 5937468080b8..00dc858c10c9 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
index 22c247a7d8ca..1793c9f79b24 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index a0475231dd90..c27c3c32188d 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 6e16c930a021..c2c57f65431e 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
index f16cfa435f77..30727b7acccc 100644
--- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
+++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index 89d92b05b48c..1185eceaf497 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c
index cea5f9dcd04e..c7db23472346 100644
--- a/drivers/staging/lustre/lustre/lov/lov_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lov_dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 1124fd5ab32f..d563dd73343a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index a21f074008af..ae28ddf80d9b 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index 9e3b150967b4..c5f5d1b106dc 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c
index e12dc5afc14f..2fcdeb707ff9 100644
--- a/drivers/staging/lustre/lustre/lov/lov_lock.c
+++ b/drivers/staging/lustre/lustre/lov/lov_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c
index 916336115989..3796bbb25305 100644
--- a/drivers/staging/lustre/lustre/lov/lov_merge.c
+++ b/drivers/staging/lustre/lustre/lov/lov_merge.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index fefd3c588681..7ce01026a409 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c
index 334ecb1bc049..105b707eed14 100644
--- a/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c
index 899d12c41aab..3e16e647b334 100644
--- a/drivers/staging/lustre/lustre/lov/lov_offset.c
+++ b/drivers/staging/lustre/lustre/lov/lov_offset.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c
index 24fb2a97532b..e5b11c4085a9 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c
index de43c609cf3d..cfae1294d77a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_page.c
+++ b/drivers/staging/lustre/lustre/lov/lov_page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c
index d774ee2a3675..ecd9329cd073 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pool.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pool.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 9d3b3f3e9f10..3bdf48e4edb4 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
index d4646a0949d2..7e89a2e485fc 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c
index d29f0bb33980..ea492be2eef3 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c
index 011296ee16e6..13d452086b61 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_object.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c
index b2e68c3e820d..915520bcdd60 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_page.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
index 9bb7e9ea0a6a..721440feef72 100644
--- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index f68513771527..6cce32491eb5 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
index cbf011501005..e0300c34ca3a 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h
+++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
index ba13f0894e0d..46eefdc09e3a 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index cbfea3dd0319..3114907ac5ff 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index f45c91d1b4ae..488b98007558 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 6ef8ddec4ab6..9e538a59f09d 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
index 2ec2d7f731d3..636770624e8f 100644
--- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
+++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index 7a2f2b7bc6b1..2c571c180578 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 3d2b969c90a7..77fa8fea0249 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_internal.h b/drivers/staging/lustre/lustre/obdclass/cl_internal.h
index 7b403fbd5f94..a0db830ca841 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_internal.h
+++ b/drivers/staging/lustre/lustre/obdclass/cl_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index 2a70e21ae07f..6ec5218a18c1 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
index 20e64051d2d6..d415f8396038 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 95c7fa3b532c..fdd27ce46fda 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index 3dc084cb93bc..7f65439f9b95 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 2df218b010e1..2985bca4dc4c 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c
index 7964cad7e780..2156a82a613a 100644
--- a/drivers/staging/lustre/lustre/obdclass/debug.c
+++ b/drivers/staging/lustre/lustre/obdclass/debug.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 739bfb9421ca..b1d6ba4a3190 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
index 4f0a42633d5a..b9bf81607bbf 100644
--- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
+++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/linkea.c b/drivers/staging/lustre/lustre/obdclass/linkea.c
index 9af86d3d56e4..fe1638b0916e 100644
--- a/drivers/staging/lustre/lustre/obdclass/linkea.c
+++ b/drivers/staging/lustre/lustre/obdclass/linkea.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 6df911112731..fc59f29a4290 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index e92cccceefa1..e5e8687784ee 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 98021a2d7238..cd051e31233e 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index 8fa969101650..d9c63adff206 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/drivers/staging/lustre/lustre/obdclass/llog_internal.h
index 8de90bc638b4..4991d4e589dc 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_internal.h
+++ b/drivers/staging/lustre/lustre/obdclass/llog_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
index 3c42de966077..28bbaa2136ac 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c
index d2d3114ce008..b431c3408fe4 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
index e4829880dc10..c83b7d7f8e72 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index e79485b4bf7f..05d71f568837 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -1507,12 +1508,16 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
1507 switch (tolower(*end)) { 1508 switch (tolower(*end)) {
1508 case 'p': 1509 case 'p':
1509 units <<= 10; 1510 units <<= 10;
1511 /* fall through */
1510 case 't': 1512 case 't':
1511 units <<= 10; 1513 units <<= 10;
1514 /* fall through */
1512 case 'g': 1515 case 'g':
1513 units <<= 10; 1516 units <<= 10;
1517 /* fall through */
1514 case 'm': 1518 case 'm':
1515 units <<= 10; 1519 units <<= 10;
1520 /* fall through */
1516 case 'k': 1521 case 'k':
1517 units <<= 10; 1522 units <<= 10;
1518 } 1523 }
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 09c98184a291..b938a3f9d50a 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
index fa690b2bd643..54fc88206534 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index e1273c997b5f..71329adc0318 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
index 2798d35ad318..e286a2665423 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 94a940faca5d..c0e192ae22a9 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 1256034b60c1..2a79a223b98a 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c
index 7083f8786e9a..c4503bc36591 100644
--- a/drivers/staging/lustre/lustre/obdclass/obdo.c
+++ b/drivers/staging/lustre/lustre/obdclass/obdo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
index 89abea26a1f8..355e888885f4 100644
--- a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
+++ b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c
index 9b1872b99f2a..6cf7a03f048f 100644
--- a/drivers/staging/lustre/lustre/obdclass/uuid.c
+++ b/drivers/staging/lustre/lustre/obdclass/uuid.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index f9808d1cc352..b9c1dc7e61b0 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/drivers/staging/lustre/lustre/obdecho/echo_internal.h
index 966414fd5424..42faa164fabb 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_internal.h
+++ b/drivers/staging/lustre/lustre/obdecho/echo_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index ae13eb055229..dc76c35ae801 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index e1207c227b79..5767ac2a7d16 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -227,6 +228,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
227 rc = 65; 228 rc = 65;
228 goto out; 229 goto out;
229 } 230 }
231 /* fall through */
230 default: 232 default:
231 if (atomic_read(&ext->oe_users) > 0) { 233 if (atomic_read(&ext->oe_users) > 0) {
232 rc = 70; 234 rc = 70;
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 35bdbfb8660d..1449013722f6 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c
index cf7b8879d7f0..2b5f324743e2 100644
--- a/drivers/staging/lustre/lustre/osc/osc_dev.c
+++ b/drivers/staging/lustre/lustre/osc/osc_dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index a536908fb26a..feda61bcdb9b 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index f7969e33f28a..76743faf3e6d 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
index b4f1f74dead8..fe8ed0d0497a 100644
--- a/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 945ae6e5a8b1..f82c87a77550 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index ed8a0dc18ee5..20094b6309f9 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c
index a6118f8ba446..ce1731dc604f 100644
--- a/drivers/staging/lustre/lustre/osc/osc_quota.c
+++ b/drivers/staging/lustre/lustre/osc/osc_quota.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 4c68c42b2281..53eda4c99142 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index b1d379a6a70f..2a9f2f2ebaa8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c
index cfdcbcec2779..dfdb4587d49d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/connection.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c
index cb788364a553..54f0c36dc2bd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c
index 62951f19b2ce..811b7ab3a582 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/events.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/events.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 21f528957b73..5b0f65536c29 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c
index 85854d9a376d..18769d335751 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/layout.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 480c20a6a792..254488be7093 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
index bc5aa7bcdba8..bc4398b9bd1d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 1392ae9747bd..36eea50a77e7 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
index 12149fb64719..047d712e850c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 2969d8da270e..4847f9a90cc9 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index df330e43bfe5..8251cbf2ad68 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index aad4ff191d95..a64e125df95f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -786,7 +787,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
786 787
787 CERROR("invalid msg %p: no ptlrpc body!\n", msg); 788 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
788 } 789 }
789 /* no break */ 790 /* fall through */
790 default: 791 default:
791 /* flags might be printed in debug code while message 792 /* flags might be printed in debug code while message
792 * uninitialized 793 * uninitialized
@@ -854,7 +855,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
854 855
855 CERROR("invalid msg %p: no ptlrpc body!\n", msg); 856 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
856 } 857 }
857 /* no break */ 858 /* fall through */
858 default: 859 default:
859 return 0; 860 return 0;
860 } 861 }
@@ -1035,7 +1036,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
1035 1036
1036 CERROR("invalid msg %p: no ptlrpc body!\n", msg); 1037 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1037 } 1038 }
1038 /* no break */ 1039 /* fall through */
1039 default: 1040 default:
1040 /* status might be printed in debug code while message 1041 /* status might be printed in debug code while message
1041 * uninitialized 1042 * uninitialized
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c
index 643388b03af7..2466868afb9c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index e4de50e18d08..fe6b47bfe8be 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
index c38e166f1502..f9decbd1459d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
index 38e488dd5409..131fc6d9646e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index 0e476828cf75..8b865294d933 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c
index 72a19a379e2f..e4d3f23e9f3a 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/recover.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index cd7a5391a574..617e004d00f8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
@@ -847,7 +848,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
847 if (req->rq_pool || !req->rq_reqbuf) 848 if (req->rq_pool || !req->rq_reqbuf)
848 return; 849 return;
849 850
850 kfree(req->rq_reqbuf); 851 kvfree(req->rq_reqbuf);
851 req->rq_reqbuf = NULL; 852 req->rq_reqbuf = NULL;
852 req->rq_reqbuf_len = 0; 853 req->rq_reqbuf_len = 0;
853} 854}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index 059294aad172..77a3721beaee 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
index 0f4af66688a3..2389f9a8f534 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
index d10a8053d04f..8d1e0edfcede 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
index 7792132eb145..fd609b63d2de 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
index dc39a54c5e1a..80cea0b24693 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 6aa9b65b1926..44e34056515b 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index 155f6a45cc8b..23cdb7c4476c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
index 07b86a1b6550..2f64eb417e77 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * GPL HEADER START 3 * GPL HEADER START
3 * 4 *
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index c32240262f57..6e87aa5aab4c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -151,7 +151,7 @@ static void atomisp_css2_hw_store(hrt_address addr,
151 const void *from, uint32_t n) 151 const void *from, uint32_t n)
152{ 152{
153 unsigned long flags; 153 unsigned long flags;
154 unsigned i; 154 unsigned int i;
155 unsigned int _to = (unsigned int)addr; 155 unsigned int _to = (unsigned int)addr;
156 const char *_from = (const char *)from; 156 const char *_from = (const char *)from;
157 157
@@ -164,7 +164,7 @@ static void atomisp_css2_hw_store(hrt_address addr,
164static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n) 164static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
165{ 165{
166 unsigned long flags; 166 unsigned long flags;
167 unsigned i; 167 unsigned int i;
168 char *_to = (char *)to; 168 char *_to = (char *)to;
169 unsigned int _from = (unsigned int)addr; 169 unsigned int _from = (unsigned int)addr;
170 170
@@ -228,9 +228,11 @@ static void __dump_pipe_config(struct atomisp_sub_device *asd,
228 unsigned int pipe_id) 228 unsigned int pipe_id)
229{ 229{
230 struct atomisp_device *isp = asd->isp; 230 struct atomisp_device *isp = asd->isp;
231
231 if (stream_env->pipes[pipe_id]) { 232 if (stream_env->pipes[pipe_id]) {
232 struct ia_css_pipe_config *p_config; 233 struct ia_css_pipe_config *p_config;
233 struct ia_css_pipe_extra_config *pe_config; 234 struct ia_css_pipe_extra_config *pe_config;
235
234 p_config = &stream_env->pipe_configs[pipe_id]; 236 p_config = &stream_env->pipe_configs[pipe_id];
235 pe_config = &stream_env->pipe_extra_configs[pipe_id]; 237 pe_config = &stream_env->pipe_extra_configs[pipe_id];
236 dev_dbg(isp->dev, "dumping pipe[%d] config:\n", pipe_id); 238 dev_dbg(isp->dev, "dumping pipe[%d] config:\n", pipe_id);
@@ -503,6 +505,7 @@ static int __destroy_stream(struct atomisp_sub_device *asd,
503static int __destroy_streams(struct atomisp_sub_device *asd, bool force) 505static int __destroy_streams(struct atomisp_sub_device *asd, bool force)
504{ 506{
505 int ret, i; 507 int ret, i;
508
506 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { 509 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
507 ret = __destroy_stream(asd, &asd->stream_env[i], force); 510 ret = __destroy_stream(asd, &asd->stream_env[i], force);
508 if (ret) 511 if (ret)
@@ -569,6 +572,7 @@ static int __destroy_stream_pipes(struct atomisp_sub_device *asd,
569 struct atomisp_device *isp = asd->isp; 572 struct atomisp_device *isp = asd->isp;
570 int ret = 0; 573 int ret = 0;
571 int i; 574 int i;
575
572 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 576 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) {
573 if (!stream_env->pipes[i] || 577 if (!stream_env->pipes[i] ||
574 !(force || stream_env->update_pipe[i])) 578 !(force || stream_env->update_pipe[i]))
@@ -888,12 +892,12 @@ static inline int __set_css_print_env(struct atomisp_device *isp, int opt)
888{ 892{
889 int ret = 0; 893 int ret = 0;
890 894
891 if (0 == opt) 895 if (opt == 0)
892 isp->css_env.isp_css_env.print_env.debug_print = NULL; 896 isp->css_env.isp_css_env.print_env.debug_print = NULL;
893 else if (1 == opt) 897 else if (opt == 1)
894 isp->css_env.isp_css_env.print_env.debug_print = 898 isp->css_env.isp_css_env.print_env.debug_print =
895 atomisp_css2_dbg_ftrace_print; 899 atomisp_css2_dbg_ftrace_print;
896 else if (2 == opt) 900 else if (opt == 2)
897 isp->css_env.isp_css_env.print_env.debug_print = 901 isp->css_env.isp_css_env.print_env.debug_print =
898 atomisp_css2_dbg_print; 902 atomisp_css2_dbg_print;
899 else 903 else
@@ -1047,6 +1051,7 @@ int atomisp_css_irq_enable(struct atomisp_device *isp,
1047void atomisp_css_init_struct(struct atomisp_sub_device *asd) 1051void atomisp_css_init_struct(struct atomisp_sub_device *asd)
1048{ 1052{
1049 int i, j; 1053 int i, j;
1054
1050 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { 1055 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
1051 asd->stream_env[i].stream = NULL; 1056 asd->stream_env[i].stream = NULL;
1052 for (j = 0; j < IA_CSS_PIPE_MODE_NUM; j++) { 1057 for (j = 0; j < IA_CSS_PIPE_MODE_NUM; j++) {
@@ -1185,6 +1190,7 @@ int atomisp_css_start(struct atomisp_sub_device *asd,
1185 struct atomisp_device *isp = asd->isp; 1190 struct atomisp_device *isp = asd->isp;
1186 bool sp_is_started = false; 1191 bool sp_is_started = false;
1187 int ret = 0, i = 0; 1192 int ret = 0, i = 0;
1193
1188 if (in_reset) { 1194 if (in_reset) {
1189 if (__destroy_streams(asd, true)) 1195 if (__destroy_streams(asd, true))
1190 dev_warn(isp->dev, "destroy stream failed.\n"); 1196 dev_warn(isp->dev, "destroy stream failed.\n");
@@ -1972,6 +1978,7 @@ void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd,
1972void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable) 1978void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable)
1973{ 1979{
1974 int i; 1980 int i;
1981
1975 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) 1982 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
1976 asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL] 1983 asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
1977 .pipe_configs[i].enable_dz = enable; 1984 .pipe_configs[i].enable_dz = enable;
@@ -1998,6 +2005,7 @@ void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
1998 int i; 2005 int i;
1999 struct atomisp_device *isp = asd->isp; 2006 struct atomisp_device *isp = asd->isp;
2000 unsigned int size_mem_words; 2007 unsigned int size_mem_words;
2008
2001 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) 2009 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++)
2002 asd->stream_env[i].stream_config.mode = mode; 2010 asd->stream_env[i].stream_config.mode = mode;
2003 2011
@@ -2271,6 +2279,7 @@ int atomisp_css_stop(struct atomisp_sub_device *asd,
2271 if (!in_reset) { 2279 if (!in_reset) {
2272 struct atomisp_stream_env *stream_env; 2280 struct atomisp_stream_env *stream_env;
2273 int i, j; 2281 int i, j;
2282
2274 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { 2283 for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
2275 stream_env = &asd->stream_env[i]; 2284 stream_env = &asd->stream_env[i];
2276 for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) { 2285 for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) {
@@ -2797,6 +2806,7 @@ static void __configure_video_vf_output(struct atomisp_sub_device *asd,
2797 struct atomisp_stream_env *stream_env = 2806 struct atomisp_stream_env *stream_env =
2798 &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]; 2807 &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
2799 struct ia_css_frame_info *css_output_info; 2808 struct ia_css_frame_info *css_output_info;
2809
2800 stream_env->pipe_configs[pipe_id].mode = 2810 stream_env->pipe_configs[pipe_id].mode =
2801 __pipe_id_to_pipe_mode(asd, pipe_id); 2811 __pipe_id_to_pipe_mode(asd, pipe_id);
2802 stream_env->update_pipe[pipe_id] = true; 2812 stream_env->update_pipe[pipe_id] = true;
@@ -4460,7 +4470,8 @@ int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd,
4460static struct atomisp_sub_device *__get_atomisp_subdev( 4470static struct atomisp_sub_device *__get_atomisp_subdev(
4461 struct ia_css_pipe *css_pipe, 4471 struct ia_css_pipe *css_pipe,
4462 struct atomisp_device *isp, 4472 struct atomisp_device *isp,
4463 enum atomisp_input_stream_id *stream_id) { 4473 enum atomisp_input_stream_id *stream_id)
4474{
4464 int i, j, k; 4475 int i, j, k;
4465 struct atomisp_sub_device *asd; 4476 struct atomisp_sub_device *asd;
4466 struct atomisp_stream_env *stream_env; 4477 struct atomisp_stream_env *stream_env;
@@ -4655,7 +4666,7 @@ int atomisp_css_dump_sp_raw_copy_linecount(bool reduced)
4655int atomisp_css_dump_blob_infor(void) 4666int atomisp_css_dump_blob_infor(void)
4656{ 4667{
4657 struct ia_css_blob_descr *bd = sh_css_blob_info; 4668 struct ia_css_blob_descr *bd = sh_css_blob_info;
4658 unsigned i, nm = sh_css_num_binaries; 4669 unsigned int i, nm = sh_css_num_binaries;
4659 4670
4660 if (nm == 0) 4671 if (nm == 0)
4661 return -EPERM; 4672 return -EPERM;
@@ -4691,7 +4702,7 @@ int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt)
4691 int ret; 4702 int ret;
4692 4703
4693 ret = __set_css_print_env(isp, opt); 4704 ret = __set_css_print_env(isp, opt);
4694 if (0 == ret) 4705 if (ret == 0)
4695 dbg_func = opt; 4706 dbg_func = opt;
4696 4707
4697 return ret; 4708 return ret;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 383d236c010c..8158ea40d069 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -146,7 +146,7 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
146 size_t statestruct_size = sizeof(struct ia_css_state_memory_offsets); 146 size_t statestruct_size = sizeof(struct ia_css_state_memory_offsets);
147 147
148 char *parambuf = kmalloc(paramstruct_size + configstruct_size + statestruct_size, 148 char *parambuf = kmalloc(paramstruct_size + configstruct_size + statestruct_size,
149 GFP_KERNEL); 149 GFP_KERNEL);
150 if (!parambuf) 150 if (!parambuf)
151 return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; 151 return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
152 152
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
index 9e957514108e..6e2dce7a5a2d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
@@ -721,7 +721,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
721 721
722 pgnr = bo->pgnr; 722 pgnr = bo->pgnr;
723 723
724 bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr, 724 bo->page_obj = kmalloc_array(pgnr, sizeof(struct hmm_page_object),
725 GFP_KERNEL); 725 GFP_KERNEL);
726 if (unlikely(!bo->page_obj)) 726 if (unlikely(!bo->page_obj))
727 return -ENOMEM; 727 return -ENOMEM;
@@ -984,11 +984,11 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
984 struct vm_area_struct *vma; 984 struct vm_area_struct *vma;
985 struct page **pages; 985 struct page **pages;
986 986
987 pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL); 987 pages = kmalloc_array(bo->pgnr, sizeof(struct page *), GFP_KERNEL);
988 if (unlikely(!pages)) 988 if (unlikely(!pages))
989 return -ENOMEM; 989 return -ENOMEM;
990 990
991 bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr, 991 bo->page_obj = kmalloc_array(bo->pgnr, sizeof(struct hmm_page_object),
992 GFP_KERNEL); 992 GFP_KERNEL);
993 if (unlikely(!bo->page_obj)) { 993 if (unlikely(!bo->page_obj)) {
994 kfree(pages); 994 kfree(pages);
@@ -1350,7 +1350,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached)
1350 bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED); 1350 bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED);
1351 } 1351 }
1352 1352
1353 pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL); 1353 pages = kmalloc_array(bo->pgnr, sizeof(*pages), GFP_KERNEL);
1354 if (unlikely(!pages)) { 1354 if (unlikely(!pages)) {
1355 mutex_unlock(&bo->mutex); 1355 mutex_unlock(&bo->mutex);
1356 return NULL; 1356 return NULL;
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 58adaea44eb5..5d3b0e5a1283 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -1964,7 +1964,7 @@ static ssize_t bcm2048_##prop##_write(struct device *dev, \
1964 return err < 0 ? err : count; \ 1964 return err < 0 ? err : count; \
1965} 1965}
1966 1966
1967#define property_read(prop, size, mask) \ 1967#define property_read(prop, mask) \
1968static ssize_t bcm2048_##prop##_read(struct device *dev, \ 1968static ssize_t bcm2048_##prop##_read(struct device *dev, \
1969 struct device_attribute *attr, \ 1969 struct device_attribute *attr, \
1970 char *buf) \ 1970 char *buf) \
@@ -1999,9 +1999,9 @@ static ssize_t bcm2048_##prop##_read(struct device *dev, \
1999 return sprintf(buf, mask "\n", value); \ 1999 return sprintf(buf, mask "\n", value); \
2000} 2000}
2001 2001
2002#define DEFINE_SYSFS_PROPERTY(prop, signal, size, mask, check) \ 2002#define DEFINE_SYSFS_PROPERTY(prop, prop_type, mask, check) \
2003property_write(prop, signal size, mask, check) \ 2003property_write(prop, prop_type, mask, check) \
2004property_read(prop, size, mask) 2004property_read(prop, mask) \
2005 2005
2006#define property_str_read(prop, size) \ 2006#define property_str_read(prop, size) \
2007static ssize_t bcm2048_##prop##_read(struct device *dev, \ 2007static ssize_t bcm2048_##prop##_read(struct device *dev, \
@@ -2027,39 +2027,39 @@ static ssize_t bcm2048_##prop##_read(struct device *dev, \
2027 return count; \ 2027 return count; \
2028} 2028}
2029 2029
2030DEFINE_SYSFS_PROPERTY(power_state, unsigned, int, "%u", 0) 2030DEFINE_SYSFS_PROPERTY(power_state, unsigned int, "%u", 0)
2031DEFINE_SYSFS_PROPERTY(mute, unsigned, int, "%u", 0) 2031DEFINE_SYSFS_PROPERTY(mute, unsigned int, "%u", 0)
2032DEFINE_SYSFS_PROPERTY(audio_route, unsigned, int, "%u", 0) 2032DEFINE_SYSFS_PROPERTY(audio_route, unsigned int, "%u", 0)
2033DEFINE_SYSFS_PROPERTY(dac_output, unsigned, int, "%u", 0) 2033DEFINE_SYSFS_PROPERTY(dac_output, unsigned int, "%u", 0)
2034 2034
2035DEFINE_SYSFS_PROPERTY(fm_hi_lo_injection, unsigned, int, "%u", 0) 2035DEFINE_SYSFS_PROPERTY(fm_hi_lo_injection, unsigned int, "%u", 0)
2036DEFINE_SYSFS_PROPERTY(fm_frequency, unsigned, int, "%u", 0) 2036DEFINE_SYSFS_PROPERTY(fm_frequency, unsigned int, "%u", 0)
2037DEFINE_SYSFS_PROPERTY(fm_af_frequency, unsigned, int, "%u", 0) 2037DEFINE_SYSFS_PROPERTY(fm_af_frequency, unsigned int, "%u", 0)
2038DEFINE_SYSFS_PROPERTY(fm_deemphasis, unsigned, int, "%u", 0) 2038DEFINE_SYSFS_PROPERTY(fm_deemphasis, unsigned int, "%u", 0)
2039DEFINE_SYSFS_PROPERTY(fm_rds_mask, unsigned, int, "%u", 0) 2039DEFINE_SYSFS_PROPERTY(fm_rds_mask, unsigned int, "%u", 0)
2040DEFINE_SYSFS_PROPERTY(fm_best_tune_mode, unsigned, int, "%u", 0) 2040DEFINE_SYSFS_PROPERTY(fm_best_tune_mode, unsigned int, "%u", 0)
2041DEFINE_SYSFS_PROPERTY(fm_search_rssi_threshold, unsigned, int, "%u", 0) 2041DEFINE_SYSFS_PROPERTY(fm_search_rssi_threshold, unsigned int, "%u", 0)
2042DEFINE_SYSFS_PROPERTY(fm_search_mode_direction, unsigned, int, "%u", 0) 2042DEFINE_SYSFS_PROPERTY(fm_search_mode_direction, unsigned int, "%u", 0)
2043DEFINE_SYSFS_PROPERTY(fm_search_tune_mode, unsigned, int, "%u", value > 3) 2043DEFINE_SYSFS_PROPERTY(fm_search_tune_mode, unsigned int, "%u", value > 3)
2044 2044
2045DEFINE_SYSFS_PROPERTY(rds, unsigned, int, "%u", 0) 2045DEFINE_SYSFS_PROPERTY(rds, unsigned int, "%u", 0)
2046DEFINE_SYSFS_PROPERTY(rds_b_block_mask, unsigned, int, "%u", 0) 2046DEFINE_SYSFS_PROPERTY(rds_b_block_mask, unsigned int, "%u", 0)
2047DEFINE_SYSFS_PROPERTY(rds_b_block_match, unsigned, int, "%u", 0) 2047DEFINE_SYSFS_PROPERTY(rds_b_block_match, unsigned int, "%u", 0)
2048DEFINE_SYSFS_PROPERTY(rds_pi_mask, unsigned, int, "%u", 0) 2048DEFINE_SYSFS_PROPERTY(rds_pi_mask, unsigned int, "%u", 0)
2049DEFINE_SYSFS_PROPERTY(rds_pi_match, unsigned, int, "%u", 0) 2049DEFINE_SYSFS_PROPERTY(rds_pi_match, unsigned int, "%u", 0)
2050DEFINE_SYSFS_PROPERTY(rds_wline, unsigned, int, "%u", 0) 2050DEFINE_SYSFS_PROPERTY(rds_wline, unsigned int, "%u", 0)
2051property_read(rds_pi, unsigned int, "%x") 2051property_read(rds_pi, "%x")
2052property_str_read(rds_rt, (BCM2048_MAX_RDS_RT + 1)) 2052property_str_read(rds_rt, (BCM2048_MAX_RDS_RT + 1))
2053property_str_read(rds_ps, (BCM2048_MAX_RDS_PS + 1)) 2053property_str_read(rds_ps, (BCM2048_MAX_RDS_PS + 1))
2054 2054
2055property_read(fm_rds_flags, unsigned int, "%u") 2055property_read(fm_rds_flags, "%u")
2056property_str_read(rds_data, BCM2048_MAX_RDS_RADIO_TEXT * 5) 2056property_str_read(rds_data, BCM2048_MAX_RDS_RADIO_TEXT * 5)
2057 2057
2058property_read(region_bottom_frequency, unsigned int, "%u") 2058property_read(region_bottom_frequency, "%u")
2059property_read(region_top_frequency, unsigned int, "%u") 2059property_read(region_top_frequency, "%u")
2060property_signed_read(fm_carrier_error, int, "%d") 2060property_signed_read(fm_carrier_error, int, "%d")
2061property_signed_read(fm_rssi, int, "%d") 2061property_signed_read(fm_rssi, int, "%d")
2062DEFINE_SYSFS_PROPERTY(region, unsigned, int, "%u", 0) 2062DEFINE_SYSFS_PROPERTY(region, unsigned int, "%u", 0)
2063 2063
2064static struct device_attribute attrs[] = { 2064static struct device_attribute attrs[] = {
2065 __ATTR(power_state, 0644, bcm2048_power_state_read, 2065 __ATTR(power_state, 0644, bcm2048_power_state_read,
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index e05ae4645d91..30532d8c310b 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -364,39 +364,39 @@ static void xlr_stats(struct net_device *ndev, struct rtnl_link_stats64 *stats)
364 stats->tx_bytes = xlr_nae_rdreg(priv->base_addr, TX_BYTE_COUNTER); 364 stats->tx_bytes = xlr_nae_rdreg(priv->base_addr, TX_BYTE_COUNTER);
365 stats->tx_errors = xlr_nae_rdreg(priv->base_addr, TX_FCS_ERROR_COUNTER); 365 stats->tx_errors = xlr_nae_rdreg(priv->base_addr, TX_FCS_ERROR_COUNTER);
366 stats->rx_dropped = xlr_nae_rdreg(priv->base_addr, 366 stats->rx_dropped = xlr_nae_rdreg(priv->base_addr,
367 RX_DROP_PACKET_COUNTER); 367 RX_DROP_PACKET_COUNTER);
368 stats->tx_dropped = xlr_nae_rdreg(priv->base_addr, 368 stats->tx_dropped = xlr_nae_rdreg(priv->base_addr,
369 TX_DROP_FRAME_COUNTER); 369 TX_DROP_FRAME_COUNTER);
370 370
371 stats->multicast = xlr_nae_rdreg(priv->base_addr, 371 stats->multicast = xlr_nae_rdreg(priv->base_addr,
372 RX_MULTICAST_PACKET_COUNTER); 372 RX_MULTICAST_PACKET_COUNTER);
373 stats->collisions = xlr_nae_rdreg(priv->base_addr, 373 stats->collisions = xlr_nae_rdreg(priv->base_addr,
374 TX_TOTAL_COLLISION_COUNTER); 374 TX_TOTAL_COLLISION_COUNTER);
375 375
376 stats->rx_length_errors = xlr_nae_rdreg(priv->base_addr, 376 stats->rx_length_errors = xlr_nae_rdreg(priv->base_addr,
377 RX_FRAME_LENGTH_ERROR_COUNTER); 377 RX_FRAME_LENGTH_ERROR_COUNTER);
378 stats->rx_over_errors = xlr_nae_rdreg(priv->base_addr, 378 stats->rx_over_errors = xlr_nae_rdreg(priv->base_addr,
379 RX_DROP_PACKET_COUNTER); 379 RX_DROP_PACKET_COUNTER);
380 stats->rx_crc_errors = xlr_nae_rdreg(priv->base_addr, 380 stats->rx_crc_errors = xlr_nae_rdreg(priv->base_addr,
381 RX_FCS_ERROR_COUNTER); 381 RX_FCS_ERROR_COUNTER);
382 stats->rx_frame_errors = xlr_nae_rdreg(priv->base_addr, 382 stats->rx_frame_errors = xlr_nae_rdreg(priv->base_addr,
383 RX_ALIGNMENT_ERROR_COUNTER); 383 RX_ALIGNMENT_ERROR_COUNTER);
384 384
385 stats->rx_fifo_errors = xlr_nae_rdreg(priv->base_addr, 385 stats->rx_fifo_errors = xlr_nae_rdreg(priv->base_addr,
386 RX_DROP_PACKET_COUNTER); 386 RX_DROP_PACKET_COUNTER);
387 stats->rx_missed_errors = xlr_nae_rdreg(priv->base_addr, 387 stats->rx_missed_errors = xlr_nae_rdreg(priv->base_addr,
388 RX_CARRIER_SENSE_ERROR_COUNTER); 388 RX_CARRIER_SENSE_ERROR_COUNTER);
389 389
390 stats->rx_errors = (stats->rx_over_errors + stats->rx_crc_errors + 390 stats->rx_errors = (stats->rx_over_errors + stats->rx_crc_errors +
391 stats->rx_frame_errors + stats->rx_fifo_errors + 391 stats->rx_frame_errors + stats->rx_fifo_errors +
392 stats->rx_missed_errors); 392 stats->rx_missed_errors);
393 393
394 stats->tx_aborted_errors = xlr_nae_rdreg(priv->base_addr, 394 stats->tx_aborted_errors = xlr_nae_rdreg(priv->base_addr,
395 TX_EXCESSIVE_COLLISION_PACKET_COUNTER); 395 TX_EXCESSIVE_COLLISION_PACKET_COUNTER);
396 stats->tx_carrier_errors = xlr_nae_rdreg(priv->base_addr, 396 stats->tx_carrier_errors = xlr_nae_rdreg(priv->base_addr,
397 TX_DROP_FRAME_COUNTER); 397 TX_DROP_FRAME_COUNTER);
398 stats->tx_fifo_errors = xlr_nae_rdreg(priv->base_addr, 398 stats->tx_fifo_errors = xlr_nae_rdreg(priv->base_addr,
399 TX_DROP_FRAME_COUNTER); 399 TX_DROP_FRAME_COUNTER);
400} 400}
401 401
402static const struct net_device_ops xlr_netdev_ops = { 402static const struct net_device_ops xlr_netdev_ops = {
@@ -448,41 +448,35 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, int reg_start_0,
448static void xlr_config_fifo_spill_area(struct xlr_net_priv *priv) 448static void xlr_config_fifo_spill_area(struct xlr_net_priv *priv)
449{ 449{
450 priv->frin_spill = xlr_config_spill(priv, 450 priv->frin_spill = xlr_config_spill(priv,
451 R_REG_FRIN_SPILL_MEM_START_0, 451 R_REG_FRIN_SPILL_MEM_START_0,
452 R_REG_FRIN_SPILL_MEM_START_1, 452 R_REG_FRIN_SPILL_MEM_START_1,
453 R_REG_FRIN_SPILL_MEM_SIZE, 453 R_REG_FRIN_SPILL_MEM_SIZE,
454 MAX_FRIN_SPILL * 454 MAX_FRIN_SPILL * sizeof(u64));
455 sizeof(u64));
456 priv->frout_spill = xlr_config_spill(priv, 455 priv->frout_spill = xlr_config_spill(priv,
457 R_FROUT_SPILL_MEM_START_0, 456 R_FROUT_SPILL_MEM_START_0,
458 R_FROUT_SPILL_MEM_START_1, 457 R_FROUT_SPILL_MEM_START_1,
459 R_FROUT_SPILL_MEM_SIZE, 458 R_FROUT_SPILL_MEM_SIZE,
460 MAX_FROUT_SPILL * 459 MAX_FROUT_SPILL * sizeof(u64));
461 sizeof(u64));
462 priv->class_0_spill = xlr_config_spill(priv, 460 priv->class_0_spill = xlr_config_spill(priv,
463 R_CLASS0_SPILL_MEM_START_0, 461 R_CLASS0_SPILL_MEM_START_0,
464 R_CLASS0_SPILL_MEM_START_1, 462 R_CLASS0_SPILL_MEM_START_1,
465 R_CLASS0_SPILL_MEM_SIZE, 463 R_CLASS0_SPILL_MEM_SIZE,
466 MAX_CLASS_0_SPILL * 464 MAX_CLASS_0_SPILL * sizeof(u64));
467 sizeof(u64));
468 priv->class_1_spill = xlr_config_spill(priv, 465 priv->class_1_spill = xlr_config_spill(priv,
469 R_CLASS1_SPILL_MEM_START_0, 466 R_CLASS1_SPILL_MEM_START_0,
470 R_CLASS1_SPILL_MEM_START_1, 467 R_CLASS1_SPILL_MEM_START_1,
471 R_CLASS1_SPILL_MEM_SIZE, 468 R_CLASS1_SPILL_MEM_SIZE,
472 MAX_CLASS_1_SPILL * 469 MAX_CLASS_1_SPILL * sizeof(u64));
473 sizeof(u64));
474 priv->class_2_spill = xlr_config_spill(priv, 470 priv->class_2_spill = xlr_config_spill(priv,
475 R_CLASS2_SPILL_MEM_START_0, 471 R_CLASS2_SPILL_MEM_START_0,
476 R_CLASS2_SPILL_MEM_START_1, 472 R_CLASS2_SPILL_MEM_START_1,
477 R_CLASS2_SPILL_MEM_SIZE, 473 R_CLASS2_SPILL_MEM_SIZE,
478 MAX_CLASS_2_SPILL * 474 MAX_CLASS_2_SPILL * sizeof(u64));
479 sizeof(u64));
480 priv->class_3_spill = xlr_config_spill(priv, 475 priv->class_3_spill = xlr_config_spill(priv,
481 R_CLASS3_SPILL_MEM_START_0, 476 R_CLASS3_SPILL_MEM_START_0,
482 R_CLASS3_SPILL_MEM_START_1, 477 R_CLASS3_SPILL_MEM_START_1,
483 R_CLASS3_SPILL_MEM_SIZE, 478 R_CLASS3_SPILL_MEM_SIZE,
484 MAX_CLASS_3_SPILL * 479 MAX_CLASS_3_SPILL * sizeof(u64));
485 sizeof(u64));
486} 480}
487 481
488/* 482/*
diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt
index 38b83b86c334..245fef33d688 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -20,7 +20,7 @@ Discription of driver operation
20a) transmission 20a) transmission
21 21
22Each transmission can take place with a different configuration of the rf 22Each transmission can take place with a different configuration of the rf
23module. Therfore each application can set its own set of parameters. The driver 23module. Therefore each application can set its own set of parameters. The driver
24takes care, that each transmission takes place with the parameterset of the 24takes care, that each transmission takes place with the parameterset of the
25application, that requests the transmission. To allow the transmission to take 25application, that requests the transmission. To allow the transmission to take
26place in the background, a tx thread is introduced. 26place in the background, a tx thread is introduced.
@@ -33,7 +33,7 @@ there is no receive request or the receiver is still waiting for something in
33the air, the rf module is set to standby, the parameters for transmission gets 33the air, the rf module is set to standby, the parameters for transmission gets
34set, the hardware fifo of the rf chip gets preloaded and the transmission gets 34set, the hardware fifo of the rf chip gets preloaded and the transmission gets
35started. Upon hardware fifo threshold interrupt it gets reloaded, thus enabling 35started. Upon hardware fifo threshold interrupt it gets reloaded, thus enabling
36much longer telegrams then hardware fifo size. If the telegram is send and there 36much longer telegrams than the hardware fifo size. If the telegram is sent and there
37is more data available in the kfifo, the procedure is repeated. If not the 37is more data available in the kfifo, the procedure is repeated. If not the
38transmission cycle ends. 38transmission cycle ends.
39 39
@@ -41,7 +41,7 @@ b) reception
41 41
42Since there is only one application allowed to receive data at a time, for 42Since there is only one application allowed to receive data at a time, for
43reception there is only one configuration set. 43reception there is only one configuration set.
44As soon as an application sets an request for receiving a telegram, the reception 44As soon as an application sets a request for receiving a telegram, the reception
45configuration set is written to the rf module and it gets set into receiving mode. 45configuration set is written to the rf module and it gets set into receiving mode.
46Now the driver is waiting, that a predefined RSSI level (signal strength at the 46Now the driver is waiting, that a predefined RSSI level (signal strength at the
47receiver) is reached. Until this hasn't happened, the reception can be 47receiver) is reached. Until this hasn't happened, the reception can be
@@ -123,7 +123,7 @@ packet format:
123 optionOff - no preamble will be generated 123 optionOff - no preamble will be generated
124 enable_sync 124 enable_sync
125 optionOn - a sync word will be automatically added to 125 optionOn - a sync word will be automatically added to
126 the telegram after preamble 126 the telegram after the preamble
127 optionOff - no sync word will be added 127 optionOff - no sync word will be added
128 Attention: While possible to generate sync without preamble, the 128 Attention: While possible to generate sync without preamble, the
129 receiver won't be able to detect the sync without preamble. 129 receiver won't be able to detect the sync without preamble.
@@ -136,7 +136,7 @@ packet format:
136 Attention: should be used in combination with sync, only 136 Attention: should be used in combination with sync, only
137 enable_address_byte 137 enable_address_byte
138 optionOn - the address byte will be automatically added to the 138 optionOn - the address byte will be automatically added to the
139 telgram. It's part of the payload 139 telegram. It's part of the payload
140 optionOff - the address byte will not be added to the telegram. 140 optionOff - the address byte will not be added to the telegram.
141 The address byte can be used for address filtering, so the receiver 141 The address byte can be used for address filtering, so the receiver
142 will only receive telegrams with a given address byte. 142 will only receive telegrams with a given address byte.
@@ -161,7 +161,7 @@ packet format:
161 one byte, used as address byte on address byte option. 161 one byte, used as address byte on address byte option.
162 162
163 163
164The rx configuration is transfered via struct pi433_rx_cfg, the parameterset for receiving. It is devided into two sections: rf parameters and packet format. 164The rx configuration is transferred via struct pi433_rx_cfg, the parameterset for receiving. It is divided into two sections: rf parameters and packet format.
165 165
166rf params: 166rf params:
167 frequency 167 frequency
@@ -178,7 +178,7 @@ rf params:
178 OOK - on off key 178 OOK - on off key
179 rssi_threshold 179 rssi_threshold
180 threshold value for the signal strength on the receiver input. 180 threshold value for the signal strength on the receiver input.
181 If this value is exeeded, a reception cycle starts 181 If this value is exceeded, a reception cycle starts
182 Allowed values: 0...255 182 Allowed values: 0...255
183 thresholdDecrement 183 thresholdDecrement
184 in order to adapt to different levels of singnal strength, over 184 in order to adapt to different levels of singnal strength, over
@@ -198,7 +198,7 @@ rf params:
198 twohundretOhm - for antennas with an impedance of 200Ohm 198 twohundretOhm - for antennas with an impedance of 200Ohm
199 lnaGain 199 lnaGain
200 sets the gain of the low noise amp 200 sets the gain of the low noise amp
201 automatic - lna gain is determed by an agc 201 automatic - lna gain is determined by an agc
202 max - lna gain is set to maximum 202 max - lna gain is set to maximum
203 maxMinus6 - lna gain is set to 6db below max 203 maxMinus6 - lna gain is set to 6db below max
204 maxMinus12 - lna gain is set to 12db below max 204 maxMinus12 - lna gain is set to 12db below max
@@ -232,7 +232,7 @@ rf params:
232 amount of bytes that were requested by the read request. 232 amount of bytes that were requested by the read request.
233 Attention: should be used in combination with sync, only 233 Attention: should be used in combination with sync, only
234 enable_address_filtering; 234 enable_address_filtering;
235 filteringOff - no adress filtering will take place 235 filteringOff - no address filtering will take place
236 nodeAddress - all telegrams, not matching the node 236 nodeAddress - all telegrams, not matching the node
237 address will be internally discarded 237 address will be internally discarded
238 nodeOrBroadcastAddress - all telegrams, neither matching the 238 nodeOrBroadcastAddress - all telegrams, neither matching the
@@ -245,7 +245,7 @@ rf params:
245 calculated crc doesn't match to two bytes, 245 calculated crc doesn't match to two bytes,
246 that follow the payload, the telegram will be 246 that follow the payload, the telegram will be
247 internally discarded. 247 internally discarded.
248 Attention: This option is only operational, if sync on and fixed length 248 Attention: This option is only operational if sync on and fixed length
249 or length byte is used 249 or length byte is used
250 sync_length 250 sync_length
251 Gives the length of the payload. 251 Gives the length of the payload.
@@ -255,9 +255,9 @@ rf params:
255 Overrides the telegram length either given by the first byte of 255 Overrides the telegram length either given by the first byte of
256 payload or by the read request. 256 payload or by the read request.
257 bytes_to_drop 257 bytes_to_drop
258 gives the number of bytes, that will be dropped before transfering 258 gives the number of bytes, that will be dropped before transferring
259 data to the read buffer 259 data to the read buffer
260 This option is only usefull, if all packet helper are switched 260 This option is only useful if all packet helper are switched
261 off and the rf chip is used in raw receiving mode. This may be 261 off and the rf chip is used in raw receiving mode. This may be
262 needed, if a telegram of a third party device should be received, 262 needed, if a telegram of a third party device should be received,
263 using a protocol not compatible with the packet engine of the rf69 chip. 263 using a protocol not compatible with the packet engine of the rf69 chip.
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 93c01680f016..d946838450d4 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -136,17 +136,17 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id)
136 if (device->irq_state[DIO0] == DIO_PacketSent) 136 if (device->irq_state[DIO0] == DIO_PacketSent)
137 { 137 {
138 device->free_in_fifo = FIFO_SIZE; 138 device->free_in_fifo = FIFO_SIZE;
139 printk("DIO0 irq: Packet sent\n"); // TODO: printk() should include KERN_ facility level 139 dev_dbg(device->dev, "DIO0 irq: Packet sent\n");
140 wake_up_interruptible(&device->fifo_wait_queue); 140 wake_up_interruptible(&device->fifo_wait_queue);
141 } 141 }
142 else if (device->irq_state[DIO0] == DIO_Rssi_DIO0) 142 else if (device->irq_state[DIO0] == DIO_Rssi_DIO0)
143 { 143 {
144 printk("DIO0 irq: RSSI level over threshold\n"); 144 dev_dbg(device->dev, "DIO0 irq: RSSI level over threshold\n");
145 wake_up_interruptible(&device->rx_wait_queue); 145 wake_up_interruptible(&device->rx_wait_queue);
146 } 146 }
147 else if (device->irq_state[DIO0] == DIO_PayloadReady) 147 else if (device->irq_state[DIO0] == DIO_PayloadReady)
148 { 148 {
149 printk("DIO0 irq: PayloadReady\n"); 149 dev_dbg(device->dev, "DIO0 irq: PayloadReady\n");
150 device->free_in_fifo = 0; 150 device->free_in_fifo = 0;
151 wake_up_interruptible(&device->fifo_wait_queue); 151 wake_up_interruptible(&device->fifo_wait_queue);
152 } 152 }
@@ -167,7 +167,8 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
167 if (device->rx_active) device->free_in_fifo = FIFO_THRESHOLD - 1; 167 if (device->rx_active) device->free_in_fifo = FIFO_THRESHOLD - 1;
168 else device->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1; 168 else device->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1;
169 } 169 }
170 printk("DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); // TODO: printk() should include KERN_ facility level 170 dev_dbg(device->dev,
171 "DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo);
171 wake_up_interruptible(&device->fifo_wait_queue); 172 wake_up_interruptible(&device->fifo_wait_queue);
172 173
173 return IRQ_HANDLED; 174 return IRQ_HANDLED;
@@ -284,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)
284 SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); 285 SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc));
285 286
286 /* configure sync, if enabled */ 287 /* configure sync, if enabled */
287 if (tx_cfg->enable_sync == optionOn) 288 if (tx_cfg->enable_sync == optionOn) {
288 {
289 SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length)); 289 SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
290 SET_CHECKED(rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern)); 290 SET_CHECKED(rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern));
291 } 291 }
@@ -407,8 +407,7 @@ pi433_receive(void *data)
407 if (retval) goto abort; /* wait was interrupted */ 407 if (retval) goto abort; /* wait was interrupted */
408 408
409 rf69_read_fifo(spi, (u8 *)&bytes_total, 1); 409 rf69_read_fifo(spi, (u8 *)&bytes_total, 1);
410 if (bytes_total > dev->rx_buffer_size) 410 if (bytes_total > dev->rx_buffer_size) {
411 {
412 retval = -1; 411 retval = -1;
413 goto abort; 412 goto abort;
414 } 413 }
@@ -466,7 +465,7 @@ pi433_receive(void *data)
466 } 465 }
467 466
468 467
469 /* rx done, wait was interrupted or error occured */ 468 /* rx done, wait was interrupted or error occurred */
470abort: 469abort:
471 dev->interrupt_rx_allowed = true; 470 dev->interrupt_rx_allowed = true;
472 SET_CHECKED(rf69_set_mode(dev->spi, standby)); 471 SET_CHECKED(rf69_set_mode(dev->spi, standby));
@@ -508,16 +507,14 @@ pi433_tx_thread(void *data)
508 mutex_lock(&device->tx_fifo_lock); 507 mutex_lock(&device->tx_fifo_lock);
509 508
510 retval = kfifo_out(&device->tx_fifo, &tx_cfg, sizeof(tx_cfg)); 509 retval = kfifo_out(&device->tx_fifo, &tx_cfg, sizeof(tx_cfg));
511 if (retval != sizeof(tx_cfg)) 510 if (retval != sizeof(tx_cfg)) {
512 {
513 dev_dbg(device->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) ); 511 dev_dbg(device->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
514 mutex_unlock(&device->tx_fifo_lock); 512 mutex_unlock(&device->tx_fifo_lock);
515 continue; 513 continue;
516 } 514 }
517 515
518 retval = kfifo_out(&device->tx_fifo, &size, sizeof(size_t)); 516 retval = kfifo_out(&device->tx_fifo, &size, sizeof(size_t));
519 if (retval != sizeof(size_t)) 517 if (retval != sizeof(size_t)) {
520 {
521 dev_dbg(device->dev, "reading msg size from fifo failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) ); 518 dev_dbg(device->dev, "reading msg size from fifo failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
522 mutex_unlock(&device->tx_fifo_lock); 519 mutex_unlock(&device->tx_fifo_lock);
523 continue; 520 continue;
@@ -649,8 +646,7 @@ pi433_tx_thread(void *data)
649 SET_CHECKED(rf69_set_mode(spi, standby)); 646 SET_CHECKED(rf69_set_mode(spi, standby));
650 647
651 /* everything sent? */ 648 /* everything sent? */
652 if ( kfifo_is_empty(&device->tx_fifo) ) 649 if (kfifo_is_empty(&device->tx_fifo)) {
653 {
654abort: 650abort:
655 if (rx_interrupted) 651 if (rx_interrupted)
656 { 652 {
@@ -704,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
704 mutex_unlock(&device->rx_lock); 700 mutex_unlock(&device->rx_lock);
705 701
706 /* if read was successful copy to user space*/ 702 /* if read was successful copy to user space*/
707 if (bytes_received > 0) 703 if (bytes_received > 0) {
708 {
709 retval = copy_to_user(buf, device->rx_buffer, bytes_received); 704 retval = copy_to_user(buf, device->rx_buffer, bytes_received);
710 if (retval) 705 if (retval)
711 return -EFAULT; 706 return -EFAULT;
@@ -805,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
805 switch (cmd) { 800 switch (cmd) {
806 case PI433_IOC_RD_TX_CFG: 801 case PI433_IOC_RD_TX_CFG:
807 tmp = _IOC_SIZE(cmd); 802 tmp = _IOC_SIZE(cmd);
808 if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) 803 if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
809 {
810 retval = -EINVAL; 804 retval = -EINVAL;
811 break; 805 break;
812 } 806 }
@@ -822,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
822 break; 816 break;
823 case PI433_IOC_WR_TX_CFG: 817 case PI433_IOC_WR_TX_CFG:
824 tmp = _IOC_SIZE(cmd); 818 tmp = _IOC_SIZE(cmd);
825 if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) 819 if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
826 {
827 retval = -EINVAL; 820 retval = -EINVAL;
828 break; 821 break;
829 } 822 }
@@ -916,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file *filp)
916 909
917 if (!device->rx_buffer) { 910 if (!device->rx_buffer) {
918 device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); 911 device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
919 if (!device->rx_buffer) 912 if (!device->rx_buffer) {
920 {
921 dev_dbg(device->dev, "open/ENOMEM\n"); 913 dev_dbg(device->dev, "open/ENOMEM\n");
922 return -ENOMEM; 914 return -ENOMEM;
923 } 915 }
@@ -925,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file *filp)
925 917
926 device->users++; 918 device->users++;
927 instance = kzalloc(sizeof(*instance), GFP_KERNEL); 919 instance = kzalloc(sizeof(*instance), GFP_KERNEL);
928 if (!instance) 920 if (!instance) {
929 {
930 kfree(device->rx_buffer); 921 kfree(device->rx_buffer);
931 device->rx_buffer = NULL; 922 device->rx_buffer = NULL;
932 return -ENOMEM; 923 return -ENOMEM;
@@ -986,8 +977,7 @@ static int setup_GPIOs(struct pi433_device *device)
986 snprintf(name, sizeof(name), "DIO%d", i); 977 snprintf(name, sizeof(name), "DIO%d", i);
987 device->gpiod[i] = gpiod_get(&device->spi->dev, name, 0 /*GPIOD_IN*/); 978 device->gpiod[i] = gpiod_get(&device->spi->dev, name, 0 /*GPIOD_IN*/);
988 979
989 if (device->gpiod[i] == ERR_PTR(-ENOENT)) 980 if (device->gpiod[i] == ERR_PTR(-ENOENT)) {
990 {
991 dev_dbg(&device->spi->dev, "Could not find entry for %s. Ignoring.", name); 981 dev_dbg(&device->spi->dev, "Could not find entry for %s. Ignoring.", name);
992 continue; 982 continue;
993 } 983 }
@@ -1016,8 +1006,7 @@ static int setup_GPIOs(struct pi433_device *device)
1016 1006
1017 /* configure irq */ 1007 /* configure irq */
1018 device->irq_num[i] = gpiod_to_irq(device->gpiod[i]); 1008 device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
1019 if (device->irq_num[i] < 0) 1009 if (device->irq_num[i] < 0) {
1020 {
1021 device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc *)device->irq_num[i]; 1010 device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc *)device->irq_num[i];
1022 return device->irq_num[i]; 1011 return device->irq_num[i];
1023 } 1012 }
@@ -1030,7 +1019,7 @@ static int setup_GPIOs(struct pi433_device *device)
1030 if (retval) 1019 if (retval)
1031 return retval; 1020 return retval;
1032 1021
1033 dev_dbg(&device->spi->dev, "%s succesfully configured", name); 1022 dev_dbg(&device->spi->dev, "%s successfully configured", name);
1034 } 1023 }
1035 1024
1036 return 0; 1025 return 0;
@@ -1156,8 +1145,7 @@ static int pi433_probe(struct spi_device *spi)
1156 1145
1157 /* setup GPIO (including irq_handler) for the different DIOs */ 1146 /* setup GPIO (including irq_handler) for the different DIOs */
1158 retval = setup_GPIOs(device); 1147 retval = setup_GPIOs(device);
1159 if (retval) 1148 if (retval) {
1160 {
1161 dev_dbg(&spi->dev, "setup of GPIOs failed"); 1149 dev_dbg(&spi->dev, "setup of GPIOs failed");
1162 goto GPIO_failed; 1150 goto GPIO_failed;
1163 } 1151 }
@@ -1175,16 +1163,14 @@ static int pi433_probe(struct spi_device *spi)
1175 device->tx_task_struct = kthread_run(pi433_tx_thread, 1163 device->tx_task_struct = kthread_run(pi433_tx_thread,
1176 device, 1164 device,
1177 "pi433_tx_task"); 1165 "pi433_tx_task");
1178 if (IS_ERR(device->tx_task_struct)) 1166 if (IS_ERR(device->tx_task_struct)) {
1179 {
1180 dev_dbg(device->dev, "start of send thread failed"); 1167 dev_dbg(device->dev, "start of send thread failed");
1181 goto send_thread_failed; 1168 goto send_thread_failed;
1182 } 1169 }
1183 1170
1184 /* determ minor number */ 1171 /* determ minor number */
1185 retval = pi433_get_minor(device); 1172 retval = pi433_get_minor(device);
1186 if (retval) 1173 if (retval) {
1187 {
1188 dev_dbg(device->dev, "get of minor number failed"); 1174 dev_dbg(device->dev, "get of minor number failed");
1189 goto minor_failed; 1175 goto minor_failed;
1190 } 1176 }
@@ -1213,8 +1199,7 @@ static int pi433_probe(struct spi_device *spi)
1213 device->cdev->owner = THIS_MODULE; 1199 device->cdev->owner = THIS_MODULE;
1214 cdev_init(device->cdev, &pi433_fops); 1200 cdev_init(device->cdev, &pi433_fops);
1215 retval = cdev_add(device->cdev, device->devt, 1); 1201 retval = cdev_add(device->cdev, device->devt, 1);
1216 if (retval) 1202 if (retval) {
1217 {
1218 dev_dbg(device->dev, "register of cdev failed"); 1203 dev_dbg(device->dev, "register of cdev failed");
1219 goto cdev_failed; 1204 goto cdev_failed;
1220 } 1205 }
@@ -1306,15 +1291,13 @@ static int __init pi433_init(void)
1306 return status; 1291 return status;
1307 1292
1308 pi433_class = class_create(THIS_MODULE, "pi433"); 1293 pi433_class = class_create(THIS_MODULE, "pi433");
1309 if (IS_ERR(pi433_class)) 1294 if (IS_ERR(pi433_class)) {
1310 {
1311 unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); 1295 unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name);
1312 return PTR_ERR(pi433_class); 1296 return PTR_ERR(pi433_class);
1313 } 1297 }
1314 1298
1315 status = spi_register_driver(&pi433_spi_driver); 1299 status = spi_register_driver(&pi433_spi_driver);
1316 if (status < 0) 1300 if (status < 0) {
1317 {
1318 class_destroy(pi433_class); 1301 class_destroy(pi433_class);
1319 unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); 1302 unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name);
1320 } 1303 }
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 290b419aa9dd..e69a2153c999 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -34,7 +34,7 @@
34/*-------------------------------------------------------------------------*/ 34/*-------------------------------------------------------------------------*/
35 35
36#define READ_REG(x) rf69_read_reg (spi, x) 36#define READ_REG(x) rf69_read_reg (spi, x)
37#define WRITE_REG(x,y) rf69_write_reg(spi, x, y) 37#define WRITE_REG(x, y) rf69_write_reg(spi, x, y)
38 38
39/*-------------------------------------------------------------------------*/ 39/*-------------------------------------------------------------------------*/
40 40
@@ -164,9 +164,12 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
164 164
165 // transmit to RF 69 165 // transmit to RF 69
166 retval = WRITE_REG(REG_BITRATE_MSB, msb); 166 retval = WRITE_REG(REG_BITRATE_MSB, msb);
167 if (retval) return retval; 167 if (retval)
168 return retval;
169
168 retval = WRITE_REG(REG_BITRATE_LSB, lsb); 170 retval = WRITE_REG(REG_BITRATE_LSB, lsb);
169 if (retval) return retval; 171 if (retval)
172 return retval;
170 173
171 return 0; 174 return 0;
172} 175}
@@ -196,7 +199,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation)
196 199
197 // calculate register settings 200 // calculate register settings
198 f_reg = deviation * factor; 201 f_reg = deviation * factor;
199 do_div(f_reg , f_step); 202 do_div(f_reg, f_step);
200 203
201 msb = (f_reg&0xff00) >> 8; 204 msb = (f_reg&0xff00) >> 8;
202 lsb = (f_reg&0xff); 205 lsb = (f_reg&0xff);
@@ -209,9 +212,12 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation)
209 212
210 // write to chip 213 // write to chip
211 retval = WRITE_REG(REG_FDEV_MSB, msb); 214 retval = WRITE_REG(REG_FDEV_MSB, msb);
212 if (retval) return retval; 215 if (retval)
216 return retval;
217
213 retval = WRITE_REG(REG_FDEV_LSB, lsb); 218 retval = WRITE_REG(REG_FDEV_LSB, lsb);
214 if (retval) return retval; 219 if (retval)
220 return retval;
215 221
216 return 0; 222 return 0;
217} 223}
@@ -244,7 +250,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)
244 250
245 // calculate reg settings 251 // calculate reg settings
246 f_reg = frequency * factor; 252 f_reg = frequency * factor;
247 do_div(f_reg , f_step); 253 do_div(f_reg, f_step);
248 254
249 msb = (f_reg&0xff0000) >> 16; 255 msb = (f_reg&0xff0000) >> 16;
250 mid = (f_reg&0xff00) >> 8; 256 mid = (f_reg&0xff00) >> 8;
@@ -252,11 +258,16 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)
252 258
253 // write to chip 259 // write to chip
254 retval = WRITE_REG(REG_FRF_MSB, msb); 260 retval = WRITE_REG(REG_FRF_MSB, msb);
255 if (retval) return retval; 261 if (retval)
262 return retval;
263
256 retval = WRITE_REG(REG_FRF_MID, mid); 264 retval = WRITE_REG(REG_FRF_MID, mid);
257 if (retval) return retval; 265 if (retval)
266 return retval;
267
258 retval = WRITE_REG(REG_FRF_LSB, lsb); 268 retval = WRITE_REG(REG_FRF_LSB, lsb);
259 if (retval) return retval; 269 if (retval)
270 return retval;
260 271
261 return 0; 272 return 0;
262} 273}
@@ -267,9 +278,9 @@ int rf69_set_amplifier_0(struct spi_device *spi, enum optionOnOff optionOnOff)
267 dev_dbg(&spi->dev, "set: amp #0"); 278 dev_dbg(&spi->dev, "set: amp #0");
268 #endif 279 #endif
269 280
270 switch(optionOnOff) { 281 switch (optionOnOff) {
271 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0) ); 282 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0));
272 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0) ); 283 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0));
273 default: 284 default:
274 dev_dbg(&spi->dev, "set: illegal input param"); 285 dev_dbg(&spi->dev, "set: illegal input param");
275 return -EINVAL; 286 return -EINVAL;
@@ -282,9 +293,9 @@ int rf69_set_amplifier_1(struct spi_device *spi, enum optionOnOff optionOnOff)
282 dev_dbg(&spi->dev, "set: amp #1"); 293 dev_dbg(&spi->dev, "set: amp #1");
283 #endif 294 #endif
284 295
285 switch(optionOnOff) { 296 switch (optionOnOff) {
286 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1) ); 297 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1));
287 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1) ); 298 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1));
288 default: 299 default:
289 dev_dbg(&spi->dev, "set: illegal input param"); 300 dev_dbg(&spi->dev, "set: illegal input param");
290 return -EINVAL; 301 return -EINVAL;
@@ -297,9 +308,9 @@ int rf69_set_amplifier_2(struct spi_device *spi, enum optionOnOff optionOnOff)
297 dev_dbg(&spi->dev, "set: amp #2"); 308 dev_dbg(&spi->dev, "set: amp #2");
298 #endif 309 #endif
299 310
300 switch(optionOnOff) { 311 switch (optionOnOff) {
301 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2) ); 312 case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2));
302 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2) ); 313 case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2));
303 default: 314 default:
304 dev_dbg(&spi->dev, "set: illegal input param"); 315 dev_dbg(&spi->dev, "set: illegal input param");
305 return -EINVAL; 316 return -EINVAL;
@@ -312,7 +323,7 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
312 dev_dbg(&spi->dev, "set: power level"); 323 dev_dbg(&spi->dev, "set: power level");
313 #endif 324 #endif
314 325
315 powerLevel +=18; // TODO Abhängigkeit von PA0,1,2 setting 326 powerLevel += 18; // TODO Abhängigkeit von PA0,1,2 setting
316 327
317 // check input value 328 // check input value
318 if (powerLevel > 0x1f) { 329 if (powerLevel > 0x1f) {
@@ -330,7 +341,7 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
330 dev_dbg(&spi->dev, "set: pa ramp"); 341 dev_dbg(&spi->dev, "set: pa ramp");
331 #endif 342 #endif
332 343
333 switch(paRamp) { 344 switch (paRamp) {
334 case ramp3400: return WRITE_REG(REG_PARAMP, PARAMP_3400); 345 case ramp3400: return WRITE_REG(REG_PARAMP, PARAMP_3400);
335 case ramp2000: return WRITE_REG(REG_PARAMP, PARAMP_2000); 346 case ramp2000: return WRITE_REG(REG_PARAMP, PARAMP_2000);
336 case ramp1000: return WRITE_REG(REG_PARAMP, PARAMP_1000); 347 case ramp1000: return WRITE_REG(REG_PARAMP, PARAMP_1000);
@@ -359,9 +370,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant
359 dev_dbg(&spi->dev, "set: antenna impedance"); 370 dev_dbg(&spi->dev, "set: antenna impedance");
360 #endif 371 #endif
361 372
362 switch(antennaImpedance) { 373 switch (antennaImpedance) {
363 case fiftyOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) & ~MASK_LNA_ZIN) ); 374 case fiftyOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) & ~MASK_LNA_ZIN));
364 case twohundretOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) | MASK_LNA_ZIN) ); 375 case twohundretOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) | MASK_LNA_ZIN));
365 default: 376 default:
366 dev_dbg(&spi->dev, "set: illegal input param"); 377 dev_dbg(&spi->dev, "set: illegal input param");
367 return -EINVAL; 378 return -EINVAL;
@@ -374,14 +385,14 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
374 dev_dbg(&spi->dev, "set: lna gain"); 385 dev_dbg(&spi->dev, "set: lna gain");
375 #endif 386 #endif
376 387
377 switch(lnaGain) { 388 switch (lnaGain) {
378 case automatic: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_AUTO) ); 389 case automatic: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_AUTO));
379 case max: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX) ); 390 case max: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX));
380 case maxMinus6: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_6) ); 391 case maxMinus6: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_6));
381 case maxMinus12: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_12) ); 392 case maxMinus12: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_12));
382 case maxMinus24: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_24) ); 393 case maxMinus24: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_24));
383 case maxMinus36: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_36) ); 394 case maxMinus36: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_36));
384 case maxMinus48: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_48) ); 395 case maxMinus48: return WRITE_REG(REG_LNA, ((READ_REG(REG_LNA) & ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_48));
385 default: 396 default:
386 dev_dbg(&spi->dev, "set: illegal input param"); 397 dev_dbg(&spi->dev, "set: illegal input param");
387 return -EINVAL; 398 return -EINVAL;
@@ -410,17 +421,17 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi)
410 } 421 }
411} 422}
412 423
413int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi ,u8 reg, enum dccPercent dccPercent) 424int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dccPercent dccPercent)
414{ 425{
415 switch (dccPercent) { 426 switch (dccPercent) {
416 case dcc16Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_16_PERCENT) ); 427 case dcc16Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_16_PERCENT));
417 case dcc8Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_8_PERCENT) ); 428 case dcc8Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_8_PERCENT));
418 case dcc4Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_4_PERCENT) ); 429 case dcc4Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_4_PERCENT));
419 case dcc2Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_2_PERCENT) ); 430 case dcc2Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_2_PERCENT));
420 case dcc1Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_1_PERCENT) ); 431 case dcc1Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_1_PERCENT));
421 case dcc0_5Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_5_PERCENT) ); 432 case dcc0_5Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_5_PERCENT));
422 case dcc0_25Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_25_PERCENT) ); 433 case dcc0_25Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_25_PERCENT));
423 case dcc0_125Percent: return WRITE_REG(reg, ( (READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_125_PERCENT) ); 434 case dcc0_125Percent: return WRITE_REG(reg, ((READ_REG(reg) & ~MASK_BW_DCC_FREQ) | BW_DCC_0_125_PERCENT));
424 default: 435 default:
425 dev_dbg(&spi->dev, "set: illegal input param"); 436 dev_dbg(&spi->dev, "set: illegal input param");
426 return -EINVAL; 437 return -EINVAL;
@@ -470,10 +481,16 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg,
470 newValue = newValue & MASK_BW_DCC_FREQ; 481 newValue = newValue & MASK_BW_DCC_FREQ;
471 482
472 // add new mantisse 483 // add new mantisse
473 switch(mantisse) { 484 switch (mantisse) {
474 case mantisse16: newValue = newValue | BW_MANT_16; break; 485 case mantisse16:
475 case mantisse20: newValue = newValue | BW_MANT_20; break; 486 newValue = newValue | BW_MANT_16;
476 case mantisse24: newValue = newValue | BW_MANT_24; break; 487 break;
488 case mantisse20:
489 newValue = newValue | BW_MANT_20;
490 break;
491 case mantisse24:
492 newValue = newValue | BW_MANT_24;
493 break;
477 } 494 }
478 495
479 // add new exponent 496 // add new exponent
@@ -508,9 +525,9 @@ int rf69_set_ook_threshold_type(struct spi_device *spi, enum thresholdType thres
508 #endif 525 #endif
509 526
510 switch (thresholdType) { 527 switch (thresholdType) {
511 case fixed: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_FIXED) ); 528 case fixed: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_FIXED));
512 case peak: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_PEAK) ); 529 case peak: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_PEAK));
513 case average: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_AVERAGE) ); 530 case average: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_AVERAGE));
514 default: 531 default:
515 dev_dbg(&spi->dev, "set: illegal input param"); 532 dev_dbg(&spi->dev, "set: illegal input param");
516 return -EINVAL; 533 return -EINVAL;
@@ -524,14 +541,14 @@ int rf69_set_ook_threshold_step(struct spi_device *spi, enum thresholdStep thres
524 #endif 541 #endif
525 542
526 switch (thresholdStep) { 543 switch (thresholdStep) {
527 case step_0_5db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_0_5_DB) ); 544 case step_0_5db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_0_5_DB));
528 case step_1_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_1_0_DB) ); 545 case step_1_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_1_0_DB));
529 case step_1_5db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_1_5_DB) ); 546 case step_1_5db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_1_5_DB));
530 case step_2_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_2_0_DB) ); 547 case step_2_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_2_0_DB));
531 case step_3_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_3_0_DB) ); 548 case step_3_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_3_0_DB));
532 case step_4_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_4_0_DB) ); 549 case step_4_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_4_0_DB));
533 case step_5_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_5_0_DB) ); 550 case step_5_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_5_0_DB));
534 case step_6_0db: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_6_0_DB) ); 551 case step_6_0db: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESSTEP) | OOKPEAK_THRESHSTEP_6_0_DB));
535 default: 552 default:
536 dev_dbg(&spi->dev, "set: illegal input param"); 553 dev_dbg(&spi->dev, "set: illegal input param");
537 return -EINVAL; 554 return -EINVAL;
@@ -545,14 +562,14 @@ int rf69_set_ook_threshold_dec(struct spi_device *spi, enum thresholdDecrement t
545 #endif 562 #endif
546 563
547 switch (thresholdDecrement) { 564 switch (thresholdDecrement) {
548 case dec_every8th: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_8TH) ); 565 case dec_every8th: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_8TH));
549 case dec_every4th: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_4TH) ); 566 case dec_every4th: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_4TH));
550 case dec_every2nd: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_2ND) ); 567 case dec_every2nd: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_EVERY_2ND));
551 case dec_once: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_ONCE) ); 568 case dec_once: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_ONCE));
552 case dec_twice: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_TWICE) ); 569 case dec_twice: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_TWICE));
553 case dec_4times: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_4_TIMES) ); 570 case dec_4times: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_4_TIMES));
554 case dec_8times: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_8_TIMES) ); 571 case dec_8times: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_8_TIMES));
555 case dec_16times: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_16_TIMES) ); 572 case dec_16times: return WRITE_REG(REG_OOKPEAK, ((READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESDEC) | OOKPEAK_THRESHDEC_16_TIMES));
556 default: 573 default:
557 dev_dbg(&spi->dev, "set: illegal input param"); 574 dev_dbg(&spi->dev, "set: illegal input param");
558 return -EINVAL; 575 return -EINVAL;
@@ -571,25 +588,37 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value)
571 #endif 588 #endif
572 589
573 switch (DIONumber) { 590 switch (DIONumber) {
574 case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; 591 case 0:
575 case 1: mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; 592 mask = MASK_DIO0; shift = SHIFT_DIO0; regaddr = REG_DIOMAPPING1;
576 case 2: mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; 593 break;
577 case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; 594 case 1:
578 case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; 595 mask = MASK_DIO1; shift = SHIFT_DIO1; regaddr = REG_DIOMAPPING1;
579 case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; 596 break;
597 case 2:
598 mask = MASK_DIO2; shift = SHIFT_DIO2; regaddr = REG_DIOMAPPING1;
599 break;
600 case 3:
601 mask = MASK_DIO3; shift = SHIFT_DIO3; regaddr = REG_DIOMAPPING1;
602 break;
603 case 4:
604 mask = MASK_DIO4; shift = SHIFT_DIO4; regaddr = REG_DIOMAPPING2;
605 break;
606 case 5:
607 mask = MASK_DIO5; shift = SHIFT_DIO5; regaddr = REG_DIOMAPPING2;
608 break;
580 default: 609 default:
581 dev_dbg(&spi->dev, "set: illegal input param"); 610 dev_dbg(&spi->dev, "set: illegal input param");
582 return -EINVAL; 611 return -EINVAL;
583 } 612 }
584 613
585 // read reg 614 // read reg
586 regValue=READ_REG(regaddr); 615 regValue = READ_REG(regaddr);
587 // delete old value 616 // delete old value
588 regValue = regValue & ~mask; 617 regValue = regValue & ~mask;
589 // add new value 618 // add new value
590 regValue = regValue | value << shift; 619 regValue = regValue | value << shift;
591 // write back 620 // write back
592 return WRITE_REG(regaddr,regValue); 621 return WRITE_REG(regaddr, regValue);
593} 622}
594 623
595bool rf69_get_flag(struct spi_device *spi, enum flag flag) 624bool rf69_get_flag(struct spi_device *spi, enum flag flag)
@@ -598,7 +627,7 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
598 dev_dbg(&spi->dev, "get: flag"); 627 dev_dbg(&spi->dev, "get: flag");
599 #endif 628 #endif
600 629
601 switch(flag) { 630 switch (flag) {
602 case modeSwitchCompleted: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY); 631 case modeSwitchCompleted: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY);
603 case readyToReceive: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY); 632 case readyToReceive: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY);
604 case readyToSend: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY); 633 case readyToSend: return (READ_REG(REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY);
@@ -626,7 +655,7 @@ int rf69_reset_flag(struct spi_device *spi, enum flag flag)
626 dev_dbg(&spi->dev, "reset: flag"); 655 dev_dbg(&spi->dev, "reset: flag");
627 #endif 656 #endif
628 657
629 switch(flag) { 658 switch (flag) {
630 case rssiExceededThreshold: return WRITE_REG(REG_IRQFLAGS1, MASK_IRQFLAGS1_RSSI); 659 case rssiExceededThreshold: return WRITE_REG(REG_IRQFLAGS1, MASK_IRQFLAGS1_RSSI);
631 case syncAddressMatch: return WRITE_REG(REG_IRQFLAGS1, MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH); 660 case syncAddressMatch: return WRITE_REG(REG_IRQFLAGS1, MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
632 case fifoOverrun: return WRITE_REG(REG_IRQFLAGS2, MASK_IRQFLAGS2_FIFO_OVERRUN); 661 case fifoOverrun: return WRITE_REG(REG_IRQFLAGS2, MASK_IRQFLAGS2_FIFO_OVERRUN);
@@ -686,10 +715,9 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength)
686 715
687 /* transmit to chip */ 716 /* transmit to chip */
688 retval = WRITE_REG(REG_PREAMBLE_MSB, msb); 717 retval = WRITE_REG(REG_PREAMBLE_MSB, msb);
689 if (retval) return retval; 718 if (retval)
690 retval = WRITE_REG(REG_PREAMBLE_LSB, lsb); 719 return retval;
691 720 return WRITE_REG(REG_PREAMBLE_LSB, lsb);
692 return retval;
693} 721}
694 722
695int rf69_set_sync_enable(struct spi_device *spi, enum optionOnOff optionOnOff) 723int rf69_set_sync_enable(struct spi_device *spi, enum optionOnOff optionOnOff)
@@ -698,9 +726,9 @@ int rf69_set_sync_enable(struct spi_device *spi, enum optionOnOff optionOnOff)
698 dev_dbg(&spi->dev, "set: sync enable"); 726 dev_dbg(&spi->dev, "set: sync enable");
699 #endif 727 #endif
700 728
701 switch(optionOnOff) { 729 switch (optionOnOff) {
702 case optionOn: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) | MASK_SYNC_CONFIG_SYNC_ON) ); 730 case optionOn: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) | MASK_SYNC_CONFIG_SYNC_ON));
703 case optionOff: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_SYNC_ON) ); 731 case optionOff: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_SYNC_ON));
704 default: 732 default:
705 dev_dbg(&spi->dev, "set: illegal input param"); 733 dev_dbg(&spi->dev, "set: illegal input param");
706 return -EINVAL; 734 return -EINVAL;
@@ -713,9 +741,9 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifoFillCondition
713 dev_dbg(&spi->dev, "set: fifo fill condition"); 741 dev_dbg(&spi->dev, "set: fifo fill condition");
714 #endif 742 #endif
715 743
716 switch(fifoFillCondition) { 744 switch (fifoFillCondition) {
717 case always: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) | MASK_SYNC_CONFIG_FIFO_FILL_CONDITION) ); 745 case always: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) | MASK_SYNC_CONFIG_FIFO_FILL_CONDITION));
718 case afterSyncInterrupt: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_FIFO_FILL_CONDITION) ); 746 case afterSyncInterrupt: return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_FIFO_FILL_CONDITION));
719 default: 747 default:
720 dev_dbg(&spi->dev, "set: illegal input param"); 748 dev_dbg(&spi->dev, "set: illegal input param");
721 return -EINVAL; 749 return -EINVAL;
@@ -735,7 +763,7 @@ int rf69_set_sync_size(struct spi_device *spi, u8 syncSize)
735 } 763 }
736 764
737 // write value 765 // write value
738 return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_SYNC_SIZE) | (syncSize << 3) ); 766 return WRITE_REG(REG_SYNC_CONFIG, (READ_REG(REG_SYNC_CONFIG) & ~MASK_SYNC_CONFIG_SYNC_SIZE) | (syncSize << 3));
739} 767}
740 768
741int rf69_set_sync_tolerance(struct spi_device *spi, u8 syncTolerance) 769int rf69_set_sync_tolerance(struct spi_device *spi, u8 syncTolerance)
@@ -780,9 +808,9 @@ int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetForma
780 dev_dbg(&spi->dev, "set: packet format"); 808 dev_dbg(&spi->dev, "set: packet format");
781 #endif 809 #endif
782 810
783 switch(packetFormat) { 811 switch (packetFormat) {
784 case packetLengthVar: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) | MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE) ); 812 case packetLengthVar: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) | MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE));
785 case packetLengthFix: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE) ); 813 case packetLengthFix: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE));
786 default: 814 default:
787 dev_dbg(&spi->dev, "set: illegal input param"); 815 dev_dbg(&spi->dev, "set: illegal input param");
788 return -EINVAL; 816 return -EINVAL;
@@ -795,9 +823,9 @@ int rf69_set_crc_enable(struct spi_device *spi, enum optionOnOff optionOnOff)
795 dev_dbg(&spi->dev, "set: crc enable"); 823 dev_dbg(&spi->dev, "set: crc enable");
796 #endif 824 #endif
797 825
798 switch(optionOnOff) { 826 switch (optionOnOff) {
799 case optionOn: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) | MASK_PACKETCONFIG1_CRC_ON) ); 827 case optionOn: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) | MASK_PACKETCONFIG1_CRC_ON));
800 case optionOff: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_CRC_ON) ); 828 case optionOff: return WRITE_REG(REG_PACKETCONFIG1, (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_CRC_ON));
801 default: 829 default:
802 dev_dbg(&spi->dev, "set: illegal input param"); 830 dev_dbg(&spi->dev, "set: illegal input param");
803 return -EINVAL; 831 return -EINVAL;
@@ -811,9 +839,9 @@ int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addre
811 #endif 839 #endif
812 840
813 switch (addressFiltering) { 841 switch (addressFiltering) {
814 case filteringOff: return WRITE_REG(REG_PACKETCONFIG1, ( (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_OFF) ); 842 case filteringOff: return WRITE_REG(REG_PACKETCONFIG1, ((READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_OFF));
815 case nodeAddress: return WRITE_REG(REG_PACKETCONFIG1, ( (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_NODE) ); 843 case nodeAddress: return WRITE_REG(REG_PACKETCONFIG1, ((READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_NODE));
816 case nodeOrBroadcastAddress: return WRITE_REG(REG_PACKETCONFIG1, ( (READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST) ); 844 case nodeOrBroadcastAddress: return WRITE_REG(REG_PACKETCONFIG1, ((READ_REG(REG_PACKETCONFIG1) & ~MASK_PACKETCONFIG1_ADDRESSFILTERING) | PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST));
817 default: 845 default:
818 dev_dbg(&spi->dev, "set: illegal input param"); 846 dev_dbg(&spi->dev, "set: illegal input param");
819 return -EINVAL; 847 return -EINVAL;
@@ -862,9 +890,9 @@ int rf69_set_tx_start_condition(struct spi_device *spi, enum txStartCondition tx
862 dev_dbg(&spi->dev, "set: start condition"); 890 dev_dbg(&spi->dev, "set: start condition");
863 #endif 891 #endif
864 892
865 switch(txStartCondition) { 893 switch (txStartCondition) {
866 case fifoLevel: return WRITE_REG(REG_FIFO_THRESH, (READ_REG(REG_FIFO_THRESH) & ~MASK_FIFO_THRESH_TXSTART) ); 894 case fifoLevel: return WRITE_REG(REG_FIFO_THRESH, (READ_REG(REG_FIFO_THRESH) & ~MASK_FIFO_THRESH_TXSTART));
867 case fifoNotEmpty: return WRITE_REG(REG_FIFO_THRESH, (READ_REG(REG_FIFO_THRESH) | MASK_FIFO_THRESH_TXSTART) ); 895 case fifoNotEmpty: return WRITE_REG(REG_FIFO_THRESH, (READ_REG(REG_FIFO_THRESH) | MASK_FIFO_THRESH_TXSTART));
868 default: 896 default:
869 dev_dbg(&spi->dev, "set: illegal input param"); 897 dev_dbg(&spi->dev, "set: illegal input param");
870 return -EINVAL; 898 return -EINVAL;
@@ -891,7 +919,7 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold)
891 return retval; 919 return retval;
892 920
893 // access the fifo to activate new threshold 921 // access the fifo to activate new threshold
894 return rf69_read_fifo (spi, (u8*) &retval, 1); // retval used as buffer 922 return rf69_read_fifo(spi, (u8 *)&retval, 1); // retval used as buffer
895} 923}
896 924
897int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) 925int rf69_set_dagc(struct spi_device *spi, enum dagc dagc)
@@ -900,7 +928,7 @@ int rf69_set_dagc(struct spi_device *spi, enum dagc dagc)
900 dev_dbg(&spi->dev, "set: dagc"); 928 dev_dbg(&spi->dev, "set: dagc");
901 #endif 929 #endif
902 930
903 switch(dagc) { 931 switch (dagc) {
904 case normalMode: return WRITE_REG(REG_TESTDAGC, DAGC_NORMAL); 932 case normalMode: return WRITE_REG(REG_TESTDAGC, DAGC_NORMAL);
905 case improve: return WRITE_REG(REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0); 933 case improve: return WRITE_REG(REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0);
906 case improve4LowModulationIndex: return WRITE_REG(REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1); 934 case improve4LowModulationIndex: return WRITE_REG(REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1);
@@ -931,14 +959,14 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, unsigned int size)
931 /* prepare a bidirectional transfer */ 959 /* prepare a bidirectional transfer */
932 local_buffer[0] = REG_FIFO; 960 local_buffer[0] = REG_FIFO;
933 memset(&transfer, 0, sizeof(transfer)); 961 memset(&transfer, 0, sizeof(transfer));
934 transfer.tx_buf = local_buffer; 962 transfer.tx_buf = local_buffer;
935 transfer.rx_buf = local_buffer; 963 transfer.rx_buf = local_buffer;
936 transfer.len = size+1; 964 transfer.len = size+1;
937 965
938 retval = spi_sync_transfer(spi, &transfer, 1); 966 retval = spi_sync_transfer(spi, &transfer, 1);
939 967
940 #ifdef DEBUG_FIFO_ACCESS 968 #ifdef DEBUG_FIFO_ACCESS
941 for (i=0; i<size; i++) 969 for (i = 0; i < size; i++)
942 dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i+1]); 970 dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i+1]);
943 #endif 971 #endif
944 972
@@ -966,8 +994,8 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
966 memcpy(&local_buffer[1], buffer, size); // TODO: ohne memcopy wäre schöner 994 memcpy(&local_buffer[1], buffer, size); // TODO: ohne memcopy wäre schöner
967 995
968 #ifdef DEBUG_FIFO_ACCESS 996 #ifdef DEBUG_FIFO_ACCESS
969 for (i=0; i<size; i++) 997 for (i = 0; i < size; i++)
970 dev_dbg(&spi->dev, "0x%x\n",buffer[i]); 998 dev_dbg(&spi->dev, "0x%x\n", buffer[i]);
971 #endif 999 #endif
972 1000
973 return spi_write (spi, local_buffer, size + 1); 1001 return spi_write (spi, local_buffer, size + 1);
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a483769975..fa611455109a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -754,7 +754,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf)
754 } 754 }
755 755
756 /* setting only at first time */ 756 /* setting only at first time */
757 if (!(pmlmepriv->cur_network.join_res)) { 757 if (pmlmepriv->cur_network.join_res != true) {
758 /* WEP Key will be set before this function, do not 758 /* WEP Key will be set before this function, do not
759 * clear CAM. 759 * clear CAM.
760 */ 760 */
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 9461bce883ea..be8542676adf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -333,7 +333,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter)
333 else 333 else
334 RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); 334 RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
335 335
336 pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 336 pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
337 if (!pcmd) { 337 if (!pcmd) {
338 res = _FAIL; 338 res = _FAIL;
339 goto exit; 339 goto exit;
@@ -508,7 +508,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
508 508
509 if (enqueue) { 509 if (enqueue) {
510 /* need enqueue, prepare cmd_obj and enqueue */ 510 /* need enqueue, prepare cmd_obj and enqueue */
511 cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL); 511 cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC);
512 if (!cmdobj) { 512 if (!cmdobj) {
513 res = _FAIL; 513 res = _FAIL;
514 kfree(param); 514 kfree(param);
diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index b9bdff0490ca..2c4c8c43b1ad 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -48,7 +48,7 @@ void Efuse_PowerSwitch(
48 if (PwrState) { 48 if (PwrState) {
49 usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); 49 usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON);
50 50
51 /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ 51 /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */
52 tmpV16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); 52 tmpV16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL);
53 if (!(tmpV16 & PWC_EV12V)) { 53 if (!(tmpV16 & PWC_EV12V)) {
54 tmpV16 |= PWC_EV12V; 54 tmpV16 |= PWC_EV12V;
diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c
index 1b9bc9817a57..c4335893d8f6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_led.c
+++ b/drivers/staging/rtl8188eu/core/rtw_led.c
@@ -22,9 +22,9 @@
22/* Callback function of LED BlinkTimer, */ 22/* Callback function of LED BlinkTimer, */
23/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ 23/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */
24/* */ 24/* */
25void BlinkTimerCallback(unsigned long data) 25static void BlinkTimerCallback(struct timer_list *t)
26{ 26{
27 struct LED_871x *pLed = (struct LED_871x *)data; 27 struct LED_871x *pLed = from_timer(pLed, t, BlinkTimer);
28 struct adapter *padapter = pLed->padapter; 28 struct adapter *padapter = pLed->padapter;
29 29
30 if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) 30 if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped))
@@ -73,8 +73,7 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed)
73 73
74 ResetLedStatus(pLed); 74 ResetLedStatus(pLed);
75 75
76 setup_timer(&pLed->BlinkTimer, BlinkTimerCallback, 76 timer_setup(&pLed->BlinkTimer, BlinkTimerCallback, 0);
77 (unsigned long)pLed);
78 77
79 INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback); 78 INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback);
80} 79}
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index f663e6c41f8a..1cd49e292804 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -106,10 +106,10 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
106 106
107void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) 107void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
108{ 108{
109 rtw_free_mlme_priv_ie_data(pmlmepriv); 109 if (pmlmepriv) {
110 110 rtw_free_mlme_priv_ie_data(pmlmepriv);
111 if (pmlmepriv)
112 vfree(pmlmepriv->free_bss_buf); 111 vfree(pmlmepriv->free_bss_buf);
112 }
113} 113}
114 114
115struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv) 115struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)
@@ -1135,7 +1135,7 @@ static u8 search_max_mac_id(struct adapter *padapter)
1135 1135
1136#if defined(CONFIG_88EU_AP_MODE) 1136#if defined(CONFIG_88EU_AP_MODE)
1137 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { 1137 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1138 for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { 1138 for (aid = pstapriv->max_num_sta; aid > 0; aid--) {
1139 if (pstapriv->sta_aid[aid-1]) 1139 if (pstapriv->sta_aid[aid-1])
1140 break; 1140 break;
1141 } 1141 }
@@ -1143,7 +1143,7 @@ static u8 search_max_mac_id(struct adapter *padapter)
1143 } else 1143 } else
1144#endif 1144#endif
1145 {/* adhoc id = 31~2 */ 1145 {/* adhoc id = 31~2 */
1146 for (mac_id = (NUM_STA-1); mac_id >= IBSS_START_MAC_ID; mac_id--) { 1146 for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) {
1147 if (pmlmeinfo->FW_sta_info[mac_id].status == 1) 1147 if (pmlmeinfo->FW_sta_info[mac_id].status == 1)
1148 break; 1148 break;
1149 } 1149 }
@@ -1329,12 +1329,13 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf)
1329} 1329}
1330 1330
1331/* 1331/*
1332 * _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss 1332 * _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss
1333 * @adapter: pointer to struct adapter structure 1333 * @adapter: pointer to struct adapter structure
1334 */ 1334 */
1335void _rtw_join_timeout_handler (unsigned long data) 1335void _rtw_join_timeout_handler (struct timer_list *t)
1336{ 1336{
1337 struct adapter *adapter = (struct adapter *)data; 1337 struct adapter *adapter =
1338 from_timer(adapter, t, mlmepriv.assoc_timer);
1338 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 1339 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
1339 int do_join_r; 1340 int do_join_r;
1340 1341
@@ -1373,9 +1374,10 @@ void _rtw_join_timeout_handler (unsigned long data)
1373 * rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey 1374 * rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey
1374 * @adapter: pointer to struct adapter structure 1375 * @adapter: pointer to struct adapter structure
1375 */ 1376 */
1376void rtw_scan_timeout_handler (unsigned long data) 1377void rtw_scan_timeout_handler (struct timer_list *t)
1377{ 1378{
1378 struct adapter *adapter = (struct adapter *)data; 1379 struct adapter *adapter =
1380 from_timer(adapter, t, mlmepriv.scan_to_timer);
1379 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 1381 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
1380 1382
1381 DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); 1383 DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
@@ -1400,9 +1402,10 @@ static void rtw_auto_scan_handler(struct adapter *padapter)
1400 } 1402 }
1401} 1403}
1402 1404
1403void rtw_dynamic_check_timer_handlder(unsigned long data) 1405void rtw_dynamic_check_timer_handlder(struct timer_list *t)
1404{ 1406{
1405 struct adapter *adapter = (struct adapter *)data; 1407 struct adapter *adapter =
1408 from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
1406 struct registry_priv *pregistrypriv = &adapter->registrypriv; 1409 struct registry_priv *pregistrypriv = &adapter->registrypriv;
1407 1410
1408 if (!adapter) 1411 if (!adapter)
@@ -1569,7 +1572,7 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
1569 psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; 1572 psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm;
1570 pcmd->cmdcode = _SetAuth_CMD_; 1573 pcmd->cmdcode = _SetAuth_CMD_;
1571 pcmd->parmbuf = (unsigned char *)psetauthparm; 1574 pcmd->parmbuf = (unsigned char *)psetauthparm;
1572 pcmd->cmdsz = (sizeof(struct setauth_parm)); 1575 pcmd->cmdsz = sizeof(struct setauth_parm);
1573 pcmd->rsp = NULL; 1576 pcmd->rsp = NULL;
1574 pcmd->rspsz = 0; 1577 pcmd->rspsz = 0;
1575 INIT_LIST_HEAD(&pcmd->list); 1578 INIT_LIST_HEAD(&pcmd->list);
@@ -1648,7 +1651,7 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in
1648 } 1651 }
1649 pcmd->cmdcode = _SetKey_CMD_; 1652 pcmd->cmdcode = _SetKey_CMD_;
1650 pcmd->parmbuf = (u8 *)psetkeyparm; 1653 pcmd->parmbuf = (u8 *)psetkeyparm;
1651 pcmd->cmdsz = (sizeof(struct setkey_parm)); 1654 pcmd->cmdsz = sizeof(struct setkey_parm);
1652 pcmd->rsp = NULL; 1655 pcmd->rsp = NULL;
1653 pcmd->rspsz = 0; 1656 pcmd->rspsz = 0;
1654 INIT_LIST_HEAD(&pcmd->list); 1657 INIT_LIST_HEAD(&pcmd->list);
@@ -1814,45 +1817,45 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter)
1814 struct security_priv *psecuritypriv = &adapter->securitypriv; 1817 struct security_priv *psecuritypriv = &adapter->securitypriv;
1815 struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; 1818 struct wlan_network *cur_network = &adapter->mlmepriv.cur_network;
1816 1819
1817 pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ 1820 pdev_network->Privacy = psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0; /* adhoc no 802.1x */
1818 1821
1819 pdev_network->Rssi = 0; 1822 pdev_network->Rssi = 0;
1820 1823
1821 switch (pregistrypriv->wireless_mode) { 1824 switch (pregistrypriv->wireless_mode) {
1822 case WIRELESS_11B: 1825 case WIRELESS_11B:
1823 pdev_network->NetworkTypeInUse = (Ndis802_11DS); 1826 pdev_network->NetworkTypeInUse = Ndis802_11DS;
1824 break; 1827 break;
1825 case WIRELESS_11G: 1828 case WIRELESS_11G:
1826 case WIRELESS_11BG: 1829 case WIRELESS_11BG:
1827 case WIRELESS_11_24N: 1830 case WIRELESS_11_24N:
1828 case WIRELESS_11G_24N: 1831 case WIRELESS_11G_24N:
1829 case WIRELESS_11BG_24N: 1832 case WIRELESS_11BG_24N:
1830 pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); 1833 pdev_network->NetworkTypeInUse = Ndis802_11OFDM24;
1831 break; 1834 break;
1832 case WIRELESS_11A: 1835 case WIRELESS_11A:
1833 case WIRELESS_11A_5N: 1836 case WIRELESS_11A_5N:
1834 pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); 1837 pdev_network->NetworkTypeInUse = Ndis802_11OFDM5;
1835 break; 1838 break;
1836 case WIRELESS_11ABGN: 1839 case WIRELESS_11ABGN:
1837 if (pregistrypriv->channel > 14) 1840 if (pregistrypriv->channel > 14)
1838 pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); 1841 pdev_network->NetworkTypeInUse = Ndis802_11OFDM5;
1839 else 1842 else
1840 pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); 1843 pdev_network->NetworkTypeInUse = Ndis802_11OFDM24;
1841 break; 1844 break;
1842 default: 1845 default:
1843 /* TODO */ 1846 /* TODO */
1844 break; 1847 break;
1845 } 1848 }
1846 1849
1847 pdev_network->Configuration.DSConfig = (pregistrypriv->channel); 1850 pdev_network->Configuration.DSConfig = pregistrypriv->channel;
1848 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 1851 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
1849 ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n", 1852 ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n",
1850 pregistrypriv->channel, pdev_network->Configuration.DSConfig)); 1853 pregistrypriv->channel, pdev_network->Configuration.DSConfig));
1851 1854
1852 if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) 1855 if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
1853 pdev_network->Configuration.ATIMWindow = (0); 1856 pdev_network->Configuration.ATIMWindow = 0;
1854 1857
1855 pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode); 1858 pdev_network->InfrastructureMode = cur_network->network.InfrastructureMode;
1856 1859
1857 /* 1. Supported rates */ 1860 /* 1. Supported rates */
1858 /* 2. IE */ 1861 /* 2. IE */
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 611c9409bb98..d73e9bdc80cc 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -605,7 +605,9 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da)
605 dump_mgntframe(padapter, pmgntframe); 605 dump_mgntframe(padapter, pmgntframe);
606} 606}
607 607
608static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, bool wait_ack) 608static int issue_probereq(struct adapter *padapter,
609 struct ndis_802_11_ssid *pssid, u8 *da,
610 bool wait_ack)
609{ 611{
610 int ret = _FAIL; 612 int ret = _FAIL;
611 struct xmit_frame *pmgntframe; 613 struct xmit_frame *pmgntframe;
@@ -707,7 +709,7 @@ static int issue_probereq_ex(struct adapter *padapter,
707 unsigned long start = jiffies; 709 unsigned long start = jiffies;
708 710
709 do { 711 do {
710 ret = issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); 712 ret = issue_probereq(padapter, pssid, da, wait_ms > 0);
711 713
712 i++; 714 i++;
713 715
@@ -1196,7 +1198,8 @@ exit:
1196} 1198}
1197 1199
1198/* when wait_ack is true, this function should be called at process context */ 1200/* when wait_ack is true, this function should be called at process context */
1199static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) 1201static int _issue_nulldata(struct adapter *padapter, unsigned char *da,
1202 unsigned int power_mode, bool wait_ack)
1200{ 1203{
1201 int ret = _FAIL; 1204 int ret = _FAIL;
1202 struct xmit_frame *pmgntframe; 1205 struct xmit_frame *pmgntframe;
@@ -1269,7 +1272,8 @@ exit:
1269 1272
1270/* when wait_ms > 0 , this function should be called at process context */ 1273/* when wait_ms > 0 , this function should be called at process context */
1271/* da == NULL for station mode */ 1274/* da == NULL for station mode */
1272int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms) 1275int issue_nulldata(struct adapter *padapter, unsigned char *da,
1276 unsigned int power_mode, int try_cnt, int wait_ms)
1273{ 1277{
1274 int ret; 1278 int ret;
1275 int i = 0; 1279 int i = 0;
@@ -1283,7 +1287,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
1283 da = pnetwork->MacAddress; 1287 da = pnetwork->MacAddress;
1284 1288
1285 do { 1289 do {
1286 ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); 1290 ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0);
1287 1291
1288 i++; 1292 i++;
1289 1293
@@ -1316,7 +1320,8 @@ exit:
1316} 1320}
1317 1321
1318/* when wait_ack is true, this function should be called at process context */ 1322/* when wait_ack is true, this function should be called at process context */
1319static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) 1323static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
1324 u16 tid, bool wait_ack)
1320{ 1325{
1321 int ret = _FAIL; 1326 int ret = _FAIL;
1322 struct xmit_frame *pmgntframe; 1327 struct xmit_frame *pmgntframe;
@@ -1396,7 +1401,8 @@ exit:
1396 1401
1397/* when wait_ms > 0 , this function should be called at process context */ 1402/* when wait_ms > 0 , this function should be called at process context */
1398/* da == NULL for station mode */ 1403/* da == NULL for station mode */
1399int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms) 1404int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
1405 u16 tid, int try_cnt, int wait_ms)
1400{ 1406{
1401 int ret; 1407 int ret;
1402 int i = 0; 1408 int i = 0;
@@ -1410,7 +1416,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int
1410 da = pnetwork->MacAddress; 1416 da = pnetwork->MacAddress;
1411 1417
1412 do { 1418 do {
1413 ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); 1419 ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0);
1414 1420
1415 i++; 1421 i++;
1416 1422
@@ -1442,7 +1448,8 @@ exit:
1442 return ret; 1448 return ret;
1443} 1449}
1444 1450
1445static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack) 1451static int _issue_deauth(struct adapter *padapter, unsigned char *da,
1452 unsigned short reason, bool wait_ack)
1446{ 1453{
1447 struct xmit_frame *pmgntframe; 1454 struct xmit_frame *pmgntframe;
1448 struct pkt_attrib *pattrib; 1455 struct pkt_attrib *pattrib;
@@ -1502,7 +1509,8 @@ exit:
1502 return ret; 1509 return ret;
1503} 1510}
1504 1511
1505int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason) 1512int issue_deauth(struct adapter *padapter, unsigned char *da,
1513 unsigned short reason)
1506{ 1514{
1507 DBG_88E("%s to %pM\n", __func__, da); 1515 DBG_88E("%s to %pM\n", __func__, da);
1508 return _issue_deauth(padapter, da, reason, false); 1516 return _issue_deauth(padapter, da, reason, false);
@@ -1517,7 +1525,7 @@ static int issue_deauth_ex(struct adapter *padapter, u8 *da,
1517 unsigned long start = jiffies; 1525 unsigned long start = jiffies;
1518 1526
1519 do { 1527 do {
1520 ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); 1528 ret = _issue_deauth(padapter, da, reason, wait_ms > 0);
1521 1529
1522 i++; 1530 i++;
1523 1531
@@ -3413,7 +3421,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter,
3413 /* following are moved to join event callback function */ 3421 /* following are moved to join event callback function */
3414 /* to handle HT, WMM, rate adaptive, update MAC reg */ 3422 /* to handle HT, WMM, rate adaptive, update MAC reg */
3415 /* for not to handle the synchronous IO in the tasklet */ 3423 /* for not to handle the synchronous IO in the tasklet */
3416 for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { 3424 for (i = 6 + WLAN_HDR_A3_LEN; i < pkt_len;) {
3417 pIE = (struct ndis_802_11_var_ie *)(pframe + i); 3425 pIE = (struct ndis_802_11_var_ie *)(pframe + i);
3418 3426
3419 switch (pIE->ElementID) { 3427 switch (pIE->ElementID) {
@@ -3757,7 +3765,8 @@ static unsigned int on_action_public_vendor(struct recv_frame *precv_frame)
3757 return ret; 3765 return ret;
3758} 3766}
3759 3767
3760static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) 3768static unsigned int on_action_public_default(struct recv_frame *precv_frame,
3769 u8 action)
3761{ 3770{
3762 unsigned int ret = _FAIL; 3771 unsigned int ret = _FAIL;
3763 u8 *pframe = precv_frame->pkt->data; 3772 u8 *pframe = precv_frame->pkt->data;
@@ -3972,9 +3981,10 @@ static int has_channel(struct rt_channel_info *channel_set,
3972 return 0; 3981 return 0;
3973} 3982}
3974 3983
3975static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, 3984static void init_channel_list(struct adapter *padapter,
3976 u8 chanset_size, 3985 struct rt_channel_info *channel_set,
3977 struct p2p_channels *channel_list) 3986 u8 chanset_size,
3987 struct p2p_channels *channel_list)
3978{ 3988{
3979 struct p2p_oper_class_map op_class[] = { 3989 struct p2p_oper_class_map op_class[] = {
3980 { IEEE80211G, 81, 1, 13, 1, BW20 }, 3990 { IEEE80211G, 81, 1, 13, 1, BW20 },
@@ -3999,7 +4009,7 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info *
3999 continue; 4009 continue;
4000 4010
4001 if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && 4011 if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) &&
4002 ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) 4012 ((o->bw == BW40MINUS) || (o->bw == BW40PLUS)))
4003 continue; 4013 continue;
4004 4014
4005 if (reg == NULL) { 4015 if (reg == NULL) {
@@ -4015,7 +4025,8 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info *
4015 channel_list->reg_classes = cla; 4025 channel_list->reg_classes = cla;
4016} 4026}
4017 4027
4018static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) 4028static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan,
4029 struct rt_channel_info *channel_set)
4019{ 4030{
4020 u8 index, chanset_size = 0; 4031 u8 index, chanset_size = 0;
4021 u8 b2_4GBand = false; 4032 u8 b2_4GBand = false;
@@ -4030,7 +4041,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c
4030 4041
4031 if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { 4042 if (padapter->registrypriv.wireless_mode & WIRELESS_11G) {
4032 b2_4GBand = true; 4043 b2_4GBand = true;
4033 if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) 4044 if (ChannelPlan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
4034 Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; 4045 Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;
4035 else 4046 else
4036 Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; 4047 Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G;
@@ -4040,14 +4051,14 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c
4040 for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { 4051 for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) {
4041 channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; 4052 channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index];
4042 4053
4043 if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ 4054 if ((ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN) ||/* Channel 1~11 is active, and 12~14 is passive */
4044 (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { 4055 (ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G)) {
4045 if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) 4056 if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11)
4046 channel_set[chanset_size].ScanType = SCAN_ACTIVE; 4057 channel_set[chanset_size].ScanType = SCAN_ACTIVE;
4047 else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) 4058 else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14))
4048 channel_set[chanset_size].ScanType = SCAN_PASSIVE; 4059 channel_set[chanset_size].ScanType = SCAN_PASSIVE;
4049 } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || 4060 } else if (ChannelPlan == RT_CHANNEL_DOMAIN_WORLD_WIDE_13 ||
4050 RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ 4061 Index2G == RT_CHANNEL_DOMAIN_2G_WORLD) {/* channel 12~13, passive scan */
4051 if (channel_set[chanset_size].ChannelNum <= 11) 4062 if (channel_set[chanset_size].ChannelNum <= 11)
4052 channel_set[chanset_size].ScanType = SCAN_ACTIVE; 4063 channel_set[chanset_size].ScanType = SCAN_ACTIVE;
4053 else 4064 else
@@ -4105,7 +4116,9 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
4105 } 4116 }
4106} 4117}
4107 4118
4108static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) 4119static void _mgt_dispatcher(struct adapter *padapter,
4120 struct mlme_handler *ptable,
4121 struct recv_frame *precv_frame)
4109{ 4122{
4110 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 4123 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
4111 u8 *pframe = precv_frame->pkt->data; 4124 u8 *pframe = precv_frame->pkt->data;
@@ -4351,7 +4364,8 @@ void report_join_res(struct adapter *padapter, int res)
4351 rtw_enqueue_cmd(pcmdpriv, pcmd_obj); 4364 rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
4352} 4365}
4353 4366
4354void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) 4367void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr,
4368 unsigned short reason)
4355{ 4369{
4356 struct cmd_obj *pcmd_obj; 4370 struct cmd_obj *pcmd_obj;
4357 u8 *pevtcmd; 4371 u8 *pevtcmd;
@@ -4406,7 +4420,8 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
4406 rtw_enqueue_cmd(pcmdpriv, pcmd_obj); 4420 rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
4407} 4421}
4408 4422
4409void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) 4423void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr,
4424 int cam_idx)
4410{ 4425{
4411 struct cmd_obj *pcmd_obj; 4426 struct cmd_obj *pcmd_obj;
4412 u8 *pevtcmd; 4427 u8 *pevtcmd;
@@ -4767,7 +4782,7 @@ void linked_status_chk(struct adapter *padapter)
4767 if (pmlmeinfo->FW_sta_info[i].status == 1) { 4782 if (pmlmeinfo->FW_sta_info[i].status == 1) {
4768 psta = pmlmeinfo->FW_sta_info[i].psta; 4783 psta = pmlmeinfo->FW_sta_info[i].psta;
4769 4784
4770 if (NULL == psta) 4785 if (psta == NULL)
4771 continue; 4786 continue;
4772 if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { 4787 if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) {
4773 if (pmlmeinfo->FW_sta_info[i].retry < 3) { 4788 if (pmlmeinfo->FW_sta_info[i].retry < 3) {
@@ -4788,9 +4803,10 @@ void linked_status_chk(struct adapter *padapter)
4788 } 4803 }
4789} 4804}
4790 4805
4791void survey_timer_hdl(unsigned long data) 4806void survey_timer_hdl(struct timer_list *t)
4792{ 4807{
4793 struct adapter *padapter = (struct adapter *)data; 4808 struct adapter *padapter = from_timer(padapter, t,
4809 mlmeextpriv.survey_timer);
4794 struct cmd_obj *ph2c; 4810 struct cmd_obj *ph2c;
4795 struct sitesurvey_parm *psurveyPara; 4811 struct sitesurvey_parm *psurveyPara;
4796 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 4812 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -4828,9 +4844,10 @@ exit_survey_timer_hdl:
4828 return; 4844 return;
4829} 4845}
4830 4846
4831void link_timer_hdl(unsigned long data) 4847void link_timer_hdl(struct timer_list *t)
4832{ 4848{
4833 struct adapter *padapter = (struct adapter *)data; 4849 struct adapter *padapter = from_timer(padapter, t,
4850 mlmeextpriv.link_timer);
4834 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 4851 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
4835 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 4852 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
4836 4853
@@ -4864,9 +4881,9 @@ void link_timer_hdl(unsigned long data)
4864 } 4881 }
4865} 4882}
4866 4883
4867void addba_timer_hdl(unsigned long data) 4884void addba_timer_hdl(struct timer_list *t)
4868{ 4885{
4869 struct sta_info *psta = (struct sta_info *)data; 4886 struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
4870 struct ht_priv *phtpriv; 4887 struct ht_priv *phtpriv;
4871 4888
4872 if (!psta) 4889 if (!psta)
@@ -5125,8 +5142,10 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf)
5125 return H2C_SUCCESS; 5142 return H2C_SUCCESS;
5126} 5143}
5127 5144
5128static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_channel *out, 5145static int rtw_scan_ch_decision(struct adapter *padapter,
5129 u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num) 5146 struct rtw_ieee80211_channel *out,
5147 u32 out_num,
5148 struct rtw_ieee80211_channel *in, u32 in_num)
5130{ 5149{
5131 int i, j; 5150 int i, j;
5132 int set_idx; 5151 int set_idx;
diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
index f86c9cebf09a..ac27f9a023bc 100644
--- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
@@ -37,7 +37,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
37 /* system suspend */ 37 /* system suspend */
38 LeaveAllPowerSaveMode(padapter); 38 LeaveAllPowerSaveMode(padapter);
39 39
40 DBG_88E("==> rtw_hw_suspend\n"); 40 DBG_88E("==> %s\n", __func__);
41 mutex_lock(&pwrpriv->mutex_lock); 41 mutex_lock(&pwrpriv->mutex_lock);
42 pwrpriv->bips_processing = true; 42 pwrpriv->bips_processing = true;
43 /* s1. */ 43 /* s1. */
@@ -89,7 +89,7 @@ static int rtw_hw_resume(struct adapter *padapter)
89 89
90 90
91 /* system resume */ 91 /* system resume */
92 DBG_88E("==> rtw_hw_resume\n"); 92 DBG_88E("==> %s\n", __func__);
93 mutex_lock(&pwrpriv->mutex_lock); 93 mutex_lock(&pwrpriv->mutex_lock);
94 pwrpriv->bips_processing = true; 94 pwrpriv->bips_processing = true;
95 rtw_reset_drv_sw(padapter); 95 rtw_reset_drv_sw(padapter);
@@ -146,7 +146,7 @@ void ips_enter(struct adapter *padapter)
146 pwrpriv->ips_mode = pwrpriv->ips_mode_req; 146 pwrpriv->ips_mode = pwrpriv->ips_mode_req;
147 147
148 pwrpriv->ips_enter_cnts++; 148 pwrpriv->ips_enter_cnts++;
149 DBG_88E("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); 149 DBG_88E("==>%s:%d\n", __func__, pwrpriv->ips_enter_cnts);
150 if (rf_off == pwrpriv->change_rfpwrstate) { 150 if (rf_off == pwrpriv->change_rfpwrstate) {
151 pwrpriv->bpower_saving = true; 151 pwrpriv->bpower_saving = true;
152 DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n"); 152 DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n");
@@ -177,7 +177,7 @@ int ips_leave(struct adapter *padapter)
177 pwrpriv->bips_processing = true; 177 pwrpriv->bips_processing = true;
178 pwrpriv->change_rfpwrstate = rf_on; 178 pwrpriv->change_rfpwrstate = rf_on;
179 pwrpriv->ips_leave_cnts++; 179 pwrpriv->ips_leave_cnts++;
180 DBG_88E("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); 180 DBG_88E("==>%s:%d\n", __func__, pwrpriv->ips_leave_cnts);
181 181
182 result = rtw_ips_pwr_up(padapter); 182 result = rtw_ips_pwr_up(padapter);
183 if (result == _SUCCESS) 183 if (result == _SUCCESS)
@@ -198,7 +198,7 @@ int ips_leave(struct adapter *padapter)
198 } 198 }
199 } 199 }
200 200
201 DBG_88E("==> ips_leave.....LED(0x%08x)...\n", usb_read32(padapter, 0x4c)); 201 DBG_88E("==> %s.....LED(0x%08x)...\n", __func__, usb_read32(padapter, 0x4c));
202 pwrpriv->bips_processing = false; 202 pwrpriv->bips_processing = false;
203 203
204 pwrpriv->bkeepfwalive = false; 204 pwrpriv->bkeepfwalive = false;
@@ -276,9 +276,11 @@ exit:
276 pwrpriv->ps_processing = false; 276 pwrpriv->ps_processing = false;
277} 277}
278 278
279static void pwr_state_check_handler(unsigned long data) 279static void pwr_state_check_handler(struct timer_list *t)
280{ 280{
281 struct adapter *padapter = (struct adapter *)data; 281 struct adapter *padapter =
282 from_timer(padapter, t,
283 pwrctrlpriv.pwr_state_check_timer);
282 284
283 rtw_ps_cmd(padapter); 285 rtw_ps_cmd(padapter);
284} 286}
@@ -332,7 +334,7 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv)
332 334
333 rpwm = pslv | pwrpriv->tog; 335 rpwm = pslv | pwrpriv->tog;
334 RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, 336 RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
335 ("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm)); 337 ("%s: rpwm=0x%02x cpwm=0x%02x\n", __func__, rpwm, pwrpriv->cpwm));
336 338
337 pwrpriv->rpwm = pslv; 339 pwrpriv->rpwm = pslv;
338 340
@@ -525,7 +527,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
525 pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; 527 pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE;
526 else 528 else
527 pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ 529 pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */
528 pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; 530 pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false;
529 531
530 pwrctrlpriv->bFwCurrentInPSMode = false; 532 pwrctrlpriv->bFwCurrentInPSMode = false;
531 533
@@ -540,9 +542,8 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
540 542
541 pwrctrlpriv->btcoex_rfon = false; 543 pwrctrlpriv->btcoex_rfon = false;
542 544
543 setup_timer(&pwrctrlpriv->pwr_state_check_timer, 545 timer_setup(&pwrctrlpriv->pwr_state_check_timer,
544 pwr_state_check_handler, 546 pwr_state_check_handler, 0);
545 (unsigned long)padapter);
546} 547}
547 548
548/* 549/*
@@ -569,7 +570,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
569 DBG_88E("%s wait ps_processing...\n", __func__); 570 DBG_88E("%s wait ps_processing...\n", __func__);
570 while (pwrpriv->ps_processing && 571 while (pwrpriv->ps_processing &&
571 jiffies_to_msecs(jiffies - start) <= 3000) 572 jiffies_to_msecs(jiffies - start) <= 3000)
572 usleep_range(1000, 3000); 573 udelay(1500);
573 if (pwrpriv->ps_processing) 574 if (pwrpriv->ps_processing)
574 DBG_88E("%s wait ps_processing timeout\n", __func__); 575 DBG_88E("%s wait ps_processing timeout\n", __func__);
575 else 576 else
@@ -595,7 +596,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
595 } 596 }
596 if (rf_off == pwrpriv->rf_pwrstate) { 597 if (rf_off == pwrpriv->rf_pwrstate) {
597 DBG_88E("%s call ips_leave....\n", __func__); 598 DBG_88E("%s call ips_leave....\n", __func__);
598 if (_FAIL == ips_leave(padapter)) { 599 if (ips_leave(padapter) == _FAIL) {
599 DBG_88E("======> ips_leave fail.............\n"); 600 DBG_88E("======> ips_leave fail.............\n");
600 ret = _FAIL; 601 ret = _FAIL;
601 goto exit; 602 goto exit;
@@ -628,12 +629,12 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode)
628 629
629 if (mode < PS_MODE_NUM) { 630 if (mode < PS_MODE_NUM) {
630 if (pwrctrlpriv->power_mgnt != mode) { 631 if (pwrctrlpriv->power_mgnt != mode) {
631 if (PS_MODE_ACTIVE == mode) 632 if (mode == PS_MODE_ACTIVE)
632 LeaveAllPowerSaveMode(padapter); 633 LeaveAllPowerSaveMode(padapter);
633 else 634 else
634 pwrctrlpriv->LpsIdleCount = 2; 635 pwrctrlpriv->LpsIdleCount = 2;
635 pwrctrlpriv->power_mgnt = mode; 636 pwrctrlpriv->power_mgnt = mode;
636 pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; 637 pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false;
637 } 638 }
638 } else { 639 } else {
639 ret = -EINVAL; 640 ret = -EINVAL;
@@ -653,7 +654,7 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
653 } else if (mode == IPS_NONE) { 654 } else if (mode == IPS_NONE) {
654 rtw_ips_mode_req(pwrctrlpriv, mode); 655 rtw_ips_mode_req(pwrctrlpriv, mode);
655 DBG_88E("%s %s\n", __func__, "IPS_NONE"); 656 DBG_88E("%s %s\n", __func__, "IPS_NONE");
656 if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter))) 657 if ((padapter->bSurpriseRemoved == 0) && (rtw_pwr_wakeup(padapter) == _FAIL))
657 return -EFAULT; 658 return -EFAULT;
658 } else { 659 } else {
659 return -EINVAL; 660 return -EINVAL;
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f4102b36..6506a1587df0 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -39,7 +39,7 @@ static u8 rtw_rfc1042_header[] = {
39 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 39 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
40}; 40};
41 41
42static void rtw_signal_stat_timer_hdl(unsigned long data); 42static void rtw_signal_stat_timer_hdl(struct timer_list *t);
43 43
44void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) 44void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
45{ 45{
@@ -86,9 +86,8 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
86 } 86 }
87 res = rtw_hal_init_recv_priv(padapter); 87 res = rtw_hal_init_recv_priv(padapter);
88 88
89 setup_timer(&precvpriv->signal_stat_timer, 89 timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl,
90 rtw_signal_stat_timer_hdl, 90 0);
91 (unsigned long)padapter);
92 91
93 precvpriv->signal_stat_sampling_interval = 1000; /* ms */ 92 precvpriv->signal_stat_sampling_interval = 1000; /* ms */
94 93
@@ -193,7 +192,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre
193 plist = phead->next; 192 plist = phead->next;
194 193
195 while (phead != plist) { 194 while (phead != plist) {
196 hdr = container_of(plist, struct recv_frame, list); 195 hdr = list_entry(plist, struct recv_frame, list);
197 196
198 plist = plist->next; 197 plist = plist->next;
199 198
@@ -237,32 +236,40 @@ static int recvframe_chkmic(struct adapter *adapter,
237 stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); 236 stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
238 237
239 if (prxattrib->encrypt == _TKIP_) { 238 if (prxattrib->encrypt == _TKIP_) {
240 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt==_TKIP_\n")); 239 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
241 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", 240 ("\n %s: prxattrib->encrypt==_TKIP_\n", __func__));
242 prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); 241 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
242 ("\n %s: da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
243 __func__, prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2],
244 prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5]));
243 245
244 /* calculate mic code */ 246 /* calculate mic code */
245 if (stainfo != NULL) { 247 if (stainfo != NULL) {
246 if (IS_MCAST(prxattrib->ra)) { 248 if (IS_MCAST(prxattrib->ra)) {
247 if (!psecuritypriv) { 249 if (!psecuritypriv) {
248 res = _FAIL; 250 res = _FAIL;
249 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); 251 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
250 DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); 252 ("\n %s: didn't install group key!!!!!!!!!!\n", __func__));
253 DBG_88E("\n %s: didn't install group key!!!!!!!!!!\n", __func__);
251 goto exit; 254 goto exit;
252 } 255 }
253 mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; 256 mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
254 257
255 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); 258 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
259 ("\n %s: bcmc key\n", __func__));
256 } else { 260 } else {
257 mickey = &stainfo->dot11tkiprxmickey.skey[0]; 261 mickey = &stainfo->dot11tkiprxmickey.skey[0];
258 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); 262 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
263 ("\n %s: unicast key\n", __func__));
259 } 264 }
260 265
261 /* icv_len included the mic code */ 266 /* icv_len included the mic code */
262 datalen = precvframe->pkt->len-prxattrib->hdrlen - 8; 267 datalen = precvframe->pkt->len-prxattrib->hdrlen -
268 prxattrib->iv_len-prxattrib->icv_len-8;
263 pframe = precvframe->pkt->data; 269 pframe = precvframe->pkt->data;
264 payload = pframe+prxattrib->hdrlen; 270 payload = pframe+prxattrib->hdrlen+prxattrib->iv_len;
265 271
272 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len));
266 rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], 273 rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0],
267 (unsigned char)prxattrib->priority); /* care the length of the data */ 274 (unsigned char)prxattrib->priority); /* care the length of the data */
268 275
@@ -273,8 +280,8 @@ static int recvframe_chkmic(struct adapter *adapter,
273 for (i = 0; i < 8; i++) { 280 for (i = 0; i < 8; i++) {
274 if (miccode[i] != *(pframemic+i)) { 281 if (miccode[i] != *(pframemic+i)) {
275 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 282 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
276 ("recvframe_chkmic:miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", 283 ("%s: miccode[%d](%02x)!=*(pframemic+%d)(%02x) ",
277 i, miccode[i], i, *(pframemic+i))); 284 __func__, i, miccode[i], i, *(pframemic + i)));
278 bmic_err = true; 285 bmic_err = true;
279 } 286 }
280 } 287 }
@@ -346,7 +353,8 @@ static int recvframe_chkmic(struct adapter *adapter,
346 } 353 }
347 } 354 }
348 } else { 355 } else {
349 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo==NULL!!!\n")); 356 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
357 ("%s: rtw_get_stainfo==NULL!!!\n", __func__));
350 } 358 }
351 359
352 skb_trim(precvframe->pkt, precvframe->pkt->len - 8); 360 skb_trim(precvframe->pkt, precvframe->pkt->len - 8);
@@ -407,15 +415,9 @@ static struct recv_frame *decryptor(struct adapter *padapter,
407 default: 415 default:
408 break; 416 break;
409 } 417 }
410 if (res != _FAIL) {
411 memmove(precv_frame->pkt->data + precv_frame->attrib.iv_len, precv_frame->pkt->data, precv_frame->attrib.hdrlen);
412 skb_pull(precv_frame->pkt, precv_frame->attrib.iv_len);
413 skb_trim(precv_frame->pkt, precv_frame->pkt->len - precv_frame->attrib.icv_len);
414 }
415 } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && 418 } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 &&
416 (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)) { 419 (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_))
417 psecuritypriv->hw_decrypted = true; 420 psecuritypriv->hw_decrypted = true;
418 }
419 421
420 if (res == _FAIL) { 422 if (res == _FAIL) {
421 rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue); 423 rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue);
@@ -456,7 +458,7 @@ static struct recv_frame *portctrl(struct adapter *adapter,
456 458
457 if (auth_alg == 2) { 459 if (auth_alg == 2) {
458 /* get ether_type */ 460 /* get ether_type */
459 ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; 461 ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE + pfhdr->attrib.iv_len;
460 memcpy(&be_tmp, ptr, 2); 462 memcpy(&be_tmp, ptr, 2);
461 ether_type = ntohs(be_tmp); 463 ether_type = ntohs(be_tmp);
462 464
@@ -943,7 +945,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
943 xmitframe_plist = xmitframe_phead->next; 945 xmitframe_plist = xmitframe_phead->next;
944 946
945 if (xmitframe_phead != xmitframe_plist) { 947 if (xmitframe_phead != xmitframe_plist) {
946 pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); 948 pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
947 949
948 xmitframe_plist = xmitframe_plist->next; 950 xmitframe_plist = xmitframe_plist->next;
949 951
@@ -1011,7 +1013,8 @@ static int validate_recv_mgnt_frame(struct adapter *padapter,
1011 1013
1012 precv_frame = recvframe_chk_defrag(padapter, precv_frame); 1014 precv_frame = recvframe_chk_defrag(padapter, precv_frame);
1013 if (precv_frame == NULL) { 1015 if (precv_frame == NULL) {
1014 RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); 1016 RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
1017 ("%s: fragment packet\n", __func__));
1015 return _SUCCESS; 1018 return _SUCCESS;
1016 } 1019 }
1017 1020
@@ -1138,8 +1141,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
1138 } 1141 }
1139 1142
1140 if (pattrib->privacy) { 1143 if (pattrib->privacy) {
1141 struct sk_buff *skb = precv_frame->pkt;
1142
1143 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("validate_recv_data_frame:pattrib->privacy=%x\n", pattrib->privacy)); 1144 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("validate_recv_data_frame:pattrib->privacy=%x\n", pattrib->privacy));
1144 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x))=%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra))); 1145 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x))=%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra)));
1145 1146
@@ -1148,13 +1149,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
1148 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt=%d\n", pattrib->encrypt)); 1149 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt=%d\n", pattrib->encrypt));
1149 1150
1150 SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); 1151 SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt);
1151
1152 if (pattrib->bdecrypted == 1 && pattrib->encrypt > 0) {
1153 memmove(skb->data + pattrib->iv_len,
1154 skb->data, pattrib->hdrlen);
1155 skb_pull(skb, pattrib->iv_len);
1156 skb_trim(skb, skb->len - pattrib->icv_len);
1157 }
1158 } else { 1152 } else {
1159 pattrib->encrypt = 0; 1153 pattrib->encrypt = 0;
1160 pattrib->iv_len = 0; 1154 pattrib->iv_len = 0;
@@ -1274,7 +1268,6 @@ static int validate_recv_frame(struct adapter *adapter,
1274 * Hence forward the frame to the monitor anyway to preserve the order 1268 * Hence forward the frame to the monitor anyway to preserve the order
1275 * in which frames were received. 1269 * in which frames were received.
1276 */ 1270 */
1277
1278 rtl88eu_mon_recv_hook(adapter->pmondev, precv_frame); 1271 rtl88eu_mon_recv_hook(adapter->pmondev, precv_frame);
1279 1272
1280exit: 1273exit:
@@ -1296,8 +1289,11 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
1296 u8 *ptr = precvframe->pkt->data; 1289 u8 *ptr = precvframe->pkt->data;
1297 struct rx_pkt_attrib *pattrib = &precvframe->attrib; 1290 struct rx_pkt_attrib *pattrib = &precvframe->attrib;
1298 1291
1299 psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen); 1292 if (pattrib->encrypt)
1300 psnap_type = ptr+pattrib->hdrlen + SNAP_SIZE; 1293 skb_trim(precvframe->pkt, precvframe->pkt->len - pattrib->icv_len);
1294
1295 psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len);
1296 psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
1301 /* convert hdr + possible LLC headers into Ethernet header */ 1297 /* convert hdr + possible LLC headers into Ethernet header */
1302 if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && 1298 if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
1303 (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && 1299 (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) &&
@@ -1310,9 +1306,12 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
1310 bsnaphdr = false; 1306 bsnaphdr = false;
1311 } 1307 }
1312 1308
1313 rmv_len = pattrib->hdrlen + (bsnaphdr ? SNAP_SIZE : 0); 1309 rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0);
1314 len = precvframe->pkt->len - rmv_len; 1310 len = precvframe->pkt->len - rmv_len;
1315 1311
1312 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
1313 ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len));
1314
1316 memcpy(&be_tmp, ptr+rmv_len, 2); 1315 memcpy(&be_tmp, ptr+rmv_len, 2);
1317 eth_type = ntohs(be_tmp); /* pattrib->ether_type */ 1316 eth_type = ntohs(be_tmp); /* pattrib->ether_type */
1318 pattrib->eth_type = eth_type; 1317 pattrib->eth_type = eth_type;
@@ -1337,6 +1336,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
1337 struct __queue *defrag_q) 1336 struct __queue *defrag_q)
1338{ 1337{
1339 struct list_head *plist, *phead; 1338 struct list_head *plist, *phead;
1339 u8 wlanhdr_offset;
1340 u8 curfragnum; 1340 u8 curfragnum;
1341 struct recv_frame *pfhdr, *pnfhdr; 1341 struct recv_frame *pfhdr, *pnfhdr;
1342 struct recv_frame *prframe, *pnextrframe; 1342 struct recv_frame *prframe, *pnextrframe;
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
1347 1347
1348 phead = get_list_head(defrag_q); 1348 phead = get_list_head(defrag_q);
1349 plist = phead->next; 1349 plist = phead->next;
1350 pfhdr = container_of(plist, struct recv_frame, list); 1350 pfhdr = list_entry(plist, struct recv_frame, list);
1351 prframe = pfhdr; 1351 prframe = pfhdr;
1352 list_del_init(&(prframe->list)); 1352 list_del_init(&(prframe->list));
1353 1353
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
1367 plist = plist->next; 1367 plist = plist->next;
1368 1368
1369 while (phead != plist) { 1369 while (phead != plist) {
1370 pnfhdr = container_of(plist, struct recv_frame, list); 1370 pnfhdr = list_entry(plist, struct recv_frame, list);
1371 pnextrframe = pnfhdr; 1371 pnextrframe = pnfhdr;
1372 1372
1373 /* check the fragment sequence (2nd ~n fragment frame) */ 1373 /* check the fragment sequence (2nd ~n fragment frame) */
@@ -1385,7 +1385,12 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
1385 /* copy the 2nd~n fragment frame's payload to the first fragment */ 1385 /* copy the 2nd~n fragment frame's payload to the first fragment */
1386 /* get the 2nd~last fragment frame's payload */ 1386 /* get the 2nd~last fragment frame's payload */
1387 1387
1388 skb_pull(pnextrframe->pkt, pnfhdr->attrib.hdrlen); 1388 wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
1389
1390 skb_pull(pnextrframe->pkt, wlanhdr_offset);
1391
1392 /* append to first fragment frame's tail (if privacy frame, pull the ICV) */
1393 skb_trim(prframe->pkt, prframe->pkt->len - pfhdr->attrib.icv_len);
1389 1394
1390 /* memcpy */ 1395 /* memcpy */
1391 memcpy(skb_tail_pointer(pfhdr->pkt), pnfhdr->pkt->data, 1396 memcpy(skb_tail_pointer(pfhdr->pkt), pnfhdr->pkt->data,
@@ -1393,7 +1398,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
1393 1398
1394 skb_put(prframe->pkt, pnfhdr->pkt->len); 1399 skb_put(prframe->pkt, pnfhdr->pkt->len);
1395 1400
1396 pfhdr->attrib.icv_len = 0; 1401 pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
1397 plist = plist->next; 1402 plist = plist->next;
1398 } 1403 }
1399 1404
@@ -1519,6 +1524,11 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe)
1519 nr_subframes = 0; 1524 nr_subframes = 0;
1520 pattrib = &prframe->attrib; 1525 pattrib = &prframe->attrib;
1521 1526
1527 skb_pull(prframe->pkt, prframe->attrib.hdrlen);
1528
1529 if (prframe->attrib.iv_len > 0)
1530 skb_pull(prframe->pkt, prframe->attrib.iv_len);
1531
1522 a_len = prframe->pkt->len; 1532 a_len = prframe->pkt->len;
1523 1533
1524 pdata = prframe->pkt->data; 1534 pdata = prframe->pkt->data;
@@ -1655,7 +1665,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
1655 plist = phead->next; 1665 plist = phead->next;
1656 1666
1657 while (phead != plist) { 1667 while (phead != plist) {
1658 hdr = container_of(plist, struct recv_frame, list); 1668 hdr = list_entry(plist, struct recv_frame, list);
1659 pnextattrib = &hdr->attrib; 1669 pnextattrib = &hdr->attrib;
1660 1670
1661 if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) 1671 if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1700,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
1690 if (list_empty(phead)) 1700 if (list_empty(phead))
1691 return true; 1701 return true;
1692 1702
1693 prhdr = container_of(plist, struct recv_frame, list); 1703 prhdr = list_entry(plist, struct recv_frame, list);
1694 pattrib = &prhdr->attrib; 1704 pattrib = &prhdr->attrib;
1695 preorder_ctrl->indicate_seq = pattrib->seq_num; 1705 preorder_ctrl->indicate_seq = pattrib->seq_num;
1696 } 1706 }
@@ -1698,7 +1708,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
1698 /* Prepare indication list and indication. */ 1708 /* Prepare indication list and indication. */
1699 /* Check if there is any packet need indicate. */ 1709 /* Check if there is any packet need indicate. */
1700 while (!list_empty(phead)) { 1710 while (!list_empty(phead)) {
1701 prhdr = container_of(plist, struct recv_frame, list); 1711 prhdr = list_entry(plist, struct recv_frame, list);
1702 prframe = prhdr; 1712 prframe = prhdr;
1703 pattrib = &prframe->attrib; 1713 pattrib = &prframe->attrib;
1704 1714
@@ -1829,9 +1839,10 @@ _err_exit:
1829 return _FAIL; 1839 return _FAIL;
1830} 1840}
1831 1841
1832void rtw_reordering_ctrl_timeout_handler(unsigned long data) 1842void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
1833{ 1843{
1834 struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)data; 1844 struct recv_reorder_ctrl *preorder_ctrl = from_timer(preorder_ctrl, t,
1845 reordering_ctrl_timer);
1835 struct adapter *padapter = preorder_ctrl->padapter; 1846 struct adapter *padapter = preorder_ctrl->padapter;
1836 struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; 1847 struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
1837 1848
@@ -1887,6 +1898,24 @@ static int process_recv_indicatepkts(struct adapter *padapter,
1887 return retval; 1898 return retval;
1888} 1899}
1889 1900
1901static int recv_func_prehandle(struct adapter *padapter,
1902 struct recv_frame *rframe)
1903{
1904 int ret = _SUCCESS;
1905 struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
1906
1907 /* check the frame crtl field and decache */
1908 ret = validate_recv_frame(padapter, rframe);
1909 if (ret != _SUCCESS) {
1910 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n"));
1911 rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */
1912 goto exit;
1913 }
1914
1915exit:
1916 return ret;
1917}
1918
1890static int recv_func_posthandle(struct adapter *padapter, 1919static int recv_func_posthandle(struct adapter *padapter,
1891 struct recv_frame *prframe) 1920 struct recv_frame *prframe)
1892{ 1921{
@@ -1939,7 +1968,6 @@ static int recv_func(struct adapter *padapter, struct recv_frame *rframe)
1939 struct rx_pkt_attrib *prxattrib = &rframe->attrib; 1968 struct rx_pkt_attrib *prxattrib = &rframe->attrib;
1940 struct security_priv *psecuritypriv = &padapter->securitypriv; 1969 struct security_priv *psecuritypriv = &padapter->securitypriv;
1941 struct mlme_priv *mlmepriv = &padapter->mlmepriv; 1970 struct mlme_priv *mlmepriv = &padapter->mlmepriv;
1942 struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
1943 1971
1944 /* check if need to handle uc_swdec_pending_queue*/ 1972 /* check if need to handle uc_swdec_pending_queue*/
1945 if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { 1973 if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) {
@@ -1951,12 +1979,9 @@ static int recv_func(struct adapter *padapter, struct recv_frame *rframe)
1951 } 1979 }
1952 } 1980 }
1953 1981
1954 /* check the frame crtl field and decache */ 1982 ret = recv_func_prehandle(padapter, rframe);
1955 ret = validate_recv_frame(padapter, rframe); 1983
1956 if (ret != _SUCCESS) { 1984 if (ret == _SUCCESS) {
1957 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n"));
1958 rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */
1959 } else {
1960 /* check if need to enqueue into uc_swdec_pending_queue*/ 1985 /* check if need to enqueue into uc_swdec_pending_queue*/
1961 if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && 1986 if (check_fwstate(mlmepriv, WIFI_STATION_STATE) &&
1962 !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 && 1987 !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 &&
@@ -1999,9 +2024,10 @@ _recv_entry_drop:
1999 return ret; 2024 return ret;
2000} 2025}
2001 2026
2002static void rtw_signal_stat_timer_hdl(unsigned long data) 2027static void rtw_signal_stat_timer_hdl(struct timer_list *t)
2003{ 2028{
2004 struct adapter *adapter = (struct adapter *)data; 2029 struct adapter *adapter =
2030 from_timer(adapter, t, recvpriv.signal_stat_timer);
2005 struct recv_priv *recvpriv = &adapter->recvpriv; 2031 struct recv_priv *recvpriv = &adapter->recvpriv;
2006 2032
2007 u32 tmp_s, tmp_q; 2033 u32 tmp_s, tmp_q;
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index b283a4903369..5b1ef229df2a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -1690,4 +1690,4 @@ do { \
1690 d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ 1690 d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
1691 d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ 1691 d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
1692 d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ 1692 d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
1693} while (0); 1693} while (0)
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362b8528..2fd2a9e2416e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -239,8 +239,8 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
239 } 239 }
240 240
241 /* init for DM */ 241 /* init for DM */
242 psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); 242 psta->rssi_stat.UndecoratedSmoothedPWDB = -1;
243 psta->rssi_stat.UndecoratedSmoothedCCK = (-1); 243 psta->rssi_stat.UndecoratedSmoothedCCK = -1;
244 244
245 /* init for the sequence number of received management frame */ 245 /* init for the sequence number of received management frame */
246 psta->RxMgmtFrameSeqNum = 0xffff; 246 psta->RxMgmtFrameSeqNum = 0xffff;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index be2f46eb9f78..e8d9858f2942 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -93,7 +93,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
93 pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; 93 pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf;
94 94
95 for (i = 0; i < NR_XMITFRAME; i++) { 95 for (i = 0; i < NR_XMITFRAME; i++) {
96 INIT_LIST_HEAD(&(pxframe->list)); 96 INIT_LIST_HEAD(&pxframe->list);
97 97
98 pxframe->padapter = padapter; 98 pxframe->padapter = padapter;
99 pxframe->frame_tag = NULL_FRAMETAG; 99 pxframe->frame_tag = NULL_FRAMETAG;
@@ -103,7 +103,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
103 pxframe->buf_addr = NULL; 103 pxframe->buf_addr = NULL;
104 pxframe->pxmitbuf = NULL; 104 pxframe->pxmitbuf = NULL;
105 105
106 list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); 106 list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue);
107 107
108 pxframe++; 108 pxframe++;
109 } 109 }
@@ -148,7 +148,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
148 148
149 pxmitbuf->flags = XMIT_VO_QUEUE; 149 pxmitbuf->flags = XMIT_VO_QUEUE;
150 150
151 list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); 151 list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue);
152 pxmitbuf++; 152 pxmitbuf++;
153 } 153 }
154 154
@@ -182,7 +182,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
182 goto exit; 182 goto exit;
183 } 183 }
184 184
185 list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); 185 list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue);
186 pxmitbuf++; 186 pxmitbuf++;
187 } 187 }
188 188
@@ -258,8 +258,8 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *
258 u32 sz; 258 u32 sz;
259 struct pkt_attrib *pattrib = &pxmitframe->attrib; 259 struct pkt_attrib *pattrib = &pxmitframe->attrib;
260 struct sta_info *psta = pattrib->psta; 260 struct sta_info *psta = pattrib->psta;
261 struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 261 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
262 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 262 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
263 263
264 if (pattrib->nr_frags != 1) 264 if (pattrib->nr_frags != 1)
265 sz = padapter->xmitpriv.frag_len; 265 sz = padapter->xmitpriv.frag_len;
@@ -697,7 +697,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
697 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len)); 697 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len));
698 } 698 }
699 } 699 }
700 rtw_secgetmic(&micdata, &(mic[0])); 700 rtw_secgetmic(&micdata, &mic[0]);
701 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); 701 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n"));
702 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz)); 702 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz));
703 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\ 703 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\
@@ -705,18 +705,18 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
705 mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); 705 mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7]));
706 /* add mic code and add the mic code length in last_txcmdsz */ 706 /* add mic code and add the mic code length in last_txcmdsz */
707 707
708 memcpy(payload, &(mic[0]), 8); 708 memcpy(payload, &mic[0], 8);
709 pattrib->last_txcmdsz += 8; 709 pattrib->last_txcmdsz += 8;
710 710
711 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n")); 711 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n"));
712 payload = payload-pattrib->last_txcmdsz+8; 712 payload = payload-pattrib->last_txcmdsz+8;
713 for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) 713 for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8)
714 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, 714 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
715 (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", 715 (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ",
716 *(payload+curfragnum), *(payload+curfragnum+1), 716 *(payload + curfragnum), *(payload + curfragnum + 1),
717 *(payload+curfragnum+2), *(payload+curfragnum+3), 717 *(payload + curfragnum + 2), *(payload + curfragnum + 3),
718 *(payload+curfragnum+4), *(payload+curfragnum+5), 718 *(payload + curfragnum + 4), *(payload + curfragnum + 5),
719 *(payload+curfragnum+6), *(payload+curfragnum+7))); 719 *(payload + curfragnum + 6), *(payload + curfragnum + 7)));
720 } else { 720 } else {
721 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n")); 721 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n"));
722 } 722 }
@@ -786,7 +786,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
786 SetFrameSubType(fctrl, pattrib->subtype); 786 SetFrameSubType(fctrl, pattrib->subtype);
787 787
788 if (pattrib->subtype & WIFI_DATA_TYPE) { 788 if (pattrib->subtype & WIFI_DATA_TYPE) {
789 if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { 789 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
790 /* to_ds = 1, fr_ds = 0; */ 790 /* to_ds = 1, fr_ds = 0; */
791 /* Data transfer to AP */ 791 /* Data transfer to AP */
792 SetToDs(fctrl); 792 SetToDs(fctrl);
@@ -899,20 +899,20 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat
899 switch (priority) { 899 switch (priority) {
900 case 1: 900 case 1:
901 case 2: 901 case 2:
902 ptxservq = &(psta->sta_xmitpriv.bk_q); 902 ptxservq = &psta->sta_xmitpriv.bk_q;
903 break; 903 break;
904 case 4: 904 case 4:
905 case 5: 905 case 5:
906 ptxservq = &(psta->sta_xmitpriv.vi_q); 906 ptxservq = &psta->sta_xmitpriv.vi_q;
907 break; 907 break;
908 case 6: 908 case 6:
909 case 7: 909 case 7:
910 ptxservq = &(psta->sta_xmitpriv.vo_q); 910 ptxservq = &psta->sta_xmitpriv.vo_q;
911 break; 911 break;
912 case 0: 912 case 0:
913 case 3: 913 case 3:
914 default: 914 default:
915 ptxservq = &(psta->sta_xmitpriv.be_q); 915 ptxservq = &psta->sta_xmitpriv.be_q;
916 break; 916 break;
917 } 917 }
918 918
@@ -1229,7 +1229,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
1229 1229
1230 list_del_init(&pxmitbuf->list); 1230 list_del_init(&pxmitbuf->list);
1231 1231
1232 list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); 1232 list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue));
1233 pxmitpriv->free_xmit_extbuf_cnt++; 1233 pxmitpriv->free_xmit_extbuf_cnt++;
1234 1234
1235 spin_unlock_irqrestore(&pfree_queue->lock, irql); 1235 spin_unlock_irqrestore(&pfree_queue->lock, irql);
@@ -1283,7 +1283,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
1283 1283
1284 list_del_init(&pxmitbuf->list); 1284 list_del_init(&pxmitbuf->list);
1285 1285
1286 list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); 1286 list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue));
1287 1287
1288 pxmitpriv->free_xmitbuf_cnt++; 1288 pxmitpriv->free_xmitbuf_cnt++;
1289 spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); 1289 spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql);
@@ -1395,7 +1395,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
1395 struct xmit_frame *pxmitframe; 1395 struct xmit_frame *pxmitframe;
1396 1396
1397 1397
1398 spin_lock_bh(&(pframequeue->lock)); 1398 spin_lock_bh(&pframequeue->lock);
1399 1399
1400 phead = get_list_head(pframequeue); 1400 phead = get_list_head(pframequeue);
1401 plist = phead->next; 1401 plist = phead->next;
@@ -1407,7 +1407,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
1407 1407
1408 rtw_free_xmitframe(pxmitpriv, pxmitframe); 1408 rtw_free_xmitframe(pxmitpriv, pxmitframe);
1409 } 1409 }
1410 spin_unlock_bh(&(pframequeue->lock)); 1410 spin_unlock_bh(&pframequeue->lock);
1411 1411
1412} 1412}
1413 1413
@@ -1503,26 +1503,26 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *
1503 switch (up) { 1503 switch (up) {
1504 case 1: 1504 case 1:
1505 case 2: 1505 case 2:
1506 ptxservq = &(psta->sta_xmitpriv.bk_q); 1506 ptxservq = &psta->sta_xmitpriv.bk_q;
1507 *(ac) = 3; 1507 *(ac) = 3;
1508 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); 1508 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n"));
1509 break; 1509 break;
1510 case 4: 1510 case 4:
1511 case 5: 1511 case 5:
1512 ptxservq = &(psta->sta_xmitpriv.vi_q); 1512 ptxservq = &psta->sta_xmitpriv.vi_q;
1513 *(ac) = 1; 1513 *(ac) = 1;
1514 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); 1514 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n"));
1515 break; 1515 break;
1516 case 6: 1516 case 6:
1517 case 7: 1517 case 7:
1518 ptxservq = &(psta->sta_xmitpriv.vo_q); 1518 ptxservq = &psta->sta_xmitpriv.vo_q;
1519 *(ac) = 0; 1519 *(ac) = 0;
1520 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); 1520 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n"));
1521 break; 1521 break;
1522 case 0: 1522 case 0:
1523 case 3: 1523 case 3:
1524 default: 1524 default:
1525 ptxservq = &(psta->sta_xmitpriv.be_q); 1525 ptxservq = &psta->sta_xmitpriv.be_q;
1526 *(ac) = 2; 1526 *(ac) = 2;
1527 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); 1527 RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n"));
1528 break; 1528 break;
@@ -1845,21 +1845,21 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta)
1845 pstapriv->sta_dz_bitmap |= BIT(psta->aid); 1845 pstapriv->sta_dz_bitmap |= BIT(psta->aid);
1846 1846
1847 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); 1847 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending);
1848 list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); 1848 list_del_init(&pstaxmitpriv->vo_q.tx_pending);
1849 1849
1850 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); 1850 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending);
1851 list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); 1851 list_del_init(&pstaxmitpriv->vi_q.tx_pending);
1852 1852
1853 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); 1853 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending);
1854 list_del_init(&(pstaxmitpriv->be_q.tx_pending)); 1854 list_del_init(&pstaxmitpriv->be_q.tx_pending);
1855 1855
1856 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); 1856 dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending);
1857 list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); 1857 list_del_init(&pstaxmitpriv->bk_q.tx_pending);
1858 1858
1859 /* for BC/MC Frames */ 1859 /* for BC/MC Frames */
1860 pstaxmitpriv = &psta_bmc->sta_xmitpriv; 1860 pstaxmitpriv = &psta_bmc->sta_xmitpriv;
1861 dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); 1861 dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending);
1862 list_del_init(&(pstaxmitpriv->be_q.tx_pending)); 1862 list_del_init(&pstaxmitpriv->be_q.tx_pending);
1863 1863
1864 spin_unlock_bh(&pxmitpriv->lock); 1864 spin_unlock_bh(&pxmitpriv->lock);
1865} 1865}
diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c
index ec8aae76bf40..001d6267b56e 100644
--- a/drivers/staging/rtl8188eu/hal/odm.c
+++ b/drivers/staging/rtl8188eu/hal/odm.c
@@ -382,7 +382,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm)
382 } 382 }
383 383
384 /* add by Neil Chen to avoid PSD is processing */ 384 /* add by Neil Chen to avoid PSD is processing */
385 if (pDM_Odm->bDMInitialGainEnable == false) { 385 if (!pDM_Odm->bDMInitialGainEnable) {
386 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n")); 386 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n"));
387 return; 387 return;
388 } 388 }
diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
index 0555e42a3787..5fcbe5639e99 100644
--- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
@@ -109,7 +109,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm,
109 109
110 dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; 110 dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++;
111 /* (1)Hardware does not provide RSSI for CCK */ 111 /* (1)Hardware does not provide RSSI for CCK */
112 /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ 112 /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */
113 113
114 cck_highpwr = dm_odm->bCckHighPower; 114 cck_highpwr = dm_odm->bCckHighPower;
115 115
@@ -223,7 +223,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm,
223 pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); 223 pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2);
224 dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); 224 dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2);
225 } 225 }
226 /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ 226 /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */
227 rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; 227 rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110;
228 228
229 PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); 229 PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
index 3039bbe44a25..20253b5b6679 100644
--- a/drivers/staging/rtl8188eu/hal/phy.c
+++ b/drivers/staging/rtl8188eu/hal/phy.c
@@ -820,9 +820,8 @@ static void save_adda_registers(struct adapter *adapt, u32 *addareg,
820{ 820{
821 u32 i; 821 u32 i;
822 822
823 for (i = 0; i < register_num; i++) { 823 for (i = 0; i < register_num; i++)
824 backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord); 824 backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord);
825 }
826} 825}
827 826
828static void save_mac_registers(struct adapter *adapt, u32 *mac_reg, 827static void save_mac_registers(struct adapter *adapt, u32 *mac_reg,
@@ -830,9 +829,9 @@ static void save_mac_registers(struct adapter *adapt, u32 *mac_reg,
830{ 829{
831 u32 i; 830 u32 i;
832 831
833 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { 832 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
834 backup[i] = usb_read8(adapt, mac_reg[i]); 833 backup[i] = usb_read8(adapt, mac_reg[i]);
835 } 834
836 backup[i] = usb_read32(adapt, mac_reg[i]); 835 backup[i] = usb_read32(adapt, mac_reg[i]);
837} 836}
838 837
@@ -850,9 +849,9 @@ static void reload_mac_registers(struct adapter *adapt,
850{ 849{
851 u32 i; 850 u32 i;
852 851
853 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { 852 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
854 usb_write8(adapt, mac_reg[i], (u8)backup[i]); 853 usb_write8(adapt, mac_reg[i], (u8)backup[i]);
855 } 854
856 usb_write32(adapt, mac_reg[i], backup[i]); 855 usb_write32(adapt, mac_reg[i], backup[i]);
857} 856}
858 857
@@ -880,9 +879,9 @@ static void mac_setting_calibration(struct adapter *adapt, u32 *mac_reg, u32 *ba
880 879
881 usb_write8(adapt, mac_reg[i], 0x3F); 880 usb_write8(adapt, mac_reg[i], 0x3F);
882 881
883 for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { 882 for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++)
884 usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(3)))); 883 usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(3))));
885 } 884
886 usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(5)))); 885 usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(5))));
887} 886}
888 887
diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 674ac5396d00..17967c944946 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1745,6 +1745,7 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val)
1745 switch (variable) { 1745 switch (variable) {
1746 case HW_VAR_BASIC_RATE: 1746 case HW_VAR_BASIC_RATE:
1747 *((u16 *)(val)) = Adapter->HalData->BasicRateSet; 1747 *((u16 *)(val)) = Adapter->HalData->BasicRateSet;
1748 /* fall through */
1748 case HW_VAR_TXPAUSE: 1749 case HW_VAR_TXPAUSE:
1749 val[0] = usb_read8(Adapter, REG_TXPAUSE); 1750 val[0] = usb_read8(Adapter, REG_TXPAUSE);
1750 break; 1751 break;
diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h
index 550ad62e7064..4e5d7fc6de07 100644
--- a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h
+++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h
@@ -75,7 +75,8 @@ enum rf_radio_path {
75#define CHANNEL_MAX_NUMBER 14 /* 14 is the max chnl number */ 75#define CHANNEL_MAX_NUMBER 14 /* 14 is the max chnl number */
76#define MAX_CHNL_GROUP_24G 6 /* ch1~2, ch3~5, ch6~8, 76#define MAX_CHNL_GROUP_24G 6 /* ch1~2, ch3~5, ch6~8,
77 *ch9~11, ch12~13, CH 14 77 *ch9~11, ch12~13, CH 14
78 * total three groups */ 78 * total three groups
79 */
79#define CHANNEL_GROUP_MAX_88E 6 80#define CHANNEL_GROUP_MAX_88E 6
80 81
81enum wireless_mode { 82enum wireless_mode {
@@ -116,35 +117,45 @@ struct bb_reg_def {
116 /* 0x80c~0x80f [4 bytes] */ 117 /* 0x80c~0x80f [4 bytes] */
117 u32 rfHSSIPara1; /* wire parameter control1 : */ 118 u32 rfHSSIPara1; /* wire parameter control1 : */
118 /* 0x820~0x823,0x828~0x82b, 119 /* 0x820~0x823,0x828~0x82b,
119 * 0x830~0x833, 0x838~0x83b [16 bytes] */ 120 * 0x830~0x833, 0x838~0x83b [16 bytes]
121 */
120 u32 rfHSSIPara2; /* wire parameter control2 : */ 122 u32 rfHSSIPara2; /* wire parameter control2 : */
121 /* 0x824~0x827,0x82c~0x82f, 0x834~0x837, 123 /* 0x824~0x827,0x82c~0x82f, 0x834~0x837,
122 * 0x83c~0x83f [16 bytes] */ 124 * 0x83c~0x83f [16 bytes]
125 */
123 u32 rfSwitchControl; /* Tx Rx antenna control : */ 126 u32 rfSwitchControl; /* Tx Rx antenna control : */
124 /* 0x858~0x85f [16 bytes] */ 127 /* 0x858~0x85f [16 bytes] */
125 u32 rfAGCControl1; /* AGC parameter control1 : */ 128 u32 rfAGCControl1; /* AGC parameter control1 : */
126 /* 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 129 /* 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63,
127 * 0xc68~0xc6b [16 bytes] */ 130 * 0xc68~0xc6b [16 bytes]
131 */
128 u32 rfAGCControl2; /* AGC parameter control2 : */ 132 u32 rfAGCControl2; /* AGC parameter control2 : */
129 /* 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 133 /* 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67,
130 * 0xc6c~0xc6f [16 bytes] */ 134 * 0xc6c~0xc6f [16 bytes]
135 */
131 u32 rfRxIQImbalance; /* OFDM Rx IQ imbalance matrix : */ 136 u32 rfRxIQImbalance; /* OFDM Rx IQ imbalance matrix : */
132 /* 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 137 /* 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27,
133 * 0xc2c~0xc2f [16 bytes] */ 138 * 0xc2c~0xc2f [16 bytes]
139 */
134 u32 rfRxAFE; /* Rx IQ DC ofset and Rx digital filter, 140 u32 rfRxAFE; /* Rx IQ DC ofset and Rx digital filter,
135 * Rx DC notch filter : */ 141 * Rx DC notch filter :
142 */
136 /* 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 143 /* 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23,
137 * 0xc28~0xc2b [16 bytes] */ 144 * 0xc28~0xc2b [16 bytes]
145 */
138 u32 rfTxIQImbalance; /* OFDM Tx IQ imbalance matrix */ 146 u32 rfTxIQImbalance; /* OFDM Tx IQ imbalance matrix */
139 /* 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 147 /* 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93,
140 * 0xc98~0xc9b [16 bytes] */ 148 * 0xc98~0xc9b [16 bytes]
149 */
141 u32 rfTxAFE; /* Tx IQ DC Offset and Tx DFIR type */ 150 u32 rfTxAFE; /* Tx IQ DC Offset and Tx DFIR type */
142 /* 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 151 /* 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97,
143 * 0xc9c~0xc9f [16 bytes] */ 152 * 0xc9c~0xc9f [16 bytes]
153 */
144 u32 rfLSSIReadBack; /* LSSI RF readback data SI mode */ 154 u32 rfLSSIReadBack; /* LSSI RF readback data SI mode */
145 /* 0x8a0~0x8af [16 bytes] */ 155 /* 0x8a0~0x8af [16 bytes] */
146 u32 rfLSSIReadBackPi; /* LSSI RF readback data PI mode 0x8b8-8bc for 156 u32 rfLSSIReadBackPi; /* LSSI RF readback data PI mode 0x8b8-8bc for
147 * Path A and B */ 157 * Path A and B
158 */
148}; 159};
149 160
150/*------------------------------Define structure----------------------------*/ 161/*------------------------------Define structure----------------------------*/
diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h
index 04159a9f90d3..8cbba85e1587 100644
--- a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h
+++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h
@@ -136,7 +136,8 @@
136#define rCCK0_CCA 0xa08 136#define rCCK0_CCA 0xa08
137 137
138/* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, 138/* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold,
139 * RX LNA Threshold useless now. Not the same as 90 series */ 139 * RX LNA Threshold useless now. Not the same as 90 series
140 */
140#define rCCK0_RxAGC1 0xa0c 141#define rCCK0_RxAGC1 0xa0c
141#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ 142#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */
142 143
diff --git a/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h
index 21996a1173ef..c7218c49ed71 100644
--- a/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h
+++ b/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h
@@ -1,19 +1,19 @@
1#ifndef __INC_RA_H 1#ifndef __INC_RA_H
2#define __INC_RA_H 2#define __INC_RA_H
3/*++ 3/*
4Copyright (c) Realtek Semiconductor Corp. All rights reserved. 4 * Copyright (c) Realtek Semiconductor Corp. All rights reserved.
5 5 *
6Module Name: 6 * Module Name:
7 RateAdaptive.h 7 * RateAdaptive.h
8 8 *
9Abstract: 9 * Abstract:
10 Prototype of RA and related data structure. 10 * Prototype of RA and related data structure.
11 11 *
12Major Change History: 12 * Major Change History:
13 When Who What 13 * When Who What
14 ---------- --------------- ------------------------------- 14 * ---------- --------------- -------------------------------
15 2011-08-12 Page Create. 15 * 2011-08-12 Page Create.
16--*/ 16 */
17 17
18/* Rate adaptive define */ 18/* Rate adaptive define */
19#define PERENTRY 23 19#define PERENTRY 23
diff --git a/drivers/staging/rtl8188eu/include/basic_types.h b/drivers/staging/rtl8188eu/include/basic_types.h
index 69c4d49f43ab..73cc86705cf3 100644
--- a/drivers/staging/rtl8188eu/include/basic_types.h
+++ b/drivers/staging/rtl8188eu/include/basic_types.h
@@ -1,4 +1,4 @@
1/****************************************************************************** 1 /******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 * 4 *
@@ -20,14 +20,15 @@
20 20
21/* port from fw */ 21/* port from fw */
22/* TODO: Macros Below are Sync from SD7-Driver. It is necessary 22/* TODO: Macros Below are Sync from SD7-Driver. It is necessary
23 * to check correctness */ 23 * to check correctness
24 */
24 25
25/* 26/*
26 * Call endian free function when 27 * Call endian free function when
27 * 1. Read/write packet content. 28 * 1. Read/write packet content.
28 * 2. Before write integer to IO. 29 * 2. Before write integer to IO.
29 * 3. After read integer from IO. 30 * 3. After read integer from IO.
30*/ 31 */
31 32
32/* Convert little data endian to host ordering */ 33/* Convert little data endian to host ordering */
33#define EF1BYTE(_val) \ 34#define EF1BYTE(_val) \
@@ -74,9 +75,10 @@
74#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ 75#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \
75 (EF1BYTE(*((u8 *)(__pstart)))) 76 (EF1BYTE(*((u8 *)(__pstart))))
76 77
77/*Description: 78/* Description:
78Translate subfield (continuous bits in little-endian) of 4-byte 79 * Translate subfield (continuous bits in little-endian) of 4-byte
79value to host byte ordering.*/ 80 * value to host byte ordering.
81 */
80#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ 82#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
81 ( \ 83 ( \
82 (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ 84 (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \
diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h
index c3517c0903ca..2734565ce802 100644
--- a/drivers/staging/rtl8188eu/include/drv_types.h
+++ b/drivers/staging/rtl8188eu/include/drv_types.h
@@ -128,7 +128,8 @@ struct dvobj_priv {
128static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) 128static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
129{ 129{
130 /* todo: get interface type from dvobj and the return 130 /* todo: get interface type from dvobj and the return
131 * the dev accordingly */ 131 * the dev accordingly
132 */
132 return &dvobj->pusbintf->dev; 133 return &dvobj->pusbintf->dev;
133}; 134};
134 135
diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
index dfdbd0254886..da4ee1561c36 100644
--- a/drivers/staging/rtl8188eu/include/hal_intf.h
+++ b/drivers/staging/rtl8188eu/include/hal_intf.h
@@ -96,9 +96,11 @@ enum hw_variables {
96 HW_VAR_FIFO_CLEARN_UP, 96 HW_VAR_FIFO_CLEARN_UP,
97 HW_VAR_CHECK_TXBUF, 97 HW_VAR_CHECK_TXBUF,
98 HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, 98 HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation,
99 * power control for MAC only */ 99 * power control for MAC only
100 */
100 /* The valid upper nav range for the HW updating, if the true value is 101 /* The valid upper nav range for the HW updating, if the true value is
101 * larger than the upper range, the HW won't update it. */ 102 * larger than the upper range, the HW won't update it.
103 */
102 /* Unit in microsecond. 0 means disable this function. */ 104 /* Unit in microsecond. 0 means disable this function. */
103 HW_VAR_NAV_UPPER, 105 HW_VAR_NAV_UPPER,
104 HW_VAR_RPT_TIMER_SETTING, 106 HW_VAR_RPT_TIMER_SETTING,
diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h
index 284db7d00f50..9f480ccec531 100644
--- a/drivers/staging/rtl8188eu/include/ieee80211.h
+++ b/drivers/staging/rtl8188eu/include/ieee80211.h
@@ -202,9 +202,9 @@ enum NETWORK_TYPE {
202#define IsSupportedTxCCK(NetType) \ 202#define IsSupportedTxCCK(NetType) \
203 ((NetType) & (WIRELESS_11B) ? true : false) 203 ((NetType) & (WIRELESS_11B) ? true : false)
204#define IsSupportedTxOFDM(NetType) \ 204#define IsSupportedTxOFDM(NetType) \
205 ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false) 205 ((NetType) & (WIRELESS_11G | WIRELESS_11A) ? true : false)
206#define IsSupportedTxMCS(NetType) \ 206#define IsSupportedTxMCS(NetType) \
207 ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) 207 ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? true : false)
208 208
209 209
210struct ieee_param { 210struct ieee_param {
@@ -276,12 +276,13 @@ struct sta_data {
276 276
277#define IEEE80211_DATA_LEN 2304 277#define IEEE80211_DATA_LEN 2304
278/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 278/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
279 6.2.1.1.2. 279 * 6.2.1.1.2.
280 280
281 The figure in section 7.1.2 suggests a body size of up to 2312 281 * The figure in section 7.1.2 suggests a body size of up to 2312
282 bytes is allowed, which is a bit confusing, I suspect this 282 * bytes is allowed, which is a bit confusing, I suspect this
283 represents the 2304 bytes of real data, plus a possible 8 bytes of 283 * represents the 2304 bytes of real data, plus a possible 8 bytes of
284 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 284 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
285 */
285 286
286 287
287#define IEEE80211_HLEN 30 288#define IEEE80211_HLEN 30
@@ -358,11 +359,11 @@ struct ieee80211_snap_hdr {
358#define IEEE80211_DATA_HDR3_LEN 24 359#define IEEE80211_DATA_HDR3_LEN 24
359#define IEEE80211_DATA_HDR4_LEN 30 360#define IEEE80211_DATA_HDR4_LEN 30
360 361
361#define IEEE80211_CCK_MODULATION (1<<0) 362#define IEEE80211_CCK_MODULATION BIT(0)
362#define IEEE80211_OFDM_MODULATION (1<<1) 363#define IEEE80211_OFDM_MODULATION BIT(1)
363 364
364#define IEEE80211_24GHZ_BAND (1<<0) 365#define IEEE80211_24GHZ_BAND BIT(0)
365#define IEEE80211_52GHZ_BAND (1<<1) 366#define IEEE80211_52GHZ_BAND BIT(1)
366 367
367#define IEEE80211_CCK_RATE_LEN 4 368#define IEEE80211_CCK_RATE_LEN 4
368#define IEEE80211_NUM_OFDM_RATESLEN 8 369#define IEEE80211_NUM_OFDM_RATESLEN 8
@@ -383,18 +384,18 @@ struct ieee80211_snap_hdr {
383#define IEEE80211_OFDM_RATE_54MB 0x6C 384#define IEEE80211_OFDM_RATE_54MB 0x6C
384#define IEEE80211_BASIC_RATE_MASK 0x80 385#define IEEE80211_BASIC_RATE_MASK 0x80
385 386
386#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 387#define IEEE80211_CCK_RATE_1MB_MASK BIT(0)
387#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 388#define IEEE80211_CCK_RATE_2MB_MASK BIT(1)
388#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 389#define IEEE80211_CCK_RATE_5MB_MASK BIT(2)
389#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 390#define IEEE80211_CCK_RATE_11MB_MASK BIT(3)
390#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 391#define IEEE80211_OFDM_RATE_6MB_MASK BIT(4)
391#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 392#define IEEE80211_OFDM_RATE_9MB_MASK BIT(5)
392#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 393#define IEEE80211_OFDM_RATE_12MB_MASK BIT(6)
393#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 394#define IEEE80211_OFDM_RATE_18MB_MASK BIT(7)
394#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 395#define IEEE80211_OFDM_RATE_24MB_MASK BIT(8)
395#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 396#define IEEE80211_OFDM_RATE_36MB_MASK BIT(9)
396#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 397#define IEEE80211_OFDM_RATE_48MB_MASK BIT(10)
397#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 398#define IEEE80211_OFDM_RATE_54MB_MASK BIT(11)
398 399
399#define IEEE80211_CCK_RATES_MASK 0x0000000F 400#define IEEE80211_CCK_RATES_MASK 0x0000000F
400#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 401#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
@@ -423,18 +424,19 @@ struct ieee80211_snap_hdr {
423/* IEEE 802.11 requires that STA supports concurrent reception of at least 424/* IEEE 802.11 requires that STA supports concurrent reception of at least
424 * three fragmented frames. This define can be increased to support more 425 * three fragmented frames. This define can be increased to support more
425 * concurrent frames, but it should be noted that each entry can consume about 426 * concurrent frames, but it should be noted that each entry can consume about
426 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 427 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
428 */
427#define IEEE80211_FRAG_CACHE_LEN 4 429#define IEEE80211_FRAG_CACHE_LEN 4
428 430
429#define SEC_KEY_1 (1<<0) 431#define SEC_KEY_1 BIT(0)
430#define SEC_KEY_2 (1<<1) 432#define SEC_KEY_2 BIT(1)
431#define SEC_KEY_3 (1<<2) 433#define SEC_KEY_3 BIT(2)
432#define SEC_KEY_4 (1<<3) 434#define SEC_KEY_4 BIT(3)
433#define SEC_ACTIVE_KEY (1<<4) 435#define SEC_ACTIVE_KEY BIT(4)
434#define SEC_AUTH_MODE (1<<5) 436#define SEC_AUTH_MODE BIT(5)
435#define SEC_UNICAST_GROUP (1<<6) 437#define SEC_UNICAST_GROUP BIT(6)
436#define SEC_LEVEL (1<<7) 438#define SEC_LEVEL BIT(7)
437#define SEC_ENABLED (1<<8) 439#define SEC_ENABLED BIT(8)
438 440
439#define SEC_LEVEL_0 0 /* None */ 441#define SEC_LEVEL_0 0 /* None */
440#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 442#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
@@ -451,7 +453,8 @@ struct ieee80211_snap_hdr {
451/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs 453/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
452 * only use 8, and then use extended rates for the remaining supported 454 * only use 8, and then use extended rates for the remaining supported
453 * rates. Other APs, however, stick all of their supported rates on the 455 * rates. Other APs, however, stick all of their supported rates on the
454 * main rates information element... */ 456 * main rates information element...
457 */
455#define MAX_RATES_LENGTH ((u8)12) 458#define MAX_RATES_LENGTH ((u8)12)
456#define MAX_RATES_EX_LENGTH ((u8)16) 459#define MAX_RATES_EX_LENGTH ((u8)16)
457#define MAX_NETWORK_COUNT 128 460#define MAX_NETWORK_COUNT 128
@@ -467,17 +470,17 @@ struct ieee80211_snap_hdr {
467#define MAX_P2P_IE_LEN (256) 470#define MAX_P2P_IE_LEN (256)
468#define MAX_WFD_IE_LEN (128) 471#define MAX_WFD_IE_LEN (128)
469 472
470#define NETWORK_EMPTY_ESSID (1<<0) 473#define NETWORK_EMPTY_ESSID BIT(0)
471#define NETWORK_HAS_OFDM (1<<1) 474#define NETWORK_HAS_OFDM BIT(1)
472#define NETWORK_HAS_CCK (1<<2) 475#define NETWORK_HAS_CCK BIT(2)
473 476
474#define IW_ESSID_MAX_SIZE 32 477#define IW_ESSID_MAX_SIZE 32
475/* 478/*
476join_res: 479 * join_res:
477-1: authentication fail 480 * -1: authentication fail
478-2: association fail 481 * -2: association fail
479> 0: TID 482 * > 0: TID
480*/ 483 */
481 484
482enum ieee80211_state { 485enum ieee80211_state {
483 /* the card is not linked at all */ 486 /* the card is not linked at all */
@@ -531,15 +534,15 @@ static inline int is_broadcast_mac_addr(const u8 *addr)
531 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff); 534 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff);
532} 535}
533 536
534#define CFG_IEEE80211_RESERVE_FCS (1<<0) 537#define CFG_IEEE80211_RESERVE_FCS BIT(0)
535#define CFG_IEEE80211_COMPUTE_FCS (1<<1) 538#define CFG_IEEE80211_COMPUTE_FCS BIT(1)
536 539
537#define MAXTID 16 540#define MAXTID 16
538 541
539#define IEEE_A (1<<0) 542#define IEEE_A BIT(0)
540#define IEEE_B (1<<1) 543#define IEEE_B BIT(1)
541#define IEEE_G (1<<2) 544#define IEEE_G BIT(2)
542#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 545#define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
543 546
544/* Action category code */ 547/* Action category code */
545enum rtw_ieee80211_category { 548enum rtw_ieee80211_category {
@@ -615,7 +618,8 @@ enum rtw_ieee80211_back_parties {
615}; 618};
616 619
617#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) 620#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
618 * 00:50:F2 */ 621 * 00:50:F2
622 */
619#define WME_OUI_TYPE 2 623#define WME_OUI_TYPE 2
620#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 624#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
621#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 625#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
@@ -655,12 +659,12 @@ enum rtw_ieee80211_back_parties {
655 * is not permitted. 659 * is not permitted.
656 */ 660 */
657enum rtw_ieee80211_channel_flags { 661enum rtw_ieee80211_channel_flags {
658 RTW_IEEE80211_CHAN_DISABLED = 1<<0, 662 RTW_IEEE80211_CHAN_DISABLED = BIT(0),
659 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, 663 RTW_IEEE80211_CHAN_PASSIVE_SCAN = BIT(1),
660 RTW_IEEE80211_CHAN_NO_IBSS = 1<<2, 664 RTW_IEEE80211_CHAN_NO_IBSS = BIT(2),
661 RTW_IEEE80211_CHAN_RADAR = 1<<3, 665 RTW_IEEE80211_CHAN_RADAR = BIT(3),
662 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4, 666 RTW_IEEE80211_CHAN_NO_HT40PLUS = BIT(4),
663 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5, 667 RTW_IEEE80211_CHAN_NO_HT40MINUS = BIT(5),
664}; 668};
665 669
666#define RTW_IEEE80211_CHAN_NO_HT40 \ 670#define RTW_IEEE80211_CHAN_NO_HT40 \
diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h
index 4fb3bb07ceaa..95426b7c6dbf 100644
--- a/drivers/staging/rtl8188eu/include/odm.h
+++ b/drivers/staging/rtl8188eu/include/odm.h
@@ -36,7 +36,8 @@
36/* Mainly, it just retains last scan result and scan again. */ 36/* Mainly, it just retains last scan result and scan again. */
37/* After that, it compares the scan result to see which one gets better 37/* After that, it compares the scan result to see which one gets better
38 * RSSI. It selects antenna with better receiving power and returns better 38 * RSSI. It selects antenna with better receiving power and returns better
39 * scan result. */ 39 * scan result.
40 */
40 41
41#define TP_MODE 0 42#define TP_MODE 0
42#define RSSI_MODE 1 43#define RSSI_MODE 1
@@ -173,10 +174,12 @@ struct rx_hpc {
173 174
174/* This indicates two different steps. */ 175/* This indicates two different steps. */
175/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to 176/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to
176 * the signal on the air. */ 177 * the signal on the air.
178 */
177/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in 179/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in
178 * SWAW_STEP_PEAK with original RSSI to determine if it is necessary to 180 * SWAW_STEP_PEAK with original RSSI to determine if it is necessary to
179 * switch antenna. */ 181 * switch antenna.
182 */
180 183
181#define SWAW_STEP_PEAK 0 184#define SWAW_STEP_PEAK 0
182#define SWAW_STEP_DETERMINE 1 185#define SWAW_STEP_DETERMINE 1
@@ -265,7 +268,8 @@ struct odm_phy_status_info {
265 s8 RxPower; /* in dBm Translate from PWdB */ 268 s8 RxPower; /* in dBm Translate from PWdB */
266 s8 RecvSignalPower;/* Real power in dBm for this packet, no 269 s8 RecvSignalPower;/* Real power in dBm for this packet, no
267 * beautification and aggregation. Keep this raw 270 * beautification and aggregation. Keep this raw
268 * info to be used for the other procedures. */ 271 * info to be used for the other procedures.
272 */
269 u8 BTRxRSSIPercentage; 273 u8 BTRxRSSIPercentage;
270 u8 SignalStrength; /* in 0-100 index. */ 274 u8 SignalStrength; /* in 0-100 index. */
271 u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ 275 u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */
@@ -478,7 +482,7 @@ enum odm_operation_mode {
478 482
479/* ODM_CMNINFO_WM_MODE */ 483/* ODM_CMNINFO_WM_MODE */
480enum odm_wireless_mode { 484enum odm_wireless_mode {
481 ODM_WM_UNKNOW = 0x0, 485 ODM_WM_UNKNOWN = 0x0,
482 ODM_WM_B = BIT(0), 486 ODM_WM_B = BIT(0),
483 ODM_WM_G = BIT(1), 487 ODM_WM_G = BIT(1),
484 ODM_WM_A = BIT(2), 488 ODM_WM_A = BIT(2),
@@ -509,7 +513,7 @@ enum odm_security {
509 ODM_SEC_RESERVE = 3, 513 ODM_SEC_RESERVE = 3,
510 ODM_SEC_AESCCMP = 4, 514 ODM_SEC_AESCCMP = 4,
511 ODM_SEC_WEP104 = 5, 515 ODM_SEC_WEP104 = 5,
512 ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ 516 ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */
513 ODM_SEC_SMS4 = 7, 517 ODM_SEC_SMS4 = 7,
514}; 518};
515 519
@@ -567,7 +571,8 @@ struct odm_ra_info {
567 u8 PTPreRssi; /* if RSSI change 5% do PT */ 571 u8 PTPreRssi; /* if RSSI change 5% do PT */
568 u8 PTModeSS; /* decide whitch rate should do PT */ 572 u8 PTModeSS; /* decide whitch rate should do PT */
569 u8 RAstage; /* StageRA, decide how many times RA will be done 573 u8 RAstage; /* StageRA, decide how many times RA will be done
570 * between PT */ 574 * between PT
575 */
571 u8 PTSmoothFactor; 576 u8 PTSmoothFactor;
572}; 577};
573 578
@@ -587,12 +592,14 @@ struct odm_rf_cal {
587 u8 TXPowercount; 592 u8 TXPowercount;
588 bool bTXPowerTracking; 593 bool bTXPowerTracking;
589 u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking 594 u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking
590 * as default */ 595 * as default
596 */
591 u8 TM_Trigger; 597 u8 TM_Trigger;
592 u8 InternalPA5G[2]; /* pathA / pathB */ 598 u8 InternalPA5G[2]; /* pathA / pathB */
593 599
594 u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0, 600 u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0,
595 * and 1 for RFIC1 */ 601 * and 1 for RFIC1
602 */
596 u8 ThermalValue; 603 u8 ThermalValue;
597 u8 ThermalValue_LCK; 604 u8 ThermalValue_LCK;
598 u8 ThermalValue_IQK; 605 u8 ThermalValue_IQK;
@@ -688,7 +695,7 @@ enum ant_div_type {
688 695
689/* Copy from SD4 defined structure. We use to support PHY DM integration. */ 696/* Copy from SD4 defined structure. We use to support PHY DM integration. */
690struct odm_dm_struct { 697struct odm_dm_struct {
691 /* Add for different team use temporarily */ 698 /* Add for different team use temporarily */
692 struct adapter *Adapter; /* For CE/NIC team */ 699 struct adapter *Adapter; /* For CE/NIC team */
693 struct rtl8192cd_priv *priv; /* For AP/ADSL team */ 700 struct rtl8192cd_priv *priv; /* For AP/ADSL team */
694 /* WHen you use above pointers, they must be initialized. */ 701 /* WHen you use above pointers, they must be initialized. */
@@ -714,7 +721,8 @@ struct odm_dm_struct {
714 /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ 721 /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */
715 u8 SupportInterface; 722 u8 SupportInterface;
716 /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any 723 /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any
717 * other type = 1/2/3/... */ 724 * other type = 1/2/3/...
725 */
718 u32 SupportICType; 726 u32 SupportICType;
719 /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */ 727 /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */
720 u8 CutVersion; 728 u8 CutVersion;
@@ -788,19 +796,21 @@ struct odm_dm_struct {
788 bool bBtHsOperation; /* BT HS mode is under progress */ 796 bool bBtHsOperation; /* BT HS mode is under progress */
789 u8 btHsDigVal; /* use BT rssi to decide the DIG value */ 797 u8 btHsDigVal; /* use BT rssi to decide the DIG value */
790 bool bBtDisableEdcaTurbo;/* Under some condition, don't enable the 798 bool bBtDisableEdcaTurbo;/* Under some condition, don't enable the
791 * EDCA Turbo */ 799 * EDCA Turbo
800 */
792 bool bBtBusy; /* BT is busy. */ 801 bool bBtBusy; /* BT is busy. */
793/* CALL BY VALUE------------- */ 802/* CALL BY VALUE------------- */
794 803
795 /* 2 Define STA info. */ 804 /* 2 Define STA info. */
796 /* _ODM_STA_INFO */ 805 /* _ODM_STA_INFO */
797 /* For MP, we need to reduce one array pointer for default port.?? */ 806 /* For MP, we need to reduce one array pointer for default port.??*/
798 struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; 807 struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM];
799 808
800 u16 CurrminRptTime; 809 u16 CurrminRptTime;
801 struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as 810 struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as
802 * array index. STA MacID=0, 811 * array index. STA MacID=0,
803 * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1} */ 812 * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1}
813 */
804 /* */ 814 /* */
805 /* 2012/02/14 MH Add to share 88E ra with other SW team. */ 815 /* 2012/02/14 MH Add to share 88E ra with other SW team. */
806 /* We need to colelct all support abilit to a proper area. */ 816 /* We need to colelct all support abilit to a proper area. */
@@ -1029,9 +1039,11 @@ extern u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8];
1029/* 20100514 Joseph: Add definition for antenna switching test after link. */ 1039/* 20100514 Joseph: Add definition for antenna switching test after link. */
1030/* This indicates two different the steps. */ 1040/* This indicates two different the steps. */
1031/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the 1041/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the
1032 * signal on the air. */ 1042 * signal on the air.
1043 */
1033/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in 1044/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in
1034 * SWAW_STEP_PEAK */ 1045 * SWAW_STEP_PEAK
1046 */
1035/* with original RSSI to determine if it is necessary to switch antenna. */ 1047/* with original RSSI to determine if it is necessary to switch antenna. */
1036#define SWAW_STEP_PEAK 0 1048#define SWAW_STEP_PEAK 0
1037#define SWAW_STEP_DETERMINE 1 1049#define SWAW_STEP_DETERMINE 1
diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h
index 97d3d8504184..f1fb3d511a45 100644
--- a/drivers/staging/rtl8188eu/include/osdep_intf.h
+++ b/drivers/staging/rtl8188eu/include/osdep_intf.h
@@ -26,7 +26,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter);
26u8 rtw_free_drv_sw(struct adapter *padapter); 26u8 rtw_free_drv_sw(struct adapter *padapter);
27u8 rtw_reset_drv_sw(struct adapter *padapter); 27u8 rtw_reset_drv_sw(struct adapter *padapter);
28 28
29void rtw_stop_drv_threads (struct adapter *padapter); 29void rtw_stop_drv_threads(struct adapter *padapter);
30void rtw_cancel_all_timer(struct adapter *padapter); 30void rtw_cancel_all_timer(struct adapter *padapter);
31 31
32int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 32int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h
index addf90b60ce9..bd77a50c0d41 100644
--- a/drivers/staging/rtl8188eu/include/pwrseq.h
+++ b/drivers/staging/rtl8188eu/include/pwrseq.h
@@ -20,28 +20,28 @@
20#include "pwrseqcmd.h" 20#include "pwrseqcmd.h"
21 21
22/* 22/*
23 Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd 23 * Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd
24 There are 6 HW Power States: 24 * There are 6 HW Power States:
25 0: POFF--Power Off 25 * 0: POFF--Power Off
26 1: PDN--Power Down 26 * 1: PDN--Power Down
27 2: CARDEMU--Card Emulation 27 * 2: CARDEMU--Card Emulation
28 3: ACT--Active Mode 28 * 3: ACT--Active Mode
29 4: LPS--Low Power State 29 * 4: LPS--Low Power State
30 5: SUS--Suspend 30 * 5: SUS--Suspend
31 31 *
32 The transition from different states are defined below 32 * The transition from different states are defined below
33 TRANS_CARDEMU_TO_ACT 33 * TRANS_CARDEMU_TO_ACT
34 TRANS_ACT_TO_CARDEMU 34 * TRANS_ACT_TO_CARDEMU
35 TRANS_CARDEMU_TO_SUS 35 * TRANS_CARDEMU_TO_SUS
36 TRANS_SUS_TO_CARDEMU 36 * TRANS_SUS_TO_CARDEMU
37 TRANS_CARDEMU_TO_PDN 37 * TRANS_CARDEMU_TO_PDN
38 TRANS_ACT_TO_LPS 38 * TRANS_ACT_TO_LPS
39 TRANS_LPS_TO_ACT 39 * TRANS_LPS_TO_ACT
40 40 *
41 TRANS_END 41 * TRANS_END
42 42 *
43 PWR SEQ Version: rtl8188E_PwrSeq_V09.h 43 * PWR SEQ Version: rtl8188E_PwrSeq_V09.h
44*/ 44 */
45#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 45#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10
46#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 46#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10
47#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10 47#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index 9330361da4ad..b4b5e217105a 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -42,7 +42,7 @@
42#define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt" 42#define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt"
43#define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt" 43#define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt"
44 44
45/* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */ 45/* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */
46#define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow 46#define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow
47#define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow 47#define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow
48#define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow 48#define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow
@@ -81,7 +81,8 @@ enum usb_rx_agg_mode {
81 81
82#define MAX_RX_DMA_BUFFER_SIZE_88E \ 82#define MAX_RX_DMA_BUFFER_SIZE_88E \
83 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8), 83 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8),
84 * WOLPattern(16*24)) */ 84 * WOLPattern(16*24))
85 */
85 86
86#define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */ 87#define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */
87 88
@@ -94,11 +95,13 @@ enum usb_rx_agg_mode {
94#define TX_SELE_NQ BIT(2) /* Normal Queue */ 95#define TX_SELE_NQ BIT(2) /* Normal Queue */
95 96
96/* Note: We will divide number of page equally for each queue other 97/* Note: We will divide number of page equally for each queue other
97 * than public queue! */ 98 * than public queue!
99 */
98/* 22k = 22528 bytes = 176 pages (@page = 128 bytes) */ 100/* 22k = 22528 bytes = 176 pages (@page = 128 bytes) */
99/* must reserved about 7 pages for LPS => 176-7 = 169 (0xA9) */ 101/* must reserved about 7 pages for LPS => 176-7 = 169 (0xA9) */
100/* 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS 102/* 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS
101 * null-data */ 103 * null-data
104 */
102 105
103#define TX_TOTAL_PAGE_NUMBER_88E 0xA9/* 169 (21632=> 21k) */ 106#define TX_TOTAL_PAGE_NUMBER_88E 0xA9/* 169 (21632=> 21k) */
104 107
@@ -110,7 +113,7 @@ enum usb_rx_agg_mode {
110#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \ 113#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \
111 (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ 114 (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */
112 115
113/* Chip specific */ 116/* Chip specific */
114#define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3) 117#define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3)
115#define CHIP_BONDING_92C_1T2R 0x1 118#define CHIP_BONDING_92C_1T2R 0x1
116#define CHIP_BONDING_88C_USB_MCARD 0x2 119#define CHIP_BONDING_88C_USB_MCARD 0x2
@@ -118,7 +121,7 @@ enum usb_rx_agg_mode {
118#include "HalVerDef.h" 121#include "HalVerDef.h"
119#include "hal_com.h" 122#include "hal_com.h"
120 123
121/* Channel Plan */ 124/* Channel Plan */
122enum ChannelPlan { 125enum ChannelPlan {
123 CHPL_FCC = 0, 126 CHPL_FCC = 0,
124 CHPL_IC = 1, 127 CHPL_IC = 1,
@@ -168,7 +171,8 @@ struct txpowerinfo24g {
168#define AVAILABLE_EFUSE_ADDR_88E(addr) \ 171#define AVAILABLE_EFUSE_ADDR_88E(addr) \
169 (addr < EFUSE_REAL_CONTENT_LEN_88E) 172 (addr < EFUSE_REAL_CONTENT_LEN_88E)
170/* To prevent out of boundary programming case, leave 1byte and program 173/* To prevent out of boundary programming case, leave 1byte and program
171 * full section */ 174 * full section
175 */
172/* 9bytes + 1byt + 5bytes and pre 1byte. */ 176/* 9bytes + 1byt + 5bytes and pre 1byte. */
173/* For worst case: */ 177/* For worst case: */
174/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */ 178/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */
@@ -176,7 +180,7 @@ struct txpowerinfo24g {
176#define EFUSE_OOB_PROTECT_BYTES_88E 18 180#define EFUSE_OOB_PROTECT_BYTES_88E 18
177#define EFUSE_PROTECT_BYTES_BANK_88E 16 181#define EFUSE_PROTECT_BYTES_BANK_88E 16
178 182
179/* EFUSE for BT definition */ 183/* EFUSE for BT definition */
180#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ 184#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */
181#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ 185#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */
182#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ 186#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */
@@ -293,7 +297,8 @@ struct hal_data_8188e {
293 u8 bDumpRxPkt;/* for debug */ 297 u8 bDumpRxPkt;/* for debug */
294 u8 bDumpTxPkt;/* for debug */ 298 u8 bDumpTxPkt;/* for debug */
295 u8 FwRsvdPageStartOffset; /* Reserve page start offset except 299 u8 FwRsvdPageStartOffset; /* Reserve page start offset except
296 * beacon in TxQ. */ 300 * beacon in TxQ.
301 */
297 302
298 /* 2010/08/09 MH Add CU power down mode. */ 303 /* 2010/08/09 MH Add CU power down mode. */
299 bool pwrdown; 304 bool pwrdown;
@@ -307,7 +312,8 @@ struct hal_data_8188e {
307 u16 EfuseUsedBytes; 312 u16 EfuseUsedBytes;
308 313
309 /* Auto FSM to Turn On, include clock, isolation, power control 314 /* Auto FSM to Turn On, include clock, isolation, power control
310 * for MAC only */ 315 * for MAC only
316 */
311 u8 bMacPwrCtrlOn; 317 u8 bMacPwrCtrlOn;
312 318
313 u32 UsbBulkOutSize; 319 u32 UsbBulkOutSize;
@@ -324,7 +330,8 @@ struct hal_data_8188e {
324 enum usb_rx_agg_mode UsbRxAggMode; 330 enum usb_rx_agg_mode UsbRxAggMode;
325 u8 UsbRxAggBlockCount; /* USB Block count. Block size is 331 u8 UsbRxAggBlockCount; /* USB Block count. Block size is
326 * 512-byte in high speed and 64-byte 332 * 512-byte in high speed and 64-byte
327 * in full speed */ 333 * in full speed
334 */
328 u8 UsbRxAggBlockTimeout; 335 u8 UsbRxAggBlockTimeout;
329 u8 UsbRxAggPageCount; /* 8192C DMA page count */ 336 u8 UsbRxAggPageCount; /* 8192C DMA page count */
330 u8 UsbRxAggPageTimeout; 337 u8 UsbRxAggPageTimeout;
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h
index c93e19d1c50f..71e2b817e20a 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h
@@ -15,7 +15,7 @@
15#ifndef __RTL8188E_SPEC_H__ 15#ifndef __RTL8188E_SPEC_H__
16#define __RTL8188E_SPEC_H__ 16#define __RTL8188E_SPEC_H__
17 17
18/* 8192C Regsiter offset definition */ 18/* 8192C Register offset definition */
19 19
20#define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */ 20#define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */
21#define HAL_92C_NAV_UPPER_UNIT 128 /* micro-second */ 21#define HAL_92C_NAV_UPPER_UNIT 128 /* micro-second */
@@ -62,12 +62,15 @@
62#define REG_HSIMR 0x0058 62#define REG_HSIMR 0x0058
63#define REG_HSISR 0x005c 63#define REG_HSISR 0x005c
64#define REG_GPIO_PIN_CTRL_2 0x0060 /* RTL8723 WIFI/BT/GPS 64#define REG_GPIO_PIN_CTRL_2 0x0060 /* RTL8723 WIFI/BT/GPS
65 * Multi-Function GPIO Pin Control. */ 65 * Multi-Function GPIO Pin Control.
66 */
66#define REG_GPIO_IO_SEL_2 0x0062 /* RTL8723 WIFI/BT/GPS 67#define REG_GPIO_IO_SEL_2 0x0062 /* RTL8723 WIFI/BT/GPS
67 * Multi-Function GPIO Select. */ 68 * Multi-Function GPIO Select.
69 */
68#define REG_BB_PAD_CTRL 0x0064 70#define REG_BB_PAD_CTRL 0x0064
69#define REG_MULTI_FUNC_CTRL 0x0068 /* RTL8723 WIFI/BT/GPS 71#define REG_MULTI_FUNC_CTRL 0x0068 /* RTL8723 WIFI/BT/GPS
70 * Multi-Function control source. */ 72 * Multi-Function control source.
73 */
71#define REG_GPIO_OUTPUT 0x006c 74#define REG_GPIO_OUTPUT 0x006c
72#define REG_AFE_XTAL_CTRL_EXT 0x0078 /* RTL8188E */ 75#define REG_AFE_XTAL_CTRL_EXT 0x0078 /* RTL8188E */
73#define REG_XCK_OUT_CTRL 0x007c /* RTL8188E */ 76#define REG_XCK_OUT_CTRL 0x007c /* RTL8188E */
@@ -87,7 +90,8 @@
87#define REG_HIMRE_88E 0x00B8 90#define REG_HIMRE_88E 0x00B8
88#define REG_HISRE_88E 0x00BC 91#define REG_HISRE_88E 0x00BC
89#define REG_EFUSE_ACCESS 0x00CF /* Efuse access protection 92#define REG_EFUSE_ACCESS 0x00CF /* Efuse access protection
90 * for RTL8723 */ 93 * for RTL8723
94 */
91#define REG_BIST_SCAN 0x00D0 95#define REG_BIST_SCAN 0x00D0
92#define REG_BIST_RPT 0x00D4 96#define REG_BIST_RPT 0x00D4
93#define REG_BIST_ROM_RPT 0x00D8 97#define REG_BIST_ROM_RPT 0x00D8
@@ -119,9 +123,9 @@
119#define REG_FWISR 0x0134 123#define REG_FWISR 0x0134
120#define REG_PKTBUF_DBG_CTRL 0x0140 124#define REG_PKTBUF_DBG_CTRL 0x0140
121#define REG_PKTBUF_DBG_ADDR (REG_PKTBUF_DBG_CTRL) 125#define REG_PKTBUF_DBG_ADDR (REG_PKTBUF_DBG_CTRL)
122#define REG_RXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+2) 126#define REG_RXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL + 2)
123#define REG_TXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+3) 127#define REG_TXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL + 3)
124#define REG_RXPKTBUF_CTRL (REG_PKTBUF_DBG_CTRL+2) 128#define REG_RXPKTBUF_CTRL (REG_PKTBUF_DBG_CTRL + 2)
125#define REG_PKTBUF_DBG_DATA_L 0x0144 129#define REG_PKTBUF_DBG_DATA_L 0x0144
126#define REG_PKTBUF_DBG_DATA_H 0x0148 130#define REG_PKTBUF_DBG_DATA_H 0x0148
127 131
@@ -252,21 +256,24 @@
252#define REG_TXPAUSE 0x0522 256#define REG_TXPAUSE 0x0522
253#define REG_DIS_TXREQ_CLR 0x0523 257#define REG_DIS_TXREQ_CLR 0x0523
254#define REG_RD_CTRL 0x0524 258#define REG_RD_CTRL 0x0524
255/* Format for offset 540h-542h: */ 259/* Format for offset 540h-542h:
256/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting 260 * [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting
257 * beacon content before TBTT. */ 261 * beacon content before TBTT.
258/* [7:4]: Reserved. */ 262 *
259/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding 263 * [7:4]: Reserved.
260 * to send the beacon packet. */ 264 * [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding
261/* [23:20]: Reserved */ 265 * to send the beacon packet.
262/* Description: */ 266 *
263/* | */ 267 * [23:20]: Reserved
264/* |<--Setup--|--Hold------------>| */ 268 * Description:
265/* --------------|---------------------- */ 269 * |
266/* | */ 270 * |<--Setup--|--Hold------------>|
267/* TBTT */ 271 * --------------|----------------------
268/* Note: We cannot update beacon content to HW or send any AC packets during 272 * |
269 * the time between Setup and Hold. */ 273 * TBTT
274 * Note: We cannot update beacon content to HW or send any AC packets during
275 * the time between Setup and Hold.
276 */
270#define REG_TBTT_PROHIBIT 0x0540 277#define REG_TBTT_PROHIBIT 0x0540
271#define REG_RD_NAV_NXT 0x0544 278#define REG_RD_NAV_NXT 0x0544
272#define REG_NAV_PROT_LEN 0x0546 279#define REG_NAV_PROT_LEN 0x0546
@@ -340,13 +347,14 @@
340#define RXERR_RPT_RST BIT(27) 347#define RXERR_RPT_RST BIT(27)
341#define _RXERR_RPT_SEL(type) ((type) << 28) 348#define _RXERR_RPT_SEL(type) ((type) << 28)
342 349
343/* Note: */ 350/* Note:
344/* The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. 351 * The NAV upper value is very important to WiFi 11n 5.2.3 NAV test.
345 * The default value is always too small, but the WiFi TestPlan test 352 * The default value is always too small, but the WiFi TestPlan test
346 * by 25,000 microseconds of NAV through sending CTS in the air. 353 * by 25,000 microseconds of NAV through sending CTS in the air.
347 * We must update this value greater than 25,000 microseconds to pass 354 * We must update this value greater than 25,000 microseconds to pass
348 * the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and 355 * the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and
349 * the offset should be 0x0652. */ 356 * the offset should be 0x0652.
357 */
350#define REG_NAV_UPPER 0x0652 /* unit of 128 */ 358#define REG_NAV_UPPER 0x0652 /* unit of 128 */
351 359
352/* WMA, BA, CCX */ 360/* WMA, BA, CCX */
@@ -453,11 +461,12 @@
453/* GPIO pins input value */ 461/* GPIO pins input value */
454#define GPIO_IN REG_GPIO_PIN_CTRL 462#define GPIO_IN REG_GPIO_PIN_CTRL
455/* GPIO pins output value */ 463/* GPIO pins output value */
456#define GPIO_OUT (REG_GPIO_PIN_CTRL+1) 464#define GPIO_OUT (REG_GPIO_PIN_CTRL + 1)
457/* GPIO pins output enable when a bit is set to "1"; otherwise, 465/* GPIO pins output enable when a bit is set to "1"; otherwise,
458 * input is configured. */ 466 * input is configured.
459#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL+2) 467 */
460#define GPIO_MOD (REG_GPIO_PIN_CTRL+3) 468#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL + 2)
469#define GPIO_MOD (REG_GPIO_PIN_CTRL + 3)
461 470
462/* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */ 471/* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */
463#define HSIMR_GPIO12_0_INT_EN BIT(0) 472#define HSIMR_GPIO12_0_INT_EN BIT(0)
@@ -475,13 +484,13 @@
475 484
476/* 8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */ 485/* 8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */
477/* 486/*
478Network Type 487 * Network Type
47900: No link 488 * 00: No link
48001: Link in ad hoc network 489 * 01: Link in ad hoc network
48110: Link in infrastructure network 490 * 10: Link in infrastructure network
48211: AP mode 491 * 11: AP mode
483Default: 00b. 492 * Default: 00b.
484*/ 493 */
485#define MSR_NOLINK 0x00 494#define MSR_NOLINK 0x00
486#define MSR_ADHOC 0x01 495#define MSR_ADHOC 0x01
487#define MSR_INFRA 0x02 496#define MSR_INFRA 0x02
@@ -635,26 +644,27 @@ So the following defines for 92C is not entire!!!!!!
635===================================================================== 644=====================================================================
636=====================================================================*/ 645=====================================================================*/
637/* 646/*
638Based on Datasheet V33---090401 647 * Based on Datasheet V33---090401
639Register Summary 648 * Register Summary
640Current IOREG MAP 649 * Current IOREG MAP
6410x0000h ~ 0x00FFh System Configuration (256 Bytes) 650 * 0x0000h ~ 0x00FFh System Configuration (256 Bytes)
6420x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes) 651 * 0x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes)
6430x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes) 652 * 0x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes)
6440x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes) 653 * 0x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes)
6450x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes) 654 * 0x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes)
6460x0400h ~ 0x04FFh Protocol Configuration (256 Bytes) 655 * 0x0400h ~ 0x04FFh Protocol Configuration (256 Bytes)
6470x0500h ~ 0x05FFh EDCA Configuration (256 Bytes) 656 * 0x0500h ~ 0x05FFh EDCA Configuration (256 Bytes)
6480x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) 657 * 0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes)
6490x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) 658 * 0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes)
650*/ 659 */
651/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */ 660/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */
652/* Note: */ 661/* Note:
653/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet 662 * The bits of stopping AC(VO/VI/BE/BK) queue in datasheet
654 * RTL8192S/RTL8192C are wrong, */ 663 * RTL8192S/RTL8192C are wrong,
655/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, 664 * the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2,
656 * and BK - Bit3. */ 665 * and BK - Bit3.
657/* 8723 and 88E may be not correct either in the earlier version. */ 666 * 8723 and 88E may be not correct either in the earlier version.
667 */
658#define StopBecon BIT(6) 668#define StopBecon BIT(6)
659#define StopHigh BIT(5) 669#define StopHigh BIT(5)
660#define StopMgt BIT(4) 670#define StopMgt BIT(4)
@@ -680,7 +690,8 @@ Current IOREG MAP
680#define RCR_AICV BIT(9) /* Accept ICV error packet */ 690#define RCR_AICV BIT(9) /* Accept ICV error packet */
681#define RCR_ACRC32 BIT(8) /* Accept CRC32 error packet */ 691#define RCR_ACRC32 BIT(8) /* Accept CRC32 error packet */
682#define RCR_CBSSID_BCN BIT(7) /* Accept BSSID match packet 692#define RCR_CBSSID_BCN BIT(7) /* Accept BSSID match packet
683 * (Rx beacon, probe rsp) */ 693 * (Rx beacon, probe rsp)
694 */
684#define RCR_CBSSID_DATA BIT(6) /* Accept BSSID match (Data)*/ 695#define RCR_CBSSID_DATA BIT(6) /* Accept BSSID match (Data)*/
685#define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */ 696#define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */
686#define RCR_APWRMGT BIT(5) /* Accept power management pkt*/ 697#define RCR_APWRMGT BIT(5) /* Accept power management pkt*/
@@ -701,7 +712,7 @@ Current IOREG MAP
701 712
702#define REG_USB_HRPWM 0xFE58 713#define REG_USB_HRPWM 0xFE58
703#define REG_USB_HCPWM 0xFE57 714#define REG_USB_HCPWM 0xFE57
704/* 8192C Regsiter Bit and Content definition */ 715/* 8192C Register Bit and Content definition */
705/* 0x0000h ~ 0x00FFh System Configuration */ 716/* 0x0000h ~ 0x00FFh System Configuration */
706 717
707/* 2 SYS_ISO_CTRL */ 718/* 2 SYS_ISO_CTRL */
@@ -798,7 +809,7 @@ Current IOREG MAP
798/* 2 EFUSE_TEST (For RTL8723 partially) */ 809/* 2 EFUSE_TEST (For RTL8723 partially) */
799#define EF_TRPT BIT(7) 810#define EF_TRPT BIT(7)
800/* 00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */ 811/* 00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */
801#define EF_CELL_SEL (BIT(8)|BIT(9)) 812#define EF_CELL_SEL (BIT(8) | BIT(9))
802#define LDOE25_EN BIT(31) 813#define LDOE25_EN BIT(31)
803#define EFUSE_SEL(x) (((x) & 0x3) << 8) 814#define EFUSE_SEL(x) (((x) & 0x3) << 8)
804#define EFUSE_SEL_MASK 0x300 815#define EFUSE_SEL_MASK 0x300
@@ -835,7 +846,7 @@ Current IOREG MAP
835#define BD_MAC2 BIT(9) 846#define BD_MAC2 BIT(9)
836#define BD_MAC1 BIT(10) 847#define BD_MAC1 BIT(10)
837#define IC_MACPHY_MODE BIT(11) 848#define IC_MACPHY_MODE BIT(11)
838#define CHIP_VER (BIT(12)|BIT(13)|BIT(14)|BIT(15)) 849#define CHIP_VER (BIT(12) | BIT(13) | BIT(14) | BIT(15))
839#define BT_FUNC BIT(16) 850#define BT_FUNC BIT(16)
840#define VENDOR_ID BIT(19) 851#define VENDOR_ID BIT(19)
841#define PAD_HWPD_IDN BIT(22) 852#define PAD_HWPD_IDN BIT(22)
@@ -849,9 +860,9 @@ Current IOREG MAP
849#define CHIP_VER_RTL_SHIFT 12 860#define CHIP_VER_RTL_SHIFT 12
850 861
851/* 2REG_GPIO_OUTSTS (For RTL8723 only) */ 862/* 2REG_GPIO_OUTSTS (For RTL8723 only) */
852#define EFS_HCI_SEL (BIT(0)|BIT(1)) 863#define EFS_HCI_SEL (BIT(0) | BIT(1))
853#define PAD_HCI_SEL (BIT(2)|BIT(3)) 864#define PAD_HCI_SEL (BIT(2) | BIT(3))
854#define HCI_SEL (BIT(4)|BIT(5)) 865#define HCI_SEL (BIT(4) | BIT(5))
855#define PKG_SEL_HCI BIT(6) 866#define PKG_SEL_HCI BIT(6)
856#define FEN_GPS BIT(7) 867#define FEN_GPS BIT(7)
857#define FEN_BT BIT(8) 868#define FEN_BT BIT(8)
@@ -868,7 +879,7 @@ Current IOREG MAP
868#define UPHY_SUSB BIT(21) 879#define UPHY_SUSB BIT(21)
869#define PCI_SUSEN BIT(22) 880#define PCI_SUSEN BIT(22)
870#define USB_SUSEN BIT(23) 881#define USB_SUSEN BIT(23)
871#define RF_RL_ID (BIT(31)|BIT(30)|BIT(29)|BIT(28)) 882#define RF_RL_ID (BIT(31) | BIT(30) | BIT(29) | BIT(28))
872 883
873/* 2SYS_CFG */ 884/* 2SYS_CFG */
874#define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */ 885#define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */
@@ -931,12 +942,12 @@ Current IOREG MAP
931#define HQSEL_HIQ BIT(5) 942#define HQSEL_HIQ BIT(5)
932 943
933/* For normal driver, 0x10C */ 944/* For normal driver, 0x10C */
934#define _TXDMA_HIQ_MAP(x) (((x)&0x3) << 14) 945#define _TXDMA_HIQ_MAP(x) (((x) & 0x3) << 14)
935#define _TXDMA_MGQ_MAP(x) (((x)&0x3) << 12) 946#define _TXDMA_MGQ_MAP(x) (((x) & 0x3) << 12)
936#define _TXDMA_BKQ_MAP(x) (((x)&0x3) << 10) 947#define _TXDMA_BKQ_MAP(x) (((x) & 0x3) << 10)
937#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8) 948#define _TXDMA_BEQ_MAP(x) (((x) & 0x3) << 8)
938#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6) 949#define _TXDMA_VIQ_MAP(x) (((x) & 0x3) << 6)
939#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4) 950#define _TXDMA_VOQ_MAP(x) (((x) & 0x3) << 4)
940 951
941#define QUEUE_LOW 1 952#define QUEUE_LOW 1
942#define QUEUE_NORMAL 2 953#define QUEUE_NORMAL 2
@@ -1242,10 +1253,12 @@ Current IOREG MAP
1242 1253
1243/* 2REG_C2HEVT_CLEAR */ 1254/* 2REG_C2HEVT_CLEAR */
1244/* Set by driver and notify FW that the driver has read 1255/* Set by driver and notify FW that the driver has read
1245 * the C2H command message */ 1256 * the C2H command message
1257 */
1246#define C2H_EVT_HOST_CLOSE 0x00 1258#define C2H_EVT_HOST_CLOSE 0x00
1247/* Set by FW indicating that FW had set the C2H command 1259/* Set by FW indicating that FW had set the C2H command
1248 * message and it's not yet read by driver. */ 1260 * message and it's not yet read by driver.
1261 */
1249#define C2H_EVT_FW_CLOSE 0xFF 1262#define C2H_EVT_FW_CLOSE 0xFF
1250 1263
1251/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ 1264/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index f79feeb4e38f..2c026bf6fecb 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -97,13 +97,13 @@ enum RFINTFS {
97}; 97};
98 98
99/* 99/*
100Caller Mode: Infra, Ad-HoC(C) 100 * Caller Mode: Infra, Ad-HoC(C)
101 101 *
102Notes: To disconnect the current associated BSS 102 * Notes: To disconnect the current associated BSS
103 103 *
104Command Mode 104 * Command Mode
105 105 *
106*/ 106 */
107struct disconnect_parm { 107struct disconnect_parm {
108 u32 deauth_timeout_ms; 108 u32 deauth_timeout_ms;
109}; 109};
@@ -114,13 +114,13 @@ struct setopmode_parm {
114}; 114};
115 115
116/* 116/*
117Caller Mode: AP, Ad-HoC, Infra 117 * Caller Mode: AP, Ad-HoC, Infra
118 118 *
119Notes: To ask RTL8711 performing site-survey 119 * Notes: To ask RTL8711 performing site-survey
120 120 *
121Command-Event Mode 121 * Command-Event Mode
122 122 *
123*/ 123 */
124 124
125#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */ 125#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */
126#define RTW_CHANNEL_SCAN_AMOUNT (14+37) 126#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
@@ -133,13 +133,13 @@ struct sitesurvey_parm {
133}; 133};
134 134
135/* 135/*
136Caller Mode: Any 136 * Caller Mode: Any
137 137 *
138Notes: To set the auth type of RTL8711. open/shared/802.1x 138 * Notes: To set the auth type of RTL8711. open/shared/802.1x
139 139 *
140Command Mode 140 * Command Mode
141 141 *
142*/ 142 */
143struct setauth_parm { 143struct setauth_parm {
144 u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */ 144 u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */
145 u8 _1x; /* 0: PSK, 1: TLS */ 145 u8 _1x; /* 0: PSK, 1: TLS */
@@ -147,40 +147,42 @@ struct setauth_parm {
147}; 147};
148 148
149/* 149/*
150Caller Mode: Infra 150 * Caller Mode: Infra
151 151 *
152a. algorithm: wep40, wep104, tkip & aes 152 * a. algorithm: wep40, wep104, tkip & aes
153b. keytype: grp key/unicast key 153 * b. keytype: grp key/unicast key
154c. key contents 154 * c. key contents
155 155 *
156when shared key ==> keyid is the camid 156 * when shared key ==> keyid is the camid
157when 802.1x ==> keyid [0:1] ==> grp key 157 * when 802.1x ==> keyid [0:1] ==> grp key
158when 802.1x ==> keyid > 2 ==> unicast key 158 * when 802.1x ==> keyid > 2 ==> unicast key
159 159 *
160*/ 160 */
161struct setkey_parm { 161struct setkey_parm {
162 u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */ 162 u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */
163 u8 keyid; 163 u8 keyid;
164 u8 grpkey; /* 1: this is the grpkey for 802.1x. 164 u8 grpkey; /* 1: this is the grpkey for 802.1x.
165 * 0: this is the unicast key for 802.1x */ 165 * 0: this is the unicast key for 802.1x
166 */
166 u8 set_tx; /* 1: main tx key for wep. 0: other key. */ 167 u8 set_tx; /* 1: main tx key for wep. 0: other key. */
167 u8 key[16]; /* this could be 40 or 104 */ 168 u8 key[16]; /* this could be 40 or 104 */
168}; 169};
169 170
170/* 171/*
171When in AP or Ad-Hoc mode, this is used to 172 * When in AP or Ad-Hoc mode, this is used to
172allocate an sw/hw entry for a newly associated sta. 173 * allocate an sw/hw entry for a newly associated sta.
173 174 *
174Command 175 * Command
175 176 *
176when shared key ==> algorithm/keyid 177 * when shared key ==> algorithm/keyid
177 178 *
178*/ 179 */
179struct set_stakey_parm { 180struct set_stakey_parm {
180 u8 addr[ETH_ALEN]; 181 u8 addr[ETH_ALEN];
181 u8 algorithm; 182 u8 algorithm;
182 u8 id;/* currently for erasing cam entry if 183 u8 id;/* currently for erasing cam entry if
183 * algorithm == _NO_PRIVACY_ */ 184 * algorithm == _NO_PRIVACY_
185 */
184 u8 key[16]; 186 u8 key[16];
185}; 187};
186 188
@@ -191,15 +193,15 @@ struct set_stakey_rsp {
191}; 193};
192 194
193/* 195/*
194Caller Ad-Hoc/AP 196 * Caller Ad-Hoc/AP
195 197 *
196Command -Rsp(AID == CAMID) mode 198 * Command -Rsp(AID == CAMID) mode
197 199 *
198This is to force fw to add an sta_data entry per driver's request. 200 * This is to force fw to add an sta_data entry per driver's request.
199 201 *
200FW will write an cam entry associated with it. 202 * FW will write an cam entry associated with it.
201 203 *
202*/ 204 */
203struct set_assocsta_parm { 205struct set_assocsta_parm {
204 u8 addr[ETH_ALEN]; 206 u8 addr[ETH_ALEN];
205}; 207};
@@ -210,55 +212,57 @@ struct set_assocsta_rsp {
210}; 212};
211 213
212/* 214/*
213 Notes: This command is used for H2C/C2H loopback testing 215 * Notes: This command is used for H2C/C2H loopback testing
214 216 *
215 mac[0] == 0 217 * mac[0] == 0
216 ==> CMD mode, return H2C_SUCCESS. 218 * ==> CMD mode, return H2C_SUCCESS.
217 The following condition must be true under CMD mode 219 * The following condition must be true under CMD mode
218 mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; 220 * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
219 s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; 221 * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
220 s2 == (b1 << 8 | b0); 222 * s2 == (b1 << 8 | b0);
221 223 *
222 mac[0] == 1 224 * mac[0] == 1
223 ==> CMD_RSP mode, return H2C_SUCCESS_RSP 225 * ==> CMD_RSP mode, return H2C_SUCCESS_RSP
224 226 *
225 The rsp layout shall be: 227 * The rsp layout shall be:
226 rsp: parm: 228 * rsp: parm:
227 mac[0] = mac[5]; 229 * mac[0] = mac[5];
228 mac[1] = mac[4]; 230 * mac[1] = mac[4];
229 mac[2] = mac[3]; 231 * mac[2] = mac[3];
230 mac[3] = mac[2]; 232 * mac[3] = mac[2];
231 mac[4] = mac[1]; 233 * mac[4] = mac[1];
232 mac[5] = mac[0]; 234 * mac[5] = mac[0];
233 s0 = s1; 235 * s0 = s1;
234 s1 = swap16(s0); 236 * s1 = swap16(s0);
235 w0 = swap32(w1); 237 * w0 = swap32(w1);
236 b0 = b1 238 * b0 = b1
237 s2 = s0 + s1 239 * s2 = s0 + s1
238 b1 = b0 240 * b1 = b0
239 w1 = w0 241 * w1 = w0
240 242 *
241 mac[0] == 2 243 * mac[0] == 2
242 ==> CMD_EVENT mode, return H2C_SUCCESS 244 * ==> CMD_EVENT mode, return H2C_SUCCESS
243 The event layout shall be: 245 * The event layout shall be:
244 event: parm: 246 * event: parm:
245 mac[0] = mac[5]; 247 * mac[0] = mac[5];
246 mac[1] = mac[4]; 248 * mac[1] = mac[4];
247 mac[2] = event's seq no, starting from 1 to parm's marc[3] 249 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
248 mac[3] = mac[2]; 250 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
249 mac[4] = mac[1]; 251 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
250 mac[5] = mac[0]; 252 * mac[3] = mac[2];
251 s0 = swap16(s0) - event.mac[2]; 253 * mac[4] = mac[1];
252 s1 = s1 + event.mac[2]; 254 * mac[5] = mac[0];
253 w0 = swap32(w0); 255 * s0 = swap16(s0) - event.mac[2];
254 b0 = b1 256 * s1 = s1 + event.mac[2];
255 s2 = s0 + event.mac[2] 257 * w0 = swap32(w0);
256 b1 = b0 258 * b0 = b1
257 w1 = swap32(w1) - event.mac[2]; 259 * s2 = s0 + event.mac[2]
258 260 * b1 = b0
259 parm->mac[3] is the total event counts that host requested. 261 * w1 = swap32(w1) - event.mac[2];
260 event will be the same with the cmd's param. 262 *
261*/ 263 * parm->mac[3] is the total event counts that host requested.
264 * event will be the same with the cmd's param.
265 */
262 266
263/* CMD param Format for driver extra cmd handler */ 267/* CMD param Format for driver extra cmd handler */
264struct drvextra_cmd_parm { 268struct drvextra_cmd_parm {
@@ -285,15 +289,15 @@ struct SetChannelPlan_param {
285}; 289};
286 290
287/* 291/*
288 292 *
289Result: 293 * Result:
2900x00: success 294 * 0x00: success
2910x01: success, and check Response. 295 * 0x01: success, and check Response.
2920x02: cmd ignored due to duplicated sequcne number 296 * 0x02: cmd ignored due to duplicated sequcne number
2930x03: cmd dropped due to invalid cmd code 297 * 0x03: cmd dropped due to invalid cmd code
2940x04: reserved. 298 * 0x04: reserved.
295 299 *
296*/ 300 */
297 301
298#define H2C_SUCCESS 0x00 302#define H2C_SUCCESS 0x00
299#define H2C_SUCCESS_RSP 0x01 303#define H2C_SUCCESS_RSP 0x01
diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h
index 9cc4b8c7c166..4873ba49900c 100644
--- a/drivers/staging/rtl8188eu/include/rtw_debug.h
+++ b/drivers/staging/rtl8188eu/include/rtw_debug.h
@@ -106,9 +106,9 @@ extern u32 GlobalDebugLevel;
106 (((__i + 1) % 4) == 0) ? \ 106 (((__i + 1) % 4) == 0) ? \
107 " " : " "); \ 107 " " : " "); \
108 if (((__i + 1) % 16) == 0) \ 108 if (((__i + 1) % 16) == 0) \
109 printk("\n"); \ 109 pr_cont("\n"); \
110 } \ 110 } \
111 printk("\n"); \ 111 pr_cont("\n"); \
112 } \ 112 } \
113 } while (0) 113 } while (0)
114 114
diff --git a/drivers/staging/rtl8188eu/include/rtw_eeprom.h b/drivers/staging/rtl8188eu/include/rtw_eeprom.h
index 5dd73841dd9e..11d1cb6de506 100644
--- a/drivers/staging/rtl8188eu/include/rtw_eeprom.h
+++ b/drivers/staging/rtl8188eu/include/rtw_eeprom.h
@@ -55,7 +55,8 @@
55/* This variable is initiailzed through EEPROM or registry, */ 55/* This variable is initiailzed through EEPROM or registry, */
56/* however, its definition may be different with that in EEPROM for */ 56/* however, its definition may be different with that in EEPROM for */
57/* EEPROM size consideration. So, we have to perform proper translation 57/* EEPROM size consideration. So, we have to perform proper translation
58 * between them. */ 58 * between them.
59 */
59/* Besides, CustomerID of registry has precedence of that of EEPROM. */ 60/* Besides, CustomerID of registry has precedence of that of EEPROM. */
60/* defined below. 060703, by rcnjko. */ 61/* defined below. 060703, by rcnjko. */
61enum RT_CUSTOMER_ID { 62enum RT_CUSTOMER_ID {
@@ -79,7 +80,8 @@ enum RT_CUSTOMER_ID {
79 RT_CID_819x_Sitecom = 17, 80 RT_CID_819x_Sitecom = 17,
80 RT_CID_CCX = 18, /* It's set under CCX logo test and isn't demanded 81 RT_CID_CCX = 18, /* It's set under CCX logo test and isn't demanded
81 * for CCX functions, but for test behavior like retry 82 * for CCX functions, but for test behavior like retry
82 * limit and tx report. By Bruce, 2009-02-17. */ 83 * limit and tx report. By Bruce, 2009-02-17.
84 */
83 RT_CID_819x_Lenovo = 19, 85 RT_CID_819x_Lenovo = 19,
84 RT_CID_819x_QMI = 20, 86 RT_CID_819x_QMI = 20,
85 RT_CID_819x_Edimax_Belkin = 21, 87 RT_CID_819x_Edimax_Belkin = 21,
@@ -89,7 +91,8 @@ enum RT_CUSTOMER_ID {
89 RT_CID_819x_Acer = 25, 91 RT_CID_819x_Acer = 25,
90 RT_CID_819x_AzWave_ASUS = 26, 92 RT_CID_819x_AzWave_ASUS = 26,
91 RT_CID_819x_AzWave = 27, /* For AzWave in PCIe,i 93 RT_CID_819x_AzWave = 27, /* For AzWave in PCIe,i
92 * The ID is AzWave use and not only Asus */ 94 * The ID is AzWave use and not only Asus
95 */
93 RT_CID_819x_HP = 28, 96 RT_CID_819x_HP = 28,
94 RT_CID_819x_WNC_COREGA = 29, 97 RT_CID_819x_WNC_COREGA = 29,
95 RT_CID_819x_Arcadyan_Belkin = 30, 98 RT_CID_819x_Arcadyan_Belkin = 30,
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 1c5ebde97091..e798e794d962 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -22,42 +22,42 @@
22#include <linux/sem.h> 22#include <linux/sem.h>
23 23
24/* 24/*
25Used to report a bss has been scanned 25 * Used to report a bss has been scanned
26*/ 26 */
27struct survey_event { 27struct survey_event {
28 struct wlan_bssid_ex bss; 28 struct wlan_bssid_ex bss;
29}; 29};
30 30
31/* 31/*
32Used to report that the requested site survey has been done. 32 * Used to report that the requested site survey has been done.
33 33 *
34bss_cnt indicates the number of bss that has been reported. 34 * bss_cnt indicates the number of bss that has been reported.
35 35 *
36 36 *
37*/ 37 */
38struct surveydone_event { 38struct surveydone_event {
39 unsigned int bss_cnt; 39 unsigned int bss_cnt;
40 40
41}; 41};
42 42
43/* 43/*
44Used to report the link result of joinning the given bss 44 * Used to report the link result of joinning the given bss
45 45 *
46 46 *
47join_res: 47 * join_res:
48-1: authentication fail 48 * -1: authentication fail
49-2: association fail 49 * -2: association fail
50> 0: TID 50 * > 0: TID
51 51 *
52*/ 52 */
53struct joinbss_event { 53struct joinbss_event {
54 struct wlan_network network; 54 struct wlan_network network;
55}; 55};
56 56
57/* 57/*
58Used to report a given STA has joinned the created BSS. 58 * Used to report a given STA has joinned the created BSS.
59It is used in AP/Ad-HoC(M) mode. 59 * It is used in AP/Ad-HoC(M) mode.
60*/ 60 */
61 61
62struct stassoc_event { 62struct stassoc_event {
63 unsigned char macaddr[6]; 63 unsigned char macaddr[6];
diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h
index 607d1ba56a46..884e1397755a 100644
--- a/drivers/staging/rtl8188eu/include/rtw_led.h
+++ b/drivers/staging/rtl8188eu/include/rtw_led.h
@@ -58,7 +58,8 @@ struct LED_871x {
58 58
59 enum LED_STATE_871x CurrLedState; /* Current LED state. */ 59 enum LED_STATE_871x CurrLedState; /* Current LED state. */
60 enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, 60 enum LED_STATE_871x BlinkingLedState; /* Next state for blinking,
61 * either RTW_LED_ON or RTW_LED_OFF are. */ 61 * either RTW_LED_ON or RTW_LED_OFF are.
62 */
62 63
63 u8 bLedOn; /* true if LED is ON, false if LED is OFF. */ 64 u8 bLedOn; /* true if LED is ON, false if LED is OFF. */
64 65
@@ -75,7 +76,8 @@ struct LED_871x {
75 u8 bLedLinkBlinkInProgress; 76 u8 bLedLinkBlinkInProgress;
76 u8 bLedScanBlinkInProgress; 77 u8 bLedScanBlinkInProgress;
77 struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to 78 struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to
78 * manipulate H/W to blink LED. */ 79 * manipulate H/W to blink LED.
80 */
79}; 81};
80 82
81#define IS_LED_WPS_BLINKING(_LED_871x) \ 83#define IS_LED_WPS_BLINKING(_LED_871x) \
@@ -91,7 +93,6 @@ struct led_priv {
91 /* add for led control */ 93 /* add for led control */
92}; 94};
93 95
94void BlinkTimerCallback(unsigned long data);
95void BlinkWorkItemCallback(struct work_struct *work); 96void BlinkWorkItemCallback(struct work_struct *work);
96 97
97void ResetLedStatus(struct LED_871x *pLed); 98void ResetLedStatus(struct LED_871x *pLed);
diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h
index 5c5d0ae8bdd1..e6d4175af3a2 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mlme.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h
@@ -70,25 +70,28 @@ enum rt_scan_type {
70enum SCAN_RESULT_TYPE { 70enum SCAN_RESULT_TYPE {
71 SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ 71 SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */
72 SCAN_RESULT_ALL = 1, /* Will return all the scanned device, 72 SCAN_RESULT_ALL = 1, /* Will return all the scanned device,
73 * include AP. */ 73 * include AP.
74 */
74 SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD 75 SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD
75 * device. */ 76 * device.
77 */
76 /* If this device is Miracast sink 78 /* If this device is Miracast sink
77 * device, it will just return all the 79 * device, it will just return all the
78 * Miracast source devices. */ 80 * Miracast source devices.
81 */
79}; 82};
80 83
81/* 84/*
82there are several "locks" in mlme_priv, 85 * there are several "locks" in mlme_priv,
83since mlme_priv is a shared resource between many threads, 86 * since mlme_priv is a shared resource between many threads,
84like ISR/Call-Back functions, the OID handlers, and even timer functions. 87 * like ISR/Call-Back functions, the OID handlers, and even timer functions.
85 88 *
86Each _queue has its own locks, already. 89 * Each _queue has its own locks, already.
87Other items are protected by mlme_priv.lock. 90 * Other items are protected by mlme_priv.lock.
88 91 *
89To avoid possible dead lock, any thread trying to modifiying mlme_priv 92 * To avoid possible dead lock, any thread trying to modifiying mlme_priv
90SHALL not lock up more than one lock at a time! 93 * SHALL not lock up more than one lock at a time!
91*/ 94 */
92 95
93#define traffic_threshold 10 96#define traffic_threshold 10
94#define traffic_scan_period 500 97#define traffic_scan_period 500
@@ -102,9 +105,11 @@ struct rt_link_detect {
102 bool bRxBusyTraffic; 105 bool bRxBusyTraffic;
103 bool bHigherBusyTraffic; /* For interrupt migration purpose. */ 106 bool bHigherBusyTraffic; /* For interrupt migration purpose. */
104 bool bHigherBusyRxTraffic; /* We may disable Tx interrupt according 107 bool bHigherBusyRxTraffic; /* We may disable Tx interrupt according
105 * to Rx traffic. */ 108 * to Rx traffic.
109 */
106 bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according 110 bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according
107 * to Tx traffic. */ 111 * to Tx traffic.
112 */
108}; 113};
109 114
110struct mlme_priv { 115struct mlme_priv {
@@ -164,7 +169,8 @@ struct mlme_priv {
164 169
165#if defined(CONFIG_88EU_AP_MODE) 170#if defined(CONFIG_88EU_AP_MODE)
166 /* Number of associated Non-ERP stations (i.e., stations using 802.11b 171 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
167 * in 802.11g BSS) */ 172 * in 802.11g BSS)
173 */
168 int num_sta_non_erp; 174 int num_sta_non_erp;
169 175
170 /* Number of associated stations that do not support Short Slot Time */ 176 /* Number of associated stations that do not support Short Slot Time */
@@ -325,10 +331,10 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter);
325 331
326void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); 332void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
327 333
328void _rtw_join_timeout_handler(unsigned long data); 334void _rtw_join_timeout_handler(struct timer_list *t);
329void rtw_scan_timeout_handler(unsigned long data); 335void rtw_scan_timeout_handler(struct timer_list *t);
330 336
331void rtw_dynamic_check_timer_handlder(unsigned long data); 337void rtw_dynamic_check_timer_handlder(struct timer_list *t);
332#define rtw_is_scan_deny(adapter) false 338#define rtw_is_scan_deny(adapter) false
333#define rtw_clear_scan_deny(adapter) do {} while (0) 339#define rtw_clear_scan_deny(adapter) do {} while (0)
334#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) 340#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
index 1b1caaf583c9..118bf5509d97 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
@@ -101,9 +101,11 @@ extern unsigned char WMM_PARA_OUI[];
101/* Channel Plan Type. */ 101/* Channel Plan Type. */
102/* Note: */ 102/* Note: */
103/* We just add new channel plan when the new channel plan is different 103/* We just add new channel plan when the new channel plan is different
104 * from any of the following channel plan. */ 104 * from any of the following channel plan.
105 */
105/* If you just want to customize the actions(scan period or join actions) 106/* If you just want to customize the actions(scan period or join actions)
106 * about one of the channel plan, */ 107 * about one of the channel plan,
108 */
107/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ 109/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
108enum RT_CHANNEL_DOMAIN { 110enum RT_CHANNEL_DOMAIN {
109 /* old channel plan mapping ===== */ 111 /* old channel plan mapping ===== */
@@ -319,7 +321,8 @@ struct mlme_ext_info {
319 u32 authModeToggle; 321 u32 authModeToggle;
320 u32 enc_algo;/* encrypt algorithm; */ 322 u32 enc_algo;/* encrypt algorithm; */
321 u32 key_index; /* this is only valid for legacy wep, 323 u32 key_index; /* this is only valid for legacy wep,
322 * 0~3 for key id. */ 324 * 0~3 for key id.
325 */
323 u32 iv; 326 u32 iv;
324 u8 chg_txt[128]; 327 u8 chg_txt[128];
325 u16 aid; 328 u16 aid;
@@ -353,16 +356,19 @@ struct mlme_ext_info {
353 struct HT_info_element HT_info; 356 struct HT_info_element HT_info;
354 struct wlan_bssid_ex network;/* join network or bss_network, 357 struct wlan_bssid_ex network;/* join network or bss_network,
355 * if in ap mode, it is the same 358 * if in ap mode, it is the same
356 * as cur_network.network */ 359 * as cur_network.network
360 */
357 struct FW_Sta_Info FW_sta_info[NUM_STA]; 361 struct FW_Sta_Info FW_sta_info[NUM_STA];
358}; 362};
359 363
360/* The channel information about this channel including joining, 364/* The channel information about this channel including joining,
361 * scanning, and power constraints. */ 365 * scanning, and power constraints.
366 */
362struct rt_channel_info { 367struct rt_channel_info {
363 u8 ChannelNum; /* The channel number. */ 368 u8 ChannelNum; /* The channel number. */
364 enum rt_scan_type ScanType; /* Scan type such as passive 369 enum rt_scan_type ScanType; /* Scan type such as passive
365 * or active scan. */ 370 * or active scan.
371 */
366 u32 rx_count; 372 u32 rx_count;
367}; 373};
368 374
@@ -413,7 +419,8 @@ struct mlme_ext_priv {
413 unsigned char cur_wireless_mode; /* NETWORK_TYPE */ 419 unsigned char cur_wireless_mode; /* NETWORK_TYPE */
414 420
415 unsigned char oper_channel; /* saved chan info when call 421 unsigned char oper_channel; /* saved chan info when call
416 * set_channel_bw */ 422 * set_channel_bw
423 */
417 unsigned char oper_bwmode; 424 unsigned char oper_bwmode;
418 unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */ 425 unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */
419 426
@@ -427,7 +434,8 @@ struct mlme_ext_priv {
427 struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including 434 struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including
428 * current scan/connecting/connected 435 * current scan/connecting/connected
429 * related info. For ap mode, 436 * related info. For ap mode,
430 * network includes ap's cap_info*/ 437 * network includes ap's cap_info
438 */
431 struct timer_list survey_timer; 439 struct timer_list survey_timer;
432 struct timer_list link_timer; 440 struct timer_list link_timer;
433 u16 chan_scan_time; 441 u16 chan_scan_time;
@@ -572,9 +580,9 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter,
572 580
573void linked_status_chk(struct adapter *padapter); 581void linked_status_chk(struct adapter *padapter);
574 582
575void survey_timer_hdl(unsigned long data); 583void survey_timer_hdl(struct timer_list *t);
576void link_timer_hdl(unsigned long data); 584void link_timer_hdl(struct timer_list *t);
577void addba_timer_hdl(unsigned long data); 585void addba_timer_hdl(struct timer_list *t);
578 586
579#define set_survey_timer(mlmeext, ms) \ 587#define set_survey_timer(mlmeext, ms) \
580 mod_timer(&mlmeext->survey_timer, jiffies + \ 588 mod_timer(&mlmeext->survey_timer, jiffies + \
@@ -690,7 +698,8 @@ enum rtw_c2h_event {
690 _C2HBCN_EVT_, 698 _C2HBCN_EVT_,
691 _ReportPwrState_EVT_, /* filen: only for PCIE, USB */ 699 _ReportPwrState_EVT_, /* filen: only for PCIE, USB */
692 _CloseRF_EVT_, /* filen: only for PCIE, 700 _CloseRF_EVT_, /* filen: only for PCIE,
693 * work around ASPM */ 701 * work around ASPM
702 */
694 MAX_C2HEVT 703 MAX_C2HEVT
695}; 704};
696 705
diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h
index 4872a21b3103..aa353aefed3d 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h
@@ -521,14 +521,16 @@
521#define bCCKRxPhase 0x4 521#define bCCKRxPhase 0x4
522#if (RTL92SE_FPGA_VERIFY == 1) 522#if (RTL92SE_FPGA_VERIFY == 1)
523#define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address 523#define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address
524 Reg 0x824 rFPGA0_XA_HSSIParameter2 */ 524 * Reg 0x824 rFPGA0_XA_HSSIParameter2
525 */
525#else 526#else
526#define bLSSIReadAddress 0x7f800000 /* T65 RF */ 527#define bLSSIReadAddress 0x7f800000 /* T65 RF */
527#endif 528#endif
528#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ 529#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */
529#if (RTL92SE_FPGA_VERIFY == 1) 530#if (RTL92SE_FPGA_VERIFY == 1)
530#define bLSSIReadBackData 0xfff /* Reg 0x8a0 531#define bLSSIReadBackData 0xfff /* Reg 0x8a0
531 rFPGA0_XA_LSSIReadBack */ 532 * rFPGA0_XA_LSSIReadBack
533 */
532#else 534#else
533#define bLSSIReadBackData 0xfffff /* T65 RF */ 535#define bLSSIReadBackData 0xfffff /* T65 RF */
534#endif 536#endif
@@ -548,13 +550,16 @@
548#define bDA6Swing 0x380000 550#define bDA6Swing 0x380000
549 551
550#define bADClkPhase 0x4000000 /* Reg 0x880 552#define bADClkPhase 0x4000000 /* Reg 0x880
551 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */ 553 * rFPGA0_AnalogParameter1 20/40 CCK
554 * support switch 40/80 BB MHZ
555 */
552 556
553#define b80MClkDelay 0x18000000 /* Useless */ 557#define b80MClkDelay 0x18000000 /* Useless */
554#define bAFEWatchDogEnable 0x20000000 558#define bAFEWatchDogEnable 0x20000000
555 559
556#define bXtalCap01 0xc0000000 /* Reg 0x884 560#define bXtalCap01 0xc0000000 /* Reg 0x884
557 rFPGA0_AnalogParameter2 Crystal cap */ 561 * rFPGA0_AnalogParameter2 Crystal cap
562 */
558#define bXtalCap23 0x3 563#define bXtalCap23 0x3
559#define bXtalCap92x 0x0f000000 564#define bXtalCap92x 0x0f000000
560#define bXtalCap 0x0f000000 565#define bXtalCap 0x0f000000
@@ -598,7 +603,8 @@
598#define bCCKTxOn 0x1 603#define bCCKTxOn 0x1
599#define bOFDMTxOn 0x2 604#define bOFDMTxOn 0x2
600#define bDebugPage 0xfff /* reset debug page and HWord, 605#define bDebugPage 0xfff /* reset debug page and HWord,
601 * LWord */ 606 * LWord
607 */
602#define bDebugItem 0xff /* reset debug page and LWord */ 608#define bDebugItem 0xff /* reset debug page and LWord */
603#define bAntL 0x10 609#define bAntL 0x10
604#define bAntNonHT 0x100 610#define bAntNonHT 0x100
@@ -1071,7 +1077,8 @@
1071#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */ 1077#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */
1072#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */ 1078#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */
1073#define RCR_OnlyErlPkt BIT(31) /* Rx Early mode is performed for 1079#define RCR_OnlyErlPkt BIT(31) /* Rx Early mode is performed for
1074 * packet size greater than 1536 */ 1080 * packet size greater than 1536
1081 */
1075 1082
1076/*--------------------------Define Parameters-------------------------------*/ 1083/*--------------------------Define Parameters-------------------------------*/
1077 1084
diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
index 18a9e744fcbe..f39e90cfc031 100644
--- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
@@ -51,11 +51,11 @@ enum power_mgnt {
51}; 51};
52 52
53/* 53/*
54 BIT[2:0] = HW state 54 * BIT[2:0] = HW state
55 BIT[3] = Protocol PS state, 0: register active state, 55 * BIT[3] = Protocol PS state, 0: register active state,
56 1: register sleep state 56 * 1: register sleep state
57 BIT[4] = sub-state 57 * BIT[4] = sub-state
58*/ 58 */
59 59
60#define PS_DPS BIT(0) 60#define PS_DPS BIT(0)
61#define PS_LCLK (PS_DPS) 61#define PS_LCLK (PS_DPS)
@@ -115,9 +115,11 @@ enum rt_rf_power_state {
115#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW*/ 115#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW*/
116#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */ 116#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */
117#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock 117#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock
118 * Req in initialization. */ 118 * Req in initialization.
119 */
119#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R 120#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R
120 * if no packet is RX or TX. */ 121 * if no packet is RX or TX.
122 */
121#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */ 123#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */
122 124
123#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) \ 125#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) \
@@ -145,7 +147,8 @@ struct pwrctrl_priv {
145 struct mutex mutex_lock; 147 struct mutex mutex_lock;
146 volatile u8 rpwm; /* requested power state for fw */ 148 volatile u8 rpwm; /* requested power state for fw */
147 volatile u8 cpwm; /* fw current power state. updated when 149 volatile u8 cpwm; /* fw current power state. updated when
148 * 1. read from HCPWM 2. driver lowers power level */ 150 * 1. read from HCPWM 2. driver lowers power level
151 */
149 volatile u8 tog; /* toggling */ 152 volatile u8 tog; /* toggling */
150 volatile u8 cpwm_tog; /* toggling */ 153 volatile u8 cpwm_tog; /* toggling */
151 154
@@ -170,7 +173,8 @@ struct pwrctrl_priv {
170 173
171 u8 ips_mode; 174 u8 ips_mode;
172 u8 ips_mode_req; /* used to accept the mode setting request, 175 u8 ips_mode_req; /* used to accept the mode setting request,
173 * will update to ipsmode later */ 176 * will update to ipsmode later
177 */
174 uint bips_processing; 178 uint bips_processing;
175 unsigned long ips_deny_time; /* will deny IPS when system time less than this */ 179 unsigned long ips_deny_time; /* will deny IPS when system time less than this */
176 u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ 180 u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */
diff --git a/drivers/staging/rtl8188eu/include/rtw_qos.h b/drivers/staging/rtl8188eu/include/rtw_qos.h
index 45a77f6f8427..576dff68d0dc 100644
--- a/drivers/staging/rtl8188eu/include/rtw_qos.h
+++ b/drivers/staging/rtl8188eu/include/rtw_qos.h
@@ -19,7 +19,8 @@
19 19
20struct qos_priv { 20struct qos_priv {
21 unsigned int qos_option; /* bit mask option: u-apsd, 21 unsigned int qos_option; /* bit mask option: u-apsd,
22 * s-apsd, ts, block ack... */ 22 * s-apsd, ts, block ack...
23 */
23}; 24};
24 25
25#endif /* _RTL871X_QOS_H_ */ 26#endif /* _RTL871X_QOS_H_ */
diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h
index 121150860450..7e85f700acb3 100644
--- a/drivers/staging/rtl8188eu/include/rtw_recv.h
+++ b/drivers/staging/rtl8188eu/include/rtw_recv.h
@@ -46,23 +46,23 @@ struct recv_reorder_ctrl {
46struct stainfo_rxcache { 46struct stainfo_rxcache {
47 u16 tid_rxseq[16]; 47 u16 tid_rxseq[16];
48/* 48/*
49 unsigned short tid0_rxseq; 49 * unsigned short tid0_rxseq;
50 unsigned short tid1_rxseq; 50 * unsigned short tid1_rxseq;
51 unsigned short tid2_rxseq; 51 * unsigned short tid2_rxseq;
52 unsigned short tid3_rxseq; 52 * unsigned short tid3_rxseq;
53 unsigned short tid4_rxseq; 53 * unsigned short tid4_rxseq;
54 unsigned short tid5_rxseq; 54 * unsigned short tid5_rxseq;
55 unsigned short tid6_rxseq; 55 * unsigned short tid6_rxseq;
56 unsigned short tid7_rxseq; 56 * unsigned short tid7_rxseq;
57 unsigned short tid8_rxseq; 57 * unsigned short tid8_rxseq;
58 unsigned short tid9_rxseq; 58 * unsigned short tid9_rxseq;
59 unsigned short tid10_rxseq; 59 * unsigned short tid10_rxseq;
60 unsigned short tid11_rxseq; 60 * unsigned short tid11_rxseq;
61 unsigned short tid12_rxseq; 61 * unsigned short tid12_rxseq;
62 unsigned short tid13_rxseq; 62 * unsigned short tid13_rxseq;
63 unsigned short tid14_rxseq; 63 * unsigned short tid14_rxseq;
64 unsigned short tid15_rxseq; 64 * unsigned short tid15_rxseq;
65*/ 65 */
66}; 66};
67 67
68struct signal_stat { 68struct signal_stat {
@@ -79,7 +79,8 @@ struct phy_info {
79 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ 79 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */
80 s8 RxPower; /* in dBm Translate from PWdB */ 80 s8 RxPower; /* in dBm Translate from PWdB */
81/* Real power in dBm for this packet, no beautification and aggregation. 81/* Real power in dBm for this packet, no beautification and aggregation.
82 * Keep this raw info to be used for the other procedures. */ 82 * Keep this raw info to be used for the other procedures.
83 */
83 s8 recvpower; 84 s8 recvpower;
84 u8 BTRxRSSIPercentage; 85 u8 BTRxRSSIPercentage;
85 u8 SignalStrength; /* in 0-100 index. */ 86 u8 SignalStrength; /* in 0-100 index. */
@@ -106,7 +107,8 @@ struct rx_pkt_attrib {
106 u8 privacy; /* in frame_ctrl field */ 107 u8 privacy; /* in frame_ctrl field */
107 u8 bdecrypted; 108 u8 bdecrypted;
108 u8 encrypt; /* when 0 indicate no encrypt. when non-zero, 109 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
109 * indicate the encrypt algorithm */ 110 * indicate the encrypt algorithm
111 */
110 u8 iv_len; 112 u8 iv_len;
111 u8 icv_len; 113 u8 icv_len;
112 u8 crc_err; 114 u8 crc_err;
@@ -152,12 +154,12 @@ struct recv_stat {
152}; 154};
153 155
154/* 156/*
155accesser of recv_priv: rtw_recv_entry(dispatch / passive level); 157 * accesser of recv_priv: rtw_recv_entry(dispatch / passive level);
156recv_thread(passive) ; returnpkt(dispatch) 158 * recv_thread(passive) ; returnpkt(dispatch)
157; halt(passive) ; 159 * ; halt(passive) ;
158 160 *
159using enter_critical section to protect 161 * using enter_critical section to protect
160*/ 162 */
161struct recv_priv { 163struct recv_priv {
162 struct __queue free_recv_queue; 164 struct __queue free_recv_queue;
163 struct __queue recv_pending_queue; 165 struct __queue recv_pending_queue;
@@ -209,20 +211,20 @@ struct recv_buf {
209}; 211};
210 212
211/* 213/*
212 head -----> 214 * head ----->
213 215 *
214 data -----> 216 * data ----->
215 217 *
216 payload 218 * payload
217 219 *
218 tail -----> 220 * tail ----->
219 221 *
220 222 *
221 end -----> 223 * end ----->
222 224 *
223 len = (unsigned int )(tail - data); 225 * len = (unsigned int )(tail - data);
224 226 *
225*/ 227 */
226struct recv_frame { 228struct recv_frame {
227 struct list_head list; 229 struct list_head list;
228 struct sk_buff *pkt; 230 struct sk_buff *pkt;
@@ -247,7 +249,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,
247 struct __queue *pfree_recv_queue); 249 struct __queue *pfree_recv_queue);
248u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); 250u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
249 251
250void rtw_reordering_ctrl_timeout_handler(unsigned long data); 252void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
251 253
252static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) 254static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
253{ 255{
diff --git a/drivers/staging/rtl8188eu/include/rtw_rf.h b/drivers/staging/rtl8188eu/include/rtw_rf.h
index 66896af02042..0718a29e7c9d 100644
--- a/drivers/staging/rtl8188eu/include/rtw_rf.h
+++ b/drivers/staging/rtl8188eu/include/rtw_rf.h
@@ -31,7 +31,8 @@
31#define RTL8711_RF_DEF_SENS 4 31#define RTL8711_RF_DEF_SENS 4
32 32
33/* We now define the following channels as the max channels in each 33/* We now define the following channels as the max channels in each
34 * channel plan. */ 34 * channel plan.
35 */
35/* 2G, total 14 chnls */ 36/* 2G, total 14 chnls */
36/* {1,2,3,4,5,6,7,8,9,10,11,12,13,14} */ 37/* {1,2,3,4,5,6,7,8,9,10,11,12,13,14} */
37#define MAX_CHANNEL_NUM_2G 14 38#define MAX_CHANNEL_NUM_2G 14
@@ -65,7 +66,8 @@ enum capability {
65 cChannelAgility = 0x0080, 66 cChannelAgility = 0x0080,
66 cSpectrumMgnt = 0x0100, 67 cSpectrumMgnt = 0x0100,
67 cQos = 0x0200, /* For HCCA, use with CF-Pollable 68 cQos = 0x0200, /* For HCCA, use with CF-Pollable
68 * and CF-PollReq */ 69 * and CF-PollReq
70 */
69 cShortSlotTime = 0x0400, 71 cShortSlotTime = 0x0400,
70 cAPSD = 0x0800, 72 cAPSD = 0x0800,
71 cRM = 0x1000, /* RRM (Radio Request Measurement) */ 73 cRM = 0x1000, /* RRM (Radio Request Measurement) */
diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h
index 74fe664787e5..a0c6cf706218 100644
--- a/drivers/staging/rtl8188eu/include/rtw_security.h
+++ b/drivers/staging/rtl8188eu/include/rtw_security.h
@@ -100,20 +100,26 @@ struct rt_pmkid_list {
100 100
101struct security_priv { 101struct security_priv {
102 u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, 102 u32 dot11AuthAlgrthm; /* 802.11 auth, could be open,
103 * shared, 8021x and authswitch */ 103 * shared, 8021x and authswitch
104 */
104 u32 dot11PrivacyAlgrthm; /* This specify the privacy for 105 u32 dot11PrivacyAlgrthm; /* This specify the privacy for
105 * shared auth. algorithm. */ 106 * shared auth. algorithm.
107 */
106 /* WEP */ 108 /* WEP */
107 u32 dot11PrivacyKeyIndex; /* this is only valid for legendary 109 u32 dot11PrivacyKeyIndex; /* this is only valid for legendary
108 * wep, 0~3 for key id.(tx key index) */ 110 * wep, 0~3 for key id.(tx key index)
111 */
109 union Keytype dot11DefKey[4]; /* this is only valid for def. key */ 112 union Keytype dot11DefKey[4]; /* this is only valid for def. key */
110 u32 dot11DefKeylen[4]; 113 u32 dot11DefKeylen[4];
111 u32 dot118021XGrpPrivacy; /* This specify the privacy algthm. 114 u32 dot118021XGrpPrivacy; /* This specify the privacy algthm.
112 * used for Grp key */ 115 * used for Grp key
116 */
113 u32 dot118021XGrpKeyid; /* key id used for Grp Key 117 u32 dot118021XGrpKeyid; /* key id used for Grp Key
114 * ( tx key index) */ 118 * ( tx key index)
119 */
115 union Keytype dot118021XGrpKey[4]; /* 802.1x Group Key, 120 union Keytype dot118021XGrpKey[4]; /* 802.1x Group Key,
116 * for inx0 and inx1 */ 121 * for inx0 and inx1
122 */
117 union Keytype dot118021XGrptxmickey[4]; 123 union Keytype dot118021XGrptxmickey[4];
118 union Keytype dot118021XGrprxmickey[4]; 124 union Keytype dot118021XGrprxmickey[4];
119 union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit.*/ 125 union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit.*/
@@ -134,10 +140,12 @@ struct security_priv {
134 u8 bcheck_grpkey; 140 u8 bcheck_grpkey;
135 u8 bgrpkey_handshake; 141 u8 bgrpkey_handshake;
136 s32 hw_decrypted;/* if the rx packets is hw_decrypted==false,i 142 s32 hw_decrypted;/* if the rx packets is hw_decrypted==false,i
137 * it means the hw has not been ready. */ 143 * it means the hw has not been ready.
144 */
138 145
139 /* keeps the auth_type & enc_status from upper layer 146 /* keeps the auth_type & enc_status from upper layer
140 * ioctl(wpa_supplicant or wzc) */ 147 * ioctl(wpa_supplicant or wzc)
148 */
141 u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */ 149 u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */
142 u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ 150 u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */
143 struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ 151 struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
@@ -256,7 +264,8 @@ static inline u32 rotr(u32 val, int bits)
256/* ===== start - public domain SHA256 implementation ===== */ 264/* ===== start - public domain SHA256 implementation ===== */
257 265
258/* This is based on SHA256 implementation in LibTomCrypt that was released into 266/* This is based on SHA256 implementation in LibTomCrypt that was released into
259 * public domain by Tom St Denis. */ 267 * public domain by Tom St Denis.
268 */
260 269
261/* the K array */ 270/* the K array */
262static const unsigned long K[64] = { 271static const unsigned long K[64] = {
diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h
index dd6b7a9a8d4a..b4b3d13ace9e 100644
--- a/drivers/staging/rtl8188eu/include/rtw_xmit.h
+++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h
@@ -115,11 +115,13 @@ struct pkt_attrib {
115 u16 seqnum; 115 u16 seqnum;
116 u16 hdrlen; /* the WLAN Header Len */ 116 u16 hdrlen; /* the WLAN Header Len */
117 u32 pktlen; /* the original 802.3 pkt raw_data len (not include 117 u32 pktlen; /* the original 802.3 pkt raw_data len (not include
118 * ether_hdr data) */ 118 * ether_hdr data)
119 */
119 u32 last_txcmdsz; 120 u32 last_txcmdsz;
120 u8 nr_frags; 121 u8 nr_frags;
121 u8 encrypt; /* when 0 indicate no encrypt. when non-zero, 122 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
122 * indicate the encrypt algorith */ 123 * indicate the encrypt algorith
124 */
123 u8 iv_len; 125 u8 iv_len;
124 u8 icv_len; 126 u8 icv_len;
125 u8 iv[18]; 127 u8 iv[18];
@@ -234,7 +236,8 @@ struct sta_xmit_priv {
234 spinlock_t lock; 236 spinlock_t lock;
235 int option; 237 int option;
236 int apsd_setting; /* When bit mask is on, the associated edca 238 int apsd_setting; /* When bit mask is on, the associated edca
237 * queue supports APSD. */ 239 * queue supports APSD.
240 */
238 struct tx_servq be_q; /* priority == 0,3 */ 241 struct tx_servq be_q; /* priority == 0,3 */
239 struct tx_servq bk_q; /* priority == 1,2 */ 242 struct tx_servq bk_q; /* priority == 1,2 */
240 struct tx_servq vi_q; /* priority == 4,5 */ 243 struct tx_servq vi_q; /* priority == 4,5 */
@@ -280,7 +283,8 @@ struct xmit_priv {
280 u8 hwxmit_entry; 283 u8 hwxmit_entry;
281 u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength 284 u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
282 * from large to small. it's value is 0->vo, 285 * from large to small. it's value is 0->vo,
283 * 1->vi, 2->be, 3->bk. */ 286 * 1->vi, 2->be, 3->bk.
287 */
284 u8 txirp_cnt;/* */ 288 u8 txirp_cnt;/* */
285 struct tasklet_struct xmit_tasklet; 289 struct tasklet_struct xmit_tasklet;
286 /* per AC pending irp */ 290 /* per AC pending irp */
diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h
index 42a035123365..8f01deed6e4a 100644
--- a/drivers/staging/rtl8188eu/include/sta_info.h
+++ b/drivers/staging/rtl8188eu/include/sta_info.h
@@ -126,7 +126,8 @@ struct sta_info {
126 /* Notes: */ 126 /* Notes: */
127 /* STA_Mode: */ 127 /* STA_Mode: */
128 /* curr_network(mlme_priv/security_priv/qos/ht) + 128 /* curr_network(mlme_priv/security_priv/qos/ht) +
129 * sta_info: (STA & AP) CAP/INFO */ 129 * sta_info: (STA & AP) CAP/INFO
130 */
130 /* scan_q: AP CAP/INFO */ 131 /* scan_q: AP CAP/INFO */
131 132
132 /* AP_Mode: */ 133 /* AP_Mode: */
@@ -184,7 +185,8 @@ struct sta_info {
184 185
185 /* ================ODM Relative Info======================= */ 186 /* ================ODM Relative Info======================= */
186 /* Please be careful, don't declare too much structure here. 187 /* Please be careful, don't declare too much structure here.
187 * It will cost memory * STA support num. */ 188 * It will cost memory * STA support num.
189 */
188 /* 2011/10/20 MH Add for ODM STA info. */ 190 /* 2011/10/20 MH Add for ODM STA info. */
189 /* Driver Write */ 191 /* Driver Write */
190 u8 bValid; /* record the sta status link or not? */ 192 u8 bValid; /* record the sta status link or not? */
@@ -318,9 +320,11 @@ struct sta_priv {
318 struct sta_info *sta_aid[NUM_STA]; 320 struct sta_info *sta_aid[NUM_STA];
319 321
320 u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap 322 u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
321 * for sleeping sta. */ 323 * for sleeping sta.
324 */
322 u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping 325 u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping
323 * bit0~bit15 */ 326 * bit0~bit15
327 */
324 328
325 u16 max_num_sta; 329 u16 max_num_sta;
326 330
diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h
index cb46d353327b..084a246eec19 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -35,7 +35,8 @@
35 35
36/* This value is tested by WiFi 11n Test Plan 5.2.3. */ 36/* This value is tested by WiFi 11n Test Plan 5.2.3. */
37/* This test verifies the WLAN NIC can update the NAV through sending 37/* This test verifies the WLAN NIC can update the NAV through sending
38 * the CTS with large duration. */ 38 * the CTS with large duration.
39 */
39#define WiFiNavUpperUs 30000 /* 30 ms */ 40#define WiFiNavUpperUs 30000 /* 30 ms */
40 41
41enum WIFI_FRAME_TYPE { 42enum WIFI_FRAME_TYPE {
@@ -459,14 +460,14 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
459#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ 460#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
460 461
461/* 462/*
462#define _NO_PRIVACY_ 0 463 * #define _NO_PRIVACY_ 0
463#define _WEP_40_PRIVACY_ 1 464 * #define _WEP_40_PRIVACY_ 1
464#define _TKIP_PRIVACY_ 2 465 * #define _TKIP_PRIVACY_ 2
465#define _WRAP_PRIVACY_ 3 466 * #define _WRAP_PRIVACY_ 3
466#define _CCMP_PRIVACY_ 4 467 * #define _CCMP_PRIVACY_ 4
467#define _WEP_104_PRIVACY_ 5 468 * #define _WEP_104_PRIVACY_ 5
468#define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA 469 * #define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA
469*/ 470 */
470 471
471/*----------------------------------------------------------------------------- 472/*-----------------------------------------------------------------------------
472 Below is the definition for WMM 473 Below is the definition for WMM
@@ -771,10 +772,12 @@ enum ht_cap_ampdu_factor {
771#define P2P_PROVISIONING_SCAN_CNT 3 772#define P2P_PROVISIONING_SCAN_CNT 3
772 773
773/* default value, used when: (1)p2p disabled or (2)p2p enabled 774/* default value, used when: (1)p2p disabled or (2)p2p enabled
774 * but only do 1 scan phase */ 775 * but only do 1 scan phase
776 */
775#define P2P_FINDPHASE_EX_NONE 0 777#define P2P_FINDPHASE_EX_NONE 0
776/* used when p2p enabled and want to do 1 scan phase and 778/* used when p2p enabled and want to do 1 scan phase and
777 * P2P_FINDPHASE_EX_MAX-1 find phase */ 779 * P2P_FINDPHASE_EX_MAX-1 find phase
780 */
778#define P2P_FINDPHASE_EX_FULL 1 781#define P2P_FINDPHASE_EX_FULL 1
779#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) 782#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1)
780#define P2P_FINDPHASE_EX_MAX 4 783#define P2P_FINDPHASE_EX_MAX 4
diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
index e1931dd04da0..d7b25d2f933a 100644
--- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
@@ -86,7 +86,8 @@ struct ndis_802_11_var_ie {
86 * + NDIS_802_11_LENGTH_RATES_EX + IELength 86 * + NDIS_802_11_LENGTH_RATES_EX + IELength
87 * 87 *
88 * Except the IELength, all other fields are fixed length. 88 * Except the IELength, all other fields are fixed length.
89 * Therefore, we can define a macro to represent the partial sum. */ 89 * Therefore, we can define a macro to represent the partial sum.
90 */
90 91
91enum ndis_802_11_auth_mode { 92enum ndis_802_11_auth_mode {
92 Ndis802_11AuthModeOpen, 93 Ndis802_11AuthModeOpen,
@@ -130,7 +131,8 @@ enum ndis_802_11_reload_def {
130struct ndis_802_11_wep { 131struct ndis_802_11_wep {
131 u32 Length; /* Length of this structure */ 132 u32 Length; /* Length of this structure */
132 u32 KeyIndex; /* 0 is the per-client key, 133 u32 KeyIndex; /* 0 is the per-client key,
133 * 1-N are the global keys */ 134 * 1-N are the global keys
135 */
134 u32 KeyLength; /* length of key in bytes */ 136 u32 KeyLength; /* length of key in bytes */
135 u8 KeyMaterial[16];/* variable len depending on above field */ 137 u8 KeyMaterial[16];/* variable len depending on above field */
136}; 138};
@@ -140,7 +142,8 @@ enum ndis_802_11_status_type {
140 Ndis802_11StatusType_MediaStreamMode, 142 Ndis802_11StatusType_MediaStreamMode,
141 Ndis802_11StatusType_PMKID_CandidateList, 143 Ndis802_11StatusType_PMKID_CandidateList,
142 Ndis802_11StatusTypeMax /* not a real type, defined as 144 Ndis802_11StatusTypeMax /* not a real type, defined as
143 * an upper bound */ 145 * an upper bound
146 */
144}; 147};
145 148
146/* mask for authentication/integrity fields */ 149/* mask for authentication/integrity fields */
@@ -166,7 +169,8 @@ struct wlan_phy_info {
166 169
167struct wlan_bcn_info { 170struct wlan_bcn_info {
168 /* these infor get from rtw_get_encrypt_info when 171 /* these infor get from rtw_get_encrypt_info when
169 * * translate scan to UI */ 172 * * translate scan to UI
173 */
170 u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */ 174 u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
171 int group_cipher; /* WPA/WPA2 group cipher */ 175 int group_cipher; /* WPA/WPA2 group cipher */
172 int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */ 176 int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */
@@ -178,8 +182,8 @@ struct wlan_bcn_info {
178}; 182};
179 183
180/* temporally add #pragma pack for structure alignment issue of 184/* temporally add #pragma pack for structure alignment issue of
181* struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz() 185 * struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz()
182*/ 186 */
183struct wlan_bssid_ex { 187struct wlan_bssid_ex {
184 u32 Length; 188 u32 Length;
185 unsigned char MacAddress[ETH_ALEN]; 189 unsigned char MacAddress[ETH_ALEN];
@@ -194,7 +198,8 @@ struct wlan_bssid_ex {
194 struct wlan_phy_info PhyInfo; 198 struct wlan_phy_info PhyInfo;
195 u32 IELength; 199 u32 IELength;
196 u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and 200 u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and
197 * capability information) */ 201 * capability information)
202 */
198} __packed; 203} __packed;
199 204
200static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) 205static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss)
@@ -206,7 +211,8 @@ struct wlan_network {
206 struct list_head list; 211 struct list_head list;
207 int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */ 212 int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */
208 int fixed; /* set fixed when not to be removed 213 int fixed; /* set fixed when not to be removed
209 * in site-surveying */ 214 * in site-surveying
215 */
210 unsigned long last_scanned; /* timestamp for the network */ 216 unsigned long last_scanned; /* timestamp for the network */
211 int aid; /* will only be valid when a BSS is joinned. */ 217 int aid; /* will only be valid when a BSS is joinned. */
212 int join_res; 218 int join_res;
diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index bc756267c7fc..831c1ecc5e28 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -24,12 +24,10 @@ void rtw_init_mlme_timer(struct adapter *padapter)
24{ 24{
25 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 25 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
26 26
27 setup_timer(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 27 timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0);
28 (unsigned long)padapter); 28 timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0);
29 setup_timer(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 29 timer_setup(&pmlmepriv->dynamic_chk_timer,
30 (unsigned long)padapter); 30 rtw_dynamic_check_timer_handlder, 0);
31 setup_timer(&pmlmepriv->dynamic_chk_timer,
32 rtw_dynamic_check_timer_handlder, (unsigned long)padapter);
33} 31}
34 32
35void rtw_os_indicate_connect(struct adapter *adapter) 33void rtw_os_indicate_connect(struct adapter *adapter)
@@ -125,18 +123,15 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
125 123
126void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) 124void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
127{ 125{
128 setup_timer(&psta->addba_retry_timer, addba_timer_hdl, 126 timer_setup(&psta->addba_retry_timer, addba_timer_hdl, 0);
129 (unsigned long)psta);
130} 127}
131 128
132void init_mlme_ext_timer(struct adapter *padapter) 129void init_mlme_ext_timer(struct adapter *padapter)
133{ 130{
134 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 131 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
135 132
136 setup_timer(&pmlmeext->survey_timer, survey_timer_hdl, 133 timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0);
137 (unsigned long)padapter); 134 timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0);
138 setup_timer(&pmlmeext->link_timer, link_timer_hdl,
139 (unsigned long)padapter);
140} 135}
141 136
142#ifdef CONFIG_88EU_AP_MODE 137#ifdef CONFIG_88EU_AP_MODE
diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c
index 37fd52d7364f..225c23fc69dc 100644
--- a/drivers/staging/rtl8188eu/os_dep/mon.c
+++ b/drivers/staging/rtl8188eu/os_dep/mon.c
@@ -66,34 +66,6 @@ static void mon_recv_decrypted(struct net_device *dev, const u8 *data,
66 netif_rx(skb); 66 netif_rx(skb);
67} 67}
68 68
69static void mon_recv_decrypted_recv(struct net_device *dev, const u8 *data,
70 int data_len)
71{
72 struct sk_buff *skb;
73 struct ieee80211_hdr *hdr;
74 int hdr_len;
75
76 skb = netdev_alloc_skb(dev, data_len);
77 if (!skb)
78 return;
79 memcpy(skb_put(skb, data_len), data, data_len);
80
81 /*
82 * Frame data is not encrypted. Strip off protection so
83 * userspace doesn't think that it is.
84 */
85
86 hdr = (struct ieee80211_hdr *)skb->data;
87 hdr_len = ieee80211_hdrlen(hdr->frame_control);
88
89 if (ieee80211_has_protected(hdr->frame_control))
90 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_PROTECTED);
91
92 skb->ip_summed = CHECKSUM_UNNECESSARY;
93 skb->protocol = eth_type_trans(skb, dev);
94 netif_rx(skb);
95}
96
97static void mon_recv_encrypted(struct net_device *dev, const u8 *data, 69static void mon_recv_encrypted(struct net_device *dev, const u8 *data,
98 int data_len) 70 int data_len)
99{ 71{
@@ -110,6 +82,7 @@ static void mon_recv_encrypted(struct net_device *dev, const u8 *data,
110void rtl88eu_mon_recv_hook(struct net_device *dev, struct recv_frame *frame) 82void rtl88eu_mon_recv_hook(struct net_device *dev, struct recv_frame *frame)
111{ 83{
112 struct rx_pkt_attrib *attr; 84 struct rx_pkt_attrib *attr;
85 int iv_len, icv_len;
113 int data_len; 86 int data_len;
114 u8 *data; 87 u8 *data;
115 88
@@ -122,8 +95,11 @@ void rtl88eu_mon_recv_hook(struct net_device *dev, struct recv_frame *frame)
122 data = frame->pkt->data; 95 data = frame->pkt->data;
123 data_len = frame->pkt->len; 96 data_len = frame->pkt->len;
124 97
98 /* Broadcast and multicast frames don't have attr->{iv,icv}_len set */
99 SET_ICE_IV_LEN(iv_len, icv_len, attr->encrypt);
100
125 if (attr->bdecrypted) 101 if (attr->bdecrypted)
126 mon_recv_decrypted_recv(dev, data, data_len); 102 mon_recv_decrypted(dev, data, data_len, iv_len, icv_len);
127 else 103 else
128 mon_recv_encrypted(dev, data, data_len); 104 mon_recv_encrypted(dev, data, data_len);
129} 105}
diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
index d14bc2b68d98..bda4ab879f58 100644
--- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
@@ -155,7 +155,6 @@ _recv_indicatepkt_drop:
155void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) 155void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
156{ 156{
157 157
158 setup_timer(&preorder_ctrl->reordering_ctrl_timer, 158 timer_setup(&preorder_ctrl->reordering_ctrl_timer,
159 rtw_reordering_ctrl_timeout_handler, 159 rtw_reordering_ctrl_timeout_handler, 0);
160 (unsigned long)preorder_ctrl);
161} 160}
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 64397b6f1248..7e75030475f7 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -407,6 +407,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
407 case -ENODEV: 407 case -ENODEV:
408 case -ESHUTDOWN: 408 case -ESHUTDOWN:
409 adapt->bSurpriseRemoved = true; 409 adapt->bSurpriseRemoved = true;
410 /* fall through */
410 case -ENOENT: 411 case -ENOENT:
411 adapt->bDriverStopped = true; 412 adapt->bDriverStopped = true;
412 RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); 413 RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n"));
diff --git a/drivers/staging/rtl8192e/dot11d.c b/drivers/staging/rtl8192e/dot11d.c
index 017fe04ebe2d..88f89d77b511 100644
--- a/drivers/staging/rtl8192e/dot11d.c
+++ b/drivers/staging/rtl8192e/dot11d.c
@@ -128,12 +128,16 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
128 pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3); 128 pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3);
129 for (i = 0; i < NumTriples; i++) { 129 for (i = 0; i < NumTriples; i++) {
130 if (MaxChnlNum >= pTriple->FirstChnl) { 130 if (MaxChnlNum >= pTriple->FirstChnl) {
131 netdev_info(dev->dev, "Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); 131 netdev_info(dev->dev,
132 "%s: Invalid country IE, skip it......1\n",
133 __func__);
132 return; 134 return;
133 } 135 }
134 if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + 136 if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl +
135 pTriple->NumChnls)) { 137 pTriple->NumChnls)) {
136 netdev_info(dev->dev, "Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n"); 138 netdev_info(dev->dev,
139 "%s: Invalid country IE, skip it......2\n",
140 __func__);
137 return; 141 return;
138 } 142 }
139 143
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index aca52654825b..d2605158546b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -85,7 +85,7 @@ static struct pci_driver rtl8192_pci_driver = {
85 85
86static short _rtl92e_is_tx_queue_empty(struct net_device *dev); 86static short _rtl92e_is_tx_queue_empty(struct net_device *dev);
87static void _rtl92e_watchdog_wq_cb(void *data); 87static void _rtl92e_watchdog_wq_cb(void *data);
88static void _rtl92e_watchdog_timer_cb(unsigned long data); 88static void _rtl92e_watchdog_timer_cb(struct timer_list *t);
89static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, 89static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
90 int rate); 90 int rate);
91static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev); 91static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -766,12 +766,12 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset)
766 priv->bfirst_init = false; 766 priv->bfirst_init = false;
767 767
768 if (priv->polling_timer_on == 0) 768 if (priv->polling_timer_on == 0)
769 rtl92e_check_rfctrl_gpio_timer((unsigned long)dev); 769 rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer);
770 770
771 if (priv->rtllib->state != RTLLIB_LINKED) 771 if (priv->rtllib->state != RTLLIB_LINKED)
772 rtllib_softmac_start_protocol(priv->rtllib, 0); 772 rtllib_softmac_start_protocol(priv->rtllib, 0);
773 rtllib_reset_queue(priv->rtllib); 773 rtllib_reset_queue(priv->rtllib);
774 _rtl92e_watchdog_timer_cb((unsigned long)dev); 774 _rtl92e_watchdog_timer_cb(&priv->watch_dog_timer);
775 775
776 if (!netif_queue_stopped(dev)) 776 if (!netif_queue_stopped(dev))
777 netif_start_queue(dev); 777 netif_start_queue(dev);
@@ -1075,13 +1075,10 @@ static short _rtl92e_init(struct net_device *dev)
1075 1075
1076 rtl92e_dm_init(dev); 1076 rtl92e_dm_init(dev);
1077 1077
1078 setup_timer(&priv->watch_dog_timer, 1078 timer_setup(&priv->watch_dog_timer, _rtl92e_watchdog_timer_cb, 0);
1079 _rtl92e_watchdog_timer_cb,
1080 (unsigned long)dev);
1081 1079
1082 setup_timer(&priv->gpio_polling_timer, 1080 timer_setup(&priv->gpio_polling_timer, rtl92e_check_rfctrl_gpio_timer,
1083 rtl92e_check_rfctrl_gpio_timer, 1081 0);
1084 (unsigned long)dev);
1085 1082
1086 rtl92e_irq_disable(dev); 1083 rtl92e_irq_disable(dev);
1087 if (request_irq(dev->irq, _rtl92e_irq, IRQF_SHARED, dev->name, dev)) { 1084 if (request_irq(dev->irq, _rtl92e_irq, IRQF_SHARED, dev->name, dev)) {
@@ -1531,9 +1528,9 @@ static void _rtl92e_watchdog_wq_cb(void *data)
1531 RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); 1528 RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
1532} 1529}
1533 1530
1534static void _rtl92e_watchdog_timer_cb(unsigned long data) 1531static void _rtl92e_watchdog_timer_cb(struct timer_list *t)
1535{ 1532{
1536 struct r8192_priv *priv = rtllib_priv((struct net_device *)data); 1533 struct r8192_priv *priv = from_timer(priv, t, watch_dog_timer);
1537 1534
1538 schedule_delayed_work(&priv->watch_dog_wq, 0); 1535 schedule_delayed_work(&priv->watch_dog_wq, 0);
1539 mod_timer(&priv->watch_dog_timer, jiffies + 1536 mod_timer(&priv->watch_dog_timer, jiffies +
@@ -2535,7 +2532,7 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev,
2535 RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); 2532 RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name);
2536 2533
2537 if (priv->polling_timer_on == 0) 2534 if (priv->polling_timer_on == 0)
2538 rtl92e_check_rfctrl_gpio_timer((unsigned long)dev); 2535 rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer);
2539 2536
2540 RT_TRACE(COMP_INIT, "Driver probe completed\n"); 2537 RT_TRACE(COMP_INIT, "Driver probe completed\n");
2541 return 0; 2538 return 0;
@@ -2648,9 +2645,9 @@ bool rtl92e_disable_nic(struct net_device *dev)
2648 2645
2649module_pci_driver(rtl8192_pci_driver); 2646module_pci_driver(rtl8192_pci_driver);
2650 2647
2651void rtl92e_check_rfctrl_gpio_timer(unsigned long data) 2648void rtl92e_check_rfctrl_gpio_timer(struct timer_list *t)
2652{ 2649{
2653 struct r8192_priv *priv = rtllib_priv((struct net_device *)data); 2650 struct r8192_priv *priv = from_timer(priv, t, gpio_polling_timer);
2654 2651
2655 priv->polling_timer_on = 1; 2652 priv->polling_timer_on = 1;
2656 2653
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 9d3089cb6a5a..866fe4d4cb28 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -587,7 +587,7 @@ void rtl92e_tx_enable(struct net_device *);
587void rtl92e_hw_sleep_wq(void *data); 587void rtl92e_hw_sleep_wq(void *data);
588void rtl92e_commit(struct net_device *dev); 588void rtl92e_commit(struct net_device *dev);
589 589
590void rtl92e_check_rfctrl_gpio_timer(unsigned long data); 590void rtl92e_check_rfctrl_gpio_timer(struct timer_list *t);
591 591
592void rtl92e_hw_wakeup_wq(void *data); 592void rtl92e_hw_wakeup_wq(void *data);
593 593
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index b8205ebafd72..9bf95bd0ad13 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -196,7 +196,7 @@ static void _rtl92e_dm_check_txrateandretrycount(struct net_device *dev);
196static void _rtl92e_dm_check_ac_dc_power(struct net_device *dev); 196static void _rtl92e_dm_check_ac_dc_power(struct net_device *dev);
197static void _rtl92e_dm_check_fsync(struct net_device *dev); 197static void _rtl92e_dm_check_fsync(struct net_device *dev);
198static void _rtl92e_dm_check_rf_ctrl_gpio(void *data); 198static void _rtl92e_dm_check_rf_ctrl_gpio(void *data);
199static void _rtl92e_dm_fsync_timer_callback(unsigned long data); 199static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t);
200 200
201/*---------------------Define local function prototype-----------------------*/ 201/*---------------------Define local function prototype-----------------------*/
202 202
@@ -2125,8 +2125,7 @@ static void _rtl92e_dm_init_fsync(struct net_device *dev)
2125 priv->rtllib->fsync_state = Default_Fsync; 2125 priv->rtllib->fsync_state = Default_Fsync;
2126 priv->framesyncMonitor = 1; 2126 priv->framesyncMonitor = 1;
2127 2127
2128 setup_timer(&priv->fsync_timer, _rtl92e_dm_fsync_timer_callback, 2128 timer_setup(&priv->fsync_timer, _rtl92e_dm_fsync_timer_callback, 0);
2129 (unsigned long)dev);
2130} 2129}
2131 2130
2132 2131
@@ -2137,10 +2136,10 @@ static void _rtl92e_dm_deinit_fsync(struct net_device *dev)
2137 del_timer_sync(&priv->fsync_timer); 2136 del_timer_sync(&priv->fsync_timer);
2138} 2137}
2139 2138
2140static void _rtl92e_dm_fsync_timer_callback(unsigned long data) 2139static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t)
2141{ 2140{
2142 struct net_device *dev = (struct net_device *)data; 2141 struct r8192_priv *priv = from_timer(priv, t, fsync_timer);
2143 struct r8192_priv *priv = rtllib_priv((struct net_device *)data); 2142 struct net_device *dev = priv->rtllib->dev;
2144 u32 rate_index, rate_count = 0, rate_count_diff = 0; 2143 u32 rate_index, rate_count = 0, rate_count_diff = 0;
2145 bool bSwitchFromCountDiff = false; 2144 bool bSwitchFromCountDiff = false;
2146 bool bDoubleTimeInterval = false; 2145 bool bDoubleTimeInterval = false;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
index 3e3273d3e043..81a68b0b4a7f 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
@@ -91,7 +91,7 @@ int rtl92e_resume(struct pci_dev *pdev)
91 pci_enable_wake(pdev, PCI_D0, 0); 91 pci_enable_wake(pdev, PCI_D0, 0);
92 92
93 if (priv->polling_timer_on == 0) 93 if (priv->polling_timer_on == 0)
94 rtl92e_check_rfctrl_gpio_timer((unsigned long)dev); 94 rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer);
95 95
96 if (!netif_running(dev)) { 96 if (!netif_running(dev)) {
97 netdev_info(dev, 97 netdev_info(dev,
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 1720e1b6ae04..eb6d841f7c45 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -528,18 +528,20 @@ void TsInitDelBA(struct rtllib_device *ieee,
528 } 528 }
529} 529}
530 530
531void BaSetupTimeOut(unsigned long data) 531void BaSetupTimeOut(struct timer_list *t)
532{ 532{
533 struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; 533 struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
534 TxPendingBARecord.Timer);
534 535
535 pTxTs->bAddBaReqInProgress = false; 536 pTxTs->bAddBaReqInProgress = false;
536 pTxTs->bAddBaReqDelayed = true; 537 pTxTs->bAddBaReqDelayed = true;
537 pTxTs->TxPendingBARecord.bValid = false; 538 pTxTs->TxPendingBARecord.bValid = false;
538} 539}
539 540
540void TxBaInactTimeout(unsigned long data) 541void TxBaInactTimeout(struct timer_list *t)
541{ 542{
542 struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; 543 struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
544 TxAdmittedBARecord.Timer);
543 struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, 545 struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device,
544 TxTsRecord[pTxTs->num]); 546 TxTsRecord[pTxTs->num]);
545 TxTsDeleteBA(ieee, pTxTs); 547 TxTsDeleteBA(ieee, pTxTs);
@@ -548,9 +550,10 @@ void TxBaInactTimeout(unsigned long data)
548 DELBA_REASON_TIMEOUT); 550 DELBA_REASON_TIMEOUT);
549} 551}
550 552
551void RxBaInactTimeout(unsigned long data) 553void RxBaInactTimeout(struct timer_list *t)
552{ 554{
553 struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; 555 struct rx_ts_record *pRxTs = from_timer(pRxTs, t,
556 RxAdmittedBARecord.Timer);
554 struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, 557 struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device,
555 RxTsRecord[pRxTs->num]); 558 RxTsRecord[pRxTs->num]);
556 559
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index dcc4eb691889..f839d2447b85 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -16,17 +16,18 @@
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include "rtl819x_TS.h" 17#include "rtl819x_TS.h"
18 18
19static void TsSetupTimeOut(unsigned long data) 19static void TsSetupTimeOut(struct timer_list *unused)
20{ 20{
21} 21}
22 22
23static void TsInactTimeout(unsigned long data) 23static void TsInactTimeout(struct timer_list *unused)
24{ 24{
25} 25}
26 26
27static void RxPktPendingTimeout(unsigned long data) 27static void RxPktPendingTimeout(struct timer_list *t)
28{ 28{
29 struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; 29 struct rx_ts_record *pRxTs = from_timer(pRxTs, t,
30 RxPktPendingTimer);
30 struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, 31 struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device,
31 RxTsRecord[pRxTs->num]); 32 RxTsRecord[pRxTs->num]);
32 33
@@ -96,9 +97,9 @@ static void RxPktPendingTimeout(unsigned long data)
96 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); 97 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
97} 98}
98 99
99static void TsAddBaProcess(unsigned long data) 100static void TsAddBaProcess(struct timer_list *t)
100{ 101{
101 struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; 102 struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TsAddBaTimer);
102 u8 num = pTxTs->num; 103 u8 num = pTxTs->num;
103 struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, 104 struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device,
104 TxTsRecord[num]); 105 TxTsRecord[num]);
@@ -150,24 +151,18 @@ void TSInitialize(struct rtllib_device *ieee)
150 151
151 for (count = 0; count < TOTAL_TS_NUM; count++) { 152 for (count = 0; count < TOTAL_TS_NUM; count++) {
152 pTxTS->num = count; 153 pTxTS->num = count;
153 setup_timer(&pTxTS->TsCommonInfo.SetupTimer, 154 timer_setup(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
154 TsSetupTimeOut, 155 0);
155 (unsigned long) pTxTS);
156 156
157 setup_timer(&pTxTS->TsCommonInfo.InactTimer, 157 timer_setup(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout,
158 TsInactTimeout, 158 0);
159 (unsigned long) pTxTS);
160 159
161 setup_timer(&pTxTS->TsAddBaTimer, 160 timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0);
162 TsAddBaProcess,
163 (unsigned long) pTxTS);
164 161
165 setup_timer(&pTxTS->TxPendingBARecord.Timer, 162 timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut,
166 BaSetupTimeOut, 163 0);
167 (unsigned long) pTxTS); 164 timer_setup(&pTxTS->TxAdmittedBARecord.Timer,
168 setup_timer(&pTxTS->TxAdmittedBARecord.Timer, 165 TxBaInactTimeout, 0);
169 TxBaInactTimeout,
170 (unsigned long) pTxTS);
171 166
172 ResetTxTsEntry(pTxTS); 167 ResetTxTsEntry(pTxTS);
173 list_add_tail(&pTxTS->TsCommonInfo.List, 168 list_add_tail(&pTxTS->TsCommonInfo.List,
@@ -182,21 +177,16 @@ void TSInitialize(struct rtllib_device *ieee)
182 pRxTS->num = count; 177 pRxTS->num = count;
183 INIT_LIST_HEAD(&pRxTS->RxPendingPktList); 178 INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
184 179
185 setup_timer(&pRxTS->TsCommonInfo.SetupTimer, 180 timer_setup(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
186 TsSetupTimeOut, 181 0);
187 (unsigned long) pRxTS);
188 182
189 setup_timer(&pRxTS->TsCommonInfo.InactTimer, 183 timer_setup(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout,
190 TsInactTimeout, 184 0);
191 (unsigned long) pRxTS);
192 185
193 setup_timer(&pRxTS->RxAdmittedBARecord.Timer, 186 timer_setup(&pRxTS->RxAdmittedBARecord.Timer,
194 RxBaInactTimeout, 187 RxBaInactTimeout, 0);
195 (unsigned long) pRxTS);
196 188
197 setup_timer(&pRxTS->RxPktPendingTimer, 189 timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0);
198 RxPktPendingTimeout,
199 (unsigned long) pRxTS);
200 190
201 ResetRxTsEntry(pRxTS); 191 ResetRxTsEntry(pRxTS);
202 list_add_tail(&pRxTS->TsCommonInfo.List, 192 list_add_tail(&pRxTS->TsCommonInfo.List,
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index 0042a0f6cf79..c01474a6db1e 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -2113,9 +2113,9 @@ void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
2113void TsInitDelBA(struct rtllib_device *ieee, 2113void TsInitDelBA(struct rtllib_device *ieee,
2114 struct ts_common_info *pTsCommonInfo, 2114 struct ts_common_info *pTsCommonInfo,
2115 enum tr_select TxRxSelect); 2115 enum tr_select TxRxSelect);
2116void BaSetupTimeOut(unsigned long data); 2116void BaSetupTimeOut(struct timer_list *t);
2117void TxBaInactTimeout(unsigned long data); 2117void TxBaInactTimeout(struct timer_list *t);
2118void RxBaInactTimeout(unsigned long data); 2118void RxBaInactTimeout(struct timer_list *t);
2119void ResetBaEntry(struct ba_record *pBA); 2119void ResetBaEntry(struct ba_record *pBA);
2120bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 *Addr, 2120bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 *Addr,
2121 u8 TID, enum tr_select TxRxSelect, bool bAddNewTs); 2121 u8 TID, enum tr_select TxRxSelect, bool bAddNewTs);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index e4be85af31e7..c2b9ffba354a 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -393,10 +393,10 @@ static void rtllib_send_beacon(struct rtllib_device *ieee)
393} 393}
394 394
395 395
396static void rtllib_send_beacon_cb(unsigned long _ieee) 396static void rtllib_send_beacon_cb(struct timer_list *t)
397{ 397{
398 struct rtllib_device *ieee = 398 struct rtllib_device *ieee =
399 (struct rtllib_device *) _ieee; 399 from_timer(ieee, t, beacon_timer);
400 unsigned long flags; 400 unsigned long flags;
401 401
402 spin_lock_irqsave(&ieee->beacon_lock, flags); 402 spin_lock_irqsave(&ieee->beacon_lock, flags);
@@ -1427,9 +1427,11 @@ static void rtllib_associate_abort(struct rtllib_device *ieee)
1427 spin_unlock_irqrestore(&ieee->lock, flags); 1427 spin_unlock_irqrestore(&ieee->lock, flags);
1428} 1428}
1429 1429
1430static void rtllib_associate_abort_cb(unsigned long dev) 1430static void rtllib_associate_abort_cb(struct timer_list *t)
1431{ 1431{
1432 rtllib_associate_abort((struct rtllib_device *) dev); 1432 struct rtllib_device *dev = from_timer(dev, t, associate_timer);
1433
1434 rtllib_associate_abort(dev);
1433} 1435}
1434 1436
1435static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr) 1437static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
@@ -2811,8 +2813,9 @@ exit:
2811 2813
2812static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) 2814static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
2813{ 2815{
2814 const u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 2816 static const u8 broadcast_addr[] = {
2815 2817 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2818 };
2816 struct sk_buff *skb; 2819 struct sk_buff *skb;
2817 struct rtllib_probe_response *b; 2820 struct rtllib_probe_response *b;
2818 2821
@@ -3011,13 +3014,9 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
3011 3014
3012 ieee->tx_pending.txb = NULL; 3015 ieee->tx_pending.txb = NULL;
3013 3016
3014 setup_timer(&ieee->associate_timer, 3017 timer_setup(&ieee->associate_timer, rtllib_associate_abort_cb, 0);
3015 rtllib_associate_abort_cb,
3016 (unsigned long) ieee);
3017 3018
3018 setup_timer(&ieee->beacon_timer, 3019 timer_setup(&ieee->beacon_timer, rtllib_send_beacon_cb, 0);
3019 rtllib_send_beacon_cb,
3020 (unsigned long) ieee);
3021 3020
3022 INIT_DELAYED_WORK_RSL(&ieee->link_change_wq, 3021 INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,
3023 (void *)rtllib_link_change_wq, ieee); 3022 (void *)rtllib_link_change_wq, ieee);
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index f7eba01b5d15..03fbff067fa4 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -694,8 +694,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
694 switch (mlme->cmd) { 694 switch (mlme->cmd) {
695 case IW_MLME_DEAUTH: 695 case IW_MLME_DEAUTH:
696 deauth = true; 696 deauth = true;
697 /* leave break out intentionly */ 697 /* fall through */
698
699 case IW_MLME_DISASSOC: 698 case IW_MLME_DISASSOC:
700 if (deauth) 699 if (deauth)
701 netdev_info(ieee->dev, "disauth packet !\n"); 700 netdev_info(ieee->dev, "disauth packet !\n");
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index b062cad052b9..3addaa65085a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -323,7 +323,7 @@ typedef struct ieee_param {
323 u8 key[0]; 323 u8 key[0];
324 } crypt; 324 } crypt;
325 } u; 325 } u;
326}ieee_param; 326} ieee_param;
327 327
328 328
329// linux under 2.6.9 release may not support it, so modify it for common use 329// linux under 2.6.9 release may not support it, so modify it for common use
@@ -412,15 +412,15 @@ typedef struct ieee_param {
412#define IEEE80211_QCTL_TID 0x000F 412#define IEEE80211_QCTL_TID 0x000F
413 413
414#define FC_QOS_BIT BIT(7) 414#define FC_QOS_BIT BIT(7)
415#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) 415#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
416#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) 416#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT)))
417//added by wb. Is this right? 417//added by wb. Is this right?
418#define IsQoSDataFrame(pframe) ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) 418#define IsQoSDataFrame(pframe) ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA))
419#define Frame_Order(pframe) (*(u16 *)pframe&IEEE80211_FCTL_ORDER) 419#define Frame_Order(pframe) (*(u16 *)pframe & IEEE80211_FCTL_ORDER)
420#define SN_LESS(a, b) (((a-b)&0x800)!=0) 420#define SN_LESS(a, b) (((a - b) & 0x800) != 0)
421#define SN_EQUAL(a, b) (a == b) 421#define SN_EQUAL(a, b) (a == b)
422#define MAX_DEV_ADDR_SIZE 8 422#define MAX_DEV_ADDR_SIZE 8
423typedef enum _ACT_CATEGORY{ 423typedef enum _ACT_CATEGORY {
424 ACT_CAT_QOS = 1, 424 ACT_CAT_QOS = 1,
425 ACT_CAT_DLS = 2, 425 ACT_CAT_DLS = 2,
426 ACT_CAT_BA = 3, 426 ACT_CAT_BA = 3,
@@ -428,24 +428,24 @@ typedef enum _ACT_CATEGORY{
428 ACT_CAT_WMM = 17, 428 ACT_CAT_WMM = 17,
429} ACT_CATEGORY, *PACT_CATEGORY; 429} ACT_CATEGORY, *PACT_CATEGORY;
430 430
431typedef enum _TS_ACTION{ 431typedef enum _TS_ACTION {
432 ACT_ADDTSREQ = 0, 432 ACT_ADDTSREQ = 0,
433 ACT_ADDTSRSP = 1, 433 ACT_ADDTSRSP = 1,
434 ACT_DELTS = 2, 434 ACT_DELTS = 2,
435 ACT_SCHEDULE = 3, 435 ACT_SCHEDULE = 3,
436} TS_ACTION, *PTS_ACTION; 436} TS_ACTION, *PTS_ACTION;
437 437
438typedef enum _BA_ACTION{ 438typedef enum _BA_ACTION {
439 ACT_ADDBAREQ = 0, 439 ACT_ADDBAREQ = 0,
440 ACT_ADDBARSP = 1, 440 ACT_ADDBARSP = 1,
441 ACT_DELBA = 2, 441 ACT_DELBA = 2,
442} BA_ACTION, *PBA_ACTION; 442} BA_ACTION, *PBA_ACTION;
443 443
444typedef enum _InitialGainOpType{ 444typedef enum _InitialGainOpType {
445 IG_Backup=0, 445 IG_Backup = 0,
446 IG_Restore, 446 IG_Restore,
447 IG_Max 447 IG_Max
448}InitialGainOpType; 448} InitialGainOpType;
449 449
450/* debug macros */ 450/* debug macros */
451#define CONFIG_IEEE80211_DEBUG 451#define CONFIG_IEEE80211_DEBUG
@@ -457,22 +457,22 @@ do { if (ieee80211_debug_level & (level)) \
457//wb added to debug out data buf 457//wb added to debug out data buf
458//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA 458//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
459#define IEEE80211_DEBUG_DATA(level, data, datalen) \ 459#define IEEE80211_DEBUG_DATA(level, data, datalen) \
460 do{ if ((ieee80211_debug_level & (level)) == (level)) \ 460 do { if ((ieee80211_debug_level & (level)) == (level)) \
461 { \ 461 { \
462 int i; \ 462 int i; \
463 u8 *pdata = (u8 *) data; \ 463 u8 *pdata = (u8 *) data; \
464 printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \ 464 printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
465 for(i=0; i<(int)(datalen); i++) \ 465 for (i = 0; i < (int)(datalen); i++) \
466 { \ 466 { \
467 printk("%2x ", pdata[i]); \ 467 printk("%2x ", pdata[i]); \
468 if ((i+1)%16 == 0) printk("\n"); \ 468 if ((i + 1) % 16 == 0) printk("\n"); \
469 } \ 469 } \
470 printk("\n"); \ 470 printk("\n"); \
471 } \ 471 } \
472 } while (0) 472 } while (0)
473#else 473#else
474#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 474#define IEEE80211_DEBUG (level, fmt, args...) do {} while (0)
475#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0) 475#define IEEE80211_DEBUG_DATA (level, data, datalen) do {} while(0)
476#endif /* CONFIG_IEEE80211_DEBUG */ 476#endif /* CONFIG_IEEE80211_DEBUG */
477 477
478/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ 478/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
@@ -876,9 +876,9 @@ enum ieee80211_mfie {
876 MFIE_TYPE_ERP = 42, 876 MFIE_TYPE_ERP = 42,
877 MFIE_TYPE_RSN = 48, 877 MFIE_TYPE_RSN = 48,
878 MFIE_TYPE_RATES_EX = 50, 878 MFIE_TYPE_RATES_EX = 50,
879 MFIE_TYPE_HT_CAP= 45, 879 MFIE_TYPE_HT_CAP = 45,
880 MFIE_TYPE_HT_INFO= 61, 880 MFIE_TYPE_HT_INFO = 61,
881 MFIE_TYPE_AIRONET=133, 881 MFIE_TYPE_AIRONET = 133,
882 MFIE_TYPE_GENERIC = 221, 882 MFIE_TYPE_GENERIC = 221,
883 MFIE_TYPE_QOS_PARAMETER = 222, 883 MFIE_TYPE_QOS_PARAMETER = 222,
884}; 884};
@@ -1051,7 +1051,7 @@ typedef union _frameqos {
1051 u16 ack_policy:2; 1051 u16 ack_policy:2;
1052 u16 reserved:1; 1052 u16 reserved:1;
1053 u16 txop:8; 1053 u16 txop:8;
1054 }field; 1054 } field;
1055} frameqos, *pframeqos; 1055} frameqos, *pframeqos;
1056 1056
1057/* SWEEP TABLE ENTRIES NUMBER*/ 1057/* SWEEP TABLE ENTRIES NUMBER*/
@@ -1196,7 +1196,7 @@ static inline u8 Frame_QoSTID(u8 *buf)
1196 u16 fc; 1196 u16 fc;
1197 hdr = (struct rtl_80211_hdr_3addr *)buf; 1197 hdr = (struct rtl_80211_hdr_3addr *)buf;
1198 fc = le16_to_cpu(hdr->frame_ctl); 1198 fc = le16_to_cpu(hdr->frame_ctl);
1199 return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; 1199 return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1200} 1200}
1201 1201
1202//added by amy for reorder 1202//added by amy for reorder
@@ -1209,7 +1209,7 @@ struct eapol {
1209 u16 length; 1209 u16 length;
1210} __packed; 1210} __packed;
1211 1211
1212struct ieee80211_softmac_stats{ 1212struct ieee80211_softmac_stats {
1213 unsigned int rx_ass_ok; 1213 unsigned int rx_ass_ok;
1214 unsigned int rx_ass_err; 1214 unsigned int rx_ass_err;
1215 unsigned int rx_probe_rq; 1215 unsigned int rx_probe_rq;
@@ -1320,7 +1320,7 @@ struct ether_header {
1320#define ETHERTYPE_IP 0x0800 /* IP protocol */ 1320#define ETHERTYPE_IP 0x0800 /* IP protocol */
1321#endif 1321#endif
1322 1322
1323typedef enum _erp_t{ 1323typedef enum _erp_t {
1324 ERP_NonERPpresent = 0x01, 1324 ERP_NonERPpresent = 0x01,
1325 ERP_UseProtection = 0x02, 1325 ERP_UseProtection = 0x02,
1326 ERP_BarkerPreambleMode = 0x04, 1326 ERP_BarkerPreambleMode = 0x04,
@@ -1479,37 +1479,35 @@ typedef struct _RX_REORDER_ENTRY {
1479 struct ieee80211_rxb *prxb; 1479 struct ieee80211_rxb *prxb;
1480} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; 1480} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
1481//added by amy for order 1481//added by amy for order
1482typedef enum _Fsync_State{ 1482typedef enum _Fsync_State {
1483 Default_Fsync, 1483 Default_Fsync,
1484 HW_Fsync, 1484 HW_Fsync,
1485 SW_Fsync 1485 SW_Fsync
1486}Fsync_State; 1486} Fsync_State;
1487 1487
1488// Power save mode configured. 1488// Power save mode configured.
1489typedef enum _RT_PS_MODE 1489typedef enum _RT_PS_MODE {
1490{
1491 eActive, // Active/Continuous access. 1490 eActive, // Active/Continuous access.
1492 eMaxPs, // Max power save mode. 1491 eMaxPs, // Max power save mode.
1493 eFastPs // Fast power save mode. 1492 eFastPs // Fast power save mode.
1494}RT_PS_MODE; 1493} RT_PS_MODE;
1495 1494
1496typedef enum _IPS_CALLBACK_FUNCION 1495typedef enum _IPS_CALLBACK_FUNCION {
1497{
1498 IPS_CALLBACK_NONE = 0, 1496 IPS_CALLBACK_NONE = 0,
1499 IPS_CALLBACK_MGNT_LINK_REQUEST = 1, 1497 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1500 IPS_CALLBACK_JOIN_REQUEST = 2, 1498 IPS_CALLBACK_JOIN_REQUEST = 2,
1501}IPS_CALLBACK_FUNCION; 1499} IPS_CALLBACK_FUNCION;
1502 1500
1503typedef enum _RT_JOIN_ACTION{ 1501typedef enum _RT_JOIN_ACTION {
1504 RT_JOIN_INFRA = 1, 1502 RT_JOIN_INFRA = 1,
1505 RT_JOIN_IBSS = 2, 1503 RT_JOIN_IBSS = 2,
1506 RT_START_IBSS = 3, 1504 RT_START_IBSS = 3,
1507 RT_NO_ACTION = 4, 1505 RT_NO_ACTION = 4,
1508}RT_JOIN_ACTION; 1506} RT_JOIN_ACTION;
1509 1507
1510typedef struct _IbssParms{ 1508typedef struct _IbssParms {
1511 u16 atimWin; 1509 u16 atimWin;
1512}IbssParms, *PIbssParms; 1510} IbssParms, *PIbssParms;
1513#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. 1511#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko.
1514 1512
1515// RF state. 1513// RF state.
@@ -1517,7 +1515,7 @@ typedef enum _RT_RF_POWER_STATE {
1517 eRfOn, 1515 eRfOn,
1518 eRfSleep, 1516 eRfSleep,
1519 eRfOff 1517 eRfOff
1520}RT_RF_POWER_STATE; 1518} RT_RF_POWER_STATE;
1521 1519
1522typedef struct _RT_POWER_SAVE_CONTROL { 1520typedef struct _RT_POWER_SAVE_CONTROL {
1523 1521
@@ -1572,8 +1570,7 @@ typedef u32 RT_RF_CHANGE_SOURCE;
1572#define RF_CHANGE_BY_IPS BIT(28) 1570#define RF_CHANGE_BY_IPS BIT(28)
1573#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17. 1571#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
1574 1572
1575typedef enum 1573typedef enum {
1576{
1577 COUNTRY_CODE_FCC = 0, 1574 COUNTRY_CODE_FCC = 0,
1578 COUNTRY_CODE_IC = 1, 1575 COUNTRY_CODE_IC = 1,
1579 COUNTRY_CODE_ETSI = 2, 1576 COUNTRY_CODE_ETSI = 2,
@@ -1585,10 +1582,10 @@ typedef enum
1585 COUNTRY_CODE_TELEC, 1582 COUNTRY_CODE_TELEC,
1586 COUNTRY_CODE_MIC, 1583 COUNTRY_CODE_MIC,
1587 COUNTRY_CODE_GLOBAL_DOMAIN 1584 COUNTRY_CODE_GLOBAL_DOMAIN
1588}country_code_type_t; 1585} country_code_type_t;
1589 1586
1590#define RT_MAX_LD_SLOT_NUM 10 1587#define RT_MAX_LD_SLOT_NUM 10
1591typedef struct _RT_LINK_DETECT_T{ 1588typedef struct _RT_LINK_DETECT_T {
1592 1589
1593 u32 NumRecvBcnInPeriod; 1590 u32 NumRecvBcnInPeriod;
1594 u32 NumRecvDataInPeriod; 1591 u32 NumRecvDataInPeriod;
@@ -1601,7 +1598,7 @@ typedef struct _RT_LINK_DETECT_T{
1601 u32 NumTxOkInPeriod; 1598 u32 NumTxOkInPeriod;
1602 u32 NumRxOkInPeriod; 1599 u32 NumRxOkInPeriod;
1603 bool bBusyTraffic; 1600 bool bBusyTraffic;
1604}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; 1601} RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
1605 1602
1606 1603
1607struct ieee80211_device { 1604struct ieee80211_device {
@@ -1917,11 +1914,11 @@ struct ieee80211_device {
1917 struct net_device *dev); 1914 struct net_device *dev);
1918 1915
1919 int (*reset_port)(struct net_device *dev); 1916 int (*reset_port)(struct net_device *dev);
1920 int (*is_queue_full) (struct net_device *dev, int pri); 1917 int (*is_queue_full)(struct net_device *dev, int pri);
1921 1918
1922 int (*handle_management) (struct net_device *dev, 1919 int (*handle_management)(struct net_device *dev,
1923 struct ieee80211_network *network, u16 type); 1920 struct ieee80211_network *network, u16 type);
1924 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); 1921 int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1925 1922
1926 /* Softmac-generated frames (management) are TXed via this 1923 /* Softmac-generated frames (management) are TXed via this
1927 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is 1924 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
@@ -1989,16 +1986,16 @@ struct ieee80211_device {
1989 * stop_send_bacons is NOT guaranteed to be called only 1986 * stop_send_bacons is NOT guaranteed to be called only
1990 * after start_send_beacons. 1987 * after start_send_beacons.
1991 */ 1988 */
1992 void (*start_send_beacons) (struct net_device *dev,u16 tx_rate); 1989 void (*start_send_beacons)(struct net_device *dev, u16 tx_rate);
1993 void (*stop_send_beacons) (struct net_device *dev); 1990 void (*stop_send_beacons)(struct net_device *dev);
1994 1991
1995 /* power save mode related */ 1992 /* power save mode related */
1996 void (*sta_wake_up) (struct net_device *dev); 1993 void (*sta_wake_up)(struct net_device *dev);
1997 void (*ps_request_tx_ack) (struct net_device *dev); 1994 void (*ps_request_tx_ack)(struct net_device *dev);
1998 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); 1995 void (*enter_sleep_state)(struct net_device *dev, u32 th, u32 tl);
1999 short (*ps_is_queue_empty) (struct net_device *dev); 1996 short (*ps_is_queue_empty)(struct net_device *dev);
2000 int (*handle_beacon) (struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network); 1997 int (*handle_beacon)(struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network);
2001 int (*handle_assoc_response) (struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network); 1998 int (*handle_assoc_response)(struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network);
2002 1999
2003 2000
2004 /* check whether Tx hw resource available */ 2001 /* check whether Tx hw resource available */
@@ -2023,7 +2020,7 @@ struct ieee80211_device {
2023#define IEEE_G (1<<2) 2020#define IEEE_G (1<<2)
2024#define IEEE_N_24G (1<<4) 2021#define IEEE_N_24G (1<<4)
2025#define IEEE_N_5G (1<<5) 2022#define IEEE_N_5G (1<<5)
2026#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 2023#define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
2027 2024
2028/* Generate a 802.11 header */ 2025/* Generate a 802.11 header */
2029 2026
@@ -2112,7 +2109,7 @@ static inline int ieee80211_get_hdrlen(u16 fc)
2112 case IEEE80211_FTYPE_DATA: 2109 case IEEE80211_FTYPE_DATA:
2113 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) 2110 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
2114 hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */ 2111 hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
2115 if(IEEE80211_QOS_HAS_SEQ(fc)) 2112 if (IEEE80211_QOS_HAS_SEQ(fc))
2116 hdrlen += 2; /* QOS ctrl*/ 2113 hdrlen += 2; /* QOS ctrl*/
2117 break; 2114 break;
2118 case IEEE80211_FTYPE_CTL: 2115 case IEEE80211_FTYPE_CTL:
@@ -2379,7 +2376,7 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
2379u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, 2376u8 HTGetHighestMCSRate(struct ieee80211_device *ieee,
2380 u8 *pMCSRateSet, u8 *pMCSFilter); 2377 u8 *pMCSRateSet, u8 *pMCSFilter);
2381extern u8 MCS_FILTER_ALL[]; 2378extern u8 MCS_FILTER_ALL[];
2382extern u16 MCS_DATA_RATE[2][2][77] ; 2379extern u16 MCS_DATA_RATE[2][2][77];
2383u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); 2380u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
2384//extern void HTSetConnectBwModeCallback(unsigned long data); 2381//extern void HTSetConnectBwModeCallback(unsigned long data);
2385void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); 2382void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
@@ -2395,9 +2392,9 @@ void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS,
2395 u8 Policy, u8 bOverwritePending); 2392 u8 Policy, u8 bOverwritePending);
2396void TsInitDelBA(struct ieee80211_device *ieee, 2393void TsInitDelBA(struct ieee80211_device *ieee,
2397 PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); 2394 PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
2398void BaSetupTimeOut(unsigned long data); 2395void BaSetupTimeOut(struct timer_list *t);
2399void TxBaInactTimeout(unsigned long data); 2396void TxBaInactTimeout(struct timer_list *t);
2400void RxBaInactTimeout(unsigned long data); 2397void RxBaInactTimeout(struct timer_list *t);
2401void ResetBaEntry(PBA_RECORD pBA); 2398void ResetBaEntry(PBA_RECORD pBA);
2402//function in TS.c 2399//function in TS.c
2403bool GetTs( 2400bool GetTs(
@@ -2426,7 +2423,8 @@ static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2426 return ieee->scans; 2423 return ieee->scans;
2427} 2424}
2428 2425
2429static inline const char *escape_essid(const char *essid, u8 essid_len) { 2426static inline const char *escape_essid(const char *essid, u8 essid_len)
2427{
2430 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 2428 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2431 2429
2432 if (ieee80211_is_empty_essid(essid, essid_len)) { 2430 if (ieee80211_is_empty_essid(essid, essid_len)) {
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
index 48e80be90ba5..6f457812e5a3 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
@@ -57,9 +57,9 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
57 } 57 }
58} 58}
59 59
60void ieee80211_crypt_deinit_handler(unsigned long data) 60void ieee80211_crypt_deinit_handler(struct timer_list *t)
61{ 61{
62 struct ieee80211_device *ieee = (struct ieee80211_device *)data; 62 struct ieee80211_device *ieee = from_timer(ieee, t, crypt_deinit_timer);
63 unsigned long flags; 63 unsigned long flags;
64 64
65 spin_lock_irqsave(&ieee->lock, flags); 65 spin_lock_irqsave(&ieee->lock, flags);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.h b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.h
index a0aa0f5be63a..1f2aea7e0e55 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.h
@@ -83,7 +83,7 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
83int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); 83int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
84struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); 84struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
85void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force); 85void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force);
86void ieee80211_crypt_deinit_handler(unsigned long data); 86void ieee80211_crypt_deinit_handler(struct timer_list *t);
87void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, 87void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
88 struct ieee80211_crypt_data **crypt); 88 struct ieee80211_crypt_data **crypt);
89 89
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index 8f236b332a47..90a097f2cd4e 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -133,8 +133,8 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
133 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ 133 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
134 134
135 INIT_LIST_HEAD(&ieee->crypt_deinit_list); 135 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
136 setup_timer(&ieee->crypt_deinit_timer, 136 timer_setup(&ieee->crypt_deinit_timer, ieee80211_crypt_deinit_handler,
137 ieee80211_crypt_deinit_handler, (unsigned long)ieee); 137 0);
138 138
139 spin_lock_init(&ieee->lock); 139 spin_lock_init(&ieee->lock);
140 spin_lock_init(&ieee->wpax_suitlist_lock); 140 spin_lock_init(&ieee->wpax_suitlist_lock);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index fe6f38b7ec35..4e7908322d77 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2948,8 +2948,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
2948 struct ieee_param *param, int param_len) 2948 struct ieee_param *param, int param_len)
2949{ 2949{
2950 int ret = 0; 2950 int ret = 0;
2951 const char *module = NULL;
2951 2952
2952 struct ieee80211_crypto_ops *ops; 2953 struct ieee80211_crypto_ops *ops = NULL;
2953 struct ieee80211_crypt_data **crypt; 2954 struct ieee80211_crypt_data **crypt;
2954 2955
2955 struct ieee80211_security sec = { 2956 struct ieee80211_security sec = {
@@ -2995,19 +2996,17 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
2995 strcmp(param->u.crypt.alg, "TKIP")) 2996 strcmp(param->u.crypt.alg, "TKIP"))
2996 goto skip_host_crypt; 2997 goto skip_host_crypt;
2997 2998
2998 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 2999 //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place
2999 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { 3000 if (!strcmp(param->u.crypt.alg, "WEP"))
3000 request_module("ieee80211_crypt_wep"); 3001 module = "ieee80211_crypt_wep";
3001 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 3002 else if (!strcmp(param->u.crypt.alg, "TKIP"))
3002 //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place 3003 module = "ieee80211_crypt_tkip";
3003 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { 3004 else if (!strcmp(param->u.crypt.alg, "CCMP"))
3004 request_module("ieee80211_crypt_tkip"); 3005 module = "ieee80211_crypt_ccmp";
3005 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 3006 if (module)
3006 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { 3007 ops = try_then_request_module(ieee80211_get_crypto_ops(param->u.crypt.alg),
3007 request_module("ieee80211_crypt_ccmp"); 3008 module);
3008 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 3009 if (!ops) {
3009 }
3010 if (ops == NULL) {
3011 printk("unknown crypto alg '%s'\n", param->u.crypt.alg); 3010 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
3012 param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; 3011 param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
3013 ret = -EINVAL; 3012 ret = -EINVAL;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index f58971a4a2e3..9a1a84548bc6 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -302,7 +302,6 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
302 } 302 }
303} 303}
304 304
305#define SN_LESS(a, b) (((a-b)&0x800)!=0)
306static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, 305static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
307 struct sk_buff *skb, struct cb_desc *tcb_desc) 306 struct sk_buff *skb, struct cb_desc *tcb_desc)
308{ 307{
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index c925e53bf013..f2fcdec9bd17 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -364,11 +364,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
364 GFP_KERNEL); 364 GFP_KERNEL);
365 if (!new_crypt) 365 if (!new_crypt)
366 return -ENOMEM; 366 return -ENOMEM;
367 new_crypt->ops = ieee80211_get_crypto_ops("WEP"); 367 new_crypt->ops = try_then_request_module(ieee80211_get_crypto_ops("WEP"),
368 if (!new_crypt->ops) { 368 "ieee80211_crypt_wep");
369 request_module("ieee80211_crypt_wep");
370 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
371 }
372 if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) 369 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
373 new_crypt->priv = new_crypt->ops->init(key); 370 new_crypt->priv = new_crypt->ops->init(key);
374 371
@@ -591,12 +588,8 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
591 } 588 }
592 printk("alg name:%s\n",alg); 589 printk("alg name:%s\n",alg);
593 590
594 ops = ieee80211_get_crypto_ops(alg); 591 ops = try_then_request_module(ieee80211_get_crypto_ops(alg), module);
595 if (ops == NULL) { 592 if (!ops) {
596 request_module(module);
597 ops = ieee80211_get_crypto_ops(alg);
598 }
599 if (ops == NULL) {
600 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", 593 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
601 dev->name, ext->alg); 594 dev->name, ext->alg);
602 printk("========>unknown crypto alg %d\n", ext->alg); 595 printk("========>unknown crypto alg %d\n", ext->alg);
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 8aa38dcf0dfd..4ef7d4e63931 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -143,7 +143,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P
143 143
144 if (ACT_ADDBARSP == type) { 144 if (ACT_ADDBARSP == type) {
145 // Status Code 145 // Status Code
146 printk(KERN_INFO "=====>to send ADDBARSP\n"); 146 netdev_info(ieee->dev, "=====>to send ADDBARSP\n");
147 147
148 put_unaligned_le16(StatusCode, tag); 148 put_unaligned_le16(StatusCode, tag);
149 tag += 2; 149 tag += 2;
@@ -345,7 +345,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
345 pBaTimeoutVal = (u16 *)(tag + 5); 345 pBaTimeoutVal = (u16 *)(tag + 5);
346 pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7); 346 pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
347 347
348 printk(KERN_INFO "====================>rx ADDBAREQ from :%pM\n", dst); 348 netdev_info(ieee->dev, "====================>rx ADDBAREQ from :%pM\n", dst);
349//some other capability is not ready now. 349//some other capability is not ready now.
350 if ((ieee->current_network.qos_data.active == 0) || 350 if ((ieee->current_network.qos_data.active == 0) ||
351 (!ieee->pHTInfo->bCurrentHTSupport)) //|| 351 (!ieee->pHTInfo->bCurrentHTSupport)) //||
@@ -672,18 +672,18 @@ TsInitDelBA( struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SE
672 * return: NULL 672 * return: NULL
673 * notice: 673 * notice:
674 ********************************************************************************************************************/ 674 ********************************************************************************************************************/
675void BaSetupTimeOut(unsigned long data) 675void BaSetupTimeOut(struct timer_list *t)
676{ 676{
677 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; 677 PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TxPendingBARecord.Timer);
678 678
679 pTxTs->bAddBaReqInProgress = false; 679 pTxTs->bAddBaReqInProgress = false;
680 pTxTs->bAddBaReqDelayed = true; 680 pTxTs->bAddBaReqDelayed = true;
681 pTxTs->TxPendingBARecord.bValid = false; 681 pTxTs->TxPendingBARecord.bValid = false;
682} 682}
683 683
684void TxBaInactTimeout(unsigned long data) 684void TxBaInactTimeout(struct timer_list *t)
685{ 685{
686 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; 686 PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TxAdmittedBARecord.Timer);
687 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]); 687 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
688 TxTsDeleteBA(ieee, pTxTs); 688 TxTsDeleteBA(ieee, pTxTs);
689 ieee80211_send_DELBA( 689 ieee80211_send_DELBA(
@@ -694,9 +694,9 @@ void TxBaInactTimeout(unsigned long data)
694 DELBA_REASON_TIMEOUT); 694 DELBA_REASON_TIMEOUT);
695} 695}
696 696
697void RxBaInactTimeout(unsigned long data) 697void RxBaInactTimeout(struct timer_list *t)
698{ 698{
699 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; 699 PRX_TS_RECORD pRxTs = from_timer(pRxTs, t, RxAdmittedBARecord.Timer);
700 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); 700 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
701 701
702 RxTsDeleteBA(ieee, pRxTs); 702 RxTsDeleteBA(ieee, pRxTs);
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index f98bb03aa293..602be096fa73 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -3,13 +3,13 @@
3#include <linux/slab.h> 3#include <linux/slab.h>
4#include "rtl819x_TS.h" 4#include "rtl819x_TS.h"
5 5
6static void TsSetupTimeOut(unsigned long data) 6static void TsSetupTimeOut(struct timer_list *unused)
7{ 7{
8 // Not implement yet 8 // Not implement yet
9 // This is used for WMMSA and ACM , that would send ADDTSReq frame. 9 // This is used for WMMSA and ACM , that would send ADDTSReq frame.
10} 10}
11 11
12static void TsInactTimeout(unsigned long data) 12static void TsInactTimeout(struct timer_list *unused)
13{ 13{
14 // Not implement yet 14 // Not implement yet
15 // This is used for WMMSA and ACM. 15 // This is used for WMMSA and ACM.
@@ -22,9 +22,9 @@ static void TsInactTimeout(unsigned long data)
22 * return: NULL 22 * return: NULL
23 * notice: 23 * notice:
24 ********************************************************************************************************************/ 24 ********************************************************************************************************************/
25static void RxPktPendingTimeout(unsigned long data) 25static void RxPktPendingTimeout(struct timer_list *t)
26{ 26{
27 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; 27 PRX_TS_RECORD pRxTs = from_timer(pRxTs, t, RxPktPendingTimer);
28 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); 28 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
29 29
30 PRX_REORDER_ENTRY pReorderEntry = NULL; 30 PRX_REORDER_ENTRY pReorderEntry = NULL;
@@ -89,9 +89,9 @@ static void RxPktPendingTimeout(unsigned long data)
89 * return: NULL 89 * return: NULL
90 * notice: 90 * notice:
91 ********************************************************************************************************************/ 91 ********************************************************************************************************************/
92static void TsAddBaProcess(unsigned long data) 92static void TsAddBaProcess(struct timer_list *t)
93{ 93{
94 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; 94 PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TsAddBaTimer);
95 u8 num = pTxTs->num; 95 u8 num = pTxTs->num;
96 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); 96 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]);
97 97
@@ -145,16 +145,15 @@ void TSInitialize(struct ieee80211_device *ieee)
145 pTxTS->num = count; 145 pTxTS->num = count;
146 // The timers for the operation of Traffic Stream and Block Ack. 146 // The timers for the operation of Traffic Stream and Block Ack.
147 // DLS related timer will be add here in the future!! 147 // DLS related timer will be add here in the future!!
148 setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, 148 timer_setup(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
149 (unsigned long)pTxTS); 149 0);
150 setup_timer(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout, 150 timer_setup(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout,
151 (unsigned long)pTxTS); 151 0);
152 setup_timer(&pTxTS->TsAddBaTimer, TsAddBaProcess, 152 timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0);
153 (unsigned long)pTxTS); 153 timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut,
154 setup_timer(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut, 154 0);
155 (unsigned long)pTxTS); 155 timer_setup(&pTxTS->TxAdmittedBARecord.Timer,
156 setup_timer(&pTxTS->TxAdmittedBARecord.Timer, 156 TxBaInactTimeout, 0);
157 TxBaInactTimeout, (unsigned long)pTxTS);
158 ResetTxTsEntry(pTxTS); 157 ResetTxTsEntry(pTxTS);
159 list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List); 158 list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List);
160 pTxTS++; 159 pTxTS++;
@@ -167,14 +166,13 @@ void TSInitialize(struct ieee80211_device *ieee)
167 for(count = 0; count < TOTAL_TS_NUM; count++) { 166 for(count = 0; count < TOTAL_TS_NUM; count++) {
168 pRxTS->num = count; 167 pRxTS->num = count;
169 INIT_LIST_HEAD(&pRxTS->RxPendingPktList); 168 INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
170 setup_timer(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, 169 timer_setup(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
171 (unsigned long)pRxTS); 170 0);
172 setup_timer(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout, 171 timer_setup(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout,
173 (unsigned long)pRxTS); 172 0);
174 setup_timer(&pRxTS->RxAdmittedBARecord.Timer, 173 timer_setup(&pRxTS->RxAdmittedBARecord.Timer,
175 RxBaInactTimeout, (unsigned long)pRxTS); 174 RxBaInactTimeout, 0);
176 setup_timer(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 175 timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0);
177 (unsigned long)pRxTS);
178 ResetRxTsEntry(pRxTS); 176 ResetRxTsEntry(pRxTS);
179 list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); 177 list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
180 pRxTS++; 178 pRxTS++;
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 46b3f19e0878..09f66b386e44 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -497,7 +497,7 @@ inline void force_pci_posting(struct net_device *dev)
497 497
498static struct net_device_stats *rtl8192_stats(struct net_device *dev); 498static struct net_device_stats *rtl8192_stats(struct net_device *dev);
499static void rtl8192_restart(struct work_struct *work); 499static void rtl8192_restart(struct work_struct *work);
500static void watch_dog_timer_callback(unsigned long data); 500static void watch_dog_timer_callback(struct timer_list *t);
501 501
502/**************************************************************************** 502/****************************************************************************
503 * -----------------------------PROCFS STUFF------------------------- 503 * -----------------------------PROCFS STUFF-------------------------
@@ -1687,9 +1687,13 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
1687#ifndef JACKSON_NEW_RX 1687#ifndef JACKSON_NEW_RX
1688 for (i = 0; i < (MAX_RX_URB + 1); i++) { 1688 for (i = 0; i < (MAX_RX_URB + 1); i++) {
1689 priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); 1689 priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
1690 if (!priv->rx_urb[i])
1691 return -ENOMEM;
1690 1692
1691 priv->rx_urb[i]->transfer_buffer = 1693 priv->rx_urb[i]->transfer_buffer =
1692 kmalloc(RX_URB_SIZE, GFP_KERNEL); 1694 kmalloc(RX_URB_SIZE, GFP_KERNEL);
1695 if (!priv->rx_urb[i]->transfer_buffer)
1696 return -ENOMEM;
1693 1697
1694 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; 1698 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
1695 } 1699 }
@@ -2690,15 +2694,11 @@ static short rtl8192_init(struct net_device *dev)
2690 err = rtl8192_read_eeprom_info(dev); 2694 err = rtl8192_read_eeprom_info(dev);
2691 if (err) { 2695 if (err) {
2692 DMESG("Reading EEPROM info failed"); 2696 DMESG("Reading EEPROM info failed");
2693 kfree(priv->pFirmware);
2694 priv->pFirmware = NULL;
2695 free_ieee80211(dev);
2696 return err; 2697 return err;
2697 } 2698 }
2698 rtl8192_get_channel_map(dev); 2699 rtl8192_get_channel_map(dev);
2699 init_hal_dm(dev); 2700 init_hal_dm(dev);
2700 setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback, 2701 timer_setup(&priv->watch_dog_timer, watch_dog_timer_callback, 0);
2701 (unsigned long)dev);
2702 if (rtl8192_usb_initendpoints(dev) != 0) { 2702 if (rtl8192_usb_initendpoints(dev) != 0) {
2703 DMESG("Endopoints initialization failed"); 2703 DMESG("Endopoints initialization failed");
2704 return -ENOMEM; 2704 return -ENOMEM;
@@ -3499,9 +3499,9 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
3499 RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); 3499 RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
3500} 3500}
3501 3501
3502static void watch_dog_timer_callback(unsigned long data) 3502static void watch_dog_timer_callback(struct timer_list *t)
3503{ 3503{
3504 struct r8192_priv *priv = ieee80211_priv((struct net_device *)data); 3504 struct r8192_priv *priv = from_timer(priv, t, watch_dog_timer);
3505 3505
3506 schedule_delayed_work(&priv->watch_dog_wq, 0); 3506 schedule_delayed_work(&priv->watch_dog_wq, 0);
3507 mod_timer(&priv->watch_dog_timer, 3507 mod_timer(&priv->watch_dog_timer,
@@ -3528,7 +3528,7 @@ static int _rtl8192_up(struct net_device *dev)
3528 if (priv->ieee80211->state != IEEE80211_LINKED) 3528 if (priv->ieee80211->state != IEEE80211_LINKED)
3529 ieee80211_softmac_start_protocol(priv->ieee80211); 3529 ieee80211_softmac_start_protocol(priv->ieee80211);
3530 ieee80211_reset_queue(priv->ieee80211); 3530 ieee80211_reset_queue(priv->ieee80211);
3531 watch_dog_timer_callback((unsigned long)dev); 3531 watch_dog_timer_callback(&priv->watch_dog_timer);
3532 if (!netif_queue_stopped(dev)) 3532 if (!netif_queue_stopped(dev))
3533 netif_start_queue(dev); 3533 netif_start_queue(dev);
3534 else 3534 else
@@ -4994,11 +4994,11 @@ static int rtl8192_usb_probe(struct usb_interface *intf,
4994 4994
4995fail2: 4995fail2:
4996 rtl8192_down(dev); 4996 rtl8192_down(dev);
4997fail:
4997 kfree(priv->pFirmware); 4998 kfree(priv->pFirmware);
4998 priv->pFirmware = NULL; 4999 priv->pFirmware = NULL;
4999 rtl8192_usb_deleteendpoints(dev); 5000 rtl8192_usb_deleteendpoints(dev);
5000 mdelay(10); 5001 mdelay(10);
5001fail:
5002 free_ieee80211(dev); 5002 free_ieee80211(dev);
5003 5003
5004 RT_TRACE(COMP_ERR, "wlan driver load failed\n"); 5004 RT_TRACE(COMP_ERR, "wlan driver load failed\n");
diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
index e6f8d1da65d9..17e650184ee5 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2729,8 +2729,7 @@ static void dm_init_fsync(struct net_device *dev)
2729 priv->ieee80211->fsync_seconddiff_ratethreshold = 200; 2729 priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
2730 priv->ieee80211->fsync_state = Default_Fsync; 2730 priv->ieee80211->fsync_state = Default_Fsync;
2731 priv->framesyncMonitor = 1; /* current default 0xc38 monitor on */ 2731 priv->framesyncMonitor = 1; /* current default 0xc38 monitor on */
2732 setup_timer(&priv->fsync_timer, dm_fsync_timer_callback, 2732 timer_setup(&priv->fsync_timer, dm_fsync_timer_callback, 0);
2733 (unsigned long)dev);
2734} 2733}
2735 2734
2736static void dm_deInit_fsync(struct net_device *dev) 2735static void dm_deInit_fsync(struct net_device *dev)
@@ -2740,10 +2739,10 @@ static void dm_deInit_fsync(struct net_device *dev)
2740 del_timer_sync(&priv->fsync_timer); 2739 del_timer_sync(&priv->fsync_timer);
2741} 2740}
2742 2741
2743void dm_fsync_timer_callback(unsigned long data) 2742void dm_fsync_timer_callback(struct timer_list *t)
2744{ 2743{
2745 struct net_device *dev = (struct net_device *)data; 2744 struct r8192_priv *priv = from_timer(priv, t, fsync_timer);
2746 struct r8192_priv *priv = ieee80211_priv((struct net_device *)data); 2745 struct net_device *dev = priv->ieee80211->dev;
2747 u32 rate_index, rate_count = 0, rate_count_diff = 0; 2746 u32 rate_index, rate_count = 0, rate_count_diff = 0;
2748 bool bSwitchFromCountDiff = false; 2747 bool bSwitchFromCountDiff = false;
2749 bool bDoubleTimeInterval = false; 2748 bool bDoubleTimeInterval = false;
diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 2d0232fb3f9b..b19b4e5b87ff 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -226,7 +226,7 @@ void dm_force_tx_fw_info(struct net_device *dev,
226void dm_init_edca_turbo(struct net_device *dev); 226void dm_init_edca_turbo(struct net_device *dev);
227void dm_rf_operation_test_callback(unsigned long data); 227void dm_rf_operation_test_callback(unsigned long data);
228void dm_rf_pathcheck_workitemcallback(struct work_struct *work); 228void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
229void dm_fsync_timer_callback(unsigned long data); 229void dm_fsync_timer_callback(struct timer_list *t);
230void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); 230void dm_cck_txpower_adjust(struct net_device *dev, bool binch14);
231void dm_shadow_init(struct net_device *dev); 231void dm_shadow_init(struct net_device *dev);
232void dm_initialize_txpower_tracking(struct net_device *dev); 232void dm_initialize_txpower_tracking(struct net_device *dev);
diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c
index a9545386fbc5..e4e6c979bedf 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.c
+++ b/drivers/staging/rtl8192u/r8192U_wx.c
@@ -964,7 +964,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
964 return wstats; 964 return wstats;
965} 965}
966 966
967struct iw_handler_def r8192_wx_handlers_def = { 967const struct iw_handler_def r8192_wx_handlers_def = {
968 .standard = r8192_wx_handlers, 968 .standard = r8192_wx_handlers,
969 .num_standard = ARRAY_SIZE(r8192_wx_handlers), 969 .num_standard = ARRAY_SIZE(r8192_wx_handlers),
970 .private = r8192_private_handler, 970 .private = r8192_private_handler,
diff --git a/drivers/staging/rtl8192u/r8192U_wx.h b/drivers/staging/rtl8192u/r8192U_wx.h
index fb5f808433d1..a6c2b95e2e69 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.h
+++ b/drivers/staging/rtl8192u/r8192U_wx.h
@@ -17,7 +17,7 @@
17#ifndef R8180_WX_H 17#ifndef R8180_WX_H
18#define R8180_WX_H 18#define R8180_WX_H
19 19
20extern struct iw_handler_def r8192_wx_handlers_def; 20extern const struct iw_handler_def r8192_wx_handlers_def;
21/* Enable the rtl819x_core.c to share this function, david 2008.9.22 */ 21/* Enable the rtl819x_core.c to share this function, david 2008.9.22 */
22struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); 22struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev);
23 23
diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index c83d7ebb164f..de832b0b5eec 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -216,9 +216,9 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
216 emem_sz = fwhdr.img_SRAM_size; 216 emem_sz = fwhdr.img_SRAM_size;
217 do { 217 do {
218 memset(ptx_desc, 0, TXDESC_SIZE); 218 memset(ptx_desc, 0, TXDESC_SIZE);
219 if (emem_sz > MAX_DUMP_FWSZ) /* max=48k */ 219 if (emem_sz > MAX_DUMP_FWSZ) { /* max=48k */
220 dump_emem_sz = MAX_DUMP_FWSZ; 220 dump_emem_sz = MAX_DUMP_FWSZ;
221 else { 221 } else {
222 dump_emem_sz = emem_sz; 222 dump_emem_sz = emem_sz;
223 ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); 223 ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
224 } 224 }
diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c
index a077069d6227..3c7c4a4faeb2 100644
--- a/drivers/staging/rtl8712/mlme_linux.c
+++ b/drivers/staging/rtl8712/mlme_linux.c
@@ -32,39 +32,45 @@
32#include "drv_types.h" 32#include "drv_types.h"
33#include "mlme_osdep.h" 33#include "mlme_osdep.h"
34 34
35static void sitesurvey_ctrl_handler(unsigned long data) 35static void sitesurvey_ctrl_handler(struct timer_list *t)
36{ 36{
37 struct _adapter *adapter = (struct _adapter *)data; 37 struct _adapter *adapter =
38 from_timer(adapter, t,
39 mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer);
38 40
39 _r8712_sitesurvey_ctrl_handler(adapter); 41 _r8712_sitesurvey_ctrl_handler(adapter);
40 mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer, 42 mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
41 jiffies + msecs_to_jiffies(3000)); 43 jiffies + msecs_to_jiffies(3000));
42} 44}
43 45
44static void join_timeout_handler (unsigned long data) 46static void join_timeout_handler (struct timer_list *t)
45{ 47{
46 struct _adapter *adapter = (struct _adapter *)data; 48 struct _adapter *adapter =
49 from_timer(adapter, t, mlmepriv.assoc_timer);
47 50
48 _r8712_join_timeout_handler(adapter); 51 _r8712_join_timeout_handler(adapter);
49} 52}
50 53
51static void _scan_timeout_handler (unsigned long data) 54static void _scan_timeout_handler (struct timer_list *t)
52{ 55{
53 struct _adapter *adapter = (struct _adapter *)data; 56 struct _adapter *adapter =
57 from_timer(adapter, t, mlmepriv.scan_to_timer);
54 58
55 r8712_scan_timeout_handler(adapter); 59 r8712_scan_timeout_handler(adapter);
56} 60}
57 61
58static void dhcp_timeout_handler (unsigned long data) 62static void dhcp_timeout_handler (struct timer_list *t)
59{ 63{
60 struct _adapter *adapter = (struct _adapter *)data; 64 struct _adapter *adapter =
65 from_timer(adapter, t, mlmepriv.dhcp_timer);
61 66
62 _r8712_dhcp_timeout_handler(adapter); 67 _r8712_dhcp_timeout_handler(adapter);
63} 68}
64 69
65static void wdg_timeout_handler (unsigned long data) 70static void wdg_timeout_handler (struct timer_list *t)
66{ 71{
67 struct _adapter *adapter = (struct _adapter *)data; 72 struct _adapter *adapter =
73 from_timer(adapter, t, mlmepriv.wdg_timer);
68 74
69 _r8712_wdg_timeout_handler(adapter); 75 _r8712_wdg_timeout_handler(adapter);
70 76
@@ -76,17 +82,12 @@ void r8712_init_mlme_timer(struct _adapter *padapter)
76{ 82{
77 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 83 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
78 84
79 setup_timer(&pmlmepriv->assoc_timer, join_timeout_handler, 85 timer_setup(&pmlmepriv->assoc_timer, join_timeout_handler, 0);
80 (unsigned long)padapter); 86 timer_setup(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer,
81 setup_timer(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer, 87 sitesurvey_ctrl_handler, 0);
82 sitesurvey_ctrl_handler, 88 timer_setup(&pmlmepriv->scan_to_timer, _scan_timeout_handler, 0);
83 (unsigned long)padapter); 89 timer_setup(&pmlmepriv->dhcp_timer, dhcp_timeout_handler, 0);
84 setup_timer(&pmlmepriv->scan_to_timer, _scan_timeout_handler, 90 timer_setup(&pmlmepriv->wdg_timer, wdg_timeout_handler, 0);
85 (unsigned long)padapter);
86 setup_timer(&pmlmepriv->dhcp_timer, dhcp_timeout_handler,
87 (unsigned long)padapter);
88 setup_timer(&pmlmepriv->wdg_timer, wdg_timeout_handler,
89 (unsigned long)padapter);
90} 91}
91 92
92void r8712_os_indicate_connect(struct _adapter *adapter) 93void r8712_os_indicate_connect(struct _adapter *adapter)
@@ -118,9 +119,8 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
118 adapter->securitypriv.btkip_countermeasure; 119 adapter->securitypriv.btkip_countermeasure;
119 memset((unsigned char *)&adapter->securitypriv, 0, 120 memset((unsigned char *)&adapter->securitypriv, 0,
120 sizeof(struct security_priv)); 121 sizeof(struct security_priv));
121 setup_timer(&adapter->securitypriv.tkip_timer, 122 timer_setup(&adapter->securitypriv.tkip_timer,
122 r8712_use_tkipkey_handler, 123 r8712_use_tkipkey_handler, 0);
123 (unsigned long)adapter);
124 /* Restore the PMK information to securitypriv structure 124 /* Restore the PMK information to securitypriv structure
125 * for the following connection. 125 * for the following connection.
126 */ 126 */
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index e698f6ede449..95caf8df9a13 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -313,8 +313,8 @@ u8 r8712_init_drv_sw(struct _adapter *padapter)
313 _r8712_init_recv_priv(&padapter->recvpriv, padapter); 313 _r8712_init_recv_priv(&padapter->recvpriv, padapter);
314 memset((unsigned char *)&padapter->securitypriv, 0, 314 memset((unsigned char *)&padapter->securitypriv, 0,
315 sizeof(struct security_priv)); 315 sizeof(struct security_priv));
316 setup_timer(&padapter->securitypriv.tkip_timer, 316 timer_setup(&padapter->securitypriv.tkip_timer,
317 r8712_use_tkipkey_handler, (unsigned long)padapter); 317 r8712_use_tkipkey_handler, 0);
318 _r8712_init_sta_priv(&padapter->stapriv); 318 _r8712_init_sta_priv(&padapter->stapriv);
319 padapter->stapriv.padapter = padapter; 319 padapter->stapriv.padapter = padapter;
320 r8712_init_bcmc_stainfo(padapter); 320 r8712_init_bcmc_stainfo(padapter);
@@ -385,11 +385,11 @@ static int netdev_open(struct net_device *pnetdev)
385 padapter->bup = true; 385 padapter->bup = true;
386 if (rtl871x_hal_init(padapter) != _SUCCESS) 386 if (rtl871x_hal_init(padapter) != _SUCCESS)
387 goto netdev_open_error; 387 goto netdev_open_error;
388 if (!r8712_initmac) 388 if (!r8712_initmac) {
389 /* Use the mac address stored in the Efuse */ 389 /* Use the mac address stored in the Efuse */
390 memcpy(pnetdev->dev_addr, 390 memcpy(pnetdev->dev_addr,
391 padapter->eeprompriv.mac_addr, ETH_ALEN); 391 padapter->eeprompriv.mac_addr, ETH_ALEN);
392 else { 392 } else {
393 /* We have to inform f/w to use user-supplied MAC 393 /* We have to inform f/w to use user-supplied MAC
394 * address. 394 * address.
395 */ 395 */
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c
index 0104aced113e..3c88994fdfcd 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -356,11 +356,11 @@ _next:
356 if ((wr_sz % 64) == 0) 356 if ((wr_sz % 64) == 0)
357 blnPending = 1; 357 blnPending = 1;
358 } 358 }
359 if (blnPending) /* 32 bytes for TX Desc - 8 offset */ 359 if (blnPending) { /* 32 bytes for TX Desc - 8 offset */
360 pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + 360 pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
361 OFFSET_SZ + 8) << OFFSET_SHT) & 361 OFFSET_SZ + 8) << OFFSET_SHT) &
362 0x00ff0000); 362 0x00ff0000);
363 else { 363 } else {
364 pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + 364 pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
365 OFFSET_SZ) << 365 OFFSET_SZ) <<
366 OFFSET_SHT) & 366 OFFSET_SHT) &
diff --git a/drivers/staging/rtl8712/rtl8712_event.h b/drivers/staging/rtl8712/rtl8712_event.h
index b38374025c93..cad7085c3f8a 100644
--- a/drivers/staging/rtl8712/rtl8712_event.h
+++ b/drivers/staging/rtl8712/rtl8712_event.h
@@ -60,7 +60,6 @@ enum rtl8712_c2h_event {
60 MAX_C2HEVT 60 MAX_C2HEVT
61}; 61};
62 62
63
64#ifdef _RTL8712_CMD_C_ 63#ifdef _RTL8712_CMD_C_
65 64
66static struct fwevent wlanevents[] = { 65static struct fwevent wlanevents[] = {
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index ea3eb94b28b3..8f555e6e1b3f 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -149,7 +149,7 @@ int r8712_free_recvframe(union recv_frame *precvframe,
149 list_add_tail(&(precvframe->u.hdr.list), &pfree_recv_queue->queue); 149 list_add_tail(&(precvframe->u.hdr.list), &pfree_recv_queue->queue);
150 if (padapter != NULL) { 150 if (padapter != NULL) {
151 if (pfree_recv_queue == &precvpriv->free_recv_queue) 151 if (pfree_recv_queue == &precvpriv->free_recv_queue)
152 precvpriv->free_recvframe_cnt++; 152 precvpriv->free_recvframe_cnt++;
153 } 153 }
154 spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL); 154 spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
155 return _SUCCESS; 155 return _SUCCESS;
@@ -883,10 +883,10 @@ static void query_rx_phy_status(struct _adapter *padapter,
883 * from 0~100. It is assigned to the BSS List in 883 * from 0~100. It is assigned to the BSS List in
884 * GetValueFromBeaconOrProbeRsp(). 884 * GetValueFromBeaconOrProbeRsp().
885 */ 885 */
886 if (bcck_rate) 886 if (bcck_rate) {
887 prframe->u.hdr.attrib.signal_strength = 887 prframe->u.hdr.attrib.signal_strength =
888 (u8)r8712_signal_scale_mapping(pwdb_all); 888 (u8)r8712_signal_scale_mapping(pwdb_all);
889 else { 889 } else {
890 if (rf_rx_num != 0) 890 if (rf_rx_num != 0)
891 prframe->u.hdr.attrib.signal_strength = 891 prframe->u.hdr.attrib.signal_strength =
892 (u8)(r8712_signal_scale_mapping(total_rssi /= 892 (u8)(r8712_signal_scale_mapping(total_rssi /=
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
index 04638f1e4e88..a424f447a725 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -899,9 +899,10 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
899 if (!pwlan) 899 if (!pwlan)
900 goto createbss_cmd_fail; 900 goto createbss_cmd_fail;
901 pwlan->last_scanned = jiffies; 901 pwlan->last_scanned = jiffies;
902 } else 902 } else {
903 list_add_tail(&(pwlan->list), 903 list_add_tail(&(pwlan->list),
904 &pmlmepriv->scanned_queue.queue); 904 &pmlmepriv->scanned_queue.queue);
905 }
905 pnetwork->Length = r8712_get_wlan_bssid_ex_sz(pnetwork); 906 pnetwork->Length = r8712_get_wlan_bssid_ex_sz(pnetwork);
906 memcpy(&(pwlan->network), pnetwork, pnetwork->Length); 907 memcpy(&(pwlan->network), pnetwork, pnetwork->Length);
907 pwlan->fixed = true; 908 pwlan->fixed = true;
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index 01a150446f5a..8a5ced4fa9d3 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -78,10 +78,10 @@ static u8 do_join(struct _adapter *padapter)
78 int ret; 78 int ret;
79 79
80 ret = r8712_select_and_join_from_scan(pmlmepriv); 80 ret = r8712_select_and_join_from_scan(pmlmepriv);
81 if (ret == _SUCCESS) 81 if (ret == _SUCCESS) {
82 mod_timer(&pmlmepriv->assoc_timer, 82 mod_timer(&pmlmepriv->assoc_timer,
83 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); 83 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
84 else { 84 } else {
85 if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { 85 if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
86 /* submit r8712_createbss_cmd to change to an 86 /* submit r8712_createbss_cmd to change to an
87 * ADHOC_MASTER pmlmepriv->lock has been 87 * ADHOC_MASTER pmlmepriv->lock has been
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index bf1ac22bae1c..111c809afc51 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -574,10 +574,10 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
574 set_fwstate(pmlmepriv, _FW_UNDER_LINKING); 574 set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
575 575
576 if (r8712_select_and_join_from_scan(pmlmepriv) 576 if (r8712_select_and_join_from_scan(pmlmepriv)
577 == _SUCCESS) 577 == _SUCCESS) {
578 mod_timer(&pmlmepriv->assoc_timer, jiffies + 578 mod_timer(&pmlmepriv->assoc_timer, jiffies +
579 msecs_to_jiffies(MAX_JOIN_TIMEOUT)); 579 msecs_to_jiffies(MAX_JOIN_TIMEOUT));
580 else { 580 } else {
581 struct wlan_bssid_ex *pdev_network = 581 struct wlan_bssid_ex *pdev_network =
582 &(adapter->registrypriv.dev_network); 582 &(adapter->registrypriv.dev_network);
583 u8 *pibss = 583 u8 *pibss =
diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c
index e42fc1404c35..ae4c9567bb55 100644
--- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c
+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c
@@ -164,9 +164,10 @@ static void rpwm_workitem_callback(struct work_struct *work)
164 } 164 }
165} 165}
166 166
167static void rpwm_check_handler (unsigned long data) 167static void rpwm_check_handler (struct timer_list *t)
168{ 168{
169 struct _adapter *adapter = (struct _adapter *)data; 169 struct _adapter *adapter =
170 from_timer(adapter, t, pwrctrlpriv.rpwm_check_timer);
170 171
171 _rpwm_check_handler(adapter); 172 _rpwm_check_handler(adapter);
172} 173}
@@ -185,8 +186,7 @@ void r8712_init_pwrctrl_priv(struct _adapter *padapter)
185 r8712_write8(padapter, 0x1025FE58, 0); 186 r8712_write8(padapter, 0x1025FE58, 0);
186 INIT_WORK(&pwrctrlpriv->SetPSModeWorkItem, SetPSModeWorkItemCallback); 187 INIT_WORK(&pwrctrlpriv->SetPSModeWorkItem, SetPSModeWorkItemCallback);
187 INIT_WORK(&pwrctrlpriv->rpwm_workitem, rpwm_workitem_callback); 188 INIT_WORK(&pwrctrlpriv->rpwm_workitem, rpwm_workitem_callback);
188 setup_timer(&pwrctrlpriv->rpwm_check_timer, rpwm_check_handler, 189 timer_setup(&pwrctrlpriv->rpwm_check_timer, rpwm_check_handler, 0);
189 (unsigned long)padapter);
190} 190}
191 191
192/* 192/*
diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c
index bd83fb492c45..56d36f6f9c46 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -1402,9 +1402,10 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
1402 return _SUCCESS; 1402 return _SUCCESS;
1403} 1403}
1404 1404
1405void r8712_use_tkipkey_handler(unsigned long data) 1405void r8712_use_tkipkey_handler(struct timer_list *t)
1406{ 1406{
1407 struct _adapter *padapter = (struct _adapter *)data; 1407 struct _adapter *padapter =
1408 from_timer(padapter, t, securitypriv.tkip_timer);
1408 1409
1409 padapter->securitypriv.busetkipkey = true; 1410 padapter->securitypriv.busetkipkey = true;
1410} 1411}
diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h
index fa952e17975b..46b88a41d236 100644
--- a/drivers/staging/rtl8712/rtl871x_security.h
+++ b/drivers/staging/rtl8712/rtl871x_security.h
@@ -224,7 +224,7 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe);
224u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe); 224u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe);
225u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe); 225u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe);
226void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe); 226void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe);
227void r8712_use_tkipkey_handler(unsigned long data); 227void r8712_use_tkipkey_handler(struct timer_list *t);
228 228
229#endif /*__RTL871X_SECURITY_H_ */ 229#endif /*__RTL871X_SECURITY_H_ */
230 230
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index b3e266bd57ab..85eadddfaf06 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -590,9 +590,10 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
590 mac[0] &= 0xFE; 590 mac[0] &= 0xFE;
591 dev_info(&udev->dev, 591 dev_info(&udev->dev,
592 "r8712u: MAC Address from user = %pM\n", mac); 592 "r8712u: MAC Address from user = %pM\n", mac);
593 } else 593 } else {
594 dev_info(&udev->dev, 594 dev_info(&udev->dev,
595 "r8712u: MAC Address from efuse = %pM\n", mac); 595 "r8712u: MAC Address from efuse = %pM\n", mac);
596 }
596 ether_addr_copy(pnetdev->dev_addr, mac); 597 ether_addr_copy(pnetdev->dev_addr, mac);
597 } 598 }
598 /* step 6. Load the firmware asynchronously */ 599 /* step 6. Load the firmware asynchronously */
diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index d3007c1c45e3..0b530ea7fd81 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1581,15 +1581,13 @@ u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
1581 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1581 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1582 u8 res = _SUCCESS; 1582 u8 res = _SUCCESS;
1583 1583
1584 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1584 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1585 if (ph2c == NULL) { 1585 if (ph2c == NULL) {
1586 res = _FAIL; 1586 res = _FAIL;
1587 goto exit; 1587 goto exit;
1588 } 1588 }
1589 1589
1590 psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc( 1590 psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
1591 sizeof(struct set_stakey_parm)
1592 );
1593 if (psetstakey_para == NULL) { 1591 if (psetstakey_para == NULL) {
1594 kfree((u8 *) ph2c); 1592 kfree((u8 *) ph2c);
1595 res = _FAIL; 1593 res = _FAIL;
@@ -1630,12 +1628,12 @@ static int rtw_ap_set_key(
1630 1628
1631 /* DBG_871X("%s\n", __func__); */ 1629 /* DBG_871X("%s\n", __func__); */
1632 1630
1633 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1631 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
1634 if (pcmd == NULL) { 1632 if (pcmd == NULL) {
1635 res = _FAIL; 1633 res = _FAIL;
1636 goto exit; 1634 goto exit;
1637 } 1635 }
1638 psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); 1636 psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm));
1639 if (psetkeyparm == NULL) { 1637 if (psetkeyparm == NULL) {
1640 kfree((unsigned char *)pcmd); 1638 kfree((unsigned char *)pcmd);
1641 res = _FAIL; 1639 res = _FAIL;
diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
index 01f78d1671de..79aa02afad01 100644
--- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c
+++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
@@ -207,11 +207,11 @@ void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable)
207 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); 207 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
208 208
209 if (true == enable) { 209 if (true == enable) {
210 pmlmeinfo->bAcceptAddbaReq = false; 210 pmlmeinfo->accept_addba_req = false;
211 if (psta) 211 if (psta)
212 send_delba(padapter, 0, psta->hwaddr); 212 send_delba(padapter, 0, psta->hwaddr);
213 } else{ 213 } else{
214 pmlmeinfo->bAcceptAddbaReq = true; 214 pmlmeinfo->accept_addba_req = true;
215 } 215 }
216} 216}
217 217
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index d381827dba3b..9ac2dea6dff1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
408 } 408 }
409 409
410 /* free cmd_obj */ 410 /* free cmd_obj */
411 kfree((unsigned char *)pcmd); 411 kfree(pcmd);
412} 412}
413 413
414 414
@@ -613,13 +613,13 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
613 rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); 613 rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
614 } 614 }
615 615
616 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 616 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
617 if (ph2c == NULL) 617 if (ph2c == NULL)
618 return _FAIL; 618 return _FAIL;
619 619
620 psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); 620 psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
621 if (psurveyPara == NULL) { 621 if (psurveyPara == NULL) {
622 kfree((unsigned char *) ph2c); 622 kfree(ph2c);
623 return _FAIL; 623 return _FAIL;
624 } 624 }
625 625
@@ -681,15 +681,15 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
681 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 681 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
682 u8 res = _SUCCESS; 682 u8 res = _SUCCESS;
683 683
684 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 684 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
685 if (ph2c == NULL) { 685 if (ph2c == NULL) {
686 res = _FAIL; 686 res = _FAIL;
687 goto exit; 687 goto exit;
688 } 688 }
689 689
690 pbsetdataratepara = (struct setdatarate_parm *)rtw_zmalloc(sizeof(struct setdatarate_parm)); 690 pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
691 if (pbsetdataratepara == NULL) { 691 if (pbsetdataratepara == NULL) {
692 kfree((u8 *) ph2c); 692 kfree(ph2c);
693 res = _FAIL; 693 res = _FAIL;
694 goto exit; 694 goto exit;
695 } 695 }
@@ -706,8 +706,8 @@ exit:
706void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) 706void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
707{ 707{
708 /* rtw_free_cmd_obj(pcmd); */ 708 /* rtw_free_cmd_obj(pcmd); */
709 kfree((unsigned char *) pcmd->parmbuf); 709 kfree(pcmd->parmbuf);
710 kfree((unsigned char *) pcmd); 710 kfree(pcmd);
711} 711}
712 712
713u8 rtw_createbss_cmd(struct adapter *padapter) 713u8 rtw_createbss_cmd(struct adapter *padapter)
@@ -724,7 +724,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter)
724 RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); 724 RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
725 } 725 }
726 726
727 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 727 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
728 if (pcmd == NULL) { 728 if (pcmd == NULL) {
729 res = _FAIL; 729 res = _FAIL;
730 goto exit; 730 goto exit;
@@ -757,7 +757,7 @@ u8 rtw_startbss_cmd(struct adapter *padapter, int flags)
757 start_bss_network(padapter, (u8 *)&(padapter->mlmepriv.cur_network.network)); 757 start_bss_network(padapter, (u8 *)&(padapter->mlmepriv.cur_network.network));
758 } else { 758 } else {
759 /* need enqueue, prepare cmd_obj and enqueue */ 759 /* need enqueue, prepare cmd_obj and enqueue */
760 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 760 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
761 if (pcmd == NULL) { 761 if (pcmd == NULL) {
762 res = _FAIL; 762 res = _FAIL;
763 goto exit; 763 goto exit;
@@ -815,7 +815,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
815 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); 815 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid));
816 } 816 }
817 817
818 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 818 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
819 if (pcmd == NULL) { 819 if (pcmd == NULL) {
820 res = _FAIL; 820 res = _FAIL;
821 RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); 821 RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n"));
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
847 psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; 847 psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
848 if (psecnetwork == NULL) { 848 if (psecnetwork == NULL) {
849 if (pcmd != NULL) 849 if (pcmd != NULL)
850 kfree((unsigned char *)pcmd); 850 kfree(pcmd);
851 851
852 res = _FAIL; 852 res = _FAIL;
853 853
@@ -943,7 +943,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
943 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); 943 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n"));
944 944
945 /* prepare cmd parameter */ 945 /* prepare cmd parameter */
946 param = (struct disconnect_parm *)rtw_zmalloc(sizeof(*param)); 946 param = rtw_zmalloc(sizeof(*param));
947 if (param == NULL) { 947 if (param == NULL) {
948 res = _FAIL; 948 res = _FAIL;
949 goto exit; 949 goto exit;
@@ -952,10 +952,10 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
952 952
953 if (enqueue) { 953 if (enqueue) {
954 /* need enqueue, prepare cmd_obj and enqueue */ 954 /* need enqueue, prepare cmd_obj and enqueue */
955 cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); 955 cmdobj = rtw_zmalloc(sizeof(*cmdobj));
956 if (cmdobj == NULL) { 956 if (cmdobj == NULL) {
957 res = _FAIL; 957 res = _FAIL;
958 kfree((u8 *)param); 958 kfree(param);
959 goto exit; 959 goto exit;
960 } 960 }
961 init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); 961 init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
964 /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ 964 /* no need to enqueue, do the cmd hdl directly and free cmd parameter */
965 if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) 965 if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
966 res = _FAIL; 966 res = _FAIL;
967 kfree((u8 *)param); 967 kfree(param);
968 } 968 }
969 969
970exit: 970exit:
@@ -979,7 +979,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST
979 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 979 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
980 u8 res = _SUCCESS; 980 u8 res = _SUCCESS;
981 981
982 psetop = (struct setopmode_parm *)rtw_zmalloc(sizeof(struct setopmode_parm)); 982 psetop = rtw_zmalloc(sizeof(struct setopmode_parm));
983 983
984 if (psetop == NULL) { 984 if (psetop == NULL) {
985 res = _FAIL; 985 res = _FAIL;
@@ -988,9 +988,9 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST
988 psetop->mode = (u8)networktype; 988 psetop->mode = (u8)networktype;
989 989
990 if (enqueue) { 990 if (enqueue) {
991 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 991 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
992 if (ph2c == NULL) { 992 if (ph2c == NULL) {
993 kfree((u8 *)psetop); 993 kfree(psetop);
994 res = _FAIL; 994 res = _FAIL;
995 goto exit; 995 goto exit;
996 } 996 }
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST
999 res = rtw_enqueue_cmd(pcmdpriv, ph2c); 999 res = rtw_enqueue_cmd(pcmdpriv, ph2c);
1000 } else{ 1000 } else{
1001 setopmode_hdl(padapter, (u8 *)psetop); 1001 setopmode_hdl(padapter, (u8 *)psetop);
1002 kfree((u8 *)psetop); 1002 kfree(psetop);
1003 } 1003 }
1004exit: 1004exit:
1005 return res; 1005 return res;
@@ -1016,7 +1016,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
1016 struct security_priv *psecuritypriv = &padapter->securitypriv; 1016 struct security_priv *psecuritypriv = &padapter->securitypriv;
1017 u8 res = _SUCCESS; 1017 u8 res = _SUCCESS;
1018 1018
1019 psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); 1019 psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
1020 if (psetstakey_para == NULL) { 1020 if (psetstakey_para == NULL) {
1021 res = _FAIL; 1021 res = _FAIL;
1022 goto exit; 1022 goto exit;
@@ -1040,17 +1040,17 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
1040 padapter->securitypriv.busetkipkey = true; 1040 padapter->securitypriv.busetkipkey = true;
1041 1041
1042 if (enqueue) { 1042 if (enqueue) {
1043 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1043 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1044 if (ph2c == NULL) { 1044 if (ph2c == NULL) {
1045 kfree((u8 *) psetstakey_para); 1045 kfree(psetstakey_para);
1046 res = _FAIL; 1046 res = _FAIL;
1047 goto exit; 1047 goto exit;
1048 } 1048 }
1049 1049
1050 psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); 1050 psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
1051 if (psetstakey_rsp == NULL) { 1051 if (psetstakey_rsp == NULL) {
1052 kfree((u8 *) ph2c); 1052 kfree(ph2c);
1053 kfree((u8 *) psetstakey_para); 1053 kfree(psetstakey_para);
1054 res = _FAIL; 1054 res = _FAIL;
1055 goto exit; 1055 goto exit;
1056 } 1056 }
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
1061 res = rtw_enqueue_cmd(pcmdpriv, ph2c); 1061 res = rtw_enqueue_cmd(pcmdpriv, ph2c);
1062 } else{ 1062 } else{
1063 set_stakey_hdl(padapter, (u8 *)psetstakey_para); 1063 set_stakey_hdl(padapter, (u8 *)psetstakey_para);
1064 kfree((u8 *) psetstakey_para); 1064 kfree(psetstakey_para);
1065 } 1065 }
1066exit: 1066exit:
1067 return res; 1067 return res;
@@ -1083,23 +1083,23 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
1083 rtw_camid_free(padapter, cam_id); 1083 rtw_camid_free(padapter, cam_id);
1084 } 1084 }
1085 } else{ 1085 } else{
1086 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1086 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1087 if (ph2c == NULL) { 1087 if (ph2c == NULL) {
1088 res = _FAIL; 1088 res = _FAIL;
1089 goto exit; 1089 goto exit;
1090 } 1090 }
1091 1091
1092 psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); 1092 psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
1093 if (psetstakey_para == NULL) { 1093 if (psetstakey_para == NULL) {
1094 kfree((u8 *) ph2c); 1094 kfree(ph2c);
1095 res = _FAIL; 1095 res = _FAIL;
1096 goto exit; 1096 goto exit;
1097 } 1097 }
1098 1098
1099 psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); 1099 psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
1100 if (psetstakey_rsp == NULL) { 1100 if (psetstakey_rsp == NULL) {
1101 kfree((u8 *) ph2c); 1101 kfree(ph2c);
1102 kfree((u8 *) psetstakey_para); 1102 kfree(psetstakey_para);
1103 res = _FAIL; 1103 res = _FAIL;
1104 goto exit; 1104 goto exit;
1105 } 1105 }
@@ -1128,15 +1128,15 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
1128 1128
1129 u8 res = _SUCCESS; 1129 u8 res = _SUCCESS;
1130 1130
1131 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1131 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1132 if (ph2c == NULL) { 1132 if (ph2c == NULL) {
1133 res = _FAIL; 1133 res = _FAIL;
1134 goto exit; 1134 goto exit;
1135 } 1135 }
1136 1136
1137 paddbareq_parm = (struct addBaReq_parm *)rtw_zmalloc(sizeof(struct addBaReq_parm)); 1137 paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
1138 if (paddbareq_parm == NULL) { 1138 if (paddbareq_parm == NULL) {
1139 kfree((unsigned char *)ph2c); 1139 kfree(ph2c);
1140 res = _FAIL; 1140 res = _FAIL;
1141 goto exit; 1141 goto exit;
1142 } 1142 }
@@ -1162,15 +1162,15 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
1162 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1162 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1163 u8 res = _SUCCESS; 1163 u8 res = _SUCCESS;
1164 1164
1165 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1165 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1166 if (ph2c == NULL) { 1166 if (ph2c == NULL) {
1167 res = _FAIL; 1167 res = _FAIL;
1168 goto exit; 1168 goto exit;
1169 } 1169 }
1170 1170
1171 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1171 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1172 if (pdrvextra_cmd_parm == NULL) { 1172 if (pdrvextra_cmd_parm == NULL) {
1173 kfree((unsigned char *)ph2c); 1173 kfree(ph2c);
1174 res = _FAIL; 1174 res = _FAIL;
1175 goto exit; 1175 goto exit;
1176 } 1176 }
@@ -1197,15 +1197,15 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
1197 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1197 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1198 u8 res = _SUCCESS; 1198 u8 res = _SUCCESS;
1199 1199
1200 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1200 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1201 if (ph2c == NULL) { 1201 if (ph2c == NULL) {
1202 res = _FAIL; 1202 res = _FAIL;
1203 goto exit; 1203 goto exit;
1204 } 1204 }
1205 1205
1206 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1206 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1207 if (pdrvextra_cmd_parm == NULL) { 1207 if (pdrvextra_cmd_parm == NULL) {
1208 kfree((unsigned char *)ph2c); 1208 kfree(ph2c);
1209 res = _FAIL; 1209 res = _FAIL;
1210 goto exit; 1210 goto exit;
1211 } 1211 }
@@ -1233,15 +1233,15 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
1233 u8 res = _SUCCESS; 1233 u8 res = _SUCCESS;
1234 1234
1235 /* only primary padapter does this cmd */ 1235 /* only primary padapter does this cmd */
1236 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1236 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1237 if (ph2c == NULL) { 1237 if (ph2c == NULL) {
1238 res = _FAIL; 1238 res = _FAIL;
1239 goto exit; 1239 goto exit;
1240 } 1240 }
1241 1241
1242 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1242 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1243 if (pdrvextra_cmd_parm == NULL) { 1243 if (pdrvextra_cmd_parm == NULL) {
1244 kfree((unsigned char *)ph2c); 1244 kfree(ph2c);
1245 res = _FAIL; 1245 res = _FAIL;
1246 goto exit; 1246 goto exit;
1247 } 1247 }
@@ -1283,7 +1283,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
1283 } 1283 }
1284 1284
1285 /* prepare cmd parameter */ 1285 /* prepare cmd parameter */
1286 setChannelPlan_param = (struct SetChannelPlan_param *)rtw_zmalloc(sizeof(struct SetChannelPlan_param)); 1286 setChannelPlan_param = rtw_zmalloc(sizeof(struct SetChannelPlan_param));
1287 if (setChannelPlan_param == NULL) { 1287 if (setChannelPlan_param == NULL) {
1288 res = _FAIL; 1288 res = _FAIL;
1289 goto exit; 1289 goto exit;
@@ -1292,9 +1292,9 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
1292 1292
1293 if (enqueue) { 1293 if (enqueue) {
1294 /* need enqueue, prepare cmd_obj and enqueue */ 1294 /* need enqueue, prepare cmd_obj and enqueue */
1295 pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1295 pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
1296 if (pcmdobj == NULL) { 1296 if (pcmdobj == NULL) {
1297 kfree((u8 *)setChannelPlan_param); 1297 kfree(setChannelPlan_param);
1298 res = _FAIL; 1298 res = _FAIL;
1299 goto exit; 1299 goto exit;
1300 } 1300 }
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
1306 if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) 1306 if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
1307 res = _FAIL; 1307 res = _FAIL;
1308 1308
1309 kfree((u8 *)setChannelPlan_param); 1309 kfree(setChannelPlan_param);
1310 } 1310 }
1311 1311
1312 /* do something based on res... */ 1312 /* do something based on res... */
@@ -1553,15 +1553,15 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
1553 /* return res; */ 1553 /* return res; */
1554 1554
1555 if (enqueue) { 1555 if (enqueue) {
1556 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1556 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1557 if (ph2c == NULL) { 1557 if (ph2c == NULL) {
1558 res = _FAIL; 1558 res = _FAIL;
1559 goto exit; 1559 goto exit;
1560 } 1560 }
1561 1561
1562 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1562 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1563 if (pdrvextra_cmd_parm == NULL) { 1563 if (pdrvextra_cmd_parm == NULL) {
1564 kfree((unsigned char *)ph2c); 1564 kfree(ph2c);
1565 res = _FAIL; 1565 res = _FAIL;
1566 goto exit; 1566 goto exit;
1567 } 1567 }
@@ -1595,15 +1595,15 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
1595 u8 res = _SUCCESS; 1595 u8 res = _SUCCESS;
1596 1596
1597 1597
1598 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1598 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1599 if (ph2c == NULL) { 1599 if (ph2c == NULL) {
1600 res = _FAIL; 1600 res = _FAIL;
1601 goto exit; 1601 goto exit;
1602 } 1602 }
1603 1603
1604 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1604 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1605 if (pdrvextra_cmd_parm == NULL) { 1605 if (pdrvextra_cmd_parm == NULL) {
1606 kfree((unsigned char *)ph2c); 1606 kfree(ph2c);
1607 res = _FAIL; 1607 res = _FAIL;
1608 goto exit; 1608 goto exit;
1609 } 1609 }
@@ -1668,15 +1668,15 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
1668 u8 res = _SUCCESS; 1668 u8 res = _SUCCESS;
1669 1669
1670 1670
1671 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1671 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1672 if (ph2c == NULL) { 1672 if (ph2c == NULL) {
1673 res = _FAIL; 1673 res = _FAIL;
1674 goto exit; 1674 goto exit;
1675 } 1675 }
1676 1676
1677 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1677 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1678 if (pdrvextra_cmd_parm == NULL) { 1678 if (pdrvextra_cmd_parm == NULL) {
1679 kfree((unsigned char *)ph2c); 1679 kfree(ph2c);
1680 res = _FAIL; 1680 res = _FAIL;
1681 goto exit; 1681 goto exit;
1682 } 1682 }
@@ -1719,15 +1719,15 @@ u8 rtw_ps_cmd(struct adapter *padapter)
1719 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1719 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1720 u8 res = _SUCCESS; 1720 u8 res = _SUCCESS;
1721 1721
1722 ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1722 ppscmd = rtw_zmalloc(sizeof(struct cmd_obj));
1723 if (ppscmd == NULL) { 1723 if (ppscmd == NULL) {
1724 res = _FAIL; 1724 res = _FAIL;
1725 goto exit; 1725 goto exit;
1726 } 1726 }
1727 1727
1728 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1728 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1729 if (pdrvextra_cmd_parm == NULL) { 1729 if (pdrvextra_cmd_parm == NULL) {
1730 kfree((unsigned char *)ppscmd); 1730 kfree(ppscmd);
1731 res = _FAIL; 1731 res = _FAIL;
1732 goto exit; 1732 goto exit;
1733 } 1733 }
@@ -1791,15 +1791,15 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
1791 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1791 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1792 u8 res = _SUCCESS; 1792 u8 res = _SUCCESS;
1793 1793
1794 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1794 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1795 if (ph2c == NULL) { 1795 if (ph2c == NULL) {
1796 res = _FAIL; 1796 res = _FAIL;
1797 goto exit; 1797 goto exit;
1798 } 1798 }
1799 1799
1800 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1800 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1801 if (pdrvextra_cmd_parm == NULL) { 1801 if (pdrvextra_cmd_parm == NULL) {
1802 kfree((unsigned char *)ph2c); 1802 kfree(ph2c);
1803 res = _FAIL; 1803 res = _FAIL;
1804 goto exit; 1804 goto exit;
1805 } 1805 }
@@ -1890,15 +1890,15 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
1890 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1890 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1891 u8 res = _SUCCESS; 1891 u8 res = _SUCCESS;
1892 1892
1893 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1893 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1894 if (ph2c == NULL) { 1894 if (ph2c == NULL) {
1895 res = _FAIL; 1895 res = _FAIL;
1896 goto exit; 1896 goto exit;
1897 } 1897 }
1898 1898
1899 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1899 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1900 if (pdrvextra_cmd_parm == NULL) { 1900 if (pdrvextra_cmd_parm == NULL) {
1901 kfree((u8 *)ph2c); 1901 kfree(ph2c);
1902 res = _FAIL; 1902 res = _FAIL;
1903 goto exit; 1903 goto exit;
1904 } 1904 }
@@ -1925,15 +1925,15 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
1925 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1925 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
1926 u8 res = _SUCCESS; 1926 u8 res = _SUCCESS;
1927 1927
1928 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 1928 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
1929 if (ph2c == NULL) { 1929 if (ph2c == NULL) {
1930 res = _FAIL; 1930 res = _FAIL;
1931 goto exit; 1931 goto exit;
1932 } 1932 }
1933 1933
1934 pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); 1934 pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
1935 if (pdrvextra_cmd_parm == NULL) { 1935 if (pdrvextra_cmd_parm == NULL) {
1936 kfree((u8 *)ph2c); 1936 kfree(ph2c);
1937 res = _FAIL; 1937 res = _FAIL;
1938 goto exit; 1938 goto exit;
1939 } 1939 }
@@ -1967,7 +1967,7 @@ static void c2h_wk_callback(_workitem *work)
1967 /* This C2H event is read, clear it */ 1967 /* This C2H event is read, clear it */
1968 c2h_evt_clear(adapter); 1968 c2h_evt_clear(adapter);
1969 } else{ 1969 } else{
1970 c2h_evt = (u8 *)rtw_malloc(16); 1970 c2h_evt = rtw_malloc(16);
1971 if (c2h_evt != NULL) { 1971 if (c2h_evt != NULL) {
1972 /* This C2H event is not read, read & clear now */ 1972 /* This C2H event is not read, read & clear now */
1973 if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) { 1973 if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c
index 3db02e9f27ab..b5dd244fee8f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -1122,7 +1122,8 @@ int proc_get_rx_ampdu(struct seq_file *m, void *v)
1122 1122
1123 if (pregpriv) 1123 if (pregpriv)
1124 DBG_871X_SEL_NL(m, 1124 DBG_871X_SEL_NL(m,
1125 "bAcceptAddbaReq = %d , 0:Reject AP's Add BA req, 1:Accept AP's Add BA req.\n", pmlmeinfo->bAcceptAddbaReq 1125 "accept_addba_req = %d , 0:Reject AP's Add BA req, 1:Accept AP's Add BA req.\n",
1126 pmlmeinfo->accept_addba_req
1126 ); 1127 );
1127 1128
1128 return 0; 1129 return 0;
@@ -1146,8 +1147,9 @@ ssize_t proc_set_rx_ampdu(struct file *file, const char __user *buffer, size_t c
1146 sscanf(tmp, "%d ", &mode); 1147 sscanf(tmp, "%d ", &mode);
1147 1148
1148 if (pregpriv && mode < 2) { 1149 if (pregpriv && mode < 2) {
1149 pmlmeinfo->bAcceptAddbaReq = mode; 1150 pmlmeinfo->accept_addba_req = mode;
1150 DBG_871X("pmlmeinfo->bAcceptAddbaReq =%d\n", pmlmeinfo->bAcceptAddbaReq); 1151 DBG_871X("pmlmeinfo->accept_addba_req =%d\n",
1152 pmlmeinfo->accept_addba_req);
1151 if (mode == 0) { 1153 if (mode == 0) {
1152 /*tear down Rx AMPDU*/ 1154 /*tear down Rx AMPDU*/
1153 send_delba(padapter, 0, get_my_bssid(&(pmlmeinfo->network)));/* recipient*/ 1155 send_delba(padapter, 0, get_my_bssid(&(pmlmeinfo->network)));/* recipient*/
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 7b37e085b793..9167900b5f7d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1189,9 +1189,9 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
1189 (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || 1189 (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
1190 ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) && 1190 ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
1191 (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) { 1191 (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) {
1192 if (np && 1192 if (np &&
1193 (addr = of_get_property(np, "local-mac-address", &len)) && 1193 (addr = of_get_property(np, "local-mac-address", &len)) &&
1194 len == ETH_ALEN) { 1194 len == ETH_ALEN) {
1195 memcpy(mac_addr, addr, ETH_ALEN); 1195 memcpy(mac_addr, addr, ETH_ALEN);
1196 } else { 1196 } else {
1197 mac[0] = 0x00; 1197 mac[0] = 0x00;
diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index d815a693fa64..e5354cec8dd5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -590,14 +590,10 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum NDIS_802_11
590u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) 590u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
591{ 591{
592 592
593 u8 bdefaultkey;
594 u8 btransmitkey;
595 sint keyid, res; 593 sint keyid, res;
596 struct security_priv *psecuritypriv = &(padapter->securitypriv); 594 struct security_priv *psecuritypriv = &(padapter->securitypriv);
597 u8 ret = _SUCCESS; 595 u8 ret = _SUCCESS;
598 596
599 bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; /* for ??? */
600 btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; /* for ??? */
601 keyid = wep->KeyIndex & 0x3fffffff; 597 keyid = wep->KeyIndex & 0x3fffffff;
602 598
603 if (keyid >= 4) { 599 if (keyid >= 4) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index cb8a95aabd6c..fe739eb2cf7d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter)
28 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 28 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
29 sint res = _SUCCESS; 29 sint res = _SUCCESS;
30 30
31 /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
32 /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */
33
34 pmlmepriv->nic_hdl = (u8 *)padapter; 31 pmlmepriv->nic_hdl = (u8 *)padapter;
35 32
36 pmlmepriv->pscanned = NULL; 33 pmlmepriv->pscanned = NULL;
@@ -1817,8 +1814,10 @@ void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf)
1817* _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss 1814* _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss
1818* @adapter: pointer to struct adapter structure 1815* @adapter: pointer to struct adapter structure
1819*/ 1816*/
1820void _rtw_join_timeout_handler (struct adapter *adapter) 1817void _rtw_join_timeout_handler(struct timer_list *t)
1821{ 1818{
1819 struct adapter *adapter = from_timer(adapter, t,
1820 mlmepriv.assoc_timer);
1822 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 1821 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
1823 1822
1824 DBG_871X("%s, fw_state =%x\n", __func__, get_fwstate(pmlmepriv)); 1823 DBG_871X("%s, fw_state =%x\n", __func__, get_fwstate(pmlmepriv));
@@ -1870,8 +1869,10 @@ void _rtw_join_timeout_handler (struct adapter *adapter)
1870* rtw_scan_timeout_handler - Timeout/Failure handler for CMD SiteSurvey 1869* rtw_scan_timeout_handler - Timeout/Failure handler for CMD SiteSurvey
1871* @adapter: pointer to struct adapter structure 1870* @adapter: pointer to struct adapter structure
1872*/ 1871*/
1873void rtw_scan_timeout_handler (struct adapter *adapter) 1872void rtw_scan_timeout_handler(struct timer_list *t)
1874{ 1873{
1874 struct adapter *adapter = from_timer(adapter, t,
1875 mlmepriv.scan_to_timer);
1875 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 1876 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
1876 1877
1877 DBG_871X(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); 1878 DBG_871X(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
@@ -1934,7 +1935,7 @@ exit:
1934 return; 1935 return;
1935} 1936}
1936 1937
1937void rtw_dynamic_check_timer_handlder(struct adapter *adapter) 1938void rtw_dynamic_check_timer_handler(struct adapter *adapter)
1938{ 1939{
1939 if (!adapter) 1940 if (!adapter)
1940 return; 1941 return;
@@ -2271,13 +2272,13 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
2271 struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); 2272 struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
2272 sint res = _SUCCESS; 2273 sint res = _SUCCESS;
2273 2274
2274 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 2275 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
2275 if (pcmd == NULL) { 2276 if (pcmd == NULL) {
2276 res = _FAIL; /* try again */ 2277 res = _FAIL; /* try again */
2277 goto exit; 2278 goto exit;
2278 } 2279 }
2279 2280
2280 psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); 2281 psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm));
2281 if (psetauthparm == NULL) { 2282 if (psetauthparm == NULL) {
2282 kfree((unsigned char *)pcmd); 2283 kfree((unsigned char *)pcmd);
2283 res = _FAIL; 2284 res = _FAIL;
@@ -2312,7 +2313,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
2312 struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); 2313 struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
2313 sint res = _SUCCESS; 2314 sint res = _SUCCESS;
2314 2315
2315 psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); 2316 psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm));
2316 if (psetkeyparm == NULL) { 2317 if (psetkeyparm == NULL) {
2317 res = _FAIL; 2318 res = _FAIL;
2318 goto exit; 2319 goto exit;
@@ -2364,7 +2365,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
2364 2365
2365 2366
2366 if (enqueue) { 2367 if (enqueue) {
2367 pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 2368 pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
2368 if (pcmd == NULL) { 2369 if (pcmd == NULL) {
2369 kfree((unsigned char *)psetkeyparm); 2370 kfree((unsigned char *)psetkeyparm);
2370 res = _FAIL; /* try again */ 2371 res = _FAIL; /* try again */
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b6d137f505e1..7d7756e40bcb 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -17,6 +17,7 @@
17#include <drv_types.h> 17#include <drv_types.h>
18#include <rtw_debug.h> 18#include <rtw_debug.h>
19#include <rtw_wifi_regd.h> 19#include <rtw_wifi_regd.h>
20#include <linux/kernel.h>
20 21
21 22
22static struct mlme_handler mlme_sta_tbl[] = { 23static struct mlme_handler mlme_sta_tbl[] = {
@@ -474,15 +475,12 @@ int init_mlme_ext_priv(struct adapter *padapter)
474 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 475 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
475 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 476 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
476 477
477 /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
478 /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */
479
480 pmlmeext->padapter = padapter; 478 pmlmeext->padapter = padapter;
481 479
482 /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ 480 /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */
483 481
484 init_mlme_ext_priv_value(padapter); 482 init_mlme_ext_priv_value(padapter);
485 pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq; 483 pmlmeinfo->accept_addba_req = pregistrypriv->accept_addba_req;
486 484
487 init_mlme_ext_timer(padapter); 485 init_mlme_ext_timer(padapter);
488 486
@@ -510,7 +508,7 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
510 if (!padapter) 508 if (!padapter)
511 return; 509 return;
512 510
513 if (padapter->bDriverStopped == true) { 511 if (padapter->bDriverStopped) {
514 del_timer_sync(&pmlmeext->survey_timer); 512 del_timer_sync(&pmlmeext->survey_timer);
515 del_timer_sync(&pmlmeext->link_timer); 513 del_timer_sync(&pmlmeext->link_timer);
516 /* del_timer_sync(&pmlmeext->ADDBA_timer); */ 514 /* del_timer_sync(&pmlmeext->ADDBA_timer); */
@@ -562,7 +560,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
562 560
563 index = GetFrameSubType(pframe) >> 4; 561 index = GetFrameSubType(pframe) >> 4;
564 562
565 if (index >= (sizeof(mlme_sta_tbl) / sizeof(struct mlme_handler))) { 563 if (index >= ARRAY_SIZE(mlme_sta_tbl)) {
566 RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index)); 564 RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index));
567 return; 565 return;
568 } 566 }
@@ -582,11 +580,11 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
582 580
583 switch (GetFrameSubType(pframe)) { 581 switch (GetFrameSubType(pframe)) {
584 case WIFI_AUTH: 582 case WIFI_AUTH:
585 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) 583 if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
586 ptable->func = &OnAuth; 584 ptable->func = &OnAuth;
587 else 585 else
588 ptable->func = &OnAuthClient; 586 ptable->func = &OnAuthClient;
589 /* pass through */ 587 /* fall through */
590 case WIFI_ASSOCREQ: 588 case WIFI_ASSOCREQ:
591 case WIFI_REASSOCREQ: 589 case WIFI_REASSOCREQ:
592 _mgt_dispatcher(padapter, ptable, precv_frame); 590 _mgt_dispatcher(padapter, ptable, precv_frame);
@@ -637,8 +635,8 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame)
637 /* DBG_871X("+OnProbeReq\n"); */ 635 /* DBG_871X("+OnProbeReq\n"); */
638 636
639#ifdef CONFIG_AUTO_AP_MODE 637#ifdef CONFIG_AUTO_AP_MODE
640 if (check_fwstate(pmlmepriv, _FW_LINKED) == true && 638 if (check_fwstate(pmlmepriv, _FW_LINKED) &&
641 pmlmepriv->cur_network.join_res == true) { 639 pmlmepriv->cur_network.join_res) {
642 struct sta_info *psta; 640 struct sta_info *psta;
643 u8 *mac_addr, *peer_addr; 641 u8 *mac_addr, *peer_addr;
644 struct sta_priv *pstapriv = &padapter->stapriv; 642 struct sta_priv *pstapriv = &padapter->stapriv;
@@ -752,7 +750,7 @@ _non_rc_device:
752 750
753 /* check (wildcard) SSID */ 751 /* check (wildcard) SSID */
754 if (p != NULL) { 752 if (p != NULL) {
755 if (is_valid_p2p_probereq == true) 753 if (is_valid_p2p_probereq)
756 goto _issue_probersp; 754 goto _issue_probersp;
757 755
758 if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) 756 if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength))
@@ -761,8 +759,8 @@ _non_rc_device:
761 return _SUCCESS; 759 return _SUCCESS;
762 760
763_issue_probersp: 761_issue_probersp:
764 if (((check_fwstate(pmlmepriv, _FW_LINKED) == true && 762 if ((check_fwstate(pmlmepriv, _FW_LINKED) &&
765 pmlmepriv->cur_network.join_res == true)) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { 763 pmlmepriv->cur_network.join_res) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
766 /* DBG_871X("+issue_probersp during ap mode\n"); */ 764 /* DBG_871X("+issue_probersp during ap mode\n"); */
767 issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); 765 issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq);
768 } 766 }
@@ -818,7 +816,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
818 if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { 816 if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
819 if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { 817 if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
820 /* we should update current network before auth, or some IE is wrong */ 818 /* we should update current network before auth, or some IE is wrong */
821 pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); 819 pbss = rtw_malloc(sizeof(struct wlan_bssid_ex));
822 if (pbss) { 820 if (pbss) {
823 if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { 821 if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) {
824 update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); 822 update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
@@ -1773,7 +1771,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
1773 1771
1774 DBG_871X("%s Reason code(%d)\n", __func__, reason); 1772 DBG_871X("%s Reason code(%d)\n", __func__, reason);
1775 1773
1776 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { 1774 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1777 struct sta_info *psta; 1775 struct sta_info *psta;
1778 struct sta_priv *pstapriv = &padapter->stapriv; 1776 struct sta_priv *pstapriv = &padapter->stapriv;
1779 1777
@@ -1848,7 +1846,7 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
1848 1846
1849 DBG_871X("%s Reason code(%d)\n", __func__, reason); 1847 DBG_871X("%s Reason code(%d)\n", __func__, reason);
1850 1848
1851 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { 1849 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1852 struct sta_info *psta; 1850 struct sta_info *psta;
1853 struct sta_priv *pstapriv = &padapter->stapriv; 1851 struct sta_priv *pstapriv = &padapter->stapriv;
1854 1852
@@ -1976,7 +1974,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
1976 /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */ 1974 /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */
1977 process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); 1975 process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr);
1978 1976
1979 if (pmlmeinfo->bAcceptAddbaReq == true) { 1977 if (pmlmeinfo->accept_addba_req) {
1980 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); 1978 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0);
1981 } else{ 1979 } else{
1982 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ 1980 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */
@@ -2227,7 +2225,7 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame)
2227 2225
2228 category = frame_body[0]; 2226 category = frame_body[0];
2229 2227
2230 for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { 2228 for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) {
2231 ptable = &OnAction_tbl[i]; 2229 ptable = &OnAction_tbl[i];
2232 2230
2233 if (category == ptable->num) 2231 if (category == ptable->num)
@@ -2350,8 +2348,8 @@ void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *p
2350 2348
2351void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) 2349void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
2352{ 2350{
2353 if (padapter->bSurpriseRemoved == true || 2351 if (padapter->bSurpriseRemoved ||
2354 padapter->bDriverStopped == true) { 2352 padapter->bDriverStopped) {
2355 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); 2353 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf);
2356 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); 2354 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe);
2357 return; 2355 return;
@@ -2368,8 +2366,8 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr
2368 struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; 2366 struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
2369 struct submit_ctx sctx; 2367 struct submit_ctx sctx;
2370 2368
2371 if (padapter->bSurpriseRemoved == true || 2369 if (padapter->bSurpriseRemoved ||
2372 padapter->bDriverStopped == true) { 2370 padapter->bDriverStopped) {
2373 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); 2371 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf);
2374 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); 2372 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe);
2375 return ret; 2373 return ret;
@@ -2397,8 +2395,8 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg
2397 u32 timeout_ms = 500;/* 500ms */ 2395 u32 timeout_ms = 500;/* 500ms */
2398 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 2396 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
2399 2397
2400 if (padapter->bSurpriseRemoved == true || 2398 if (padapter->bSurpriseRemoved ||
2401 padapter->bDriverStopped == true) { 2399 padapter->bDriverStopped) {
2402 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); 2400 rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf);
2403 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); 2401 rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe);
2404 return -1; 2402 return -1;
@@ -2833,7 +2831,9 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
2833 2831
2834} 2832}
2835 2833
2836static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, u8 ch, bool append_wps, int wait_ack) 2834static int _issue_probereq(struct adapter *padapter,
2835 struct ndis_802_11_ssid *pssid,
2836 u8 *da, u8 ch, bool append_wps, bool wait_ack)
2837{ 2837{
2838 int ret = _FAIL; 2838 int ret = _FAIL;
2839 struct xmit_frame *pmgntframe; 2839 struct xmit_frame *pmgntframe;
@@ -3394,7 +3394,7 @@ void issue_assocreq(struct adapter *padapter)
3394 pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); 3394 pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen));
3395 break; 3395 break;
3396 case EID_HTCapability: 3396 case EID_HTCapability:
3397 if (padapter->mlmepriv.htpriv.ht_option == true) { 3397 if (padapter->mlmepriv.htpriv.ht_option) {
3398 if (!(is_ap_in_tkip(padapter))) { 3398 if (!(is_ap_in_tkip(padapter))) {
3399 memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); 3399 memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element));
3400 pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); 3400 pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen));
@@ -3403,7 +3403,7 @@ void issue_assocreq(struct adapter *padapter)
3403 break; 3403 break;
3404 3404
3405 case EID_EXTCapability: 3405 case EID_EXTCapability:
3406 if (padapter->mlmepriv.htpriv.ht_option == true) 3406 if (padapter->mlmepriv.htpriv.ht_option)
3407 pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen)); 3407 pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen));
3408 break; 3408 break;
3409 default: 3409 default:
@@ -3432,7 +3432,8 @@ exit:
3432} 3432}
3433 3433
3434/* when wait_ack is ture, this function shoule be called at process context */ 3434/* when wait_ack is ture, this function shoule be called at process context */
3435static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) 3435static int _issue_nulldata(struct adapter *padapter, unsigned char *da,
3436 unsigned int power_mode, bool wait_ack)
3436{ 3437{
3437 int ret = _FAIL; 3438 int ret = _FAIL;
3438 struct xmit_frame *pmgntframe; 3439 struct xmit_frame *pmgntframe;
@@ -3593,7 +3594,8 @@ s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da)
3593} 3594}
3594 3595
3595/* when wait_ack is ture, this function shoule be called at process context */ 3596/* when wait_ack is ture, this function shoule be called at process context */
3596static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) 3597static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
3598 u16 tid, bool wait_ack)
3597{ 3599{
3598 int ret = _FAIL; 3600 int ret = _FAIL;
3599 struct xmit_frame *pmgntframe; 3601 struct xmit_frame *pmgntframe;
@@ -3717,7 +3719,8 @@ exit:
3717 return ret; 3719 return ret;
3718} 3720}
3719 3721
3720static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack) 3722static int _issue_deauth(struct adapter *padapter, unsigned char *da,
3723 unsigned short reason, bool wait_ack)
3721{ 3724{
3722 struct xmit_frame *pmgntframe; 3725 struct xmit_frame *pmgntframe;
3723 struct pkt_attrib *pattrib; 3726 struct pkt_attrib *pattrib;
@@ -4219,7 +4222,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr)
4219 4222
4220 if (initiator == 0) {/* recipient */ 4223 if (initiator == 0) {/* recipient */
4221 for (tid = 0; tid < MAXTID; tid++) { 4224 for (tid = 0; tid < MAXTID; tid++) {
4222 if (psta->recvreorder_ctrl[tid].enable == true) { 4225 if (psta->recvreorder_ctrl[tid].enable) {
4223 DBG_871X("rx agg disable tid(%d)\n", tid); 4226 DBG_871X("rx agg disable tid(%d)\n", tid);
4224 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); 4227 issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
4225 psta->recvreorder_ctrl[tid].enable = false; 4228 psta->recvreorder_ctrl[tid].enable = false;
@@ -4408,7 +4411,7 @@ void site_survey(struct adapter *padapter)
4408 Restore_DM_Func_Flag(padapter); 4411 Restore_DM_Func_Flag(padapter);
4409 /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ 4412 /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */
4410 4413
4411 if (is_client_associated_to_ap(padapter) == true) 4414 if (is_client_associated_to_ap(padapter))
4412 issue_nulldata(padapter, NULL, 0, 3, 500); 4415 issue_nulldata(padapter, NULL, 0, 3, 500);
4413 4416
4414 val8 = 0; /* survey done */ 4417 val8 = 0; /* survey done */
@@ -5049,12 +5052,12 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
5049 pmlmeext = &padapter->mlmeextpriv; 5052 pmlmeext = &padapter->mlmeextpriv;
5050 pcmdpriv = &padapter->cmdpriv; 5053 pcmdpriv = &padapter->cmdpriv;
5051 5054
5052 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5055 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5053 if (pcmd_obj == NULL) 5056 if (pcmd_obj == NULL)
5054 return; 5057 return;
5055 5058
5056 cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); 5059 cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
5057 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5060 pevtcmd = rtw_zmalloc(cmdsz);
5058 if (pevtcmd == NULL) { 5061 if (pevtcmd == NULL) {
5059 kfree((u8 *)pcmd_obj); 5062 kfree((u8 *)pcmd_obj);
5060 return; 5063 return;
@@ -5102,12 +5105,12 @@ void report_surveydone_event(struct adapter *padapter)
5102 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5105 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
5103 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5106 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
5104 5107
5105 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5108 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5106 if (pcmd_obj == NULL) 5109 if (pcmd_obj == NULL)
5107 return; 5110 return;
5108 5111
5109 cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); 5112 cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
5110 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5113 pevtcmd = rtw_zmalloc(cmdsz);
5111 if (pevtcmd == NULL) { 5114 if (pevtcmd == NULL) {
5112 kfree((u8 *)pcmd_obj); 5115 kfree((u8 *)pcmd_obj);
5113 return; 5116 return;
@@ -5149,12 +5152,12 @@ void report_join_res(struct adapter *padapter, int res)
5149 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 5152 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
5150 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5153 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
5151 5154
5152 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5155 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5153 if (pcmd_obj == NULL) 5156 if (pcmd_obj == NULL)
5154 return; 5157 return;
5155 5158
5156 cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); 5159 cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
5157 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5160 pevtcmd = rtw_zmalloc(cmdsz);
5158 if (pevtcmd == NULL) { 5161 if (pevtcmd == NULL) {
5159 kfree((u8 *)pcmd_obj); 5162 kfree((u8 *)pcmd_obj);
5160 return; 5163 return;
@@ -5200,12 +5203,12 @@ void report_wmm_edca_update(struct adapter *padapter)
5200 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5203 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
5201 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5204 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
5202 5205
5203 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5206 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5204 if (pcmd_obj == NULL) 5207 if (pcmd_obj == NULL)
5205 return; 5208 return;
5206 5209
5207 cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header)); 5210 cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header));
5208 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5211 pevtcmd = rtw_zmalloc(cmdsz);
5209 if (pevtcmd == NULL) { 5212 if (pevtcmd == NULL) {
5210 kfree((u8 *)pcmd_obj); 5213 kfree((u8 *)pcmd_obj);
5211 return; 5214 return;
@@ -5246,13 +5249,13 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
5246 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5249 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
5247 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5250 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
5248 5251
5249 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5252 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5250 if (pcmd_obj == NULL) { 5253 if (pcmd_obj == NULL) {
5251 return; 5254 return;
5252 } 5255 }
5253 5256
5254 cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); 5257 cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
5255 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5258 pevtcmd = rtw_zmalloc(cmdsz);
5256 if (pevtcmd == NULL) { 5259 if (pevtcmd == NULL) {
5257 kfree((u8 *)pcmd_obj); 5260 kfree((u8 *)pcmd_obj);
5258 return; 5261 return;
@@ -5302,12 +5305,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
5302 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5305 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
5303 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5306 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
5304 5307
5305 pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5308 pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
5306 if (pcmd_obj == NULL) 5309 if (pcmd_obj == NULL)
5307 return; 5310 return;
5308 5311
5309 cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); 5312 cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
5310 pevtcmd = (u8 *)rtw_zmalloc(cmdsz); 5313 pevtcmd = rtw_zmalloc(cmdsz);
5311 if (pevtcmd == NULL) { 5314 if (pevtcmd == NULL) {
5312 kfree((u8 *)pcmd_obj); 5315 kfree((u8 *)pcmd_obj);
5313 return; 5316 return;
@@ -5445,7 +5448,7 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter)
5445 pmlmeinfo->state = WIFI_FW_NULL_STATE; 5448 pmlmeinfo->state = WIFI_FW_NULL_STATE;
5446 5449
5447 if (state_backup == WIFI_FW_STATION_STATE) { 5450 if (state_backup == WIFI_FW_STATION_STATE) {
5448 if (rtw_port_switch_chk(padapter) == true) { 5451 if (rtw_port_switch_chk(padapter)) {
5449 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); 5452 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
5450 { 5453 {
5451 struct adapter *port0_iface = dvobj_get_port0_adapter(adapter_to_dvobj(padapter)); 5454 struct adapter *port0_iface = dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
@@ -5534,7 +5537,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
5534 rtw_hal_macid_wakeup(padapter, psta->mac_id); 5537 rtw_hal_macid_wakeup(padapter, psta->mac_id);
5535 } 5538 }
5536 5539
5537 if (rtw_port_switch_chk(padapter) == true) 5540 if (rtw_port_switch_chk(padapter))
5538 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); 5541 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
5539 5542
5540 join_type = 2; 5543 join_type = 2;
@@ -5659,7 +5662,7 @@ void _linked_info_dump(struct adapter *padapter)
5659 5662
5660 } 5663 }
5661 for (i = 0; i < NUM_STA; i++) { 5664 for (i = 0; i < NUM_STA; i++) {
5662 if (pdvobj->macid[i] == true) { 5665 if (pdvobj->macid[i]) {
5663 if (i != 1) /* skip bc/mc sta */ 5666 if (i != 1) /* skip bc/mc sta */
5664 /* tx info ============ */ 5667 /* tx info ============ */
5665 rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &i); 5668 rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &i);
@@ -5827,8 +5830,10 @@ void linked_status_chk(struct adapter *padapter)
5827 5830
5828} 5831}
5829 5832
5830void survey_timer_hdl(struct adapter *padapter) 5833void survey_timer_hdl(struct timer_list *t)
5831{ 5834{
5835 struct adapter *padapter =
5836 from_timer(padapter, t, mlmeextpriv.survey_timer);
5832 struct cmd_obj *ph2c; 5837 struct cmd_obj *ph2c;
5833 struct sitesurvey_parm *psurveyPara; 5838 struct sitesurvey_parm *psurveyPara;
5834 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 5839 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -5842,7 +5847,7 @@ void survey_timer_hdl(struct adapter *padapter)
5842 pmlmeext->sitesurvey_res.channel_idx++; 5847 pmlmeext->sitesurvey_res.channel_idx++;
5843 } 5848 }
5844 5849
5845 if (pmlmeext->scan_abort == true) { 5850 if (pmlmeext->scan_abort) {
5846 { 5851 {
5847 pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; 5852 pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
5848 DBG_871X("%s idx:%d\n", __func__ 5853 DBG_871X("%s idx:%d\n", __func__
@@ -5853,12 +5858,12 @@ void survey_timer_hdl(struct adapter *padapter)
5853 pmlmeext->scan_abort = false;/* reset */ 5858 pmlmeext->scan_abort = false;/* reset */
5854 } 5859 }
5855 5860
5856 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 5861 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
5857 if (ph2c == NULL) { 5862 if (ph2c == NULL) {
5858 goto exit_survey_timer_hdl; 5863 goto exit_survey_timer_hdl;
5859 } 5864 }
5860 5865
5861 psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); 5866 psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
5862 if (psurveyPara == NULL) { 5867 if (psurveyPara == NULL) {
5863 kfree((unsigned char *)ph2c); 5868 kfree((unsigned char *)ph2c);
5864 goto exit_survey_timer_hdl; 5869 goto exit_survey_timer_hdl;
@@ -5874,8 +5879,10 @@ exit_survey_timer_hdl:
5874 return; 5879 return;
5875} 5880}
5876 5881
5877void link_timer_hdl(struct adapter *padapter) 5882void link_timer_hdl(struct timer_list *t)
5878{ 5883{
5884 struct adapter *padapter =
5885 from_timer(padapter, t, mlmeextpriv.link_timer);
5879 /* static unsigned int rx_pkt = 0; */ 5886 /* static unsigned int rx_pkt = 0; */
5880 /* static u64 tx_cnt = 0; */ 5887 /* static u64 tx_cnt = 0; */
5881 /* struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); */ 5888 /* struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); */
@@ -5924,8 +5931,9 @@ void link_timer_hdl(struct adapter *padapter)
5924 return; 5931 return;
5925} 5932}
5926 5933
5927void addba_timer_hdl(struct sta_info *psta) 5934void addba_timer_hdl(struct timer_list *t)
5928{ 5935{
5936 struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
5929 struct ht_priv *phtpriv; 5937 struct ht_priv *phtpriv;
5930 5938
5931 if (!psta) 5939 if (!psta)
@@ -5933,20 +5941,22 @@ void addba_timer_hdl(struct sta_info *psta)
5933 5941
5934 phtpriv = &psta->htpriv; 5942 phtpriv = &psta->htpriv;
5935 5943
5936 if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) { 5944 if (phtpriv->ht_option && phtpriv->ampdu_enable) {
5937 if (phtpriv->candidate_tid_bitmap) 5945 if (phtpriv->candidate_tid_bitmap)
5938 phtpriv->candidate_tid_bitmap = 0x0; 5946 phtpriv->candidate_tid_bitmap = 0x0;
5939 5947
5940 } 5948 }
5941} 5949}
5942 5950
5943void sa_query_timer_hdl(struct adapter *padapter) 5951void sa_query_timer_hdl(struct timer_list *t)
5944{ 5952{
5953 struct adapter *padapter =
5954 from_timer(padapter, t, mlmeextpriv.sa_query_timer);
5945 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 5955 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
5946 /* disconnect */ 5956 /* disconnect */
5947 spin_lock_bh(&pmlmepriv->lock); 5957 spin_lock_bh(&pmlmepriv->lock);
5948 5958
5949 if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { 5959 if (check_fwstate(pmlmepriv, _FW_LINKED)) {
5950 rtw_disassoc_cmd(padapter, 0, true); 5960 rtw_disassoc_cmd(padapter, 0, true);
5951 rtw_indicate_disconnect(padapter); 5961 rtw_indicate_disconnect(padapter);
5952 rtw_free_assoc_resources(padapter, 1); 5962 rtw_free_assoc_resources(padapter, 1);
@@ -6084,7 +6094,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
6084 rtw_auto_ap_start_beacon(padapter); 6094 rtw_auto_ap_start_beacon(padapter);
6085#endif 6095#endif
6086 6096
6087 if (rtw_port_switch_chk(padapter) == true) { 6097 if (rtw_port_switch_chk(padapter)) {
6088 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); 6098 rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
6089 6099
6090 if (psetop->mode == Ndis802_11APMode) 6100 if (psetop->mode == Ndis802_11APMode)
@@ -6358,7 +6368,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c
6358 set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); 6368 set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value);
6359 if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) 6369 if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED)
6360 && set_idx >= 0 6370 && set_idx >= 0
6361 && rtw_mlme_band_check(padapter, in[i].hw_value) == true 6371 && rtw_mlme_band_check(padapter, in[i].hw_value)
6362 ) { 6372 ) {
6363 if (j >= out_num) { 6373 if (j >= out_num) {
6364 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n", 6374 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n",
@@ -6383,7 +6393,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c
6383 6393
6384 DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), pmlmeext->channel_set[i].ChannelNum); 6394 DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), pmlmeext->channel_set[i].ChannelNum);
6385 6395
6386 if (rtw_mlme_band_check(padapter, pmlmeext->channel_set[i].ChannelNum) == true) { 6396 if (rtw_mlme_band_check(padapter, pmlmeext->channel_set[i].ChannelNum)) {
6387 6397
6388 if (j >= out_num) { 6398 if (j >= out_num) {
6389 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n", 6399 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n",
@@ -6435,7 +6445,7 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)
6435 pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; 6445 pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode;
6436 6446
6437 /* issue null data if associating to the AP */ 6447 /* issue null data if associating to the AP */
6438 if (is_client_associated_to_ap(padapter) == true) { 6448 if (is_client_associated_to_ap(padapter)) {
6439 pmlmeext->sitesurvey_res.state = SCAN_TXNULL; 6449 pmlmeext->sitesurvey_res.state = SCAN_TXNULL;
6440 6450
6441 issue_nulldata(padapter, NULL, 1, 3, 500); 6451 issue_nulldata(padapter, NULL, 1, 3, 500);
@@ -6602,7 +6612,7 @@ u8 chk_bmc_sleepq_cmd(struct adapter *padapter)
6602 struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); 6612 struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
6603 u8 res = _SUCCESS; 6613 u8 res = _SUCCESS;
6604 6614
6605 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 6615 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
6606 if (ph2c == NULL) { 6616 if (ph2c == NULL) {
6607 res = _FAIL; 6617 res = _FAIL;
6608 goto exit; 6618 goto exit;
@@ -6626,13 +6636,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
6626 u8 res = _SUCCESS; 6636 u8 res = _SUCCESS;
6627 int len_diff = 0; 6637 int len_diff = 0;
6628 6638
6629 ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); 6639 ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
6630 if (ph2c == NULL) { 6640 if (ph2c == NULL) {
6631 res = _FAIL; 6641 res = _FAIL;
6632 goto exit; 6642 goto exit;
6633 } 6643 }
6634 6644
6635 ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); 6645 ptxBeacon_parm = rtw_zmalloc(sizeof(struct Tx_Beacon_param));
6636 if (ptxBeacon_parm == NULL) { 6646 if (ptxBeacon_parm == NULL) {
6637 kfree((unsigned char *)ph2c); 6647 kfree((unsigned char *)ph2c);
6638 res = _FAIL; 6648 res = _FAIL;
@@ -6767,7 +6777,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)
6767 6777
6768 pxmitframe->attrib.triggered = 1; 6778 pxmitframe->attrib.triggered = 1;
6769 6779
6770 if (xmitframe_hiq_filter(pxmitframe) == true) 6780 if (xmitframe_hiq_filter(pxmitframe))
6771 pxmitframe->attrib.qsel = 0x11;/* HIQ */ 6781 pxmitframe->attrib.qsel = 0x11;/* HIQ */
6772 6782
6773 rtw_hal_xmitframe_enqueue(padapter, pxmitframe); 6783 rtw_hal_xmitframe_enqueue(padapter, pxmitframe);
@@ -6809,7 +6819,7 @@ int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset
6809 connect_allow = false; 6819 connect_allow = false;
6810 } 6820 }
6811 6821
6812 if (connect_allow == true) { 6822 if (connect_allow) {
6813 DBG_871X("start_join_set_ch_bw: ch =%d, bwmode =%d, ch_offset =%d\n", cur_ch, cur_bw, cur_ch_offset); 6823 DBG_871X("start_join_set_ch_bw: ch =%d, bwmode =%d, ch_offset =%d\n", cur_ch, cur_bw, cur_ch_offset);
6814 *ch = cur_ch; 6824 *ch = cur_ch;
6815 *bw = cur_bw; 6825 *bw = cur_bw;
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index aabdaafcbdd3..4a6af72013fa 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -34,7 +34,7 @@ void _ips_enter(struct adapter *padapter)
34 34
35 if (rf_off == pwrpriv->change_rfpwrstate) { 35 if (rf_off == pwrpriv->change_rfpwrstate) {
36 pwrpriv->bpower_saving = true; 36 pwrpriv->bpower_saving = true;
37 DBG_871X_LEVEL(_drv_always_, "nolinked power save enter\n"); 37 DBG_871X("nolinked power save enter\n");
38 38
39 if (pwrpriv->ips_mode == IPS_LEVEL_2) 39 if (pwrpriv->ips_mode == IPS_LEVEL_2)
40 pwrpriv->bkeepfwalive = true; 40 pwrpriv->bkeepfwalive = true;
@@ -73,7 +73,7 @@ int _ips_leave(struct adapter *padapter)
73 if (result == _SUCCESS) { 73 if (result == _SUCCESS) {
74 pwrpriv->rf_pwrstate = rf_on; 74 pwrpriv->rf_pwrstate = rf_on;
75 } 75 }
76 DBG_871X_LEVEL(_drv_always_, "nolinked power save leave\n"); 76 DBG_871X("nolinked power save leave\n");
77 77
78 DBG_871X("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); 78 DBG_871X("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c));
79 pwrpriv->bips_processing = false; 79 pwrpriv->bips_processing = false;
@@ -201,10 +201,12 @@ exit:
201 return; 201 return;
202} 202}
203 203
204void pwr_state_check_handler(RTW_TIMER_HDL_ARGS); 204static void pwr_state_check_handler(struct timer_list *t)
205void pwr_state_check_handler(RTW_TIMER_HDL_ARGS)
206{ 205{
207 struct adapter *padapter = (struct adapter *)FunctionContext; 206 struct pwrctrl_priv *pwrctrlpriv =
207 from_timer(pwrctrlpriv, t, pwr_state_check_timer);
208 struct adapter *padapter = pwrctrlpriv->adapter;
209
208 rtw_ps_cmd(padapter); 210 rtw_ps_cmd(padapter);
209} 211}
210 212
@@ -823,14 +825,10 @@ exit:
823/* 825/*
824 * This function is a timer handler, can't do any IO in it. 826 * This function is a timer handler, can't do any IO in it.
825 */ 827 */
826static void pwr_rpwm_timeout_handler(void *FunctionContext) 828static void pwr_rpwm_timeout_handler(struct timer_list *t)
827{ 829{
828 struct adapter *padapter; 830 struct pwrctrl_priv *pwrpriv = from_timer(pwrpriv, t, pwr_rpwm_timer);
829 struct pwrctrl_priv *pwrpriv;
830
831 831
832 padapter = FunctionContext;
833 pwrpriv = adapter_to_pwrctl(padapter);
834 DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); 832 DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
835 833
836 if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { 834 if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
@@ -1154,7 +1152,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
1154 1152
1155 pwrctrlpriv->LpsIdleCount = 0; 1153 pwrctrlpriv->LpsIdleCount = 0;
1156 pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ 1154 pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */
1157 pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; 1155 pwrctrlpriv->bLeisurePs = pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;
1158 1156
1159 pwrctrlpriv->bFwCurrentInPSMode = false; 1157 pwrctrlpriv->bFwCurrentInPSMode = false;
1160 1158
@@ -1173,10 +1171,11 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
1173 _init_workitem(&pwrctrlpriv->cpwm_event, cpwm_event_callback, NULL); 1171 _init_workitem(&pwrctrlpriv->cpwm_event, cpwm_event_callback, NULL);
1174 1172
1175 pwrctrlpriv->brpwmtimeout = false; 1173 pwrctrlpriv->brpwmtimeout = false;
1174 pwrctrlpriv->adapter = padapter;
1176 _init_workitem(&pwrctrlpriv->rpwmtimeoutwi, rpwmtimeout_workitem_callback, NULL); 1175 _init_workitem(&pwrctrlpriv->rpwmtimeoutwi, rpwmtimeout_workitem_callback, NULL);
1177 _init_timer(&pwrctrlpriv->pwr_rpwm_timer, padapter->pnetdev, pwr_rpwm_timeout_handler, padapter); 1176 timer_setup(&pwrctrlpriv->pwr_rpwm_timer, pwr_rpwm_timeout_handler, 0);
1178 1177 timer_setup(&pwrctrlpriv->pwr_state_check_timer,
1179 rtw_init_timer(&pwrctrlpriv->pwr_state_check_timer, padapter, pwr_state_check_handler); 1178 pwr_state_check_handler, 0);
1180 1179
1181 pwrctrlpriv->wowlan_mode = false; 1180 pwrctrlpriv->wowlan_mode = false;
1182 pwrctrlpriv->wowlan_ap_mode = false; 1181 pwrctrlpriv->wowlan_ap_mode = false;
@@ -1193,8 +1192,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
1193 1192
1194void rtw_free_pwrctrl_priv(struct adapter *adapter) 1193void rtw_free_pwrctrl_priv(struct adapter *adapter)
1195{ 1194{
1196 /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */
1197
1198#ifdef CONFIG_PNO_SUPPORT 1195#ifdef CONFIG_PNO_SUPPORT
1199 if (pwrctrlpriv->pnlo_info != NULL) 1196 if (pwrctrlpriv->pnlo_info != NULL)
1200 printk("****** pnlo_info memory leak********\n"); 1197 printk("****** pnlo_info memory leak********\n");
@@ -1327,7 +1324,8 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode)
1327 pwrctrlpriv->LpsIdleCount = 2; 1324 pwrctrlpriv->LpsIdleCount = 2;
1328 1325
1329 pwrctrlpriv->power_mgnt = mode; 1326 pwrctrlpriv->power_mgnt = mode;
1330 pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; 1327 pwrctrlpriv->bLeisurePs =
1328 pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;
1331 } 1329 }
1332 } else 1330 } else
1333 ret = -EINVAL; 1331 ret = -EINVAL;
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 68a6303e2754..9c7c3be0553a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -26,7 +26,7 @@ u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
26/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ 26/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
27u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; 27u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
28 28
29void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); 29static void rtw_signal_stat_timer_hdl(struct timer_list *t);
30 30
31void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) 31void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
32{ 32{
@@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
46 union recv_frame *precvframe; 46 union recv_frame *precvframe;
47 sint res = _SUCCESS; 47 sint res = _SUCCESS;
48 48
49 /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
50 /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */
51
52 spin_lock_init(&precvpriv->lock); 49 spin_lock_init(&precvpriv->lock);
53 50
54 _rtw_init_queue(&precvpriv->free_recv_queue); 51 _rtw_init_queue(&precvpriv->free_recv_queue);
@@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
65 res = _FAIL; 62 res = _FAIL;
66 goto exit; 63 goto exit;
67 } 64 }
68 /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */
69 65
70 precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); 66 precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ);
71 /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ 67 /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */
@@ -90,7 +86,8 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
90 86
91 res = rtw_hal_init_recv_priv(padapter); 87 res = rtw_hal_init_recv_priv(padapter);
92 88
93 rtw_init_timer(&precvpriv->signal_stat_timer, padapter, rtw_signal_stat_timer_hdl); 89 timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl,
90 0);
94 91
95 precvpriv->signal_stat_sampling_interval = 2000; /* ms */ 92 precvpriv->signal_stat_sampling_interval = 2000; /* ms */
96 93
@@ -129,7 +126,7 @@ union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
129 126
130 plist = get_next(phead); 127 plist = get_next(phead);
131 128
132 precvframe = LIST_CONTAINOR(plist, union recv_frame, u); 129 precvframe = (union recv_frame *)plist;
133 130
134 list_del_init(&precvframe->u.hdr.list); 131 list_del_init(&precvframe->u.hdr.list);
135 padapter = precvframe->u.hdr.adapter; 132 padapter = precvframe->u.hdr.adapter;
@@ -243,7 +240,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre
243 plist = get_next(phead); 240 plist = get_next(phead);
244 241
245 while (phead != plist) { 242 while (phead != plist) {
246 precvframe = LIST_CONTAINOR(plist, union recv_frame, u); 243 precvframe = (union recv_frame *)plist;
247 244
248 plist = get_next(plist); 245 plist = get_next(plist);
249 246
@@ -1732,7 +1729,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
1732 1729
1733 phead = get_list_head(defrag_q); 1730 phead = get_list_head(defrag_q);
1734 plist = get_next(phead); 1731 plist = get_next(phead);
1735 prframe = LIST_CONTAINOR(plist, union recv_frame, u); 1732 prframe = (union recv_frame *)plist;
1736 pfhdr = &prframe->u.hdr; 1733 pfhdr = &prframe->u.hdr;
1737 list_del_init(&(prframe->u.list)); 1734 list_del_init(&(prframe->u.list));
1738 1735
@@ -1754,7 +1751,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
1754 data = get_recvframe_data(prframe); 1751 data = get_recvframe_data(prframe);
1755 1752
1756 while (phead != plist) { 1753 while (phead != plist) {
1757 pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); 1754 pnextrframe = (union recv_frame *)plist;
1758 pnfhdr = &pnextrframe->u.hdr; 1755 pnfhdr = &pnextrframe->u.hdr;
1759 1756
1760 1757
@@ -2071,7 +2068,7 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec
2071 plist = get_next(phead); 2068 plist = get_next(phead);
2072 2069
2073 while (phead != plist) { 2070 while (phead != plist) {
2074 pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); 2071 pnextrframe = (union recv_frame *)plist;
2075 pnextattrib = &pnextrframe->u.hdr.attrib; 2072 pnextattrib = &pnextrframe->u.hdr.attrib;
2076 2073
2077 if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) 2074 if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -2146,7 +2143,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
2146 return true; 2143 return true;
2147 } 2144 }
2148 2145
2149 prframe = LIST_CONTAINOR(plist, union recv_frame, u); 2146 prframe = (union recv_frame *)plist;
2150 pattrib = &prframe->u.hdr.attrib; 2147 pattrib = &prframe->u.hdr.attrib;
2151 2148
2152 #ifdef DBG_RX_SEQ 2149 #ifdef DBG_RX_SEQ
@@ -2162,7 +2159,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
2162 /* Check if there is any packet need indicate. */ 2159 /* Check if there is any packet need indicate. */
2163 while (!list_empty(phead)) { 2160 while (!list_empty(phead)) {
2164 2161
2165 prframe = LIST_CONTAINOR(plist, union recv_frame, u); 2162 prframe = (union recv_frame *)plist;
2166 pattrib = &prframe->u.hdr.attrib; 2163 pattrib = &prframe->u.hdr.attrib;
2167 2164
2168 if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { 2165 if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
@@ -2358,9 +2355,10 @@ _err_exit:
2358} 2355}
2359 2356
2360 2357
2361void rtw_reordering_ctrl_timeout_handler(void *pcontext) 2358void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
2362{ 2359{
2363 struct recv_reorder_ctrl *preorder_ctrl = pcontext; 2360 struct recv_reorder_ctrl *preorder_ctrl =
2361 from_timer(preorder_ctrl, t, reordering_ctrl_timer);
2364 struct adapter *padapter = preorder_ctrl->padapter; 2362 struct adapter *padapter = preorder_ctrl->padapter;
2365 struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; 2363 struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
2366 2364
@@ -2601,9 +2599,10 @@ _recv_entry_drop:
2601 return ret; 2599 return ret;
2602} 2600}
2603 2601
2604void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) 2602static void rtw_signal_stat_timer_hdl(struct timer_list *t)
2605{ 2603{
2606 struct adapter *adapter = (struct adapter *)FunctionContext; 2604 struct adapter *adapter =
2605 from_timer(adapter, t, recvpriv.signal_stat_timer);
2607 struct recv_priv *recvpriv = &adapter->recvpriv; 2606 struct recv_priv *recvpriv = &adapter->recvpriv;
2608 2607
2609 u32 tmp_s, tmp_q; 2608 u32 tmp_s, tmp_q;
diff --git a/drivers/staging/rtl8723bs/core/rtw_rf.c b/drivers/staging/rtl8723bs/core/rtw_rf.c
index b87ea4e388c0..07f5577cc073 100644
--- a/drivers/staging/rtl8723bs/core/rtw_rf.c
+++ b/drivers/staging/rtl8723bs/core/rtw_rf.c
@@ -15,6 +15,7 @@
15#define _RTW_RF_C_ 15#define _RTW_RF_C_
16 16
17#include <drv_types.h> 17#include <drv_types.h>
18#include <linux/kernel.h>
18 19
19 20
20struct ch_freq { 21struct ch_freq {
@@ -44,20 +45,18 @@ static struct ch_freq ch_freq_map[] = {
44 {216, 5080},/* Japan, means J16 */ 45 {216, 5080},/* Japan, means J16 */
45}; 46};
46 47
47static int ch_freq_map_num = (sizeof(ch_freq_map) / sizeof(struct ch_freq));
48
49u32 rtw_ch2freq(u32 channel) 48u32 rtw_ch2freq(u32 channel)
50{ 49{
51 u8 i; 50 u8 i;
52 u32 freq = 0; 51 u32 freq = 0;
53 52
54 for (i = 0; i < ch_freq_map_num; i++) { 53 for (i = 0; i < ARRAY_SIZE(ch_freq_map); i++) {
55 if (channel == ch_freq_map[i].channel) { 54 if (channel == ch_freq_map[i].channel) {
56 freq = ch_freq_map[i].frequency; 55 freq = ch_freq_map[i].frequency;
57 break; 56 break;
58 } 57 }
59 } 58 }
60 if (i == ch_freq_map_num) 59 if (i == ARRAY_SIZE(ch_freq_map))
61 freq = 2412; 60 freq = 2412;
62 61
63 return freq; 62 return freq;
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 06a7e4059fbb..aadf67bd0559 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -2272,7 +2272,7 @@ static void *aes_encrypt_init(u8 *key, size_t len)
2272 u32 *rk; 2272 u32 *rk;
2273 if (len != 16) 2273 if (len != 16)
2274 return NULL; 2274 return NULL;
2275 rk = (u32 *)rtw_malloc(AES_PRIV_SIZE); 2275 rk = rtw_malloc(AES_PRIV_SIZE);
2276 if (rk == NULL) 2276 if (rk == NULL)
2277 return NULL; 2277 return NULL;
2278 rijndaelKeySetupEnc(rk, key); 2278 rijndaelKeySetupEnc(rk, key);
diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index cb43ec90a648..03dd6848daa1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -429,7 +429,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
429 plist = get_next(phead); 429 plist = get_next(phead);
430 430
431 while (!list_empty(phead)) { 431 while (!list_empty(phead)) {
432 prframe = LIST_CONTAINOR(plist, union recv_frame, u); 432 prframe = (union recv_frame *)plist;
433 433
434 plist = get_next(plist); 434 plist = get_next(plist);
435 435
@@ -604,10 +604,10 @@ struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter)
604 604
605u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) 605u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
606{ 606{
607 u8 res = true; 607 bool res = true;
608 struct list_head *plist, *phead; 608 struct list_head *plist, *phead;
609 struct rtw_wlan_acl_node *paclnode; 609 struct rtw_wlan_acl_node *paclnode;
610 u8 match = false; 610 bool match = false;
611 struct sta_priv *pstapriv = &padapter->stapriv; 611 struct sta_priv *pstapriv = &padapter->stapriv;
612 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; 612 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
613 struct __queue *pacl_node_q = &pacl_list->acl_node_q; 613 struct __queue *pacl_node_q = &pacl_list->acl_node_q;
@@ -630,10 +630,10 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
630 630
631 631
632 if (pacl_list->mode == 1) /* accept unless in deny list */ 632 if (pacl_list->mode == 1) /* accept unless in deny list */
633 res = (match == true) ? false:true; 633 res = !match;
634 634
635 else if (pacl_list->mode == 2)/* deny unless in accept list */ 635 else if (pacl_list->mode == 2)/* deny unless in accept list */
636 res = (match == true) ? true:false; 636 res = match;
637 else 637 else
638 res = true; 638 res = true;
639 639
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index f485f541e36d..f6dc26c8bd3d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1359,7 +1359,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
1359 return true; 1359 return true;
1360 } 1360 }
1361 1361
1362 bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); 1362 bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex));
1363 if (bssid == NULL) { 1363 if (bssid == NULL) {
1364 DBG_871X("%s rtw_zmalloc fail !!!\n", __func__); 1364 DBG_871X("%s rtw_zmalloc fail !!!\n", __func__);
1365 return true; 1365 return true;
@@ -1946,7 +1946,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
1946 preorder_ctrl->indicate_seq = 0xffff; 1946 preorder_ctrl->indicate_seq = 0xffff;
1947 #endif 1947 #endif
1948 1948
1949 preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq == true) ? true : false; 1949 preorder_ctrl->enable = pmlmeinfo->accept_addba_req;
1950 } 1950 }
1951 1951
1952} 1952}
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 022f654419e4..be54186fb223 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
51 struct xmit_frame *pxframe; 51 struct xmit_frame *pxframe;
52 sint res = _SUCCESS; 52 sint res = _SUCCESS;
53 53
54 /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
55 /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */
56
57 spin_lock_init(&pxmitpriv->lock); 54 spin_lock_init(&pxmitpriv->lock);
58 spin_lock_init(&pxmitpriv->lock_sctx); 55 spin_lock_init(&pxmitpriv->lock_sctx);
59 sema_init(&pxmitpriv->xmit_sema, 0); 56 sema_init(&pxmitpriv->xmit_sema, 0);
@@ -2166,7 +2163,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
2166 2163
2167 pxmitpriv->hwxmits = NULL; 2164 pxmitpriv->hwxmits = NULL;
2168 2165
2169 pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); 2166 pxmitpriv->hwxmits = rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry);
2170 2167
2171 if (pxmitpriv->hwxmits == NULL) { 2168 if (pxmitpriv->hwxmits == NULL) {
2172 DBG_871X("alloc hwxmits fail!...\n"); 2169 DBG_871X("alloc hwxmits fail!...\n");
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
index 51d4219177d3..951585467ab1 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
@@ -13,7 +13,7 @@
13* 13*
14******************************************************************************/ 14******************************************************************************/
15 15
16 16#include <linux/kernel.h>
17#include "odm_precomp.h" 17#include "odm_precomp.h"
18 18
19static bool CheckPositive( 19static bool CheckPositive(
@@ -268,7 +268,7 @@ static u32 Array_MP_8723B_AGC_TAB[] = {
268void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm) 268void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
269{ 269{
270 u32 i = 0; 270 u32 i = 0;
271 u32 ArrayLen = sizeof(Array_MP_8723B_AGC_TAB)/sizeof(u32); 271 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_AGC_TAB);
272 u32 *Array = Array_MP_8723B_AGC_TAB; 272 u32 *Array = Array_MP_8723B_AGC_TAB;
273 273
274 ODM_RT_TRACE( 274 ODM_RT_TRACE(
@@ -537,7 +537,7 @@ static u32 Array_MP_8723B_PHY_REG[] = {
537void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm) 537void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
538{ 538{
539 u32 i = 0; 539 u32 i = 0;
540 u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG)/sizeof(u32); 540 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_PHY_REG);
541 u32 *Array = Array_MP_8723B_PHY_REG; 541 u32 *Array = Array_MP_8723B_PHY_REG;
542 542
543 ODM_RT_TRACE( 543 ODM_RT_TRACE(
@@ -617,7 +617,6 @@ static u32 Array_MP_8723B_PHY_REG_PG[] = {
617void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm) 617void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm)
618{ 618{
619 u32 i = 0; 619 u32 i = 0;
620 u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG_PG)/sizeof(u32);
621 u32 *Array = Array_MP_8723B_PHY_REG_PG; 620 u32 *Array = Array_MP_8723B_PHY_REG_PG;
622 621
623 ODM_RT_TRACE( 622 ODM_RT_TRACE(
@@ -630,7 +629,7 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm)
630 pDM_Odm->PhyRegPgVersion = 1; 629 pDM_Odm->PhyRegPgVersion = 1;
631 pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; 630 pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE;
632 631
633 for (i = 0; i < ArrayLen; i += 6) { 632 for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_PHY_REG_PG); i += 6) {
634 u32 v1 = Array[i]; 633 u32 v1 = Array[i];
635 u32 v2 = Array[i+1]; 634 u32 v2 = Array[i+1];
636 u32 v3 = Array[i+2]; 635 u32 v3 = Array[i+2];
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
index b868e26f20ac..7f8afa1be1ca 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
@@ -13,7 +13,7 @@
13* 13*
14******************************************************************************/ 14******************************************************************************/
15 15
16 16#include <linux/kernel.h>
17#include "odm_precomp.h" 17#include "odm_precomp.h"
18 18
19static bool CheckPositive( 19static bool CheckPositive(
@@ -239,7 +239,7 @@ static u32 Array_MP_8723B_MAC_REG[] = {
239void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm) 239void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
240{ 240{
241 u32 i = 0; 241 u32 i = 0;
242 u32 ArrayLen = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u32); 242 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG);
243 u32 *Array = Array_MP_8723B_MAC_REG; 243 u32 *Array = Array_MP_8723B_MAC_REG;
244 244
245 ODM_RT_TRACE( 245 ODM_RT_TRACE(
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
index 84a0be7ba697..fadfcbd91858 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
@@ -13,7 +13,7 @@
13* 13*
14******************************************************************************/ 14******************************************************************************/
15 15
16 16#include <linux/kernel.h>
17#include "odm_precomp.h" 17#include "odm_precomp.h"
18 18
19static bool CheckPositive( 19static bool CheckPositive(
@@ -270,7 +270,7 @@ static u32 Array_MP_8723B_RadioA[] = {
270void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm) 270void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm)
271{ 271{
272 u32 i = 0; 272 u32 i = 0;
273 u32 ArrayLen = sizeof(Array_MP_8723B_RadioA)/sizeof(u32); 273 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_RadioA);
274 u32 *Array = Array_MP_8723B_RadioA; 274 u32 *Array = Array_MP_8723B_RadioA;
275 275
276 ODM_RT_TRACE( 276 ODM_RT_TRACE(
@@ -766,7 +766,6 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = {
766void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm) 766void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm)
767{ 767{
768 u32 i = 0; 768 u32 i = 0;
769 u32 ArrayLen = sizeof(Array_MP_8723B_TXPWR_LMT)/sizeof(u8 *);
770 u8 **Array = Array_MP_8723B_TXPWR_LMT; 769 u8 **Array = Array_MP_8723B_TXPWR_LMT;
771 770
772 ODM_RT_TRACE( 771 ODM_RT_TRACE(
@@ -776,7 +775,7 @@ void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm)
776 ("===> ODM_ReadAndConfig_MP_8723B_TXPWR_LMT\n") 775 ("===> ODM_ReadAndConfig_MP_8723B_TXPWR_LMT\n")
777 ); 776 );
778 777
779 for (i = 0; i < ArrayLen; i += 7) { 778 for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_TXPWR_LMT); i += 7) {
780 u8 *regulation = Array[i]; 779 u8 *regulation = Array[i];
781 u8 *band = Array[i+1]; 780 u8 *band = Array[i+1];
782 u8 *bandwidth = Array[i+2]; 781 u8 *bandwidth = Array[i+2];
diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
index 86fee109e42d..7d4df5a8832e 100644
--- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c
+++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
@@ -463,7 +463,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
463 break; 463 break;
464 464
465 case BTC_GET_BL_WIFI_UNDER_5G: 465 case BTC_GET_BL_WIFI_UNDER_5G:
466 *pu8 = (pHalData->CurrentBandType == 1) ? true : false; 466 *pu8 = pHalData->CurrentBandType == 1;
467 break; 467 break;
468 468
469 case BTC_GET_BL_WIFI_AP_MODE_ENABLE: 469 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
@@ -1411,15 +1411,8 @@ void hal_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
1411 1411
1412u8 hal_btcoex_Initialize(struct adapter *padapter) 1412u8 hal_btcoex_Initialize(struct adapter *padapter)
1413{ 1413{
1414 u8 ret1;
1415 u8 ret2;
1416
1417
1418 memset(&GLBtCoexist, 0, sizeof(GLBtCoexist)); 1414 memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
1419 ret1 = EXhalbtcoutsrc_InitlizeVariables((void *)padapter); 1415 return EXhalbtcoutsrc_InitlizeVariables((void *)padapter);
1420 ret2 = (ret1 == true) ? true : false;
1421
1422 return ret2;
1423} 1416}
1424 1417
1425void hal_btcoex_PowerOnSetting(struct adapter *padapter) 1418void hal_btcoex_PowerOnSetting(struct adapter *padapter)
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c
index 3e63b6d9c097..dec887a5b338 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -14,6 +14,7 @@
14 ******************************************************************************/ 14 ******************************************************************************/
15#define _HAL_COM_C_ 15#define _HAL_COM_C_
16 16
17#include <linux/kernel.h>
17#include <drv_types.h> 18#include <drv_types.h>
18#include <rtw_debug.h> 19#include <rtw_debug.h>
19#include "hal_com_h2c.h" 20#include "hal_com_h2c.h"
@@ -1622,7 +1623,7 @@ void rtw_get_raw_rssi_info(void *sel, struct adapter *padapter)
1622 psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all 1623 psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all
1623 ); 1624 );
1624 1625
1625 isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M) ? true : false; 1626 isCCKrate = psample_pkt_rssi->data_rate <= DESC_RATE11M;
1626 1627
1627 if (isCCKrate) 1628 if (isCCKrate)
1628 psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball; 1629 psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball;
@@ -1655,7 +1656,7 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter)
1655 DBG_871X("RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n", 1656 DBG_871X("RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n",
1656 HDATA_RATE(psample_pkt_rssi->data_rate), psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all); 1657 HDATA_RATE(psample_pkt_rssi->data_rate), psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all);
1657 1658
1658 isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M) ? true : false; 1659 isCCKrate = psample_pkt_rssi->data_rate <= DESC_RATE11M;
1659 1660
1660 if (isCCKrate) 1661 if (isCCKrate)
1661 psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball; 1662 psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball;
@@ -1683,7 +1684,7 @@ void rtw_store_phy_info(struct adapter *padapter, union recv_frame *prframe)
1683 struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info; 1684 struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info;
1684 1685
1685 psample_pkt_rssi->data_rate = pattrib->data_rate; 1686 psample_pkt_rssi->data_rate = pattrib->data_rate;
1686 isCCKrate = (pattrib->data_rate <= DESC_RATE11M) ? true : false; 1687 isCCKrate = pattrib->data_rate <= DESC_RATE11M;
1687 1688
1688 psample_pkt_rssi->pwdball = pPhyInfo->RxPWDBAll; 1689 psample_pkt_rssi->pwdball = pPhyInfo->RxPWDBAll;
1689 psample_pkt_rssi->pwr_all = pPhyInfo->RecvSignalPower; 1690 psample_pkt_rssi->pwr_all = pPhyInfo->RecvSignalPower;
@@ -1716,7 +1717,6 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter)
1716{ 1717{
1717 u8 value = padapter->eeprompriv.EEPROMRFGainOffset; 1718 u8 value = padapter->eeprompriv.EEPROMRFGainOffset;
1718 u32 res, i = 0; 1719 u32 res, i = 0;
1719 u32 ArrayLen = sizeof(Array_kfreemap)/sizeof(u32);
1720 u32 *Array = Array_kfreemap; 1720 u32 *Array = Array_kfreemap;
1721 u32 v1 = 0, v2 = 0, target = 0; 1721 u32 v1 = 0, v2 = 0, target = 0;
1722 /* DBG_871X("+%s value: 0x%02x+\n", __func__, value); */ 1722 /* DBG_871X("+%s value: 0x%02x+\n", __func__, value); */
@@ -1729,7 +1729,7 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter)
1729 res &= 0xfff87fff; 1729 res &= 0xfff87fff;
1730 DBG_871X("Offset RF Gain. before reg 0x7f = 0x%08x\n", res); 1730 DBG_871X("Offset RF Gain. before reg 0x7f = 0x%08x\n", res);
1731 /* res &= 0xfff87fff; */ 1731 /* res &= 0xfff87fff; */
1732 for (i = 0; i < ArrayLen; i += 2) { 1732 for (i = 0; i < ARRAY_SIZE(Array_kfreemap); i += 2) {
1733 v1 = Array[i]; 1733 v1 = Array[i];
1734 v2 = Array[i+1]; 1734 v2 = Array[i+1];
1735 if (v1 == padapter->eeprompriv.EEPROMRFGainVal) { 1735 if (v1 == padapter->eeprompriv.EEPROMRFGainVal) {
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 566b6f0997da..e6787c22e00b 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -17,6 +17,7 @@
17#include <drv_types.h> 17#include <drv_types.h>
18#include <rtw_debug.h> 18#include <rtw_debug.h>
19#include <hal_data.h> 19#include <hal_data.h>
20#include <linux/kernel.h>
20 21
21u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath, 22u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
22 u8 TxNum, enum RATE_SECTION RateSection) 23 u8 TxNum, enum RATE_SECTION RateSection)
@@ -860,7 +861,7 @@ struct adapter *padapter
860 for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { 861 for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) {
861 /* CCK */ 862 /* CCK */
862 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_11M); 863 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_11M);
863 for (i = 0; i < sizeof(cckRates); ++i) { 864 for (i = 0; i < ARRAY_SIZE(cckRates); ++i) {
864 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, cckRates[i]); 865 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, cckRates[i]);
865 PHY_SetTxPowerByRate(padapter, band, path, txNum, cckRates[i], value - base); 866 PHY_SetTxPowerByRate(padapter, band, path, txNum, cckRates[i], value - base);
866 } 867 }
@@ -939,58 +940,78 @@ void PHY_SetTxPowerIndexByRateSection(
939 if (RateSection == CCK) { 940 if (RateSection == CCK) {
940 u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}; 941 u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M};
941 if (pHalData->CurrentBandType == BAND_ON_2_4G) 942 if (pHalData->CurrentBandType == BAND_ON_2_4G)
942 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 943 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
943 cckRates, sizeof(cckRates)/sizeof(u8)); 944 pHalData->CurrentChannelBW,
945 Channel, cckRates,
946 ARRAY_SIZE(cckRates));
944 947
945 } else if (RateSection == OFDM) { 948 } else if (RateSection == OFDM) {
946 u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M}; 949 u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M};
947 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 950 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
948 ofdmRates, sizeof(ofdmRates)/sizeof(u8)); 951 pHalData->CurrentChannelBW,
952 Channel, ofdmRates,
953 ARRAY_SIZE(ofdmRates));
949 954
950 } else if (RateSection == HT_MCS0_MCS7) { 955 } else if (RateSection == HT_MCS0_MCS7) {
951 u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}; 956 u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7};
952 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 957 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
953 htRates1T, sizeof(htRates1T)/sizeof(u8)); 958 pHalData->CurrentChannelBW,
959 Channel, htRates1T,
960 ARRAY_SIZE(htRates1T));
954 961
955 } else if (RateSection == HT_MCS8_MCS15) { 962 } else if (RateSection == HT_MCS8_MCS15) {
956 u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}; 963 u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15};
957 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 964 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
958 htRates2T, sizeof(htRates2T)/sizeof(u8)); 965 pHalData->CurrentChannelBW,
966 Channel, htRates2T,
967 ARRAY_SIZE(htRates2T));
959 968
960 } else if (RateSection == HT_MCS16_MCS23) { 969 } else if (RateSection == HT_MCS16_MCS23) {
961 u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}; 970 u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23};
962 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 971 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
963 htRates3T, sizeof(htRates3T)/sizeof(u8)); 972 pHalData->CurrentChannelBW,
973 Channel, htRates3T,
974 ARRAY_SIZE(htRates3T));
964 975
965 } else if (RateSection == HT_MCS24_MCS31) { 976 } else if (RateSection == HT_MCS24_MCS31) {
966 u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31}; 977 u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31};
967 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 978 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
968 htRates4T, sizeof(htRates4T)/sizeof(u8)); 979 pHalData->CurrentChannelBW,
980 Channel, htRates4T,
981 ARRAY_SIZE(htRates4T));
969 982
970 } else if (RateSection == VHT_1SSMCS0_1SSMCS9) { 983 } else if (RateSection == VHT_1SSMCS0_1SSMCS9) {
971 u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4, 984 u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4,
972 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9}; 985 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9};
973 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 986 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
974 vhtRates1T, sizeof(vhtRates1T)/sizeof(u8)); 987 pHalData->CurrentChannelBW,
988 Channel, vhtRates1T,
989 ARRAY_SIZE(vhtRates1T));
975 990
976 } else if (RateSection == VHT_2SSMCS0_2SSMCS9) { 991 } else if (RateSection == VHT_2SSMCS0_2SSMCS9) {
977 u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, 992 u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4,
978 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9}; 993 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9};
979 994
980 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 995 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
981 vhtRates2T, sizeof(vhtRates2T)/sizeof(u8)); 996 pHalData->CurrentChannelBW,
997 Channel, vhtRates2T,
998 ARRAY_SIZE(vhtRates2T));
982 } else if (RateSection == VHT_3SSMCS0_3SSMCS9) { 999 } else if (RateSection == VHT_3SSMCS0_3SSMCS9) {
983 u8 vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4, 1000 u8 vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4,
984 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9}; 1001 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9};
985 1002
986 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 1003 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
987 vhtRates3T, sizeof(vhtRates3T)/sizeof(u8)); 1004 pHalData->CurrentChannelBW,
1005 Channel, vhtRates3T,
1006 ARRAY_SIZE(vhtRates3T));
988 } else if (RateSection == VHT_4SSMCS0_4SSMCS9) { 1007 } else if (RateSection == VHT_4SSMCS0_4SSMCS9) {
989 u8 vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4, 1008 u8 vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4,
990 MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9}; 1009 MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9};
991 1010
992 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, 1011 PHY_SetTxPowerIndexByRateArray(padapter, RFPath,
993 vhtRates4T, sizeof(vhtRates4T)/sizeof(u8)); 1012 pHalData->CurrentChannelBW,
1013 Channel, vhtRates4T,
1014 ARRAY_SIZE(vhtRates4T));
994 } else 1015 } else
995 DBG_871X("Invalid RateSection %d in %s", RateSection, __func__); 1016 DBG_871X("Invalid RateSection %d in %s", RateSection, __func__);
996} 1017}
@@ -1012,7 +1033,7 @@ static bool phy_GetChnlIndex(u8 Channel, u8 *ChannelIdx)
1012 } else { 1033 } else {
1013 bIn24G = false; 1034 bIn24G = false;
1014 1035
1015 for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { 1036 for (i = 0; i < ARRAY_SIZE(channel5G); ++i) {
1016 if (channel5G[i] == Channel) { 1037 if (channel5G[i] == Channel) {
1017 *ChannelIdx = i; 1038 *ChannelIdx = i;
1018 return bIn24G; 1039 return bIn24G;
@@ -1149,7 +1170,7 @@ u8 PHY_GetTxPowerIndexBase(
1149 } else if (BandWidth == CHANNEL_WIDTH_80) { /* BW80-1S, BW80-2S */ 1170 } else if (BandWidth == CHANNEL_WIDTH_80) { /* BW80-1S, BW80-2S */
1150 /* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */ 1171 /* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */
1151 u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171}; 1172 u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171};
1152 for (i = 0; i < sizeof(channel5G_80M)/sizeof(u8); ++i) 1173 for (i = 0; i < ARRAY_SIZE(channel5G_80M); ++i)
1153 if (channel5G_80M[i] == Channel) 1174 if (channel5G_80M[i] == Channel)
1154 chnlIdx = i; 1175 chnlIdx = i;
1155 1176
@@ -1588,7 +1609,7 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
1588 if (Band == BAND_ON_2_4G) 1609 if (Band == BAND_ON_2_4G)
1589 channelIndex = Channel - 1; 1610 channelIndex = Channel - 1;
1590 else if (Band == BAND_ON_5G) { 1611 else if (Band == BAND_ON_5G) {
1591 for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { 1612 for (i = 0; i < ARRAY_SIZE(channel5G); ++i) {
1592 if (channel5G[i] == Channel) 1613 if (channel5G[i] == Channel)
1593 channelIndex = i; 1614 channelIndex = i;
1594 } 1615 }
diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
index 9cde6c66235b..71853e6f7106 100644
--- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
+++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
@@ -23,7 +23,7 @@ static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap)
23 struct adapter *Adapter = pDM_Odm->Adapter; 23 struct adapter *Adapter = pDM_Odm->Adapter;
24 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); 24 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
25 25
26 bEEPROMCheck = (pHalData->EEPROMVersion >= 0x01) ? true : false; 26 bEEPROMCheck = pHalData->EEPROMVersion >= 0x01;
27 27
28 if (pCfoTrack->CrystalCap == CrystalCap) 28 if (pCfoTrack->CrystalCap == CrystalCap)
29 return; 29 return;
diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c
index 0bde9444471d..f02eb63a45ce 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DIG.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c
@@ -553,7 +553,7 @@ void odm_DIG(void *pDM_VOID)
553 dm_dig_min = DM_DIG_MIN_NIC; 553 dm_dig_min = DM_DIG_MIN_NIC;
554 DIG_MaxOfMin = DM_DIG_MAX_AP; 554 DIG_MaxOfMin = DM_DIG_MAX_AP;
555 555
556 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Absolutly upper bound = 0x%x, lower bound = 0x%x\n", dm_dig_max, dm_dig_min)); 556 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Absolutely upper bound = 0x%x, lower bound = 0x%x\n", dm_dig_max, dm_dig_min));
557 557
558 /* 1 Adjust boundary by RSSI */ 558 /* 1 Adjust boundary by RSSI */
559 if (pDM_Odm->bLinked && bPerformance) { 559 if (pDM_Odm->bLinked && bPerformance) {
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
index ba2700135b60..8dd6da8a4e26 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
@@ -106,7 +106,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(
106 u8 LNA_idx, VGA_idx; 106 u8 LNA_idx, VGA_idx;
107 PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus; 107 PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus;
108 108
109 isCCKrate = (pPktinfo->DataRate <= DESC_RATE11M) ? true : false; 109 isCCKrate = pPktinfo->DataRate <= DESC_RATE11M;
110 pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1; 110 pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1;
111 pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; 111 pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1;
112 112
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index 1565f2d67ea4..d6cef9e8378d 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -891,7 +891,7 @@ static void hal_ReadEFuse_WiFi(
891 return; 891 return;
892 } 892 }
893 893
894 efuseTbl = (u8 *)rtw_malloc(EFUSE_MAX_MAP_LEN); 894 efuseTbl = rtw_malloc(EFUSE_MAX_MAP_LEN);
895 if (efuseTbl == NULL) { 895 if (efuseTbl == NULL) {
896 DBG_8192C("%s: alloc efuseTbl fail!\n", __func__); 896 DBG_8192C("%s: alloc efuseTbl fail!\n", __func__);
897 return; 897 return;
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index d0b317077511..6281dfa1a3ca 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -113,7 +113,7 @@ query_free_page:
113 RT_TRACE( 113 RT_TRACE(
114 _module_hal_xmit_c_, 114 _module_hal_xmit_c_,
115 _drv_notice_, 115 _drv_notice_,
116 ("%s: bSurpriseRemoved(wirte port)\n", __func__) 116 ("%s: bSurpriseRemoved(write port)\n", __func__)
117 ); 117 );
118 goto free_xmitbuf; 118 goto free_xmitbuf;
119 } 119 }
diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
index 6dfb06a49d41..1af77add6af4 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
@@ -1019,8 +1019,8 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
1019 1019
1020 rtw_btcoex_IQKNotify(padapter, true); 1020 rtw_btcoex_IQKNotify(padapter, true);
1021 1021
1022 restore_iqk_rst = (pwrpriv->bips_processing == true) ? true : false; 1022 restore_iqk_rst = pwrpriv->bips_processing;
1023 b2Ant = pHalData->EEPROMBluetoothAntNum == Ant_x2 ? true : false; 1023 b2Ant = pHalData->EEPROMBluetoothAntNum == Ant_x2;
1024 PHY_IQCalibrate_8723B(padapter, false, restore_iqk_rst, b2Ant, pHalData->ant_path); 1024 PHY_IQCalibrate_8723B(padapter, false, restore_iqk_rst, b2Ant, pHalData->ant_path);
1025 pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true; 1025 pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true;
1026 1026
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 1d1b14dedd35..9a4c24861947 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -218,7 +218,7 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr)
218 } else { 218 } else {
219 u8 *ptmpbuf; 219 u8 *ptmpbuf;
220 220
221 ptmpbuf = (u8 *)rtw_malloc(8); 221 ptmpbuf = rtw_malloc(8);
222 if (NULL == ptmpbuf) { 222 if (NULL == ptmpbuf) {
223 DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr); 223 DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr);
224 return SDIO_ERR_VAL32; 224 return SDIO_ERR_VAL32;
@@ -594,7 +594,7 @@ static s32 _sdio_local_read(
594 } 594 }
595 595
596 n = RND4(cnt); 596 n = RND4(cnt);
597 ptmpbuf = (u8 *)rtw_malloc(n); 597 ptmpbuf = rtw_malloc(n);
598 if (!ptmpbuf) 598 if (!ptmpbuf)
599 return (-1); 599 return (-1);
600 600
@@ -637,7 +637,7 @@ s32 sdio_local_read(
637 } 637 }
638 638
639 n = RND4(cnt); 639 n = RND4(cnt);
640 ptmpbuf = (u8 *)rtw_malloc(n); 640 ptmpbuf = rtw_malloc(n);
641 if (!ptmpbuf) 641 if (!ptmpbuf)
642 return (-1); 642 return (-1);
643 643
@@ -684,7 +684,7 @@ s32 sdio_local_write(
684 return err; 684 return err;
685 } 685 }
686 686
687 ptmpbuf = (u8 *)rtw_malloc(cnt); 687 ptmpbuf = rtw_malloc(cnt);
688 if (!ptmpbuf) 688 if (!ptmpbuf)
689 return (-1); 689 return (-1);
690 690
@@ -1108,7 +1108,7 @@ void sd_int_dpc(struct adapter *padapter)
1108 struct c2h_evt_hdr_88xx *c2h_evt; 1108 struct c2h_evt_hdr_88xx *c2h_evt;
1109 1109
1110 DBG_8192C("%s: C2H Command\n", __func__); 1110 DBG_8192C("%s: C2H Command\n", __func__);
1111 c2h_evt = (struct c2h_evt_hdr_88xx *)rtw_zmalloc(16); 1111 c2h_evt = rtw_zmalloc(16);
1112 if (c2h_evt != NULL) { 1112 if (c2h_evt != NULL) {
1113 if (rtw_hal_c2h_evt_read(padapter, (u8 *)c2h_evt) == _SUCCESS) { 1113 if (rtw_hal_c2h_evt_read(padapter, (u8 *)c2h_evt) == _SUCCESS) {
1114 if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { 1114 if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) {
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index 4d14fbc5a1fe..32129ac8e169 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -177,7 +177,8 @@ struct registry_priv
177 u8 bt_ampdu; 177 u8 bt_ampdu;
178 s8 ant_num; 178 s8 ant_num;
179 179
180 bool bAcceptAddbaReq; 180 /* false:Reject AP's Add BA req, true:accept AP's Add BA req */
181 bool accept_addba_req;
181 182
182 u8 antdiv_cfg; 183 u8 antdiv_cfg;
183 u8 antdiv_type; 184 u8 antdiv_type;
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h
index ac9ffe0e3b84..e62ed71e1d80 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -96,8 +96,8 @@ typedef enum mstat_status{
96 96
97#define rtw_mstat_update(flag, status, sz) do {} while (0) 97#define rtw_mstat_update(flag, status, sz) do {} while (0)
98#define rtw_mstat_dump(sel) do {} while (0) 98#define rtw_mstat_dump(sel) do {} while (0)
99u8*_rtw_zmalloc(u32 sz); 99void *_rtw_zmalloc(u32 sz);
100u8*_rtw_malloc(u32 sz); 100void *_rtw_malloc(u32 sz);
101void _kfree(u8 *pbuf, u32 sz); 101void _kfree(u8 *pbuf, u32 sz);
102 102
103struct sk_buff *_rtw_skb_alloc(u32 sz); 103struct sk_buff *_rtw_skb_alloc(u32 sz);
@@ -118,8 +118,6 @@ int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb);
118 118
119extern void _rtw_init_queue(struct __queue *pqueue); 119extern void _rtw_init_queue(struct __queue *pqueue);
120 120
121extern void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc);
122
123static __inline void thread_enter(char *name) 121static __inline void thread_enter(char *name)
124{ 122{
125 allow_signal(SIGTERM); 123 allow_signal(SIGTERM);
diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 0c9b4f622fee..711863d74a01 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -86,17 +86,7 @@ __inline static struct list_head *get_list_head(struct __queue *queue)
86 86
87 87
88#define LIST_CONTAINOR(ptr, type, member) \ 88#define LIST_CONTAINOR(ptr, type, member) \
89 ((type *)((char *)(ptr)-(__kernel_size_t)(&((type *)0)->member))) 89 container_of(ptr, type, member)
90
91#define RTW_TIMER_HDL_ARGS void *FunctionContext
92
93__inline static void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void* cntx)
94{
95 /* setup_timer(ptimer, pfunc, (u32)cntx); */
96 ptimer->function = pfunc;
97 ptimer->data = (unsigned long)cntx;
98 init_timer(ptimer);
99}
100 90
101__inline static void _set_timer(_timer *ptimer, u32 delay_time) 91__inline static void _set_timer(_timer *ptimer, u32 delay_time)
102{ 92{
@@ -109,7 +99,6 @@ __inline static void _cancel_timer(_timer *ptimer, u8 *bcancelled)
109 *bcancelled = true;/* true == 1; false == 0 */ 99 *bcancelled = true;/* true == 1; false == 0 */
110} 100}
111 101
112
113__inline static void _init_workitem(_workitem *pwork, void *pfunc, void *cntx) 102__inline static void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
114{ 103{
115 INIT_WORK(pwork, pfunc); 104 INIT_WORK(pwork, pfunc);
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h
index d88ef67ce8d6..00b3d92c9f51 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h
@@ -518,8 +518,8 @@ extern void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
518extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf); 518extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
519extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf); 519extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf);
520 520
521extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS); 521extern void rtw_join_timeout_handler(struct timer_list *t);
522extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS); 522extern void _rtw_scan_timeout_handler(struct timer_list *t);
523 523
524int event_thread(void *context); 524int event_thread(void *context);
525 525
@@ -618,10 +618,10 @@ extern void rtw_update_registrypriv_dev_network(struct adapter *adapter);
618 618
619extern void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); 619extern void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
620 620
621extern void _rtw_join_timeout_handler(struct adapter *adapter); 621extern void _rtw_join_timeout_handler(struct timer_list *t);
622extern void rtw_scan_timeout_handler(struct adapter *adapter); 622extern void rtw_scan_timeout_handler(struct timer_list *t);
623 623
624extern void rtw_dynamic_check_timer_handlder(struct adapter *adapter); 624extern void rtw_dynamic_check_timer_handler(struct adapter *adapter);
625bool rtw_is_scan_deny(struct adapter *adapter); 625bool rtw_is_scan_deny(struct adapter *adapter);
626void rtw_clear_scan_deny(struct adapter *adapter); 626void rtw_clear_scan_deny(struct adapter *adapter);
627void rtw_set_scan_deny_timer_hdl(struct adapter *adapter); 627void rtw_set_scan_deny_timer_hdl(struct adapter *adapter);
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index f3952463697e..6613dea2b283 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -424,7 +424,7 @@ struct mlme_ext_info
424 u8 candidate_tid_bitmap; 424 u8 candidate_tid_bitmap;
425 u8 dialogToken; 425 u8 dialogToken;
426 /* Accept ADDBA Request */ 426 /* Accept ADDBA Request */
427 bool bAcceptAddbaReq; 427 bool accept_addba_req;
428 u8 bwmode_updated; 428 u8 bwmode_updated;
429 u8 hidden_ssid_mode; 429 u8 hidden_ssid_mode;
430 u8 VHT_enable; 430 u8 VHT_enable;
@@ -719,10 +719,10 @@ void linked_status_chk(struct adapter *padapter);
719 719
720void _linked_info_dump(struct adapter *padapter); 720void _linked_info_dump(struct adapter *padapter);
721 721
722void survey_timer_hdl (struct adapter *padapter); 722void survey_timer_hdl (struct timer_list *t);
723void link_timer_hdl (struct adapter *padapter); 723void link_timer_hdl (struct timer_list *t);
724void addba_timer_hdl(struct sta_info *psta); 724void addba_timer_hdl(struct timer_list *t);
725void sa_query_timer_hdl(struct adapter *padapter); 725void sa_query_timer_hdl(struct timer_list *t);
726/* void reauth_timer_hdl(struct adapter *padapter); */ 726/* void reauth_timer_hdl(struct adapter *padapter); */
727/* void reassoc_timer_hdl(struct adapter *padapter); */ 727/* void reassoc_timer_hdl(struct adapter *padapter); */
728 728
diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
index cf8e766a27a8..faf91022f54a 100644
--- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
@@ -250,7 +250,7 @@ struct pwrctrl_priv
250 u8 ips_mode; 250 u8 ips_mode;
251 u8 ips_org_mode; 251 u8 ips_org_mode;
252 u8 ips_mode_req; /* used to accept the mode setting request, will update to ipsmode later */ 252 u8 ips_mode_req; /* used to accept the mode setting request, will update to ipsmode later */
253 uint bips_processing; 253 bool bips_processing;
254 unsigned long ips_deny_time; /* will deny IPS when system time is smaller than this */ 254 unsigned long ips_deny_time; /* will deny IPS when system time is smaller than this */
255 u8 pre_ips_type;/* 0: default flow, 1: carddisbale flow */ 255 u8 pre_ips_type;/* 0: default flow, 1: carddisbale flow */
256 256
@@ -300,6 +300,7 @@ struct pwrctrl_priv
300 u64 wowlan_fw_iv; 300 u64 wowlan_fw_iv;
301#endif /* CONFIG_WOWLAN */ 301#endif /* CONFIG_WOWLAN */
302 _timer pwr_state_check_timer; 302 _timer pwr_state_check_timer;
303 struct adapter *adapter;
303 int pwr_state_check_interval; 304 int pwr_state_check_interval;
304 u8 pwr_state_check_cnts; 305 u8 pwr_state_check_cnts;
305 306
diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h
index 570a3c333aa0..71039ca79e4b 100644
--- a/drivers/staging/rtl8723bs/include/rtw_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtw_recv.h
@@ -411,7 +411,7 @@ sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queu
411sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); 411sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
412struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue); 412struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue);
413 413
414void rtw_reordering_ctrl_timeout_handler(void *pcontext); 414void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
415 415
416__inline static u8 *get_rxmem(union recv_frame *precvframe) 416__inline static u8 *get_rxmem(union recv_frame *precvframe)
417{ 417{
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index bd4352fe2de3..51d48de24a24 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -136,11 +136,9 @@ static struct ieee80211_supported_band *rtw_spt_band_alloc(
136 goto exit; 136 goto exit;
137 } 137 }
138 138
139 spt_band = (struct ieee80211_supported_band *)rtw_zmalloc( 139 spt_band = rtw_zmalloc(sizeof(struct ieee80211_supported_band) +
140 sizeof(struct ieee80211_supported_band) 140 sizeof(struct ieee80211_channel) * n_channels +
141 + sizeof(struct ieee80211_channel)*n_channels 141 sizeof(struct ieee80211_rate) * n_bitrates);
142 + sizeof(struct ieee80211_rate)*n_bitrates
143 );
144 if (!spt_band) 142 if (!spt_band)
145 goto exit; 143 goto exit;
146 144
@@ -1094,7 +1092,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
1094 DBG_871X("pairwise =%d\n", pairwise); 1092 DBG_871X("pairwise =%d\n", pairwise);
1095 1093
1096 param_len = sizeof(struct ieee_param) + params->key_len; 1094 param_len = sizeof(struct ieee_param) + params->key_len;
1097 param = (struct ieee_param *)rtw_malloc(param_len); 1095 param = rtw_malloc(param_len);
1098 if (param == NULL) 1096 if (param == NULL)
1099 return -1; 1097 return -1;
1100 1098
@@ -2183,7 +2181,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
2183 { 2181 {
2184 wep_key_len = wep_key_len <= 5 ? 5 : 13; 2182 wep_key_len = wep_key_len <= 5 ? 5 : 13;
2185 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); 2183 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
2186 pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); 2184 pwep = rtw_malloc(wep_total_len);
2187 if (pwep == NULL) { 2185 if (pwep == NULL) {
2188 DBG_871X(" wpa_set_encryption: pwep allocate fail !!!\n"); 2186 DBG_871X(" wpa_set_encryption: pwep allocate fail !!!\n");
2189 ret = -ENOMEM; 2187 ret = -ENOMEM;
@@ -2677,7 +2675,7 @@ static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, st
2677 pnpi->sizeof_priv = sizeof(struct adapter); 2675 pnpi->sizeof_priv = sizeof(struct adapter);
2678 2676
2679 /* wdev */ 2677 /* wdev */
2680 mon_wdev = (struct wireless_dev *)rtw_zmalloc(sizeof(struct wireless_dev)); 2678 mon_wdev = rtw_zmalloc(sizeof(struct wireless_dev));
2681 if (!mon_wdev) { 2679 if (!mon_wdev) {
2682 DBG_871X(FUNC_ADPT_FMT" allocate mon_wdev fail\n", FUNC_ADPT_ARG(padapter)); 2680 DBG_871X(FUNC_ADPT_FMT" allocate mon_wdev fail\n", FUNC_ADPT_ARG(padapter));
2683 ret = -ENOMEM; 2681 ret = -ENOMEM;
@@ -3497,7 +3495,7 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
3497 } 3495 }
3498 3496
3499 /* wdev */ 3497 /* wdev */
3500 wdev = (struct wireless_dev *)rtw_zmalloc(sizeof(struct wireless_dev)); 3498 wdev = rtw_zmalloc(sizeof(struct wireless_dev));
3501 if (!wdev) { 3499 if (!wdev) {
3502 DBG_8192C("Couldn't allocate wireless device\n"); 3500 DBG_8192C("Couldn't allocate wireless device\n");
3503 ret = -ENOMEM; 3501 ret = -ENOMEM;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index d5e5f830f2a1..3fca0c2d4c8d 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -18,6 +18,7 @@
18#include <rtw_debug.h> 18#include <rtw_debug.h>
19#include <rtw_mp.h> 19#include <rtw_mp.h>
20#include <linux/jiffies.h> 20#include <linux/jiffies.h>
21#include <linux/kernel.h>
21 22
22#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV+30) 23#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV+30)
23 24
@@ -557,7 +558,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
557 if (wep_key_len > 0) { 558 if (wep_key_len > 0) {
558 wep_key_len = wep_key_len <= 5 ? 5 : 13; 559 wep_key_len = wep_key_len <= 5 ? 5 : 13;
559 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); 560 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
560 pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); 561 pwep = rtw_malloc(wep_total_len);
561 if (pwep == NULL) { 562 if (pwep == NULL) {
562 RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); 563 RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n"));
563 goto exit; 564 goto exit;
@@ -2123,12 +2124,9 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
2123 struct iw_request_info *info, 2124 struct iw_request_info *info,
2124 union iwreq_data *wrqu, char *extra) 2125 union iwreq_data *wrqu, char *extra)
2125{ 2126{
2126 int ret;
2127 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); 2127 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
2128 2128
2129 ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); 2129 return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
2130
2131 return ret;
2132} 2130}
2133 2131
2134static int rtw_wx_set_auth(struct net_device *dev, 2132static int rtw_wx_set_auth(struct net_device *dev,
@@ -2238,7 +2236,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
2238 int ret = 0; 2236 int ret = 0;
2239 2237
2240 param_len = sizeof(struct ieee_param) + pext->key_len; 2238 param_len = sizeof(struct ieee_param) + pext->key_len;
2241 param = (struct ieee_param *)rtw_malloc(param_len); 2239 param = rtw_malloc(param_len);
2242 if (param == NULL) 2240 if (param == NULL)
2243 return -1; 2241 return -1;
2244 2242
@@ -2347,7 +2345,7 @@ static int rtw_wx_read32(struct net_device *dev,
2347 if (0 == len) 2345 if (0 == len)
2348 return -EINVAL; 2346 return -EINVAL;
2349 2347
2350 ptmp = (u8 *)rtw_malloc(len); 2348 ptmp = rtw_malloc(len);
2351 if (NULL == ptmp) 2349 if (NULL == ptmp)
2352 return -ENOMEM; 2350 return -ENOMEM;
2353 2351
@@ -3500,7 +3498,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
3500 goto out; 3498 goto out;
3501 } 3499 }
3502 3500
3503 param = (struct ieee_param *)rtw_malloc(p->length); 3501 param = rtw_malloc(p->length);
3504 if (param == NULL) { 3502 if (param == NULL) {
3505 ret = -ENOMEM; 3503 ret = -ENOMEM;
3506 goto out; 3504 goto out;
@@ -3621,7 +3619,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
3621 if (wep_key_len > 0) { 3619 if (wep_key_len > 0) {
3622 wep_key_len = wep_key_len <= 5 ? 5 : 13; 3620 wep_key_len = wep_key_len <= 5 ? 5 : 13;
3623 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); 3621 wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
3624 pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len); 3622 pwep = rtw_malloc(wep_total_len);
3625 if (pwep == NULL) { 3623 if (pwep == NULL) {
3626 DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n"); 3624 DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n");
3627 goto exit; 3625 goto exit;
@@ -3857,7 +3855,6 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
3857{ 3855{
3858 /* _irqL irqL; */ 3856 /* _irqL irqL; */
3859 /* struct list_head *phead, *plist; */ 3857 /* struct list_head *phead, *plist; */
3860 int ret = 0;
3861 /* struct sta_info *psta = NULL; */ 3858 /* struct sta_info *psta = NULL; */
3862 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); 3859 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
3863 /* struct sta_priv *pstapriv = &padapter->stapriv; */ 3860 /* struct sta_priv *pstapriv = &padapter->stapriv; */
@@ -3866,9 +3863,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
3866 3863
3867 flush_all_cam_entry(padapter); /* clear CAM */ 3864 flush_all_cam_entry(padapter); /* clear CAM */
3868 3865
3869 ret = rtw_sta_flush(padapter); 3866 return rtw_sta_flush(padapter);
3870
3871 return ret;
3872 3867
3873} 3868}
3874 3869
@@ -4266,7 +4261,6 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
4266 4261
4267static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) 4262static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
4268{ 4263{
4269 int ret = 0;
4270 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); 4264 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
4271 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 4265 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
4272 4266
@@ -4279,15 +4273,12 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
4279 return -EINVAL; 4273 return -EINVAL;
4280 } 4274 }
4281 4275
4282 ret = rtw_acl_remove_sta(padapter, param->sta_addr); 4276 return rtw_acl_remove_sta(padapter, param->sta_addr);
4283
4284 return ret;
4285 4277
4286} 4278}
4287 4279
4288static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) 4280static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
4289{ 4281{
4290 int ret = 0;
4291 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); 4282 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
4292 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 4283 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
4293 4284
@@ -4300,9 +4291,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
4300 return -EINVAL; 4291 return -EINVAL;
4301 } 4292 }
4302 4293
4303 ret = rtw_acl_add_sta(padapter, param->sta_addr); 4294 return rtw_acl_add_sta(padapter, param->sta_addr);
4304
4305 return ret;
4306 4295
4307} 4296}
4308 4297
@@ -4345,7 +4334,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
4345 goto out; 4334 goto out;
4346 } 4335 }
4347 4336
4348 param = (struct ieee_param *)rtw_malloc(p->length); 4337 param = rtw_malloc(p->length);
4349 if (param == NULL) { 4338 if (param == NULL) {
4350 ret = -ENOMEM; 4339 ret = -ENOMEM;
4351 goto out; 4340 goto out;
@@ -4673,7 +4662,7 @@ static int rtw_test(
4673 DBG_871X("+%s\n", __func__); 4662 DBG_871X("+%s\n", __func__);
4674 len = wrqu->data.length; 4663 len = wrqu->data.length;
4675 4664
4676 pbuf = (u8 *)rtw_zmalloc(len); 4665 pbuf = rtw_zmalloc(len);
4677 if (pbuf == NULL) { 4666 if (pbuf == NULL) {
4678 DBG_871X("%s: no memory!\n", __func__); 4667 DBG_871X("%s: no memory!\n", __func__);
4679 return -ENOMEM; 4668 return -ENOMEM;
@@ -5029,12 +5018,12 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
5029 5018
5030struct iw_handler_def rtw_handlers_def = { 5019struct iw_handler_def rtw_handlers_def = {
5031 .standard = rtw_handlers, 5020 .standard = rtw_handlers,
5032 .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), 5021 .num_standard = ARRAY_SIZE(rtw_handlers),
5033#if defined(CONFIG_WEXT_PRIV) 5022#if defined(CONFIG_WEXT_PRIV)
5034 .private = rtw_private_handler, 5023 .private = rtw_private_handler,
5035 .private_args = (struct iw_priv_args *)rtw_private_args, 5024 .private_args = (struct iw_priv_args *)rtw_private_args,
5036 .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), 5025 .num_private = ARRAY_SIZE(rtw_private_handler),
5037 .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), 5026 .num_private_args = ARRAY_SIZE(rtw_private_args),
5038#endif 5027#endif
5039 .get_wireless_stats = rtw_get_wireless_stats, 5028 .get_wireless_stats = rtw_get_wireless_stats,
5040}; 5029};
@@ -5121,8 +5110,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
5121 5110
5122 priv = rtw_private_handler; 5111 priv = rtw_private_handler;
5123 priv_args = rtw_private_args; 5112 priv_args = rtw_private_args;
5124 num_priv = sizeof(rtw_private_handler) / sizeof(iw_handler); 5113 num_priv = ARRAY_SIZE(rtw_private_handler);
5125 num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); 5114 num_priv_args = ARRAY_SIZE(rtw_private_args);
5126 5115
5127 if (num_priv_args == 0) { 5116 if (num_priv_args == 0) {
5128 err = -EOPNOTSUPP; 5117 err = -EOPNOTSUPP;
diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index 80ca2d781c5d..a4ef5789d794 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -19,18 +19,21 @@
19#include <drv_types.h> 19#include <drv_types.h>
20#include <rtw_debug.h> 20#include <rtw_debug.h>
21 21
22static void _dynamic_check_timer_handlder (void *FunctionContext) 22static void _dynamic_check_timer_handler(struct timer_list *t)
23{ 23{
24 struct adapter *adapter = FunctionContext; 24 struct adapter *adapter =
25 from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
25 26
26 rtw_dynamic_check_timer_handlder(adapter); 27 rtw_dynamic_check_timer_handler(adapter);
27 28
28 _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); 29 _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
29} 30}
30 31
31static void _rtw_set_scan_deny_timer_hdl(void *FunctionContext) 32static void _rtw_set_scan_deny_timer_hdl(struct timer_list *t)
32{ 33{
33 struct adapter *adapter = FunctionContext; 34 struct adapter *adapter =
35 from_timer(adapter, t, mlmepriv.set_scan_deny_timer);
36
34 rtw_set_scan_deny_timer_hdl(adapter); 37 rtw_set_scan_deny_timer_hdl(adapter);
35} 38}
36 39
@@ -38,21 +41,20 @@ void rtw_init_mlme_timer(struct adapter *padapter)
38{ 41{
39 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 42 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
40 43
41 _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, _rtw_join_timeout_handler, padapter); 44 timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0);
42 /* _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer), padapter->pnetdev, sitesurvey_ctrl_handler, padapter); */ 45 timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0);
43 _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, rtw_scan_timeout_handler, padapter); 46 timer_setup(&pmlmepriv->dynamic_chk_timer,
44 47 _dynamic_check_timer_handler, 0);
45 _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); 48 timer_setup(&pmlmepriv->set_scan_deny_timer,
46 49 _rtw_set_scan_deny_timer_hdl, 0);
47 _init_timer(&(pmlmepriv->set_scan_deny_timer), padapter->pnetdev, _rtw_set_scan_deny_timer_hdl, padapter);
48} 50}
49 51
50void rtw_os_indicate_connect(struct adapter *adapter) 52void rtw_os_indicate_connect(struct adapter *adapter)
51{ 53{
52 struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); 54 struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
53 55
54 if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ==true) || 56 if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
55 (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true)) 57 (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
56 { 58 {
57 rtw_cfg80211_ibss_indicate_connect(adapter); 59 rtw_cfg80211_ibss_indicate_connect(adapter);
58 } 60 }
@@ -99,7 +101,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
99 /* reset RX BIP packet number */ 101 /* reset RX BIP packet number */
100 pmlmeext->mgnt_80211w_IPN_rx = 0; 102 pmlmeext->mgnt_80211w_IPN_rx = 0;
101 103
102 memset((unsigned char *)&adapter->securitypriv, 0, sizeof (struct security_priv)); 104 memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
103 105
104 /* Added by Albert 2009/02/18 */ 106 /* Added by Albert 2009/02/18 */
105 /* Restore the PMK information to securitypriv structure for the following connection. */ 107 /* Restore the PMK information to securitypriv structure for the following connection. */
@@ -116,9 +118,9 @@ void rtw_reset_securitypriv(struct adapter *adapter)
116 { 118 {
117 /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */ 119 /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */
118 /* */ 120 /* */
119 struct security_priv *psec_priv =&adapter->securitypriv; 121 struct security_priv *psec_priv = &adapter->securitypriv;
120 122
121 psec_priv->dot11AuthAlgrthm =dot11AuthAlgrthm_Open; /* open system */ 123 psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
122 psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; 124 psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
123 psec_priv->dot11PrivacyKeyIndex = 0; 125 psec_priv->dot11PrivacyKeyIndex = 0;
124 126
@@ -150,7 +152,7 @@ void rtw_os_indicate_disconnect(struct adapter *adapter)
150void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) 152void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
151{ 153{
152 uint len; 154 uint len;
153 u8 *buff,*p, i; 155 u8 *buff, *p, i;
154 union iwreq_data wrqu; 156 union iwreq_data wrqu;
155 157
156 RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode)); 158 RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode));
@@ -168,22 +170,22 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
168 } 170 }
169 p = buff; 171 p = buff;
170 172
171 p+=sprintf(p,"ASSOCINFO(ReqIEs ="); 173 p += sprintf(p, "ASSOCINFO(ReqIEs =");
172 174
173 len = sec_ie[1]+2; 175 len = sec_ie[1] + 2;
174 len = (len < IW_CUSTOM_MAX) ? len:IW_CUSTOM_MAX; 176 len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
175 177
176 for (i = 0;i<len;i++) { 178 for (i = 0; i < len; i++) {
177 p+=sprintf(p,"%02x", sec_ie[i]); 179 p += sprintf(p, "%02x", sec_ie[i]);
178 } 180 }
179 181
180 p+=sprintf(p,")"); 182 p += sprintf(p, ")");
181 183
182 memset(&wrqu, 0, sizeof(wrqu)); 184 memset(&wrqu, 0, sizeof(wrqu));
183 185
184 wrqu.data.length =p-buff; 186 wrqu.data.length = p - buff;
185 187
186 wrqu.data.length = (wrqu.data.length<IW_CUSTOM_MAX) ? wrqu.data.length:IW_CUSTOM_MAX; 188 wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX;
187 189
188 kfree(buff); 190 kfree(buff);
189 } 191 }
@@ -191,14 +193,14 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
191 193
192void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) 194void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
193{ 195{
194 _init_timer(&psta->addba_retry_timer, padapter->pnetdev, addba_timer_hdl, psta); 196 timer_setup(&psta->addba_retry_timer, addba_timer_hdl, 0);
195} 197}
196 198
197void init_mlme_ext_timer(struct adapter *padapter) 199void init_mlme_ext_timer(struct adapter *padapter)
198{ 200{
199 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 201 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
200 202
201 _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, survey_timer_hdl, padapter); 203 timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0);
202 _init_timer(&pmlmeext->link_timer, padapter->pnetdev, link_timer_hdl, padapter); 204 timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0);
203 _init_timer(&pmlmeext->sa_query_timer, padapter->pnetdev, sa_query_timer_hdl, padapter); 205 timer_setup(&pmlmeext->sa_query_timer, sa_query_timer_hdl, 0);
204} 206}
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 021589913681..fc5e3d4739c0 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -24,9 +24,9 @@ MODULE_AUTHOR("Realtek Semiconductor Corp.");
24MODULE_VERSION(DRIVERVERSION); 24MODULE_VERSION(DRIVERVERSION);
25 25
26/* module param defaults */ 26/* module param defaults */
27static int rtw_chip_version = 0x00; 27static int rtw_chip_version;
28static int rtw_rfintfs = HWPI; 28static int rtw_rfintfs = HWPI;
29static int rtw_lbkmode = 0;/* RTL8712_AIR_TRX; */ 29static int rtw_lbkmode;/* RTL8712_AIR_TRX; */
30 30
31 31
32static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure;infra, ad-hoc, auto */ 32static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure;infra, ad-hoc, auto */
@@ -40,12 +40,12 @@ static int rtw_frag_thresh = 2346;/* */
40static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */ 40static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */
41static int rtw_scan_mode = 1;/* active, passive */ 41static int rtw_scan_mode = 1;/* active, passive */
42static int rtw_adhoc_tx_pwr = 1; 42static int rtw_adhoc_tx_pwr = 1;
43static int rtw_soft_ap = 0; 43static int rtw_soft_ap;
44/* int smart_ps = 1; */ 44/* int smart_ps = 1; */
45static int rtw_power_mgnt = 1; 45static int rtw_power_mgnt = 1;
46static int rtw_ips_mode = IPS_NORMAL; 46static int rtw_ips_mode = IPS_NORMAL;
47module_param(rtw_ips_mode, int, 0644); 47module_param(rtw_ips_mode, int, 0644);
48MODULE_PARM_DESC(rtw_ips_mode,"The default IPS mode"); 48MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode");
49 49
50static int rtw_smart_ps = 2; 50static int rtw_smart_ps = 2;
51 51
@@ -61,18 +61,18 @@ static int rtw_busy_thresh = 40;
61/* int qos_enable = 0; */ 61/* int qos_enable = 0; */
62static int rtw_ack_policy = NORMAL_ACK; 62static int rtw_ack_policy = NORMAL_ACK;
63 63
64static int rtw_software_encrypt = 0; 64static int rtw_software_encrypt;
65static int rtw_software_decrypt = 0; 65static int rtw_software_decrypt;
66 66
67static int rtw_acm_method = 0;/* 0:By SW 1:By HW. */ 67static int rtw_acm_method;/* 0:By SW 1:By HW. */
68 68
69static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ 69static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */
70static int rtw_uapsd_enable = 0; 70static int rtw_uapsd_enable;
71static int rtw_uapsd_max_sp = NO_LIMIT; 71static int rtw_uapsd_max_sp = NO_LIMIT;
72static int rtw_uapsd_acbk_en = 0; 72static int rtw_uapsd_acbk_en;
73static int rtw_uapsd_acbe_en = 0; 73static int rtw_uapsd_acbe_en;
74static int rtw_uapsd_acvi_en = 0; 74static int rtw_uapsd_acvi_en;
75static int rtw_uapsd_acvo_en = 0; 75static int rtw_uapsd_acvo_en;
76 76
77int rtw_ht_enable = 1; 77int rtw_ht_enable = 1;
78/* 0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160MHz, 4: 80+80MHz */ 78/* 0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160MHz, 4: 80+80MHz */
@@ -81,7 +81,7 @@ int rtw_ht_enable = 1;
81static int rtw_bw_mode = 0x21; 81static int rtw_bw_mode = 0x21;
82static int rtw_ampdu_enable = 1;/* for enable tx_ampdu ,0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ 82static int rtw_ampdu_enable = 1;/* for enable tx_ampdu ,0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
83static int rtw_rx_stbc = 1;/* 0: disable, 1:enable 2.4g */ 83static int rtw_rx_stbc = 1;/* 0: disable, 1:enable 2.4g */
84static int rtw_ampdu_amsdu = 0;/* 0: disabled, 1:enabled, 2:auto . There is an IOT issu with DLINK DIR-629 when the flag turn on */ 84static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto . There is an IOT issu with DLINK DIR-629 when the flag turn on */
85/* Short GI support Bit Map */ 85/* Short GI support Bit Map */
86/* BIT0 - 20MHz, 0: non-support, 1: support */ 86/* BIT0 - 20MHz, 0: non-support, 1: support */
87/* BIT1 - 40MHz, 0: non-support, 1: support */ 87/* BIT1 - 40MHz, 0: non-support, 1: support */
@@ -99,8 +99,8 @@ static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and lega
99 99
100/* int rf_config = RF_1T2R; 1T2R */ 100/* int rf_config = RF_1T2R; 1T2R */
101static int rtw_rf_config = RF_MAX_TYPE; /* auto */ 101static int rtw_rf_config = RF_MAX_TYPE; /* auto */
102static int rtw_low_power = 0; 102static int rtw_low_power;
103static int rtw_wifi_spec = 0; 103static int rtw_wifi_spec;
104static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; 104static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX;
105 105
106static int rtw_btcoex_enable = 1; 106static int rtw_btcoex_enable = 1;
@@ -113,40 +113,38 @@ static int rtw_ant_num = -1; /* <0: undefined, >0: Antenna number */
113module_param(rtw_ant_num, int, 0644); 113module_param(rtw_ant_num, int, 0644);
114MODULE_PARM_DESC(rtw_ant_num, "Antenna number setting"); 114MODULE_PARM_DESC(rtw_ant_num, "Antenna number setting");
115 115
116static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
117
118static int rtw_antdiv_cfg = 1; /* 0:OFF , 1:ON, 2:decide by Efuse config */ 116static int rtw_antdiv_cfg = 1; /* 0:OFF , 1:ON, 2:decide by Efuse config */
119static int rtw_antdiv_type = 0 ; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ 117static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
120 118
121 119
122static int rtw_enusbss = 0;/* 0:disable, 1:enable */ 120static int rtw_enusbss;/* 0:disable, 1:enable */
123 121
124static int rtw_hwpdn_mode =2;/* 0:disable, 1:enable, 2: by EFUSE config */ 122static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
125 123
126#ifdef CONFIG_HW_PWRP_DETECTION 124#ifdef CONFIG_HW_PWRP_DETECTION
127static int rtw_hwpwrp_detect = 1; 125static int rtw_hwpwrp_detect = 1;
128#else 126#else
129static int rtw_hwpwrp_detect = 0; /* HW power ping detect 0:disable , 1:enable */ 127static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */
130#endif 128#endif
131 129
132static int rtw_hw_wps_pbc = 0; 130static int rtw_hw_wps_pbc;
133 131
134int rtw_mc2u_disable = 0; 132int rtw_mc2u_disable = 0;
135 133
136static int rtw_80211d = 0; 134static int rtw_80211d;
137 135
138#ifdef CONFIG_QOS_OPTIMIZATION 136#ifdef CONFIG_QOS_OPTIMIZATION
139static int rtw_qos_opt_enable = 1;/* 0: disable, 1:enable */ 137static int rtw_qos_opt_enable = 1;/* 0: disable, 1:enable */
140#else 138#else
141static int rtw_qos_opt_enable = 0;/* 0: disable, 1:enable */ 139static int rtw_qos_opt_enable;/* 0: disable, 1:enable */
142#endif 140#endif
143module_param(rtw_qos_opt_enable, int, 0644); 141module_param(rtw_qos_opt_enable, int, 0644);
144 142
145static char* ifname = "wlan%d"; 143static char *ifname = "wlan%d";
146module_param(ifname, charp, 0644); 144module_param(ifname, charp, 0644);
147MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); 145MODULE_PARM_DESC(ifname, "The default name to allocate for first interface");
148 146
149char* rtw_initmac = NULL; /* temp mac address if users want to use instead of the mac address in Efuse */ 147char *rtw_initmac = NULL; /* temp mac address if users want to use instead of the mac address in Efuse */
150 148
151module_param(rtw_initmac, charp, 0644); 149module_param(rtw_initmac, charp, 0644);
152module_param(rtw_channel_plan, int, 0644); 150module_param(rtw_channel_plan, int, 0644);
@@ -183,16 +181,16 @@ module_param(rtw_hwpwrp_detect, int, 0644);
183 181
184module_param(rtw_hw_wps_pbc, int, 0644); 182module_param(rtw_hw_wps_pbc, int, 0644);
185 183
186static uint rtw_max_roaming_times =2; 184static uint rtw_max_roaming_times = 2;
187module_param(rtw_max_roaming_times, uint, 0644); 185module_param(rtw_max_roaming_times, uint, 0644);
188MODULE_PARM_DESC(rtw_max_roaming_times,"The max roaming times to try"); 186MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try");
189 187
190module_param(rtw_mc2u_disable, int, 0644); 188module_param(rtw_mc2u_disable, int, 0644);
191 189
192module_param(rtw_80211d, int, 0644); 190module_param(rtw_80211d, int, 0644);
193MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism"); 191MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism");
194 192
195static uint rtw_notch_filter = 0; 193static uint rtw_notch_filter;
196module_param(rtw_notch_filter, uint, 0644); 194module_param(rtw_notch_filter, uint, 0644);
197MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P"); 195MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P");
198 196
@@ -202,14 +200,14 @@ static uint rtw_hiq_filter = CONFIG_RTW_HIQ_FILTER;
202module_param(rtw_hiq_filter, uint, 0644); 200module_param(rtw_hiq_filter, uint, 0644);
203MODULE_PARM_DESC(rtw_hiq_filter, "0:allow all, 1:allow special, 2:deny all"); 201MODULE_PARM_DESC(rtw_hiq_filter, "0:allow all, 1:allow special, 2:deny all");
204 202
205static int rtw_tx_pwr_lmt_enable = 0; 203static int rtw_tx_pwr_lmt_enable;
206static int rtw_tx_pwr_by_rate = 0; 204static int rtw_tx_pwr_by_rate;
207 205
208module_param(rtw_tx_pwr_lmt_enable, int, 0644); 206module_param(rtw_tx_pwr_lmt_enable, int, 0644);
209MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable,"0:Disable, 1:Enable, 2: Depend on efuse"); 207MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 1:Enable, 2: Depend on efuse");
210 208
211module_param(rtw_tx_pwr_by_rate, int, 0644); 209module_param(rtw_tx_pwr_by_rate, int, 0644);
212MODULE_PARM_DESC(rtw_tx_pwr_by_rate,"0:Disable, 1:Enable, 2: Depend on efuse"); 210MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on efuse");
213 211
214char *rtw_phy_file_path = ""; 212char *rtw_phy_file_path = "";
215module_param(rtw_phy_file_path, charp, 0644); 213module_param(rtw_phy_file_path, charp, 0644);
@@ -222,12 +220,12 @@ MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter");
222/* BIT4 - RF, 0: non-support, 1: support */ 220/* BIT4 - RF, 0: non-support, 1: support */
223/* BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */ 221/* BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */
224/* BIT6 - RF_TXPWR_LMT, 0: non-support, 1: support */ 222/* BIT6 - RF_TXPWR_LMT, 0: non-support, 1: support */
225static int rtw_load_phy_file = (BIT2|BIT6); 223static int rtw_load_phy_file = (BIT2 | BIT6);
226module_param(rtw_load_phy_file, int, 0644); 224module_param(rtw_load_phy_file, int, 0644);
227MODULE_PARM_DESC(rtw_load_phy_file,"PHY File Bit Map"); 225MODULE_PARM_DESC(rtw_load_phy_file, "PHY File Bit Map");
228static int rtw_decrypt_phy_file = 0; 226static int rtw_decrypt_phy_file;
229module_param(rtw_decrypt_phy_file, int, 0644); 227module_param(rtw_decrypt_phy_file, int, 0644);
230MODULE_PARM_DESC(rtw_decrypt_phy_file,"Enable Decrypt PHY File"); 228MODULE_PARM_DESC(rtw_decrypt_phy_file, "Enable Decrypt PHY File");
231 229
232int _netdev_open(struct net_device *pnetdev); 230int _netdev_open(struct net_device *pnetdev);
233int netdev_open (struct net_device *pnetdev); 231int netdev_open (struct net_device *pnetdev);
@@ -255,8 +253,8 @@ static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev)
255 253
256 registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; 254 registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ;
257 registry_par->vcs_type = (u8)rtw_vcs_type; 255 registry_par->vcs_type = (u8)rtw_vcs_type;
258 registry_par->rts_thresh =(u16)rtw_rts_thresh; 256 registry_par->rts_thresh = (u16)rtw_rts_thresh;
259 registry_par->frag_thresh =(u16)rtw_frag_thresh; 257 registry_par->frag_thresh = (u16)rtw_frag_thresh;
260 registry_par->preamble = (u8)rtw_preamble; 258 registry_par->preamble = (u8)rtw_preamble;
261 registry_par->scan_mode = (u8)rtw_scan_mode; 259 registry_par->scan_mode = (u8)rtw_scan_mode;
262 registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr; 260 registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr;
@@ -311,7 +309,7 @@ static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev)
311 registry_par->bt_ampdu = (u8)rtw_bt_ampdu; 309 registry_par->bt_ampdu = (u8)rtw_bt_ampdu;
312 registry_par->ant_num = (s8)rtw_ant_num; 310 registry_par->ant_num = (s8)rtw_ant_num;
313 311
314 registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq; 312 registry_par->accept_addba_req = true;
315 313
316 registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg; 314 registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg;
317 registry_par->antdiv_type = (u8)rtw_antdiv_type; 315 registry_par->antdiv_type = (u8)rtw_antdiv_type;
@@ -351,8 +349,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
351 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); 349 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
352 struct sockaddr *addr = p; 350 struct sockaddr *addr = p;
353 351
354 if (padapter->bup == false) 352 if (padapter->bup == false) {
355 {
356 /* DBG_871X("r8711_net_set_mac_address(), MAC =%x:%x:%x:%x:%x:%x\n", addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], */ 353 /* DBG_871X("r8711_net_set_mac_address(), MAC =%x:%x:%x:%x:%x:%x\n", addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], */
357 /* addr->sa_data[4], addr->sa_data[5]); */ 354 /* addr->sa_data[4], addr->sa_data[5]); */
358 memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN); 355 memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
@@ -425,9 +422,7 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
425 skb->priority = rtw_classify8021d(skb); 422 skb->priority = rtw_classify8021d(skb);
426 423
427 if (pmlmepriv->acm_mask != 0) 424 if (pmlmepriv->acm_mask != 0)
428 {
429 skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority); 425 skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority);
430 }
431 426
432 return rtw_1d_to_queue[skb->priority]; 427 return rtw_1d_to_queue[skb->priority];
433} 428}
@@ -440,12 +435,12 @@ u16 rtw_recv_select_queue(struct sk_buff *skb)
440 u32 priority; 435 u32 priority;
441 u8 *pdata = skb->data; 436 u8 *pdata = skb->data;
442 437
443 memcpy(&eth_type, pdata+(ETH_ALEN<<1), 2); 438 memcpy(&eth_type, pdata + (ETH_ALEN << 1), 2);
444 439
445 switch (be16_to_cpu(eth_type)) { 440 switch (be16_to_cpu(eth_type)) {
446 case ETH_P_IP: 441 case ETH_P_IP:
447 442
448 piphdr = (struct iphdr *)(pdata+ETH_HLEN); 443 piphdr = (struct iphdr *)(pdata + ETH_HLEN);
449 444
450 dscp = piphdr->tos & 0xfc; 445 dscp = piphdr->tos & 0xfc;
451 446
@@ -457,17 +452,16 @@ u16 rtw_recv_select_queue(struct sk_buff *skb)
457 } 452 }
458 453
459 return rtw_1d_to_queue[priority]; 454 return rtw_1d_to_queue[priority];
460
461} 455}
462 456
463static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long state, void *ptr) 457static int rtw_ndev_notifier_call(struct notifier_block *nb, unsigned long state, void *ptr)
464{ 458{
465 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 459 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
466 460
467 if (dev->netdev_ops->ndo_do_ioctl != rtw_ioctl) 461 if (dev->netdev_ops->ndo_do_ioctl != rtw_ioctl)
468 return NOTIFY_DONE; 462 return NOTIFY_DONE;
469 463
470 DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT" state:%lu\n", FUNC_NDEV_ARG(dev), state); 464 DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT " state:%lu\n", FUNC_NDEV_ARG(dev), state);
471 465
472 switch (state) { 466 switch (state) {
473 case NETDEV_CHANGENAME: 467 case NETDEV_CHANGENAME:
@@ -497,7 +491,7 @@ static int rtw_ndev_init(struct net_device *dev)
497{ 491{
498 struct adapter *adapter = rtw_netdev_priv(dev); 492 struct adapter *adapter = rtw_netdev_priv(dev);
499 493
500 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); 494 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
501 strncpy(adapter->old_ifname, dev->name, IFNAMSIZ); 495 strncpy(adapter->old_ifname, dev->name, IFNAMSIZ);
502 rtw_adapter_proc_init(dev); 496 rtw_adapter_proc_init(dev);
503 497
@@ -508,7 +502,7 @@ static void rtw_ndev_uninit(struct net_device *dev)
508{ 502{
509 struct adapter *adapter = rtw_netdev_priv(dev); 503 struct adapter *adapter = rtw_netdev_priv(dev);
510 504
511 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); 505 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
512 rtw_adapter_proc_deinit(dev); 506 rtw_adapter_proc_deinit(dev);
513} 507}
514 508
@@ -561,7 +555,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
561 pnetdev->netdev_ops = &rtw_netdev_ops; 555 pnetdev->netdev_ops = &rtw_netdev_ops;
562 556
563 /* pnetdev->tx_timeout = NULL; */ 557 /* pnetdev->tx_timeout = NULL; */
564 pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ 558 pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */
565 pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; 559 pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;
566 560
567 /* step 2. */ 561 /* step 2. */
@@ -597,7 +591,7 @@ u32 rtw_start_drv_threads(struct adapter *padapter)
597 _status = _FAIL; 591 _status = _FAIL;
598 592
599 padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); 593 padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
600 if (IS_ERR(padapter->cmdThread)) 594 if (IS_ERR(padapter->cmdThread))
601 _status = _FAIL; 595 _status = _FAIL;
602 else 596 else
603 down(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ 597 down(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */
@@ -623,7 +617,7 @@ void rtw_stop_drv_threads (struct adapter *padapter)
623static u8 rtw_init_default_value(struct adapter *padapter) 617static u8 rtw_init_default_value(struct adapter *padapter)
624{ 618{
625 u8 ret = _SUCCESS; 619 u8 ret = _SUCCESS;
626 struct registry_priv* pregistrypriv = &padapter->registrypriv; 620 struct registry_priv *pregistrypriv = &padapter->registrypriv;
627 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 621 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
628 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 622 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
629 struct security_priv *psecuritypriv = &padapter->securitypriv; 623 struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -652,8 +646,8 @@ static u8 rtw_init_default_value(struct adapter *padapter)
652#ifdef CONFIG_GTK_OL 646#ifdef CONFIG_GTK_OL
653 psecuritypriv->binstallKCK_KEK = _FAIL; 647 psecuritypriv->binstallKCK_KEK = _FAIL;
654#endif /* CONFIG_GTK_OL */ 648#endif /* CONFIG_GTK_OL */
655 psecuritypriv->sw_encrypt =pregistrypriv->software_encrypt; 649 psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
656 psecuritypriv->sw_decrypt =pregistrypriv->software_decrypt; 650 psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
657 651
658 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ 652 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
659 psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; 653 psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
@@ -691,7 +685,8 @@ struct dvobj_priv *devobj_init(void)
691{ 685{
692 struct dvobj_priv *pdvobj = NULL; 686 struct dvobj_priv *pdvobj = NULL;
693 687
694 if ((pdvobj = (struct dvobj_priv*)rtw_zmalloc(sizeof(*pdvobj))) == NULL) 688 pdvobj = rtw_zmalloc(sizeof(*pdvobj));
689 if (pdvobj == NULL)
695 return NULL; 690 return NULL;
696 691
697 mutex_init(&pdvobj->hw_init_mutex); 692 mutex_init(&pdvobj->hw_init_mutex);
@@ -722,7 +717,7 @@ void devobj_deinit(struct dvobj_priv *pdvobj)
722 mutex_destroy(&pdvobj->setch_mutex); 717 mutex_destroy(&pdvobj->setch_mutex);
723 mutex_destroy(&pdvobj->setbw_mutex); 718 mutex_destroy(&pdvobj->setbw_mutex);
724 719
725 kfree((u8 *)pdvobj); 720 kfree(pdvobj);
726} 721}
727 722
728u8 rtw_reset_drv_sw(struct adapter *padapter) 723u8 rtw_reset_drv_sw(struct adapter *padapter)
@@ -748,7 +743,7 @@ u8 rtw_reset_drv_sw(struct adapter *padapter)
748 pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0; 743 pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0;
749 pmlmepriv->LinkDetectInfo.LowPowerTransitionCount = 0; 744 pmlmepriv->LinkDetectInfo.LowPowerTransitionCount = 0;
750 745
751 _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY |_FW_UNDER_LINKING); 746 _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING);
752 747
753 pwrctrlpriv->pwr_state_check_cnts = 0; 748 pwrctrlpriv->pwr_state_check_cnts = 0;
754 749
@@ -777,7 +772,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
777 goto exit; 772 goto exit;
778 } 773 }
779 774
780 padapter->cmdpriv.padapter =padapter; 775 padapter->cmdpriv.padapter = padapter;
781 776
782 if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { 777 if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) {
783 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); 778 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n"));
@@ -935,7 +930,7 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name)
935 goto error_register_netdev; 930 goto error_register_netdev;
936 } 931 }
937 932
938 DBG_871X("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__, (padapter->iface_id+1), MAC_ARG(pnetdev->dev_addr)); 933 DBG_871X("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__, (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr));
939 934
940 return ret; 935 return ret;
941 936
@@ -984,9 +979,9 @@ int _netdev_open(struct net_device *pnetdev)
984 goto netdev_open_error; 979 goto netdev_open_error;
985 } 980 }
986 981
987 DBG_871X("MAC Address = "MAC_FMT"\n", MAC_ARG(pnetdev->dev_addr)); 982 DBG_871X("MAC Address = " MAC_FMT "\n", MAC_ARG(pnetdev->dev_addr));
988 983
989 status =rtw_start_drv_threads(padapter); 984 status = rtw_start_drv_threads(padapter);
990 if (status == _FAIL) { 985 if (status == _FAIL) {
991 DBG_871X("Initialize driver software resource Failed!\n"); 986 DBG_871X("Initialize driver software resource Failed!\n");
992 goto netdev_open_error; 987 goto netdev_open_error;
@@ -1027,7 +1022,6 @@ netdev_open_error:
1027 DBG_871X("-871x_drv - drv_open fail, bup =%d\n", padapter->bup); 1022 DBG_871X("-871x_drv - drv_open fail, bup =%d\n", padapter->bup);
1028 1023
1029 return (-1); 1024 return (-1);
1030
1031} 1025}
1032 1026
1033int netdev_open(struct net_device *pnetdev) 1027int netdev_open(struct net_device *pnetdev)
@@ -1036,8 +1030,7 @@ int netdev_open(struct net_device *pnetdev)
1036 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); 1030 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
1037 struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); 1031 struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
1038 1032
1039 if (pwrctrlpriv->bInSuspend == true) 1033 if (pwrctrlpriv->bInSuspend == true) {
1040 {
1041 DBG_871X("+871x_drv - drv_open, bInSuspend =%d\n", pwrctrlpriv->bInSuspend); 1034 DBG_871X("+871x_drv - drv_open, bInSuspend =%d\n", pwrctrlpriv->bInSuspend);
1042 return 0; 1035 return 0;
1043 } 1036 }
@@ -1066,16 +1059,13 @@ static int ips_netdrv_open(struct adapter *padapter)
1066 /* padapter->bup = true; */ 1059 /* padapter->bup = true; */
1067 1060
1068 status = rtw_hal_init(padapter); 1061 status = rtw_hal_init(padapter);
1069 if (status == _FAIL) 1062 if (status == _FAIL) {
1070 {
1071 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n")); 1063 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n"));
1072 goto netdev_open_error; 1064 goto netdev_open_error;
1073 } 1065 }
1074 1066
1075 if (padapter->intf_start) 1067 if (padapter->intf_start)
1076 {
1077 padapter->intf_start(padapter); 1068 padapter->intf_start(padapter);
1078 }
1079 1069
1080 _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); 1070 _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
1081 1071
@@ -1098,7 +1088,6 @@ int rtw_ips_pwr_up(struct adapter *padapter)
1098 1088
1099 DBG_871X("<=== rtw_ips_pwr_up..............\n"); 1089 DBG_871X("<=== rtw_ips_pwr_up..............\n");
1100 return result; 1090 return result;
1101
1102} 1091}
1103 1092
1104void rtw_ips_pwr_down(struct adapter *padapter) 1093void rtw_ips_pwr_down(struct adapter *padapter)
@@ -1119,10 +1108,7 @@ void rtw_ips_dev_unload(struct adapter *padapter)
1119 1108
1120 1109
1121 if (padapter->bSurpriseRemoved == false) 1110 if (padapter->bSurpriseRemoved == false)
1122 {
1123 rtw_hal_deinit(padapter); 1111 rtw_hal_deinit(padapter);
1124 }
1125
1126} 1112}
1127 1113
1128 1114
@@ -1132,15 +1118,14 @@ static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
1132 1118
1133 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); 1119 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
1134 1120
1135 if (true == bnormal) 1121 if (true == bnormal) {
1136 {
1137 if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->hw_init_mutex)) == 0) { 1122 if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->hw_init_mutex)) == 0) {
1138 status = _netdev_open(pnetdev); 1123 status = _netdev_open(pnetdev);
1139 mutex_unlock(&(adapter_to_dvobj(padapter)->hw_init_mutex)); 1124 mutex_unlock(&(adapter_to_dvobj(padapter)->hw_init_mutex));
1140 } 1125 }
1141 } 1126 }
1142 else 1127 else
1143 status = (_SUCCESS == ips_netdrv_open(padapter))?(0):(-1); 1128 status = (_SUCCESS == ips_netdrv_open(padapter)) ? (0) : (-1);
1144 1129
1145 return status; 1130 return status;
1146} 1131}
@@ -1152,8 +1137,7 @@ static int netdev_close(struct net_device *pnetdev)
1152 1137
1153 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n")); 1138 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n"));
1154 1139
1155 if (pwrctl->bInternalAutoSuspend == true) 1140 if (pwrctl->bInternalAutoSuspend == true) {
1156 {
1157 /* rtw_pwr_wakeup(padapter); */ 1141 /* rtw_pwr_wakeup(padapter); */
1158 if (pwrctl->rf_pwrstate == rf_off) 1142 if (pwrctl->rf_pwrstate == rf_off)
1159 pwrctl->ps_flag = true; 1143 pwrctl->ps_flag = true;
@@ -1174,8 +1158,7 @@ static int netdev_close(struct net_device *pnetdev)
1174 DBG_871X("(2)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed); 1158 DBG_871X("(2)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed);
1175 1159
1176 /* s1. */ 1160 /* s1. */
1177 if (pnetdev) 1161 if (pnetdev) {
1178 {
1179 if (!rtw_netif_queue_stopped(pnetdev)) 1162 if (!rtw_netif_queue_stopped(pnetdev))
1180 rtw_netif_stop_queue(pnetdev); 1163 rtw_netif_stop_queue(pnetdev);
1181 } 1164 }
@@ -1198,12 +1181,11 @@ static int netdev_close(struct net_device *pnetdev)
1198 DBG_871X("-871x_drv - drv_close, bup =%d\n", padapter->bup); 1181 DBG_871X("-871x_drv - drv_close, bup =%d\n", padapter->bup);
1199 1182
1200 return 0; 1183 return 0;
1201
1202} 1184}
1203 1185
1204void rtw_ndev_destructor(struct net_device *ndev) 1186void rtw_ndev_destructor(struct net_device *ndev)
1205{ 1187{
1206 DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); 1188 DBG_871X(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev));
1207 1189
1208 if (ndev->ieee80211_ptr) 1190 if (ndev->ieee80211_ptr)
1209 kfree((u8 *)ndev->ieee80211_ptr); 1191 kfree((u8 *)ndev->ieee80211_ptr);
@@ -1219,8 +1201,7 @@ void rtw_dev_unload(struct adapter *padapter)
1219 1201
1220 RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+%s\n", __func__)); 1202 RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+%s\n", __func__));
1221 1203
1222 if (padapter->bup == true) 1204 if (padapter->bup == true) {
1223 {
1224 DBG_871X("===> %s\n", __func__); 1205 DBG_871X("===> %s\n", __func__);
1225 1206
1226 padapter->bDriverStopped = true; 1207 padapter->bDriverStopped = true;
@@ -1257,12 +1238,11 @@ void rtw_dev_unload(struct adapter *padapter)
1257 DBG_871X_LEVEL(_drv_always_, "%s: driver not in IPS\n", __func__); 1238 DBG_871X_LEVEL(_drv_always_, "%s: driver not in IPS\n", __func__);
1258 } 1239 }
1259 1240
1260 if (padapter->bSurpriseRemoved == false) 1241 if (padapter->bSurpriseRemoved == false) {
1261 {
1262 rtw_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); 1242 rtw_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req);
1263#ifdef CONFIG_WOWLAN 1243#ifdef CONFIG_WOWLAN
1264 if (pwrctl->bSupportRemoteWakeup == true && 1244 if (pwrctl->bSupportRemoteWakeup == true &&
1265 pwrctl->wowlan_mode ==true) { 1245 pwrctl->wowlan_mode == true) {
1266 DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true do not run rtw_hal_deinit()\n", __func__); 1246 DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true do not run rtw_hal_deinit()\n", __func__);
1267 } 1247 }
1268 else 1248 else
@@ -1292,12 +1272,11 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
1292{ 1272{
1293 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1273 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1294 1274
1295 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1275 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1296 1276
1297 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { 1277 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
1298 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) 1278 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
1299 && check_fwstate(pmlmepriv, _FW_LINKED)) 1279 && check_fwstate(pmlmepriv, _FW_LINKED)) {
1300 {
1301 DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__, 1280 DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__,
1302 pmlmepriv->cur_network.network.Ssid.Ssid, 1281 pmlmepriv->cur_network.network.Ssid.Ssid,
1303 MAC_ARG(pmlmepriv->cur_network.network.MacAddress), 1282 MAC_ARG(pmlmepriv->cur_network.network.MacAddress),
@@ -1307,14 +1286,12 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
1307 } 1286 }
1308 } 1287 }
1309 1288
1310 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) 1289 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) {
1311 {
1312 rtw_disassoc_cmd(padapter, 0, false); 1290 rtw_disassoc_cmd(padapter, 0, false);
1313 /* s2-2. indicate disconnect to os */ 1291 /* s2-2. indicate disconnect to os */
1314 rtw_indicate_disconnect(padapter); 1292 rtw_indicate_disconnect(padapter);
1315 } 1293 }
1316 else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) 1294 else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1317 {
1318 rtw_sta_flush(padapter); 1295 rtw_sta_flush(padapter);
1319 } 1296 }
1320 1297
@@ -1327,13 +1304,12 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
1327 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) 1304 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
1328 rtw_indicate_scan_done(padapter, 1); 1305 rtw_indicate_scan_done(padapter, 1);
1329 1306
1330 if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) 1307 if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
1331 {
1332 DBG_871X_LEVEL(_drv_always_, "%s: fw_under_linking\n", __func__); 1308 DBG_871X_LEVEL(_drv_always_, "%s: fw_under_linking\n", __func__);
1333 rtw_indicate_disconnect(padapter); 1309 rtw_indicate_disconnect(padapter);
1334 } 1310 }
1335 1311
1336 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1312 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1337 return _SUCCESS; 1313 return _SUCCESS;
1338} 1314}
1339 1315
@@ -1347,7 +1323,7 @@ int rtw_suspend_wow(struct adapter *padapter)
1347 struct wowlan_ioctl_param poidparam; 1323 struct wowlan_ioctl_param poidparam;
1348 int ret = _SUCCESS; 1324 int ret = _SUCCESS;
1349 1325
1350 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1326 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1351 1327
1352 1328
1353 DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode); 1329 DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode);
@@ -1379,8 +1355,7 @@ int rtw_suspend_wow(struct adapter *padapter)
1379 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam); 1355 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
1380 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { 1356 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
1381 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) 1357 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
1382 && check_fwstate(pmlmepriv, _FW_LINKED)) 1358 && check_fwstate(pmlmepriv, _FW_LINKED)) {
1383 {
1384 DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__, 1359 DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__,
1385 pmlmepriv->cur_network.network.Ssid.Ssid, 1360 pmlmepriv->cur_network.network.Ssid.Ssid,
1386 MAC_ARG(pmlmepriv->cur_network.network.MacAddress), 1361 MAC_ARG(pmlmepriv->cur_network.network.MacAddress),
@@ -1393,15 +1368,14 @@ int rtw_suspend_wow(struct adapter *padapter)
1393 1368
1394 DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__); 1369 DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
1395 1370
1396 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) 1371 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
1397 {
1398 DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__); 1372 DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__);
1399 rtw_indicate_scan_done(padapter, 1); 1373 rtw_indicate_scan_done(padapter, 1);
1400 clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY); 1374 clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
1401 } 1375 }
1402 1376
1403 if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) { 1377 if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
1404 DBG_871X(FUNC_ADPT_FMT" back to linked/linking union - ch:%u, bw:%u, offset:%u\n", 1378 DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
1405 FUNC_ADPT_ARG(padapter), ch, bw, offset); 1379 FUNC_ADPT_ARG(padapter), ch, bw, offset);
1406 set_channel_bwmode(padapter, ch, offset, bw); 1380 set_channel_bwmode(padapter, ch, offset, bw);
1407 } 1381 }
@@ -1410,13 +1384,11 @@ int rtw_suspend_wow(struct adapter *padapter)
1410 DBG_871X_LEVEL(_drv_always_, "%s: pno: %d\n", __func__, pwrpriv->wowlan_pno_enable); 1384 DBG_871X_LEVEL(_drv_always_, "%s: pno: %d\n", __func__, pwrpriv->wowlan_pno_enable);
1411 else 1385 else
1412 rtw_set_ps_mode(padapter, PS_MODE_DTIM, 0, 0, "WOWLAN"); 1386 rtw_set_ps_mode(padapter, PS_MODE_DTIM, 0, 0, "WOWLAN");
1413
1414 } 1387 }
1415 else 1388 else {
1416 {
1417 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); 1389 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
1418 } 1390 }
1419 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1391 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1420 return ret; 1392 return ret;
1421} 1393}
1422#endif /* ifdef CONFIG_WOWLAN */ 1394#endif /* ifdef CONFIG_WOWLAN */
@@ -1430,7 +1402,7 @@ int rtw_suspend_ap_wow(struct adapter *padapter)
1430 struct wowlan_ioctl_param poidparam; 1402 struct wowlan_ioctl_param poidparam;
1431 int ret = _SUCCESS; 1403 int ret = _SUCCESS;
1432 1404
1433 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1405 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1434 1406
1435 pwrpriv->wowlan_ap_mode = true; 1407 pwrpriv->wowlan_ap_mode = true;
1436 1408
@@ -1462,14 +1434,14 @@ int rtw_suspend_ap_wow(struct adapter *padapter)
1462 DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__); 1434 DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
1463 1435
1464 if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) { 1436 if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
1465 DBG_871X(FUNC_ADPT_FMT" back to linked/linking union - ch:%u, bw:%u, offset:%u\n", 1437 DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
1466 FUNC_ADPT_ARG(padapter), ch, bw, offset); 1438 FUNC_ADPT_ARG(padapter), ch, bw, offset);
1467 set_channel_bwmode(padapter, ch, offset, bw); 1439 set_channel_bwmode(padapter, ch, offset, bw);
1468 } 1440 }
1469 1441
1470 rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, 0, "AP-WOWLAN"); 1442 rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, 0, "AP-WOWLAN");
1471 1443
1472 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1444 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1473 return ret; 1445 return ret;
1474} 1446}
1475#endif /* ifdef CONFIG_AP_WOWLAN */ 1447#endif /* ifdef CONFIG_AP_WOWLAN */
@@ -1480,7 +1452,7 @@ static int rtw_suspend_normal(struct adapter *padapter)
1480 struct net_device *pnetdev = padapter->pnetdev; 1452 struct net_device *pnetdev = padapter->pnetdev;
1481 int ret = _SUCCESS; 1453 int ret = _SUCCESS;
1482 1454
1483 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1455 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1484 if (pnetdev) { 1456 if (pnetdev) {
1485 netif_carrier_off(pnetdev); 1457 netif_carrier_off(pnetdev);
1486 rtw_netif_stop_queue(pnetdev); 1458 rtw_netif_stop_queue(pnetdev);
@@ -1489,10 +1461,8 @@ static int rtw_suspend_normal(struct adapter *padapter)
1489 rtw_suspend_free_assoc_resource(padapter); 1461 rtw_suspend_free_assoc_resource(padapter);
1490 1462
1491 if ((rtw_hal_check_ips_status(padapter) == true) 1463 if ((rtw_hal_check_ips_status(padapter) == true)
1492 || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)) 1464 || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)) {
1493 {
1494 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR #### driver in IPS ####ERROR###!!!\n", __func__); 1465 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR #### driver in IPS ####ERROR###!!!\n", __func__);
1495
1496 } 1466 }
1497 1467
1498 rtw_dev_unload(padapter); 1468 rtw_dev_unload(padapter);
@@ -1501,7 +1471,7 @@ static int rtw_suspend_normal(struct adapter *padapter)
1501 if (padapter->intf_deinit) 1471 if (padapter->intf_deinit)
1502 padapter->intf_deinit(adapter_to_dvobj(padapter)); 1472 padapter->intf_deinit(adapter_to_dvobj(padapter));
1503 1473
1504 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1474 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1505 return ret; 1475 return ret;
1506} 1476}
1507 1477
@@ -1524,8 +1494,7 @@ int rtw_suspend_common(struct adapter *padapter)
1524 while (pwrpriv->bips_processing == true) 1494 while (pwrpriv->bips_processing == true)
1525 msleep(1); 1495 msleep(1);
1526 1496
1527 if ((!padapter->bup) || (padapter->bDriverStopped)||(padapter->bSurpriseRemoved)) 1497 if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) {
1528 {
1529 DBG_871X("%s bup =%d bDriverStopped =%d bSurpriseRemoved = %d\n", __func__ 1498 DBG_871X("%s bup =%d bDriverStopped =%d bSurpriseRemoved = %d\n", __func__
1530 , padapter->bup, padapter->bDriverStopped, padapter->bSurpriseRemoved); 1499 , padapter->bup, padapter->bDriverStopped, padapter->bSurpriseRemoved);
1531 pdbgpriv->dbg_suspend_error_cnt++; 1500 pdbgpriv->dbg_suspend_error_cnt++;
@@ -1599,7 +1568,7 @@ int rtw_resume_process_wow(struct adapter *padapter)
1599 struct sta_info *psta = NULL; 1568 struct sta_info *psta = NULL;
1600 int ret = _SUCCESS; 1569 int ret = _SUCCESS;
1601 1570
1602 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1571 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1603 1572
1604 if (padapter) { 1573 if (padapter) {
1605 pnetdev = padapter->pnetdev; 1574 pnetdev = padapter->pnetdev;
@@ -1641,7 +1610,7 @@ int rtw_resume_process_wow(struct adapter *padapter)
1641 } 1610 }
1642 1611
1643 /* Disable WOW, set H2C command */ 1612 /* Disable WOW, set H2C command */
1644 poidparam.subcode =WOWLAN_DISABLE; 1613 poidparam.subcode = WOWLAN_DISABLE;
1645 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam); 1614 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
1646 1615
1647 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); 1616 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
@@ -1667,11 +1636,10 @@ int rtw_resume_process_wow(struct adapter *padapter)
1667 } 1636 }
1668 } 1637 }
1669 else { 1638 else {
1670
1671 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); 1639 DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
1672 } 1640 }
1673 1641
1674 if (padapter->pid[1]!= 0) { 1642 if (padapter->pid[1] != 0) {
1675 DBG_871X("pid[1]:%d\n", padapter->pid[1]); 1643 DBG_871X("pid[1]:%d\n", padapter->pid[1]);
1676 rtw_signal_process(padapter->pid[1], SIGUSR2); 1644 rtw_signal_process(padapter->pid[1], SIGUSR2);
1677 } 1645 }
@@ -1680,7 +1648,6 @@ int rtw_resume_process_wow(struct adapter *padapter)
1680 if (pwrpriv->wowlan_wake_reason == FWDecisionDisconnect || 1648 if (pwrpriv->wowlan_wake_reason == FWDecisionDisconnect ||
1681 pwrpriv->wowlan_wake_reason == Rx_DisAssoc || 1649 pwrpriv->wowlan_wake_reason == Rx_DisAssoc ||
1682 pwrpriv->wowlan_wake_reason == Rx_DeAuth) { 1650 pwrpriv->wowlan_wake_reason == Rx_DeAuth) {
1683
1684 DBG_871X("%s: disconnect reason: %02x\n", __func__, 1651 DBG_871X("%s: disconnect reason: %02x\n", __func__,
1685 pwrpriv->wowlan_wake_reason); 1652 pwrpriv->wowlan_wake_reason);
1686 rtw_indicate_disconnect(padapter); 1653 rtw_indicate_disconnect(padapter);
@@ -1705,12 +1672,12 @@ int rtw_resume_process_wow(struct adapter *padapter)
1705 DBG_871X_LEVEL(_drv_always_, "do not reset timer\n"); 1672 DBG_871X_LEVEL(_drv_always_, "do not reset timer\n");
1706 } 1673 }
1707 1674
1708 pwrpriv->wowlan_mode =false; 1675 pwrpriv->wowlan_mode = false;
1709 1676
1710 /* clean driver side wake up reason. */ 1677 /* clean driver side wake up reason. */
1711 pwrpriv->wowlan_wake_reason = 0; 1678 pwrpriv->wowlan_wake_reason = 0;
1712exit: 1679exit:
1713 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1680 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1714 return ret; 1681 return ret;
1715} 1682}
1716#endif /* ifdef CONFIG_WOWLAN */ 1683#endif /* ifdef CONFIG_WOWLAN */
@@ -1725,7 +1692,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter)
1725 struct wowlan_ioctl_param poidparam; 1692 struct wowlan_ioctl_param poidparam;
1726 int ret = _SUCCESS; 1693 int ret = _SUCCESS;
1727 1694
1728 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1695 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1729 1696
1730 if (padapter) { 1697 if (padapter) {
1731 pnetdev = padapter->pnetdev; 1698 pnetdev = padapter->pnetdev;
@@ -1774,7 +1741,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter)
1774 rtw_netif_wake_queue(pnetdev); 1741 rtw_netif_wake_queue(pnetdev);
1775 } 1742 }
1776 1743
1777 if (padapter->pid[1]!= 0) { 1744 if (padapter->pid[1] != 0) {
1778 DBG_871X("pid[1]:%d\n", padapter->pid[1]); 1745 DBG_871X("pid[1]:%d\n", padapter->pid[1]);
1779 rtw_signal_process(padapter->pid[1], SIGUSR2); 1746 rtw_signal_process(padapter->pid[1], SIGUSR2);
1780 } 1747 }
@@ -1785,7 +1752,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter)
1785 /* clean driver side wake up reason. */ 1752 /* clean driver side wake up reason. */
1786 pwrpriv->wowlan_wake_reason = 0; 1753 pwrpriv->wowlan_wake_reason = 0;
1787exit: 1754exit:
1788 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1755 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1789 return ret; 1756 return ret;
1790} 1757}
1791#endif /* ifdef CONFIG_APWOWLAN */ 1758#endif /* ifdef CONFIG_APWOWLAN */
@@ -1811,19 +1778,17 @@ static int rtw_resume_process_normal(struct adapter *padapter)
1811 psdpriv = padapter->dvobj; 1778 psdpriv = padapter->dvobj;
1812 pdbgpriv = &psdpriv->drv_dbg; 1779 pdbgpriv = &psdpriv->drv_dbg;
1813 1780
1814 DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); 1781 DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
1815 /* interface init */ 1782 /* interface init */
1816 /* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */ 1783 /* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
1817 if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) 1784 if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
1818 {
1819 ret = -1; 1785 ret = -1;
1820 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!!\n", __func__)); 1786 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!!\n", __func__));
1821 goto exit; 1787 goto exit;
1822 } 1788 }
1823 rtw_hal_disable_interrupt(padapter); 1789 rtw_hal_disable_interrupt(padapter);
1824 /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */ 1790 /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
1825 if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) 1791 if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
1826 {
1827 ret = -1; 1792 ret = -1;
1828 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__)); 1793 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
1829 goto exit; 1794 goto exit;
@@ -1842,28 +1807,28 @@ static int rtw_resume_process_normal(struct adapter *padapter)
1842 netif_device_attach(pnetdev); 1807 netif_device_attach(pnetdev);
1843 netif_carrier_on(pnetdev); 1808 netif_carrier_on(pnetdev);
1844 1809
1845 if (padapter->pid[1]!= 0) { 1810 if (padapter->pid[1] != 0) {
1846 DBG_871X("pid[1]:%d\n", padapter->pid[1]); 1811 DBG_871X("pid[1]:%d\n", padapter->pid[1]);
1847 rtw_signal_process(padapter->pid[1], SIGUSR2); 1812 rtw_signal_process(padapter->pid[1], SIGUSR2);
1848 } 1813 }
1849 1814
1850 1815
1851 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { 1816 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
1852 DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); 1817 DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
1853 1818
1854 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) 1819 if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME))
1855 rtw_roaming(padapter, NULL); 1820 rtw_roaming(padapter, NULL);
1856 1821
1857 } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { 1822 } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1858 DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); 1823 DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
1859 rtw_ap_restore_network(padapter); 1824 rtw_ap_restore_network(padapter);
1860 } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { 1825 } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
1861 DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); 1826 DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
1862 } else { 1827 } else {
1863 DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); 1828 DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
1864 } 1829 }
1865 1830
1866 DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); 1831 DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
1867 1832
1868exit: 1833exit:
1869 return ret; 1834 return ret;
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index a05daf06a870..f4221952dd1b 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -30,22 +30,17 @@ inline int RTW_STATUS_CODE(int error_code)
30 return _FAIL; 30 return _FAIL;
31} 31}
32 32
33u8 *_rtw_malloc(u32 sz) 33void *_rtw_malloc(u32 sz)
34{ 34{
35 u8 *pbuf = NULL; 35 return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
36
37 pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
38
39 return pbuf;
40} 36}
41 37
42u8 *_rtw_zmalloc(u32 sz) 38void *_rtw_zmalloc(u32 sz)
43{ 39{
44 u8 *pbuf = _rtw_malloc(sz); 40 void *pbuf = _rtw_malloc(sz);
45 41
46 if (pbuf != NULL) { 42 if (pbuf)
47 memset(pbuf, 0, sz); 43 memset(pbuf, 0, sz);
48 }
49 44
50 return pbuf; 45 return pbuf;
51} 46}
@@ -71,13 +66,6 @@ inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb)
71 return netif_rx(skb); 66 return netif_rx(skb);
72} 67}
73 68
74void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc)
75{
76 struct adapter *adapter = padapter;
77
78 _init_timer(ptimer, adapter->pnetdev, pfunc, adapter);
79}
80
81void _rtw_init_queue(struct __queue *pqueue) 69void _rtw_init_queue(struct __queue *pqueue)
82{ 70{
83 INIT_LIST_HEAD(&(pqueue->queue)); 71 INIT_LIST_HEAD(&(pqueue->queue));
@@ -470,7 +458,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
470{ 458{
471 struct rtw_cbuf *cbuf; 459 struct rtw_cbuf *cbuf;
472 460
473 cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + sizeof(void*)*size); 461 cbuf = rtw_malloc(sizeof(*cbuf) + sizeof(void *) * size);
474 462
475 if (cbuf) { 463 if (cbuf) {
476 cbuf->write = cbuf->read = 0; 464 cbuf->write = cbuf->read = 0;
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index f42e00081e0e..e804b430931c 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -356,8 +356,7 @@ _recv_indicatepkt_drop:
356 356
357void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) 357void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
358{ 358{
359 struct adapter *padapter = preorder_ctrl->padapter; 359 timer_setup(&preorder_ctrl->reordering_ctrl_timer,
360 360 rtw_reordering_ctrl_timeout_handler, 0);
361 _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, rtw_reordering_ctrl_timeout_handler, preorder_ctrl);
362 361
363} 362}
diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
index ce1dd6f9036f..9a885e626d1c 100644
--- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
+++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
@@ -87,7 +87,7 @@ static ssize_t proc_set_log_level(struct file *file, const char __user *buffer,
87* rtw_drv_proc: 87* rtw_drv_proc:
88* init/deinit when register/unregister driver 88* init/deinit when register/unregister driver
89*/ 89*/
90static const struct rtw_proc_hdl drv_proc_hdls [] = { 90static const struct rtw_proc_hdl drv_proc_hdls[] = {
91 {"ver_info", proc_get_drv_version, NULL}, 91 {"ver_info", proc_get_drv_version, NULL},
92 {"log_level", proc_get_log_level, proc_set_log_level}, 92 {"log_level", proc_get_log_level, proc_set_log_level},
93}; 93};
@@ -365,7 +365,7 @@ static int proc_get_cam_cache(struct seq_file *m, void *v)
365* rtw_adapter_proc: 365* rtw_adapter_proc:
366* init/deinit when register/unregister net_device 366* init/deinit when register/unregister net_device
367*/ 367*/
368static const struct rtw_proc_hdl adapter_proc_hdls [] = { 368static const struct rtw_proc_hdl adapter_proc_hdls[] = {
369 {"write_reg", proc_get_dummy, proc_set_write_reg}, 369 {"write_reg", proc_get_dummy, proc_set_write_reg},
370 {"read_reg", proc_get_read_reg, proc_set_read_reg}, 370 {"read_reg", proc_get_read_reg, proc_set_read_reg},
371 {"fwstate", proc_get_fwstate, NULL}, 371 {"fwstate", proc_get_fwstate, NULL},
@@ -600,7 +600,7 @@ ssize_t proc_set_odm_adaptivity(struct file *file, const char __user *buffer, si
600* rtw_odm_proc: 600* rtw_odm_proc:
601* init/deinit when register/unregister net_device, along with rtw_adapter_proc 601* init/deinit when register/unregister net_device, along with rtw_adapter_proc
602*/ 602*/
603static const struct rtw_proc_hdl odm_proc_hdls [] = { 603static const struct rtw_proc_hdl odm_proc_hdls[] = {
604 {"dbg_comp", proc_get_odm_dbg_comp, proc_set_odm_dbg_comp}, 604 {"dbg_comp", proc_get_odm_dbg_comp, proc_set_odm_dbg_comp},
605 {"dbg_level", proc_get_odm_dbg_level, proc_set_odm_dbg_level}, 605 {"dbg_level", proc_get_odm_dbg_level, proc_set_odm_dbg_level},
606 {"ability", proc_get_odm_ability, proc_set_odm_ability}, 606 {"ability", proc_get_odm_ability, proc_set_odm_ability},
diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index b88b0e8edd3d..c947def37d31 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -465,10 +465,10 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
465 struct rtl_priv *rtlpriv = rtl_priv(hw); 465 struct rtl_priv *rtlpriv = rtl_priv(hw);
466 466
467 /* <1> timer */ 467 /* <1> timer */
468 setup_timer(&rtlpriv->works.watchdog_timer, 468 timer_setup(&rtlpriv->works.watchdog_timer,
469 rtl_watch_dog_timer_callback, (unsigned long)hw); 469 rtl_watch_dog_timer_callback, 0);
470 setup_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer, 470 timer_setup(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
471 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw); 471 rtl_easy_concurrent_retrytimer_callback, 0);
472 /* <2> work queue */ 472 /* <2> work queue */
473 rtlpriv->works.hw = hw; 473 rtlpriv->works.hw = hw;
474 rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name); 474 rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
@@ -637,7 +637,7 @@ static void _rtl_query_shortgi(struct ieee80211_hw *hw,
637 sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20; 637 sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
638 sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80; 638 sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80;
639 639
640 if ((!sta->ht_cap.ht_supported) && (!sta->vht_cap.vht_supported)) 640 if (!sta->ht_cap.ht_supported && !sta->vht_cap.vht_supported)
641 return; 641 return;
642 642
643 if (!sgi_40 && !sgi_20) 643 if (!sgi_40 && !sgi_20)
@@ -734,10 +734,10 @@ u8 rtl_mrate_idx_to_arfr_id(
734 ret = RATEID_IDX_B; 734 ret = RATEID_IDX_B;
735 break; 735 break;
736 case RATR_INX_WIRELESS_MC: 736 case RATR_INX_WIRELESS_MC:
737 if ((wirelessmode == WIRELESS_MODE_B) || 737 if (wirelessmode == WIRELESS_MODE_B ||
738 (wirelessmode == WIRELESS_MODE_G) || 738 wirelessmode == WIRELESS_MODE_G ||
739 (wirelessmode == WIRELESS_MODE_N_24G) || 739 wirelessmode == WIRELESS_MODE_N_24G ||
740 (wirelessmode == WIRELESS_MODE_AC_24G)) 740 wirelessmode == WIRELESS_MODE_AC_24G)
741 ret = RATEID_IDX_BG; 741 ret = RATEID_IDX_BG;
742 else 742 else
743 ret = RATEID_IDX_G; 743 ret = RATEID_IDX_G;
@@ -920,7 +920,7 @@ static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw,
920 else if ((tx_mcs_map & 0x000c) >> 2 == 920 else if ((tx_mcs_map & 0x000c) >> 2 ==
921 IEEE80211_VHT_MCS_SUPPORT_0_8) 921 IEEE80211_VHT_MCS_SUPPORT_0_8)
922 hw_rate = 922 hw_rate =
923 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; 923 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS8];
924 else 924 else
925 hw_rate = 925 hw_rate =
926 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; 926 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
@@ -932,7 +932,7 @@ static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw,
932 else if ((tx_mcs_map & 0x0003) == 932 else if ((tx_mcs_map & 0x0003) ==
933 IEEE80211_VHT_MCS_SUPPORT_0_8) 933 IEEE80211_VHT_MCS_SUPPORT_0_8)
934 hw_rate = 934 hw_rate =
935 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; 935 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS8];
936 else 936 else
937 hw_rate = 937 hw_rate =
938 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; 938 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
@@ -948,8 +948,8 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
948 struct rtl_phy *rtlphy = &rtlpriv->phy; 948 struct rtl_phy *rtlphy = &rtlpriv->phy;
949 u8 hw_rate; 949 u8 hw_rate;
950 950
951 if ((get_rf_type(rtlphy) == RF_2T2R) && 951 if (get_rf_type(rtlphy) == RF_2T2R &&
952 (sta->ht_cap.mcs.rx_mask[1] != 0)) 952 sta->ht_cap.mcs.rx_mask[1] != 0)
953 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15]; 953 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15];
954 else 954 else
955 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7]; 955 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7];
@@ -1277,7 +1277,7 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
1277 tcb_desc->hw_rate = 1277 tcb_desc->hw_rate =
1278 _rtl_get_vht_highest_n_rate(hw, sta); 1278 _rtl_get_vht_highest_n_rate(hw, sta);
1279 } else { 1279 } else {
1280 if (sta && (sta->ht_cap.ht_supported)) { 1280 if (sta && sta->ht_cap.ht_supported) {
1281 tcb_desc->hw_rate = 1281 tcb_desc->hw_rate =
1282 _rtl_get_highest_n_rate(hw, sta); 1282 _rtl_get_highest_n_rate(hw, sta);
1283 } else { 1283 } else {
@@ -2080,9 +2080,9 @@ void rtl_watchdog_wq_callback(void *data)
2080 rtlpriv->btcoexist.btc_ops->btc_is_bt_ctrl_lps(rtlpriv)) 2080 rtlpriv->btcoexist.btc_ops->btc_is_bt_ctrl_lps(rtlpriv))
2081 goto label_lps_done; 2081 goto label_lps_done;
2082 2082
2083 if (((rtlpriv->link_info.num_rx_inperiod + 2083 if (rtlpriv->link_info.num_rx_inperiod +
2084 rtlpriv->link_info.num_tx_inperiod) > 8) || 2084 rtlpriv->link_info.num_tx_inperiod > 8 ||
2085 (rtlpriv->link_info.num_rx_inperiod > 2)) 2085 rtlpriv->link_info.num_rx_inperiod > 2)
2086 rtl_lps_leave(hw); 2086 rtl_lps_leave(hw);
2087 else 2087 else
2088 rtl_lps_enter(hw); 2088 rtl_lps_enter(hw);
@@ -2161,10 +2161,9 @@ label_lps_done:
2161 rtl_scan_list_expire(hw); 2161 rtl_scan_list_expire(hw);
2162} 2162}
2163 2163
2164void rtl_watch_dog_timer_callback(unsigned long data) 2164void rtl_watch_dog_timer_callback(struct timer_list *t)
2165{ 2165{
2166 struct ieee80211_hw *hw = (struct ieee80211_hw *)data; 2166 struct rtl_priv *rtlpriv = from_timer(rtlpriv, t, works.watchdog_timer);
2167 struct rtl_priv *rtlpriv = rtl_priv(hw);
2168 2167
2169 queue_delayed_work(rtlpriv->works.rtl_wq, 2168 queue_delayed_work(rtlpriv->works.rtl_wq,
2170 &rtlpriv->works.watchdog_wq, 0); 2169 &rtlpriv->works.watchdog_wq, 0);
@@ -2270,10 +2269,11 @@ void rtl_c2hcmd_wq_callback(void *data)
2270 rtl_c2hcmd_launcher(hw, 1); 2269 rtl_c2hcmd_launcher(hw, 1);
2271} 2270}
2272 2271
2273void rtl_easy_concurrent_retrytimer_callback(unsigned long data) 2272void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t)
2274{ 2273{
2275 struct ieee80211_hw *hw = (struct ieee80211_hw *)data; 2274 struct rtl_priv *rtlpriv =
2276 struct rtl_priv *rtlpriv = rtl_priv(hw); 2275 from_timer(rtlpriv, t, works.dualmac_easyconcurrent_retrytimer);
2276 struct ieee80211_hw *hw = rtlpriv->hw;
2277 struct rtl_priv *buddy_priv = rtlpriv->buddy_priv; 2277 struct rtl_priv *buddy_priv = rtlpriv->buddy_priv;
2278 2278
2279 if (!buddy_priv) 2279 if (!buddy_priv)
@@ -2334,9 +2334,7 @@ static struct sk_buff *rtl_make_smps_action(struct ieee80211_hw *hw,
2334 case IEEE80211_SMPS_AUTOMATIC:/* 0 */ 2334 case IEEE80211_SMPS_AUTOMATIC:/* 0 */
2335 case IEEE80211_SMPS_NUM_MODES:/* 4 */ 2335 case IEEE80211_SMPS_NUM_MODES:/* 4 */
2336 WARN_ON(1); 2336 WARN_ON(1);
2337 /* Here will get a 'MISSING_BREAK' in Coverity Test, just ignore it. 2337 /* fall through */
2338 * According to Kernel Code, here is right.
2339 */
2340 case IEEE80211_SMPS_OFF:/* 1 */ /*MIMO_PS_NOLIMIT*/ 2338 case IEEE80211_SMPS_OFF:/* 1 */ /*MIMO_PS_NOLIMIT*/
2341 action_frame->u.action.u.ht_smps.smps_control = 2339 action_frame->u.action.u.ht_smps.smps_control =
2342 WLAN_HT_SMPS_CONTROL_DISABLED;/* 0 */ 2340 WLAN_HT_SMPS_CONTROL_DISABLED;/* 0 */
@@ -2552,8 +2550,8 @@ bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data, unsigned int len)
2552 bcn_key.valid = true; 2550 bcn_key.valid = true;
2553 2551
2554 /* update cur_beacon_keys or compare beacon key */ 2552 /* update cur_beacon_keys or compare beacon key */
2555 if ((rtlpriv->mac80211.link_state != MAC80211_LINKED) && 2553 if (rtlpriv->mac80211.link_state != MAC80211_LINKED &&
2556 (rtlpriv->mac80211.link_state != MAC80211_LINKED_SCANNING)) 2554 rtlpriv->mac80211.link_state != MAC80211_LINKED_SCANNING)
2557 return true; 2555 return true;
2558 2556
2559 if (!cur_bcn_key->valid) { 2557 if (!cur_bcn_key->valid) {
@@ -2576,8 +2574,8 @@ bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data, unsigned int len)
2576 goto chk_exit; 2574 goto chk_exit;
2577 } 2575 }
2578 2576
2579 if ((cur_bcn_key->bcn_channel == bcn_key.bcn_channel) && 2577 if (cur_bcn_key->bcn_channel == bcn_key.bcn_channel &&
2580 (cur_bcn_key->ht_cap_info == bcn_key.ht_cap_info)) { 2578 cur_bcn_key->ht_cap_info == bcn_key.ht_cap_info) {
2581 /* Beacon HT info IE, secondary channel offset check */ 2579 /* Beacon HT info IE, secondary channel offset check */
2582 /* 40M -> 20M */ 2580 /* 40M -> 20M */
2583 if (cur_bcn_key->ht_info_infos_0_sco > 2581 if (cur_bcn_key->ht_info_infos_0_sco >
diff --git a/drivers/staging/rtlwifi/base.h b/drivers/staging/rtlwifi/base.h
index 1829712dc4e2..b7f92b32978e 100644
--- a/drivers/staging/rtlwifi/base.h
+++ b/drivers/staging/rtlwifi/base.h
@@ -120,7 +120,7 @@ void rtl_init_rx_config(struct ieee80211_hw *hw);
120void rtl_init_rfkill(struct ieee80211_hw *hw); 120void rtl_init_rfkill(struct ieee80211_hw *hw);
121void rtl_deinit_rfkill(struct ieee80211_hw *hw); 121void rtl_deinit_rfkill(struct ieee80211_hw *hw);
122 122
123void rtl_watch_dog_timer_callback(unsigned long data); 123void rtl_watch_dog_timer_callback(struct timer_list *t);
124void rtl_deinit_deferred_work(struct ieee80211_hw *hw); 124void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
125 125
126bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx); 126bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
@@ -176,7 +176,7 @@ int rtl_send_smps_action(struct ieee80211_hw *hw,
176u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie); 176u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie);
177void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len); 177void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
178u8 rtl_tid_to_ac(u8 tid); 178u8 rtl_tid_to_ac(u8 tid);
179void rtl_easy_concurrent_retrytimer_callback(unsigned long data); 179void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t);
180extern struct rtl_global_var rtl_global_var; 180extern struct rtl_global_var rtl_global_var;
181void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation); 181void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
182bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data, 182bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data,
diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index d33847d0550d..b00e51df984f 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -49,43 +49,6 @@ u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = {
49 42, 58, 106, 122, 138, 155, 171 49 42, 58, 106, 122, 138, 155, 171
50}; 50};
51 51
52void rtl_addr_delay(u32 addr)
53{
54 if (addr == 0xfe)
55 mdelay(50);
56 else if (addr == 0xfd)
57 msleep(5);
58 else if (addr == 0xfc)
59 msleep(1);
60 else if (addr == 0xfb)
61 usleep_range(50, 100);
62 else if (addr == 0xfa)
63 usleep_range(5, 10);
64 else if (addr == 0xf9)
65 usleep_range(1, 2);
66}
67
68void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
69 u32 mask, u32 data)
70{
71 if (addr >= 0xf9 && addr <= 0xfe) {
72 rtl_addr_delay(addr);
73 } else {
74 rtl_set_rfreg(hw, rfpath, addr, mask, data);
75 udelay(1);
76 }
77}
78
79void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
80{
81 if (addr >= 0xf9 && addr <= 0xfe) {
82 rtl_addr_delay(addr);
83 } else {
84 rtl_set_bbreg(hw, addr, MASKDWORD, data);
85 udelay(1);
86 }
87}
88
89static void rtl_fw_do_work(const struct firmware *firmware, void *context, 52static void rtl_fw_do_work(const struct firmware *firmware, void *context,
90 bool is_wow) 53 bool is_wow)
91{ 54{
@@ -153,7 +116,7 @@ static int rtl_op_start(struct ieee80211_hw *hw)
153 mutex_lock(&rtlpriv->locks.conf_mutex); 116 mutex_lock(&rtlpriv->locks.conf_mutex);
154 err = rtlpriv->intf_ops->adapter_start(hw); 117 err = rtlpriv->intf_ops->adapter_start(hw);
155 if (!err) 118 if (!err)
156 rtl_watch_dog_timer_callback((unsigned long)hw); 119 rtl_watch_dog_timer_callback(&rtlpriv->works.watchdog_timer);
157 mutex_unlock(&rtlpriv->locks.conf_mutex); 120 mutex_unlock(&rtlpriv->locks.conf_mutex);
158 return err; 121 return err;
159} 122}
@@ -339,9 +302,9 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw,
339 mutex_lock(&rtlpriv->locks.conf_mutex); 302 mutex_lock(&rtlpriv->locks.conf_mutex);
340 303
341 /* Free beacon resources */ 304 /* Free beacon resources */
342 if ((vif->type == NL80211_IFTYPE_AP) || 305 if (vif->type == NL80211_IFTYPE_AP ||
343 (vif->type == NL80211_IFTYPE_ADHOC) || 306 vif->type == NL80211_IFTYPE_ADHOC ||
344 (vif->type == NL80211_IFTYPE_MESH_POINT)) { 307 vif->type == NL80211_IFTYPE_MESH_POINT) {
345 if (mac->beacon_enabled == 1) { 308 if (mac->beacon_enabled == 1) {
346 mac->beacon_enabled = 0; 309 mac->beacon_enabled = 0;
347 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, 310 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
@@ -449,7 +412,8 @@ static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
449 for (i = 0; i < wow->n_patterns; i++) { 412 for (i = 0; i < wow->n_patterns; i++) {
450 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern)); 413 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
451 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE); 414 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
452 if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) { 415 if (patterns[i].pattern_len < 0 ||
416 patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
453 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING, 417 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
454 "Pattern[%d] is too long\n", i); 418 "Pattern[%d] is too long\n", i);
455 continue; 419 continue;
@@ -856,8 +820,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
856 * here just used for linked scanning, & linked 820 * here just used for linked scanning, & linked
857 * and nolink check bssid is set in set network_type 821 * and nolink check bssid is set in set network_type
858 */ 822 */
859 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) && 823 if (changed_flags & FIF_BCN_PRBRESP_PROMISC &&
860 (mac->link_state >= MAC80211_LINKED)) { 824 mac->link_state >= MAC80211_LINKED) {
861 if (mac->opmode != NL80211_IFTYPE_AP && 825 if (mac->opmode != NL80211_IFTYPE_AP &&
862 mac->opmode != NL80211_IFTYPE_MESH_POINT) { 826 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
863 if (*new_flags & FIF_BCN_PRBRESP_PROMISC) 827 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
@@ -1078,10 +1042,10 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1078 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1042 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1079 1043
1080 mutex_lock(&rtlpriv->locks.conf_mutex); 1044 mutex_lock(&rtlpriv->locks.conf_mutex);
1081 if ((vif->type == NL80211_IFTYPE_ADHOC) || 1045 if (vif->type == NL80211_IFTYPE_ADHOC ||
1082 (vif->type == NL80211_IFTYPE_AP) || 1046 vif->type == NL80211_IFTYPE_AP ||
1083 (vif->type == NL80211_IFTYPE_MESH_POINT)) { 1047 vif->type == NL80211_IFTYPE_MESH_POINT) {
1084 if ((changed & BSS_CHANGED_BEACON) || 1048 if (changed & BSS_CHANGED_BEACON ||
1085 (changed & BSS_CHANGED_BEACON_ENABLED && 1049 (changed & BSS_CHANGED_BEACON_ENABLED &&
1086 bss_conf->enable_beacon)) { 1050 bss_conf->enable_beacon)) {
1087 if (mac->beacon_enabled == 0) { 1051 if (mac->beacon_enabled == 0) {
@@ -1160,7 +1124,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1160 if (rtlpriv->dm.supp_phymode_switch) { 1124 if (rtlpriv->dm.supp_phymode_switch) {
1161 if (sta->ht_cap.ht_supported) 1125 if (sta->ht_cap.ht_supported)
1162 rtl_send_smps_action(hw, sta, 1126 rtl_send_smps_action(hw, sta,
1163 IEEE80211_SMPS_STATIC); 1127 IEEE80211_SMPS_STATIC);
1164 } 1128 }
1165 1129
1166 if (rtlhal->current_bandtype == BAND_ON_5G) { 1130 if (rtlhal->current_bandtype == BAND_ON_5G) {
@@ -1224,7 +1188,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1224 cfg80211_unlink_bss(hw->wiphy, bss); 1188 cfg80211_unlink_bss(hw->wiphy, bss);
1225 cfg80211_put_bss(hw->wiphy, bss); 1189 cfg80211_put_bss(hw->wiphy, bss);
1226 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 1190 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1227 "cfg80211_unlink !!\n"); 1191 "cfg80211_unlink !!\n");
1228 } 1192 }
1229 1193
1230 eth_zero_addr(mac->bssid); 1194 eth_zero_addr(mac->bssid);
@@ -1621,8 +1585,8 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1621 return -ENOSPC; /*User disabled HW-crypto */ 1585 return -ENOSPC; /*User disabled HW-crypto */
1622 } 1586 }
1623 /* To support IBSS, use sw-crypto for GTK */ 1587 /* To support IBSS, use sw-crypto for GTK */
1624 if (((vif->type == NL80211_IFTYPE_ADHOC) || 1588 if ((vif->type == NL80211_IFTYPE_ADHOC ||
1625 (vif->type == NL80211_IFTYPE_MESH_POINT)) && 1589 vif->type == NL80211_IFTYPE_MESH_POINT) &&
1626 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) 1590 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1627 return -ENOSPC; 1591 return -ENOSPC;
1628 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1592 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
@@ -1697,7 +1661,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1697 rtlpriv->cfg->ops->enable_hw_sec(hw); 1661 rtlpriv->cfg->ops->enable_hw_sec(hw);
1698 } 1662 }
1699 } else { 1663 } else {
1700 if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) || 1664 if (!group_key || vif->type == NL80211_IFTYPE_ADHOC ||
1701 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) { 1665 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1702 if (rtlpriv->sec.pairwise_enc_algorithm == 1666 if (rtlpriv->sec.pairwise_enc_algorithm ==
1703 NO_ENCRYPTION && 1667 NO_ENCRYPTION &&
@@ -1885,7 +1849,7 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1885 break; 1849 break;
1886 case PWR_CMD_WRITE: 1850 case PWR_CMD_WRITE:
1887 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1851 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1888 "%s(): PWR_CMD_WRITE\n", __func__); 1852 "%s(): PWR_CMD_WRITE\n", __func__);
1889 offset = GET_PWR_CFG_OFFSET(cfg_cmd); 1853 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1890 1854
1891 /*Read the value from system register*/ 1855 /*Read the value from system register*/
diff --git a/drivers/staging/rtlwifi/core.h b/drivers/staging/rtlwifi/core.h
index 782ac2fc4b28..4c2b69412621 100644
--- a/drivers/staging/rtlwifi/core.h
+++ b/drivers/staging/rtlwifi/core.h
@@ -75,10 +75,6 @@ enum dm_dig_connect_e {
75extern const struct ieee80211_ops rtl_ops; 75extern const struct ieee80211_ops rtl_ops;
76void rtl_fw_cb(const struct firmware *firmware, void *context); 76void rtl_fw_cb(const struct firmware *firmware, void *context);
77void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context); 77void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
78void rtl_addr_delay(u32 addr);
79void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
80 u32 mask, u32 data);
81void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
82bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); 78bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
83bool rtl_btc_status_false(void); 79bool rtl_btc_status_false(void);
84void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval); 80void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval);
diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index 7446d71c41d1..be8d72cb63db 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -33,7 +33,7 @@ void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
33 const char *fmt, ...) 33 const char *fmt, ...)
34{ 34{
35 if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) && 35 if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) &&
36 (level <= rtlpriv->cfg->mod_params->debug_level))) { 36 level <= rtlpriv->cfg->mod_params->debug_level)) {
37 struct va_format vaf; 37 struct va_format vaf;
38 va_list args; 38 va_list args;
39 39
@@ -52,7 +52,7 @@ void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level,
52 const char *fmt, ...) 52 const char *fmt, ...)
53{ 53{
54 if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) && 54 if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) &&
55 (level <= rtlpriv->cfg->mod_params->debug_level))) { 55 level <= rtlpriv->cfg->mod_params->debug_level)) {
56 struct va_format vaf; 56 struct va_format vaf;
57 va_list args; 57 va_list args;
58 58
@@ -127,10 +127,10 @@ static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
127 return 0; 127 return 0;
128} 128}
129 129
130#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \ 130#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \
131struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \ 131static struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \
132 .cb_read = rtl_debug_get_mac_page, \ 132 .cb_read = rtl_debug_get_mac_page, \
133 .cb_data = addr, \ 133 .cb_data = addr, \
134} 134}
135 135
136RTL_DEBUG_IMPL_MAC_SERIES(0, 0x0000); 136RTL_DEBUG_IMPL_MAC_SERIES(0, 0x0000);
@@ -169,10 +169,10 @@ static int rtl_debug_get_bb_page(struct seq_file *m, void *v)
169 return 0; 169 return 0;
170} 170}
171 171
172#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \ 172#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \
173struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = { \ 173static struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = { \
174 .cb_read = rtl_debug_get_bb_page, \ 174 .cb_read = rtl_debug_get_bb_page, \
175 .cb_data = addr, \ 175 .cb_data = addr, \
176} 176}
177 177
178RTL_DEBUG_IMPL_BB_SERIES(8, 0x0800); 178RTL_DEBUG_IMPL_BB_SERIES(8, 0x0800);
@@ -216,10 +216,10 @@ static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
216 return 0; 216 return 0;
217} 217}
218 218
219#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \ 219#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \
220struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = { \ 220static struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = { \
221 .cb_read = rtl_debug_get_reg_rf, \ 221 .cb_read = rtl_debug_get_reg_rf, \
222 .cb_data = addr, \ 222 .cb_data = addr, \
223} 223}
224 224
225RTL_DEBUG_IMPL_RF_SERIES(a, RF90_PATH_A); 225RTL_DEBUG_IMPL_RF_SERIES(a, RF90_PATH_A);
@@ -271,10 +271,10 @@ static int rtl_debug_get_cam_register(struct seq_file *m, void *v)
271 return 0; 271 return 0;
272} 272}
273 273
274#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \ 274#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \
275struct rtl_debugfs_priv rtl_debug_priv_cam_ ##page = { \ 275static struct rtl_debugfs_priv rtl_debug_priv_cam_ ##page = { \
276 .cb_read = rtl_debug_get_cam_register, \ 276 .cb_read = rtl_debug_get_cam_register, \
277 .cb_data = addr, \ 277 .cb_data = addr, \
278} 278}
279 279
280RTL_DEBUG_IMPL_CAM_SERIES(1, 0); 280RTL_DEBUG_IMPL_CAM_SERIES(1, 0);
diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c
index 6d5e657017c6..d74c80d512c9 100644
--- a/drivers/staging/rtlwifi/efuse.c
+++ b/drivers/staging/rtlwifi/efuse.c
@@ -252,12 +252,11 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
252 sizeof(u8), GFP_ATOMIC); 252 sizeof(u8), GFP_ATOMIC);
253 if (!efuse_tbl) 253 if (!efuse_tbl)
254 return; 254 return;
255 efuse_word = kzalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC); 255 efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
256 if (!efuse_word) 256 if (!efuse_word)
257 goto out; 257 goto out;
258 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { 258 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
259 efuse_word[i] = kzalloc(efuse_max_section * sizeof(u16), 259 efuse_word[i] = kcalloc(efuse_max_section, sizeof(u16), GFP_ATOMIC);
260 GFP_ATOMIC);
261 if (!efuse_word[i]) 260 if (!efuse_word[i])
262 goto done; 261 goto done;
263 } 262 }
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
index edbf6af1c8b7..448b1379d220 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
@@ -3391,8 +3391,10 @@ halmac_cfg_txbf_88xx(struct halmac_adapter *halmac_adapter, u8 userid,
3391 switch (bw) { 3391 switch (bw) {
3392 case HALMAC_BW_80: 3392 case HALMAC_BW_80:
3393 temp42C |= BIT_R_TXBF0_80M; 3393 temp42C |= BIT_R_TXBF0_80M;
3394 /* fall through */
3394 case HALMAC_BW_40: 3395 case HALMAC_BW_40:
3395 temp42C |= BIT_R_TXBF0_40M; 3396 temp42C |= BIT_R_TXBF0_40M;
3397 /* fall through */
3396 case HALMAC_BW_20: 3398 case HALMAC_BW_20:
3397 temp42C |= BIT_R_TXBF0_20M; 3399 temp42C |= BIT_R_TXBF0_20M;
3398 break; 3400 break;
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
index 544f638ed3ef..c4cb217d3d1f 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
@@ -276,17 +276,13 @@ halmac_dump_efuse_drv_88xx(struct halmac_adapter *halmac_adapter)
276 276
277 if (!halmac_adapter->hal_efuse_map) { 277 if (!halmac_adapter->hal_efuse_map) {
278 halmac_adapter->hal_efuse_map = kzalloc(efuse_size, GFP_KERNEL); 278 halmac_adapter->hal_efuse_map = kzalloc(efuse_size, GFP_KERNEL);
279 if (!halmac_adapter->hal_efuse_map) { 279 if (!halmac_adapter->hal_efuse_map)
280 pr_err("[ERR]halmac allocate efuse map Fail!!\n");
281 return HALMAC_RET_MALLOC_FAIL; 280 return HALMAC_RET_MALLOC_FAIL;
282 }
283 } 281 }
284 282
285 efuse_map = kzalloc(efuse_size, GFP_KERNEL); 283 efuse_map = kzalloc(efuse_size, GFP_KERNEL);
286 if (!efuse_map) { 284 if (!efuse_map)
287 /* out of memory */
288 return HALMAC_RET_MALLOC_FAIL; 285 return HALMAC_RET_MALLOC_FAIL;
289 }
290 286
291 if (halmac_read_hw_efuse_88xx(halmac_adapter, 0, efuse_size, 287 if (halmac_read_hw_efuse_88xx(halmac_adapter, 0, efuse_size,
292 efuse_map) != HALMAC_RET_SUCCESS) { 288 efuse_map) != HALMAC_RET_SUCCESS) {
@@ -325,10 +321,8 @@ halmac_dump_efuse_fw_88xx(struct halmac_adapter *halmac_adapter)
325 if (!halmac_adapter->hal_efuse_map) { 321 if (!halmac_adapter->hal_efuse_map) {
326 halmac_adapter->hal_efuse_map = kzalloc( 322 halmac_adapter->hal_efuse_map = kzalloc(
327 halmac_adapter->hw_config_info.efuse_size, GFP_KERNEL); 323 halmac_adapter->hw_config_info.efuse_size, GFP_KERNEL);
328 if (!halmac_adapter->hal_efuse_map) { 324 if (!halmac_adapter->hal_efuse_map)
329 /* out of memory */
330 return HALMAC_RET_MALLOC_FAIL; 325 return HALMAC_RET_MALLOC_FAIL;
331 }
332 } 326 }
333 327
334 if (!halmac_adapter->hal_efuse_map_valid) { 328 if (!halmac_adapter->hal_efuse_map_valid) {
@@ -537,10 +531,8 @@ halmac_read_logical_efuse_map_88xx(struct halmac_adapter *halmac_adapter,
537 531
538 if (!halmac_adapter->hal_efuse_map_valid) { 532 if (!halmac_adapter->hal_efuse_map_valid) {
539 efuse_map = kzalloc(efuse_size, GFP_KERNEL); 533 efuse_map = kzalloc(efuse_size, GFP_KERNEL);
540 if (!efuse_map) { 534 if (!efuse_map)
541 pr_err("[ERR]halmac allocate local efuse map Fail!!\n");
542 return HALMAC_RET_MALLOC_FAIL; 535 return HALMAC_RET_MALLOC_FAIL;
543 }
544 536
545 status = halmac_func_read_efuse_88xx(halmac_adapter, 0, 537 status = halmac_func_read_efuse_88xx(halmac_adapter, 0,
546 efuse_size, efuse_map); 538 efuse_size, efuse_map);
@@ -554,7 +546,6 @@ halmac_read_logical_efuse_map_88xx(struct halmac_adapter *halmac_adapter,
554 halmac_adapter->hal_efuse_map = 546 halmac_adapter->hal_efuse_map =
555 kzalloc(efuse_size, GFP_KERNEL); 547 kzalloc(efuse_size, GFP_KERNEL);
556 if (!halmac_adapter->hal_efuse_map) { 548 if (!halmac_adapter->hal_efuse_map) {
557 pr_err("[ERR]halmac allocate efuse map Fail!!\n");
558 kfree(efuse_map); 549 kfree(efuse_map);
559 return HALMAC_RET_MALLOC_FAIL; 550 return HALMAC_RET_MALLOC_FAIL;
560 } 551 }
@@ -592,10 +583,8 @@ halmac_func_write_logical_efuse_88xx(struct halmac_adapter *halmac_adapter,
592 driver_adapter = halmac_adapter->driver_adapter; 583 driver_adapter = halmac_adapter->driver_adapter;
593 584
594 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); 585 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL);
595 if (!eeprom_map) { 586 if (!eeprom_map)
596 /* out of memory */
597 return HALMAC_RET_MALLOC_FAIL; 587 return HALMAC_RET_MALLOC_FAIL;
598 }
599 memset(eeprom_map, 0xFF, eeprom_size); 588 memset(eeprom_map, 0xFF, eeprom_size);
600 589
601 status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map); 590 status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map);
@@ -687,10 +676,8 @@ halmac_func_pg_efuse_by_map_88xx(struct halmac_adapter *halmac_adapter,
687 enum halmac_ret_status status = HALMAC_RET_SUCCESS; 676 enum halmac_ret_status status = HALMAC_RET_SUCCESS;
688 677
689 eeprom_mask_updated = kzalloc(eeprom_mask_size, GFP_KERNEL); 678 eeprom_mask_updated = kzalloc(eeprom_mask_size, GFP_KERNEL);
690 if (!eeprom_mask_updated) { 679 if (!eeprom_mask_updated)
691 /* out of memory */
692 return HALMAC_RET_MALLOC_FAIL; 680 return HALMAC_RET_MALLOC_FAIL;
693 }
694 681
695 status = halmac_update_eeprom_mask_88xx(halmac_adapter, pg_efuse_info, 682 status = halmac_update_eeprom_mask_88xx(halmac_adapter, pg_efuse_info,
696 eeprom_mask_updated); 683 eeprom_mask_updated);
@@ -743,12 +730,10 @@ halmac_update_eeprom_mask_88xx(struct halmac_adapter *halmac_adapter,
743 driver_adapter = halmac_adapter->driver_adapter; 730 driver_adapter = halmac_adapter->driver_adapter;
744 731
745 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); 732 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL);
746 if (!eeprom_map) { 733 if (!eeprom_map)
747 /* out of memory */
748 return HALMAC_RET_MALLOC_FAIL; 734 return HALMAC_RET_MALLOC_FAIL;
749 }
750 memset(eeprom_map, 0xFF, eeprom_size);
751 735
736 memset(eeprom_map, 0xFF, eeprom_size);
752 memset(eeprom_mask_updated, 0x00, pg_efuse_info->efuse_mask_size); 737 memset(eeprom_mask_updated, 0x00, pg_efuse_info->efuse_mask_size);
753 738
754 status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map); 739 status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map);
@@ -1036,7 +1021,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code,
1036 if (halmac_send_fwpkt_88xx( 1021 if (halmac_send_fwpkt_88xx(
1037 halmac_adapter, code_ptr + mem_offset, 1022 halmac_adapter, code_ptr + mem_offset,
1038 send_pkt_size) != HALMAC_RET_SUCCESS) { 1023 send_pkt_size) != HALMAC_RET_SUCCESS) {
1039 pr_err("halmac_send_fwpkt_88xx fail!!"); 1024 pr_err("halmac_send_fwpkt_88xx fail!!\n");
1040 return HALMAC_RET_DLFW_FAIL; 1025 return HALMAC_RET_DLFW_FAIL;
1041 } 1026 }
1042 1027
@@ -1046,7 +1031,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code,
1046 halmac_adapter->hw_config_info.txdesc_size, 1031 halmac_adapter->hw_config_info.txdesc_size,
1047 dest + mem_offset, send_pkt_size, 1032 dest + mem_offset, send_pkt_size,
1048 first_part) != HALMAC_RET_SUCCESS) { 1033 first_part) != HALMAC_RET_SUCCESS) {
1049 pr_err("halmac_iddma_dlfw_88xx fail!!"); 1034 pr_err("halmac_iddma_dlfw_88xx fail!!\n");
1050 return HALMAC_RET_DLFW_FAIL; 1035 return HALMAC_RET_DLFW_FAIL;
1051 } 1036 }
1052 1037
@@ -1057,7 +1042,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code,
1057 1042
1058 if (halmac_check_fw_chksum_88xx(halmac_adapter, dest) != 1043 if (halmac_check_fw_chksum_88xx(halmac_adapter, dest) !=
1059 HALMAC_RET_SUCCESS) { 1044 HALMAC_RET_SUCCESS) {
1060 pr_err("halmac_check_fw_chksum_88xx fail!!"); 1045 pr_err("halmac_check_fw_chksum_88xx fail!!\n");
1061 return HALMAC_RET_DLFW_FAIL; 1046 return HALMAC_RET_DLFW_FAIL;
1062 } 1047 }
1063 1048
@@ -2549,10 +2534,8 @@ halmac_parse_efuse_data_88xx(struct halmac_adapter *halmac_adapter, u8 *c2h_buf,
2549 halmac_adapter->efuse_segment_size = segment_size; 2534 halmac_adapter->efuse_segment_size = segment_size;
2550 2535
2551 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); 2536 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL);
2552 if (!eeprom_map) { 2537 if (!eeprom_map)
2553 /* out of memory */
2554 return HALMAC_RET_MALLOC_FAIL; 2538 return HALMAC_RET_MALLOC_FAIL;
2555 }
2556 memset(eeprom_map, 0xFF, eeprom_size); 2539 memset(eeprom_map, 0xFF, eeprom_size);
2557 2540
2558 spin_lock(&halmac_adapter->efuse_lock); 2541 spin_lock(&halmac_adapter->efuse_lock);
@@ -3355,10 +3338,8 @@ enum halmac_ret_status halmac_query_dump_logical_efuse_status_88xx(
3355 *size = eeprom_size; 3338 *size = eeprom_size;
3356 3339
3357 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); 3340 eeprom_map = kzalloc(eeprom_size, GFP_KERNEL);
3358 if (!eeprom_map) { 3341 if (!eeprom_map)
3359 /* out of memory */
3360 return HALMAC_RET_MALLOC_FAIL; 3342 return HALMAC_RET_MALLOC_FAIL;
3361 }
3362 memset(eeprom_map, 0xFF, eeprom_size); 3343 memset(eeprom_map, 0xFF, eeprom_size);
3363 3344
3364 if (halmac_eeprom_parser_88xx( 3345 if (halmac_eeprom_parser_88xx(
@@ -3579,10 +3560,8 @@ halmac_verify_send_rsvd_page_88xx(struct halmac_adapter *halmac_adapter)
3579 3560
3580 rsvd_buf = kzalloc(h2c_pkt_verify_size, GFP_KERNEL); 3561 rsvd_buf = kzalloc(h2c_pkt_verify_size, GFP_KERNEL);
3581 3562
3582 if (!rsvd_buf) { 3563 if (!rsvd_buf)
3583 /*pr_err("[ERR]rsvd buffer malloc fail!!\n");*/
3584 return HALMAC_RET_MALLOC_FAIL; 3564 return HALMAC_RET_MALLOC_FAIL;
3585 }
3586 3565
3587 memset(rsvd_buf, (u8)h2c_pkt_verify_payload, h2c_pkt_verify_size); 3566 memset(rsvd_buf, (u8)h2c_pkt_verify_payload, h2c_pkt_verify_size);
3588 3567
@@ -3599,7 +3578,6 @@ halmac_verify_send_rsvd_page_88xx(struct halmac_adapter *halmac_adapter)
3599 GFP_KERNEL); 3578 GFP_KERNEL);
3600 3579
3601 if (!rsvd_page) { 3580 if (!rsvd_page) {
3602 pr_err("[ERR]rsvd page malloc fail!!\n");
3603 kfree(rsvd_buf); 3581 kfree(rsvd_buf);
3604 return HALMAC_RET_MALLOC_FAIL; 3582 return HALMAC_RET_MALLOC_FAIL;
3605 } 3583 }
diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 6448a8bfc14b..66f0a6dfc52c 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -617,7 +617,7 @@ static int _send_general_info(struct rtl_priv *rtlpriv)
617 RT_TRACE(rtlpriv, COMP_HALMAC, DBG_WARNING, 617 RT_TRACE(rtlpriv, COMP_HALMAC, DBG_WARNING,
618 "%s: halmac_send_general_info() fail because fw not dl!\n", 618 "%s: halmac_send_general_info() fail because fw not dl!\n",
619 __func__); 619 __func__);
620 /* fallthrough here */ 620 /* fall through */
621 default: 621 default:
622 return -1; 622 return -1;
623 } 623 }
diff --git a/drivers/staging/rtlwifi/pci.c b/drivers/staging/rtlwifi/pci.c
index 4035b8835bd1..70a64a5f564a 100644
--- a/drivers/staging/rtlwifi/pci.c
+++ b/drivers/staging/rtlwifi/pci.c
@@ -649,7 +649,7 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
649 prio, ring->idx, 649 prio, ring->idx,
650 skb_queue_len(&ring->queue)); 650 skb_queue_len(&ring->queue));
651 651
652 ieee80211_wake_queue(hw, skb_get_queue_mapping (skb)); 652 ieee80211_wake_queue(hw, skb_get_queue_mapping(skb));
653 } 653 }
654tx_status_ok: 654tx_status_ok:
655 skb = NULL; 655 skb = NULL;
diff --git a/drivers/staging/rtlwifi/phydm/halphyrf_ce.c b/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
index 684e383201d6..5986892e767e 100644
--- a/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
+++ b/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
@@ -798,7 +798,7 @@ void odm_txpowertracking_callback_thermal_meter(void *dm_void)
798 798
799 if (xtal_offset_eanble != 0 && 799 if (xtal_offset_eanble != 0 &&
800 cali_info->txpowertrack_control && 800 cali_info->txpowertrack_control &&
801 (rtlefu->eeprom_thermalmeter != 0xff)) { 801 rtlefu->eeprom_thermalmeter != 0xff) {
802 ODM_RT_TRACE( 802 ODM_RT_TRACE(
803 dm, ODM_COMP_TX_PWR_TRACK, 803 dm, ODM_COMP_TX_PWR_TRACK,
804 "**********Enter Xtal Tracking**********\n"); 804 "**********Enter Xtal Tracking**********\n");
diff --git a/drivers/staging/rtlwifi/phydm/phydm.c b/drivers/staging/rtlwifi/phydm/phydm.c
index 37888c3087a4..8b2a180cc13c 100644
--- a/drivers/staging/rtlwifi/phydm/phydm.c
+++ b/drivers/staging/rtlwifi/phydm/phydm.c
@@ -1338,7 +1338,7 @@ static void odm_update_power_training_state(struct phy_dm_struct *dm)
1338 return; 1338 return;
1339 1339
1340 /* First connect */ 1340 /* First connect */
1341 if ((dm->is_linked) && !dig_tab->is_media_connect_0) { 1341 if (dm->is_linked && !dig_tab->is_media_connect_0) {
1342 dm->PT_score = 0; 1342 dm->PT_score = 0;
1343 dm->is_change_state = true; 1343 dm->is_change_state = true;
1344 dm->phy_dbg_info.num_qry_phy_status_ofdm = 0; 1344 dm->phy_dbg_info.num_qry_phy_status_ofdm = 0;
@@ -1360,7 +1360,7 @@ static void odm_update_power_training_state(struct phy_dm_struct *dm)
1360 (u32)(dm->phy_dbg_info.num_qry_phy_status_cck); 1360 (u32)(dm->phy_dbg_info.num_qry_phy_status_cck);
1361 1361
1362 if ((false_alm_cnt->cnt_cca_all > 31 && rx_pkt_cnt > 31) && 1362 if ((false_alm_cnt->cnt_cca_all > 31 && rx_pkt_cnt > 31) &&
1363 (false_alm_cnt->cnt_cca_all >= rx_pkt_cnt)) { 1363 false_alm_cnt->cnt_cca_all >= rx_pkt_cnt) {
1364 if ((rx_pkt_cnt + (rx_pkt_cnt >> 1)) <= 1364 if ((rx_pkt_cnt + (rx_pkt_cnt >> 1)) <=
1365 false_alm_cnt->cnt_cca_all) 1365 false_alm_cnt->cnt_cca_all)
1366 score = 0; 1366 score = 0;
@@ -1697,7 +1697,7 @@ static u8 phydm_calculate_fc(void *dm_void, u32 channel, u32 bw, u32 second_ch,
1697 1697
1698 fc = 2412 + (channel - 1) * 5; 1698 fc = 2412 + (channel - 1) * 5;
1699 1699
1700 if (bw == 40 && (second_ch == PHYDM_ABOVE)) { 1700 if (bw == 40 && second_ch == PHYDM_ABOVE) {
1701 if (channel >= 10) { 1701 if (channel >= 10) {
1702 ODM_RT_TRACE( 1702 ODM_RT_TRACE(
1703 dm, ODM_COMP_API, 1703 dm, ODM_COMP_API,
@@ -1774,7 +1774,7 @@ static u8 phydm_calculate_intf_distance(void *dm_void, u32 bw, u32 fc,
1774 "[f_l, fc, fh] = [ %d, %d, %d ], f_int = ((%d))\n", bw_low, 1774 "[f_l, fc, fh] = [ %d, %d, %d ], f_int = ((%d))\n", bw_low,
1775 fc, bw_up, f_interference); 1775 fc, bw_up, f_interference);
1776 1776
1777 if ((f_interference >= bw_low) && (f_interference <= bw_up)) { 1777 if (f_interference >= bw_low && f_interference <= bw_up) {
1778 int_distance = (fc >= f_interference) ? (fc - f_interference) : 1778 int_distance = (fc >= f_interference) ? (fc - f_interference) :
1779 (f_interference - fc); 1779 (f_interference - fc);
1780 tone_idx_tmp = 1780 tone_idx_tmp =
diff --git a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
index 4f9e267409f6..103a774f9c8f 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
@@ -762,7 +762,7 @@ void phydm_adaptivity(void *dm_void)
762 dm->rssi_min, adaptivity->adajust_igi_level, 762 dm->rssi_min, adaptivity->adajust_igi_level,
763 dm->adaptivity_flag, dm->adaptivity_enable); 763 dm->adaptivity_flag, dm->adaptivity_enable);
764 764
765 if (adaptivity->dynamic_link_adaptivity && (!dm->is_linked) && 765 if (adaptivity->dynamic_link_adaptivity && !dm->is_linked &&
766 !dm->adaptivity_enable) { 766 !dm->adaptivity_enable) {
767 phydm_set_edcca_threshold(dm, 0x7f, 0x7f); 767 phydm_set_edcca_threshold(dm, 0x7f, 0x7f);
768 ODM_RT_TRACE( 768 ODM_RT_TRACE(
@@ -773,7 +773,7 @@ void phydm_adaptivity(void *dm_void)
773 773
774 if (dm->support_ic_type & 774 if (dm->support_ic_type &
775 (ODM_IC_11AC_GAIN_IDX_EDCCA | ODM_IC_11N_GAIN_IDX_EDCCA)) { 775 (ODM_IC_11AC_GAIN_IDX_EDCCA | ODM_IC_11N_GAIN_IDX_EDCCA)) {
776 if ((adaptivity->adajust_igi_level > IGI) && 776 if (adaptivity->adajust_igi_level > IGI &&
777 dm->adaptivity_enable) 777 dm->adaptivity_enable)
778 diff = adaptivity->adajust_igi_level - IGI; 778 diff = adaptivity->adajust_igi_level - IGI;
779 779
diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.c b/drivers/staging/rtlwifi/phydm/phydm_debug.c
index a5f90afdae9b..e18ba2cca2bd 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_debug.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_debug.c
@@ -29,6 +29,7 @@
29 29
30#include "mp_precomp.h" 30#include "mp_precomp.h"
31#include "phydm_precomp.h" 31#include "phydm_precomp.h"
32#include <linux/kernel.h>
32 33
33bool phydm_api_set_txagc(struct phy_dm_struct *, u32, enum odm_rf_radio_path, 34bool phydm_api_set_txagc(struct phy_dm_struct *, u32, enum odm_rf_radio_path,
34 u8, bool); 35 u8, bool);
@@ -1441,9 +1442,9 @@ static void phydm_get_per_path_txagc(void *dm_void, u8 path, u32 *_used,
1441 u32 out_len = *_out_len; 1442 u32 out_len = *_out_len;
1442 1443
1443 if (((dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8197F)) && 1444 if (((dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8197F)) &&
1444 (path <= ODM_RF_PATH_B)) || 1445 path <= ODM_RF_PATH_B) ||
1445 ((dm->support_ic_type & (ODM_RTL8821C)) && 1446 ((dm->support_ic_type & (ODM_RTL8821C)) &&
1446 (path <= ODM_RF_PATH_A))) { 1447 path <= ODM_RF_PATH_A)) {
1447 for (rate_idx = 0; rate_idx <= 0x53; rate_idx++) { 1448 for (rate_idx = 0; rate_idx <= 0x53; rate_idx++) {
1448 if (rate_idx == ODM_RATE1M) 1449 if (rate_idx == ODM_RATE1M)
1449 PHYDM_SNPRINTF(output + used, out_len - used, 1450 PHYDM_SNPRINTF(output + used, out_len - used,
@@ -2107,8 +2108,7 @@ void phydm_cmd_parser(struct phy_dm_struct *dm, char input[][MAX_ARGV],
2107 2108
2108 /* Parsing Cmd ID */ 2109 /* Parsing Cmd ID */
2109 if (input_num) { 2110 if (input_num) {
2110 phydm_ary_size = 2111 phydm_ary_size = ARRAY_SIZE(phy_dm_ary);
2111 sizeof(phy_dm_ary) / sizeof(struct phydm_command);
2112 for (i = 0; i < phydm_ary_size; i++) { 2112 for (i = 0; i < phydm_ary_size; i++) {
2113 if (strcmp(phy_dm_ary[i].name, input[0]) == 0) { 2113 if (strcmp(phy_dm_ary[i].name, input[0]) == 0) {
2114 id = phy_dm_ary[i].id; 2114 id = phy_dm_ary[i].id;
@@ -2530,7 +2530,7 @@ void phydm_cmd_parser(struct phy_dm_struct *dm, char input[][MAX_ARGV],
2530 } 2530 }
2531 2531
2532 /* NMH trigger */ 2532 /* NMH trigger */
2533 if ((var1[0] <= 2) && (var1[0] != 0)) { 2533 if (var1[0] <= 2 && var1[0] != 0) {
2534 ccx_info->echo_NHM_en = true; 2534 ccx_info->echo_NHM_en = true;
2535 ccx_info->echo_IGI = 2535 ccx_info->echo_IGI =
2536 (u8)odm_get_bb_reg(dm, 0xC50, MASKBYTE0); 2536 (u8)odm_get_bb_reg(dm, 0xC50, MASKBYTE0);
@@ -2808,7 +2808,7 @@ void phydm_fw_trace_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len)
2808 freg_num = (buf_0 & 0xf); 2808 freg_num = (buf_0 & 0xf);
2809 c2h_seq = (buf_0 & 0xf0) >> 4; 2809 c2h_seq = (buf_0 & 0xf0) >> 4;
2810 2810
2811 if ((c2h_seq != dm->pre_c2h_seq) && !dm->fw_buff_is_enpty) { 2811 if (c2h_seq != dm->pre_c2h_seq && !dm->fw_buff_is_enpty) {
2812 dm->fw_debug_trace[dm->c2h_cmd_start] = '\0'; 2812 dm->fw_debug_trace[dm->c2h_cmd_start] = '\0';
2813 ODM_RT_TRACE(dm, ODM_FW_DEBUG_TRACE, 2813 ODM_RT_TRACE(dm, ODM_FW_DEBUG_TRACE,
2814 "[FW Dbg Queue Overflow] %s\n", 2814 "[FW Dbg Queue Overflow] %s\n",
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.c b/drivers/staging/rtlwifi/phydm/phydm_dig.c
index 31a4f3fcad19..f851ff12dc35 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dig.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_dig.c
@@ -198,7 +198,7 @@ static u8 odm_forbidden_igi_check(void *dm_void, u8 dig_dynamic_min,
198 if ((fa_cnt->cnt_all > 198 if ((fa_cnt->cnt_all >
199 (fa_cnt->cnt_all_pre + (fa_cnt->cnt_all_pre >> 3) + 199 (fa_cnt->cnt_all_pre + (fa_cnt->cnt_all_pre >> 3) +
200 (fa_cnt->cnt_all_pre >> 4))) && 200 (fa_cnt->cnt_all_pre >> 4))) &&
201 (current_igi < dig_tab->pre_ig_value)) { 201 current_igi < dig_tab->pre_ig_value) {
202 if (dig_tab->large_fa_hit != 3) 202 if (dig_tab->large_fa_hit != 3)
203 dig_tab->large_fa_hit++; 203 dig_tab->large_fa_hit++;
204 204
@@ -319,7 +319,7 @@ void odm_write_dig(void *dm_void, u8 current_igi)
319 __func__, ODM_REG(IGI_A, dm), ODM_BIT(IGI, dm)); 319 __func__, ODM_REG(IGI_A, dm), ODM_BIT(IGI, dm));
320 320
321 /* 1 Check initial gain by upper bound */ 321 /* 1 Check initial gain by upper bound */
322 if ((!dig_tab->is_psd_in_progress) && dm->is_linked) { 322 if (!dig_tab->is_psd_in_progress && dm->is_linked) {
323 if (current_igi > dig_tab->rx_gain_range_max) { 323 if (current_igi > dig_tab->rx_gain_range_max) {
324 ODM_RT_TRACE( 324 ODM_RT_TRACE(
325 dm, ODM_COMP_DIG, 325 dm, ODM_COMP_DIG,
@@ -353,7 +353,7 @@ void odm_write_dig(void *dm_void, u8 current_igi)
353 353
354 /*Add by YuChen for USB IO too slow issue*/ 354 /*Add by YuChen for USB IO too slow issue*/
355 if ((dm->support_ability & ODM_BB_ADAPTIVITY) && 355 if ((dm->support_ability & ODM_BB_ADAPTIVITY) &&
356 (current_igi > dig_tab->cur_ig_value)) { 356 current_igi > dig_tab->cur_ig_value) {
357 dig_tab->cur_ig_value = current_igi; 357 dig_tab->cur_ig_value = current_igi;
358 phydm_adaptivity(dm); 358 phydm_adaptivity(dm);
359 } 359 }
@@ -388,7 +388,7 @@ void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,
388 ODM_RT_TRACE(dm, ODM_COMP_DIG, "%s()=========> level = %d\n", __func__, 388 ODM_RT_TRACE(dm, ODM_COMP_DIG, "%s()=========> level = %d\n", __func__,
389 pause_level); 389 pause_level);
390 390
391 if ((dig_tab->pause_dig_level == 0) && 391 if (dig_tab->pause_dig_level == 0 &&
392 (!(dm->support_ability & ODM_BB_DIG) || 392 (!(dm->support_ability & ODM_BB_DIG) ||
393 !(dm->support_ability & ODM_BB_FA_CNT))) { 393 !(dm->support_ability & ODM_BB_FA_CNT))) {
394 ODM_RT_TRACE( 394 ODM_RT_TRACE(
@@ -490,6 +490,8 @@ void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,
490 break; 490 break;
491 } 491 }
492 492
493 /* pin max_level to be >= 0 */
494 max_level = max_t(s8, 0, max_level);
493 /* write IGI of lower level */ 495 /* write IGI of lower level */
494 odm_write_dig(dm, dig_tab->pause_dig_value[max_level]); 496 odm_write_dig(dm, dig_tab->pause_dig_value[max_level]);
495 ODM_RT_TRACE(dm, ODM_COMP_DIG, 497 ODM_RT_TRACE(dm, ODM_COMP_DIG,
@@ -718,7 +720,7 @@ void odm_DIG(void *dm_void)
718 /* 4 Modify DIG upper bound for 92E, 8723A\B, 8821 & 8812 BT */ 720 /* 4 Modify DIG upper bound for 92E, 8723A\B, 8821 & 8812 BT */
719 if ((dm->support_ic_type & (ODM_RTL8192E | ODM_RTL8723B | 721 if ((dm->support_ic_type & (ODM_RTL8192E | ODM_RTL8723B |
720 ODM_RTL8812 | ODM_RTL8821)) && 722 ODM_RTL8812 | ODM_RTL8821)) &&
721 (dm->is_bt_limited_dig == 1)) { 723 dm->is_bt_limited_dig == 1) {
722 offset = 10; 724 offset = 10;
723 ODM_RT_TRACE( 725 ODM_RT_TRACE(
724 dm, ODM_COMP_DIG, 726 dm, ODM_COMP_DIG,
@@ -817,8 +819,8 @@ void odm_DIG(void *dm_void)
817 if (dm->is_linked && !first_connect) { 819 if (dm->is_linked && !first_connect) {
818 ODM_RT_TRACE(dm, ODM_COMP_DIG, "Beacon Num (%d)\n", 820 ODM_RT_TRACE(dm, ODM_COMP_DIG, "Beacon Num (%d)\n",
819 dm->phy_dbg_info.num_qry_beacon_pkt); 821 dm->phy_dbg_info.num_qry_beacon_pkt);
820 if ((dm->phy_dbg_info.num_qry_beacon_pkt < 5) && 822 if (dm->phy_dbg_info.num_qry_beacon_pkt < 5 &&
821 (dm->bsta_state)) { 823 dm->bsta_state) {
822 dig_tab->rx_gain_range_min = 0x1c; 824 dig_tab->rx_gain_range_min = 0x1c;
823 ODM_RT_TRACE( 825 ODM_RT_TRACE(
824 dm, ODM_COMP_DIG, 826 dm, ODM_COMP_DIG,
@@ -880,9 +882,9 @@ void odm_DIG(void *dm_void)
880 current_igi = current_igi - 2; 882 current_igi = current_igi - 2;
881 883
882 /* 4 Abnormal # beacon case */ 884 /* 4 Abnormal # beacon case */
883 if ((dm->phy_dbg_info.num_qry_beacon_pkt < 5) && 885 if (dm->phy_dbg_info.num_qry_beacon_pkt < 5 &&
884 (fa_cnt->cnt_all < DM_DIG_FA_TH1) && 886 fa_cnt->cnt_all < DM_DIG_FA_TH1 &&
885 (dm->bsta_state)) { 887 dm->bsta_state) {
886 current_igi = dig_tab->rx_gain_range_min; 888 current_igi = dig_tab->rx_gain_range_min;
887 ODM_RT_TRACE( 889 ODM_RT_TRACE(
888 dm, ODM_COMP_DIG, 890 dm, ODM_COMP_DIG,
@@ -1319,7 +1321,7 @@ void odm_pause_cck_packet_detection(void *dm_void,
1319 ODM_RT_TRACE(dm, ODM_COMP_DIG, "%s()=========> level = %d\n", __func__, 1321 ODM_RT_TRACE(dm, ODM_COMP_DIG, "%s()=========> level = %d\n", __func__,
1320 pause_level); 1322 pause_level);
1321 1323
1322 if ((dig_tab->pause_cckpd_level == 0) && 1324 if (dig_tab->pause_cckpd_level == 0 &&
1323 (!(dm->support_ability & ODM_BB_CCK_PD) || 1325 (!(dm->support_ability & ODM_BB_CCK_PD) ||
1324 !(dm->support_ability & ODM_BB_FA_CNT))) { 1326 !(dm->support_ability & ODM_BB_FA_CNT))) {
1325 ODM_RT_TRACE( 1327 ODM_RT_TRACE(
diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c b/drivers/staging/rtlwifi/phydm/phydm_interface.c
index 102576a46c04..2f9bf6708c54 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c
@@ -179,29 +179,6 @@ void ODM_sleep_ms(u32 ms) { msleep(ms); }
179 179
180void ODM_sleep_us(u32 us) { usleep_range(us, us + 1); } 180void ODM_sleep_us(u32 us) { usleep_range(us, us + 1); }
181 181
182void odm_set_timer(struct phy_dm_struct *dm, struct timer_list *timer,
183 u32 ms_delay)
184{
185 mod_timer(timer, jiffies + msecs_to_jiffies(ms_delay));
186}
187
188void odm_initialize_timer(struct phy_dm_struct *dm, struct timer_list *timer,
189 void *call_back_func, void *context,
190 const char *sz_id)
191{
192 init_timer(timer);
193 timer->function = call_back_func;
194 timer->data = (unsigned long)dm;
195 /*mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */
196}
197
198void odm_cancel_timer(struct phy_dm_struct *dm, struct timer_list *timer)
199{
200 del_timer(timer);
201}
202
203void odm_release_timer(struct phy_dm_struct *dm, struct timer_list *timer) {}
204
205static u8 phydm_trans_h2c_id(struct phy_dm_struct *dm, u8 phydm_h2c_id) 182static u8 phydm_trans_h2c_id(struct phy_dm_struct *dm, u8 phydm_h2c_id)
206{ 183{
207 u8 platform_h2c_id = phydm_h2c_id; 184 u8 platform_h2c_id = phydm_h2c_id;
diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.h b/drivers/staging/rtlwifi/phydm/phydm_interface.h
index d315c79c962a..53ba5585bf33 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.h
@@ -172,17 +172,6 @@ void ODM_sleep_ms(u32 ms);
172 172
173void ODM_sleep_us(u32 us); 173void ODM_sleep_us(u32 us);
174 174
175void odm_set_timer(struct phy_dm_struct *dm, struct timer_list *timer,
176 u32 ms_delay);
177
178void odm_initialize_timer(struct phy_dm_struct *dm, struct timer_list *timer,
179 void *call_back_func, void *context,
180 const char *sz_id);
181
182void odm_cancel_timer(struct phy_dm_struct *dm, struct timer_list *timer);
183
184void odm_release_timer(struct phy_dm_struct *dm, struct timer_list *timer);
185
186/* 175/*
187 * ODM FW relative API. 176 * ODM FW relative API.
188 */ 177 */
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
index 4e7946019fcb..29d19f2b300e 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
@@ -26,6 +26,7 @@
26/*Image2HeaderVersion: 3.2*/ 26/*Image2HeaderVersion: 3.2*/
27#include "../mp_precomp.h" 27#include "../mp_precomp.h"
28#include "../phydm_precomp.h" 28#include "../phydm_precomp.h"
29#include <linux/kernel.h>
29 30
30static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, 31static bool check_positive(struct phy_dm_struct *dm, const u32 condition1,
31 const u32 condition2, const u32 condition3, 32 const u32 condition2, const u32 condition3,
@@ -1350,7 +1351,6 @@ void odm_read_and_config_mp_8822b_agc_tab(struct phy_dm_struct *dm)
1350 u32 i = 0; 1351 u32 i = 0;
1351 u8 c_cond; 1352 u8 c_cond;
1352 bool is_matched = true, is_skipped = false; 1353 bool is_matched = true, is_skipped = false;
1353 u32 array_len = sizeof(array_mp_8822b_agc_tab) / sizeof(u32);
1354 u32 *array = array_mp_8822b_agc_tab; 1354 u32 *array = array_mp_8822b_agc_tab;
1355 1355
1356 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; 1356 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
@@ -1358,7 +1358,7 @@ void odm_read_and_config_mp_8822b_agc_tab(struct phy_dm_struct *dm)
1358 ODM_RT_TRACE(dm, ODM_COMP_INIT, 1358 ODM_RT_TRACE(dm, ODM_COMP_INIT,
1359 "===> %s\n", __func__); 1359 "===> %s\n", __func__);
1360 1360
1361 for (; (i + 1) < array_len; i = i + 2) { 1361 for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_agc_tab); i = i + 2) {
1362 v1 = array[i]; 1362 v1 = array[i];
1363 v2 = array[i + 1]; 1363 v2 = array[i + 1];
1364 1364
@@ -1843,7 +1843,6 @@ void odm_read_and_config_mp_8822b_phy_reg(struct phy_dm_struct *dm)
1843 u32 i = 0; 1843 u32 i = 0;
1844 u8 c_cond; 1844 u8 c_cond;
1845 bool is_matched = true, is_skipped = false; 1845 bool is_matched = true, is_skipped = false;
1846 u32 array_len = sizeof(array_mp_8822b_phy_reg) / sizeof(u32);
1847 u32 *array = array_mp_8822b_phy_reg; 1846 u32 *array = array_mp_8822b_phy_reg;
1848 1847
1849 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; 1848 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
@@ -1851,7 +1850,7 @@ void odm_read_and_config_mp_8822b_phy_reg(struct phy_dm_struct *dm)
1851 ODM_RT_TRACE(dm, ODM_COMP_INIT, 1850 ODM_RT_TRACE(dm, ODM_COMP_INIT,
1852 "===> %s\n", __func__); 1851 "===> %s\n", __func__);
1853 1852
1854 for (; (i + 1) < array_len; i = i + 2) { 1853 for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_phy_reg); i = i + 2) {
1855 v1 = array[i]; 1854 v1 = array[i];
1856 v2 = array[i + 1]; 1855 v2 = array[i + 1];
1857 1856
@@ -1947,7 +1946,6 @@ static u32 array_mp_8822b_phy_reg_pg[] = {
1947void odm_read_and_config_mp_8822b_phy_reg_pg(struct phy_dm_struct *dm) 1946void odm_read_and_config_mp_8822b_phy_reg_pg(struct phy_dm_struct *dm)
1948{ 1947{
1949 u32 i = 0; 1948 u32 i = 0;
1950 u32 array_len = sizeof(array_mp_8822b_phy_reg_pg) / sizeof(u32);
1951 u32 *array = array_mp_8822b_phy_reg_pg; 1949 u32 *array = array_mp_8822b_phy_reg_pg;
1952 1950
1953 ODM_RT_TRACE(dm, ODM_COMP_INIT, 1951 ODM_RT_TRACE(dm, ODM_COMP_INIT,
@@ -1956,7 +1954,7 @@ void odm_read_and_config_mp_8822b_phy_reg_pg(struct phy_dm_struct *dm)
1956 dm->phy_reg_pg_version = 1; 1954 dm->phy_reg_pg_version = 1;
1957 dm->phy_reg_pg_value_type = PHY_REG_PG_EXACT_VALUE; 1955 dm->phy_reg_pg_value_type = PHY_REG_PG_EXACT_VALUE;
1958 1956
1959 for (i = 0; i < array_len; i += 6) { 1957 for (i = 0; i < ARRAY_SIZE(array_mp_8822b_phy_reg_pg); i += 6) {
1960 u32 v1 = array[i]; 1958 u32 v1 = array[i];
1961 u32 v2 = array[i + 1]; 1959 u32 v2 = array[i + 1];
1962 u32 v3 = array[i + 2]; 1960 u32 v3 = array[i + 2];
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
index 1a9daed2e609..70924f002541 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
@@ -26,6 +26,7 @@
26/*Image2HeaderVersion: 3.2*/ 26/*Image2HeaderVersion: 3.2*/
27#include "../mp_precomp.h" 27#include "../mp_precomp.h"
28#include "../phydm_precomp.h" 28#include "../phydm_precomp.h"
29#include <linux/kernel.h>
29 30
30static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, 31static bool check_positive(struct phy_dm_struct *dm, const u32 condition1,
31 const u32 condition2, const u32 condition3, 32 const u32 condition2, const u32 condition3,
@@ -173,7 +174,6 @@ void odm_read_and_config_mp_8822b_mac_reg(struct phy_dm_struct *dm)
173 u32 i = 0; 174 u32 i = 0;
174 u8 c_cond; 175 u8 c_cond;
175 bool is_matched = true, is_skipped = false; 176 bool is_matched = true, is_skipped = false;
176 u32 array_len = sizeof(array_mp_8822b_mac_reg) / sizeof(u32);
177 u32 *array = array_mp_8822b_mac_reg; 177 u32 *array = array_mp_8822b_mac_reg;
178 178
179 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; 179 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
@@ -181,7 +181,7 @@ void odm_read_and_config_mp_8822b_mac_reg(struct phy_dm_struct *dm)
181 ODM_RT_TRACE(dm, ODM_COMP_INIT, 181 ODM_RT_TRACE(dm, ODM_COMP_INIT,
182 "===> %s\n", __func__); 182 "===> %s\n", __func__);
183 183
184 for (; (i + 1) < array_len; i = i + 2) { 184 for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_mac_reg); i = i + 2) {
185 v1 = array[i]; 185 v1 = array[i];
186 v2 = array[i + 1]; 186 v2 = array[i + 1];
187 187
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
index 84cdc0644207..0ff3a9a712d6 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
@@ -26,6 +26,7 @@
26/*Image2HeaderVersion: 3.2*/ 26/*Image2HeaderVersion: 3.2*/
27#include "../mp_precomp.h" 27#include "../mp_precomp.h"
28#include "../phydm_precomp.h" 28#include "../phydm_precomp.h"
29#include <linux/kernel.h>
29 30
30static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, 31static bool check_positive(struct phy_dm_struct *dm, const u32 condition1,
31 const u32 condition2, const u32 condition3, 32 const u32 condition2, const u32 condition3,
@@ -1346,7 +1347,6 @@ void odm_read_and_config_mp_8822b_radioa(struct phy_dm_struct *dm)
1346 u32 i = 0; 1347 u32 i = 0;
1347 u8 c_cond; 1348 u8 c_cond;
1348 bool is_matched = true, is_skipped = false; 1349 bool is_matched = true, is_skipped = false;
1349 u32 array_len = sizeof(array_mp_8822b_radioa) / sizeof(u32);
1350 u32 *array = array_mp_8822b_radioa; 1350 u32 *array = array_mp_8822b_radioa;
1351 1351
1352 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; 1352 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
@@ -1354,7 +1354,7 @@ void odm_read_and_config_mp_8822b_radioa(struct phy_dm_struct *dm)
1354 ODM_RT_TRACE(dm, ODM_COMP_INIT, 1354 ODM_RT_TRACE(dm, ODM_COMP_INIT,
1355 "===> %s\n", __func__); 1355 "===> %s\n", __func__);
1356 1356
1357 for (; (i + 1) < array_len; i = i + 2) { 1357 for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_radioa); i = i + 2) {
1358 v1 = array[i]; 1358 v1 = array[i];
1359 v2 = array[i + 1]; 1359 v2 = array[i + 1];
1360 1360
@@ -2506,7 +2506,6 @@ void odm_read_and_config_mp_8822b_radiob(struct phy_dm_struct *dm)
2506 u32 i = 0; 2506 u32 i = 0;
2507 u8 c_cond; 2507 u8 c_cond;
2508 bool is_matched = true, is_skipped = false; 2508 bool is_matched = true, is_skipped = false;
2509 u32 array_len = sizeof(array_mp_8822b_radiob) / sizeof(u32);
2510 u32 *array = array_mp_8822b_radiob; 2509 u32 *array = array_mp_8822b_radiob;
2511 2510
2512 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; 2511 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
@@ -2514,7 +2513,7 @@ void odm_read_and_config_mp_8822b_radiob(struct phy_dm_struct *dm)
2514 ODM_RT_TRACE(dm, ODM_COMP_INIT, 2513 ODM_RT_TRACE(dm, ODM_COMP_INIT,
2515 "===> %s\n", __func__); 2514 "===> %s\n", __func__);
2516 2515
2517 for (; (i + 1) < array_len; i = i + 2) { 2516 for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_radiob); i = i + 2) {
2518 v1 = array[i]; 2517 v1 = array[i];
2519 v2 = array[i + 1]; 2518 v2 = array[i + 1];
2520 2519
@@ -4239,13 +4238,12 @@ static const char *const array_mp_8822b_txpwr_lmt[] = {
4239void odm_read_and_config_mp_8822b_txpwr_lmt(struct phy_dm_struct *dm) 4238void odm_read_and_config_mp_8822b_txpwr_lmt(struct phy_dm_struct *dm)
4240{ 4239{
4241 u32 i = 0; 4240 u32 i = 0;
4242 u32 array_len = sizeof(array_mp_8822b_txpwr_lmt) / sizeof(u8 *);
4243 u8 **array = (u8 **)array_mp_8822b_txpwr_lmt; 4241 u8 **array = (u8 **)array_mp_8822b_txpwr_lmt;
4244 4242
4245 ODM_RT_TRACE(dm, ODM_COMP_INIT, 4243 ODM_RT_TRACE(dm, ODM_COMP_INIT,
4246 "===> %s\n", __func__); 4244 "===> %s\n", __func__);
4247 4245
4248 for (i = 0; i < array_len; i += 7) { 4246 for (i = 0; i < ARRAY_SIZE(array_mp_8822b_txpwr_lmt); i += 7) {
4249 u8 *regulation = array[i]; 4247 u8 *regulation = array[i];
4250 u8 *band = array[i + 1]; 4248 u8 *band = array[i + 1];
4251 u8 *bandwidth = array[i + 2]; 4249 u8 *bandwidth = array[i + 2];
@@ -4723,13 +4721,12 @@ static const char *const array_mp_8822b_txpwr_lmt_type5[] = {
4723void odm_read_and_config_mp_8822b_txpwr_lmt_type5(struct phy_dm_struct *dm) 4721void odm_read_and_config_mp_8822b_txpwr_lmt_type5(struct phy_dm_struct *dm)
4724{ 4722{
4725 u32 i = 0; 4723 u32 i = 0;
4726 u32 array_len = sizeof(array_mp_8822b_txpwr_lmt_type5) / sizeof(u8 *);
4727 u8 **array = (u8 **)array_mp_8822b_txpwr_lmt_type5; 4724 u8 **array = (u8 **)array_mp_8822b_txpwr_lmt_type5;
4728 4725
4729 ODM_RT_TRACE(dm, ODM_COMP_INIT, 4726 ODM_RT_TRACE(dm, ODM_COMP_INIT,
4730 "===> odm_read_and_config_mp_8822b_txpwr_lmt_type5\n"); 4727 "===> odm_read_and_config_mp_8822b_txpwr_lmt_type5\n");
4731 4728
4732 for (i = 0; i < array_len; i += 7) { 4729 for (i = 0; i < ARRAY_SIZE(array_mp_8822b_txpwr_lmt_type5); i += 7) {
4733 u8 *regulation = array[i]; 4730 u8 *regulation = array[i];
4734 u8 *band = array[i + 1]; 4731 u8 *band = array[i + 1];
4735 u8 *bandwidth = array[i + 2]; 4732 u8 *bandwidth = array[i + 2];
diff --git a/drivers/staging/rtlwifi/ps.c b/drivers/staging/rtlwifi/ps.c
index 9172cee45f74..7856fc5d10bd 100644
--- a/drivers/staging/rtlwifi/ps.c
+++ b/drivers/staging/rtlwifi/ps.c
@@ -61,7 +61,7 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
61 rtlpriv->cfg->ops->enable_interrupt(hw); 61 rtlpriv->cfg->ops->enable_interrupt(hw);
62 62
63 /*<enable timer> */ 63 /*<enable timer> */
64 rtl_watch_dog_timer_callback((unsigned long)hw); 64 rtl_watch_dog_timer_callback(&rtlpriv->works.watchdog_timer);
65 65
66 return true; 66 return true;
67} 67}
diff --git a/drivers/staging/rtlwifi/rc.c b/drivers/staging/rtlwifi/rc.c
index 65de0c7b5a67..c835be91f398 100644
--- a/drivers/staging/rtlwifi/rc.c
+++ b/drivers/staging/rtlwifi/rc.c
@@ -125,8 +125,8 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
125 } 125 }
126 rate->count = tries; 126 rate->count = tries;
127 rate->idx = rix >= 0x00 ? rix : 0x00; 127 rate->idx = rix >= 0x00 ? rix : 0x00;
128 if (((rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE) || 128 if ((rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE ||
129 (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8822BE)) && 129 rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8822BE) &&
130 wireless_mode == WIRELESS_MODE_AC_5G) 130 wireless_mode == WIRELESS_MODE_AC_5G)
131 rate->idx |= 0x10;/*2NSS for 8812AE, 8822BE*/ 131 rate->idx |= 0x10;/*2NSS for 8812AE, 8822BE*/
132 132
@@ -138,7 +138,7 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
138 if (sta && (sta->ht_cap.cap & 138 if (sta && (sta->ht_cap.cap &
139 IEEE80211_HT_CAP_SUP_WIDTH_20_40)) 139 IEEE80211_HT_CAP_SUP_WIDTH_20_40))
140 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; 140 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
141 if (sta && (sta->vht_cap.vht_supported)) 141 if (sta && sta->vht_cap.vht_supported)
142 rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; 142 rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
143 } else { 143 } else {
144 if (mac->bw_80) 144 if (mac->bw_80)
@@ -150,8 +150,8 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
150 if (sgi_20 || sgi_40 || sgi_80) 150 if (sgi_20 || sgi_40 || sgi_80)
151 rate->flags |= IEEE80211_TX_RC_SHORT_GI; 151 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
152 if (sta && sta->ht_cap.ht_supported && 152 if (sta && sta->ht_cap.ht_supported &&
153 ((wireless_mode == WIRELESS_MODE_N_5G) || 153 (wireless_mode == WIRELESS_MODE_N_5G ||
154 (wireless_mode == WIRELESS_MODE_N_24G))) 154 wireless_mode == WIRELESS_MODE_N_24G))
155 rate->flags |= IEEE80211_TX_RC_MCS; 155 rate->flags |= IEEE80211_TX_RC_MCS;
156 if (sta && sta->vht_cap.vht_supported && 156 if (sta && sta->vht_cap.vht_supported &&
157 (wireless_mode == WIRELESS_MODE_AC_5G || 157 (wireless_mode == WIRELESS_MODE_AC_5G ||
@@ -232,7 +232,7 @@ static void rtl_tx_status(void *ppriv,
232 if (sta) { 232 if (sta) {
233 /* Check if aggregation has to be enabled for this tid */ 233 /* Check if aggregation has to be enabled for this tid */
234 sta_entry = (struct rtl_sta_info *)sta->drv_priv; 234 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
235 if ((sta->ht_cap.ht_supported) && 235 if (sta->ht_cap.ht_supported &&
236 !(skb->protocol == cpu_to_be16(ETH_P_PAE))) { 236 !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
237 if (ieee80211_is_data_qos(fc)) { 237 if (ieee80211_is_data_qos(fc)) {
238 u8 tid = rtl_get_tid(skb); 238 u8 tid = rtl_get_tid(skb);
@@ -281,10 +281,8 @@ static void *rtl_rate_alloc_sta(void *ppriv,
281 struct rtl_rate_priv *rate_priv; 281 struct rtl_rate_priv *rate_priv;
282 282
283 rate_priv = kzalloc(sizeof(*rate_priv), gfp); 283 rate_priv = kzalloc(sizeof(*rate_priv), gfp);
284 if (!rate_priv) { 284 if (!rate_priv)
285 pr_err("Unable to allocate private rc structure\n");
286 return NULL; 285 return NULL;
287 }
288 286
289 rtlpriv->rate_priv = rate_priv; 287 rtlpriv->rate_priv = rate_priv;
290 288
diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c
index 8e24da16752c..f45487122517 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -330,7 +330,7 @@ void rtl8822be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
330 byte5 = btc_ops->btc_get_lps_val(rtlpriv); 330 byte5 = btc_ops->btc_get_lps_val(rtlpriv);
331 power_state = btc_ops->btc_get_rpwm_val(rtlpriv); 331 power_state = btc_ops->btc_get_rpwm_val(rtlpriv);
332 332
333 if ((rlbm == 2) && (byte5 & BIT(4))) { 333 if (rlbm == 2 && (byte5 & BIT(4))) {
334 /* Keep awake interval to 1 to prevent from 334 /* Keep awake interval to 1 to prevent from
335 * decreasing coex performance 335 * decreasing coex performance
336 */ 336 */
@@ -419,7 +419,7 @@ static bool _rtl8822be_send_bcn_or_cmd_packet(struct ieee80211_hw *hw,
419 dma_addr = rtlpriv->cfg->ops->get_desc( 419 dma_addr = rtlpriv->cfg->ops->get_desc(
420 hw, (u8 *)pbd_desc, true, HW_DESC_TXBUFF_ADDR); 420 hw, (u8 *)pbd_desc, true, HW_DESC_TXBUFF_ADDR);
421 421
422 pci_unmap_single(rtlpci->pdev, dma_addr, skb->len, 422 pci_unmap_single(rtlpci->pdev, dma_addr, pskb->len,
423 PCI_DMA_TODEVICE); 423 PCI_DMA_TODEVICE);
424 kfree_skb(pskb); 424 kfree_skb(pskb);
425 425
@@ -766,9 +766,10 @@ void rtl8822be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
766 rtl8822be_fill_h2c_cmd(hw, H2C_8822B_RSVDPAGE, 766 rtl8822be_fill_h2c_cmd(hw, H2C_8822B_RSVDPAGE,
767 sizeof(u1_rsvd_page_loc), 767 sizeof(u1_rsvd_page_loc),
768 u1_rsvd_page_loc); 768 u1_rsvd_page_loc);
769 } else 769 } else {
770 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 770 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
771 "Set RSVD page location to Fw FAIL!!!!!!.\n"); 771 "Set RSVD page location to Fw FAIL!!!!!!.\n");
772 }
772} 773}
773 774
774/* Should check FW support p2p or not. */ 775/* Should check FW support p2p or not. */
@@ -834,7 +835,7 @@ void rtl8822be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state)
834 rtl_write_dword(rtlpriv, 0x5EC, 835 rtl_write_dword(rtlpriv, 0x5EC,
835 p2pinfo->noa_count_type[i]); 836 p2pinfo->noa_count_type[i]);
836 } 837 }
837 if ((p2pinfo->opp_ps == 1) || (p2pinfo->noa_num > 0)) { 838 if (p2pinfo->opp_ps == 1 || p2pinfo->noa_num > 0) {
838 /* rst p2p circuit */ 839 /* rst p2p circuit */
839 rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST_8822B, BIT(4)); 840 rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST_8822B, BIT(4));
840 p2p_ps_offload->offload_en = 1; 841 p2p_ps_offload->offload_en = 1;
diff --git a/drivers/staging/rtlwifi/rtl8822be/led.c b/drivers/staging/rtlwifi/rtl8822be/led.c
index f4b5af8ab116..0054c892dce6 100644
--- a/drivers/staging/rtlwifi/rtl8822be/led.c
+++ b/drivers/staging/rtlwifi/rtl8822be/led.c
@@ -114,7 +114,7 @@ void rtl8822be_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
114 struct rtl_priv *rtlpriv = rtl_priv(hw); 114 struct rtl_priv *rtlpriv = rtl_priv(hw);
115 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 115 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
116 116
117 if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) && 117 if (ppsc->rfoff_reason > RF_CHANGE_BY_PS &&
118 (ledaction == LED_CTL_TX || ledaction == LED_CTL_RX || 118 (ledaction == LED_CTL_TX || ledaction == LED_CTL_RX ||
119 ledaction == LED_CTL_SITE_SURVEY || ledaction == LED_CTL_LINK || 119 ledaction == LED_CTL_SITE_SURVEY || ledaction == LED_CTL_LINK ||
120 ledaction == LED_CTL_NO_LINK || 120 ledaction == LED_CTL_NO_LINK ||
diff --git a/drivers/staging/rtlwifi/rtl8822be/phy.c b/drivers/staging/rtlwifi/rtl8822be/phy.c
index 4cba2adc3165..ef37ae98c803 100644
--- a/drivers/staging/rtlwifi/rtl8822be/phy.c
+++ b/drivers/staging/rtlwifi/rtl8822be/phy.c
@@ -890,7 +890,7 @@ bool rtl8822be_load_txpower_by_rate(struct ieee80211_hw *hw)
890 rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_by_rate(rtlpriv); 890 rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_by_rate(rtlpriv);
891 891
892 if (!rtstatus) { 892 if (!rtstatus) {
893 pr_err("BB_PG Reg Fail!!"); 893 pr_err("BB_PG Reg Fail!!\n");
894 return false; 894 return false;
895 } 895 }
896 896
@@ -915,7 +915,7 @@ bool rtl8822be_load_txpower_limit(struct ieee80211_hw *hw)
915 rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_limit(rtlpriv); 915 rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_limit(rtlpriv);
916 916
917 if (!rtstatus) { 917 if (!rtstatus) {
918 pr_err("RF TxPwr Limit Fail!!"); 918 pr_err("RF TxPwr Limit Fail!!\n");
919 return false; 919 return false;
920 } 920 }
921 921
@@ -1562,9 +1562,10 @@ static char _rtl8822be_phy_get_txpower_limit(struct ieee80211_hw *hw, u8 band,
1562 [channel_index] 1562 [channel_index]
1563 [rate_section] 1563 [rate_section]
1564 [channel_index][rf_path]; 1564 [channel_index][rf_path];
1565 } else 1565 } else {
1566 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1566 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1567 "No power limit table of the specified band\n"); 1567 "No power limit table of the specified band\n");
1568 }
1568 1569
1569 return power_limit; 1570 return power_limit;
1570} 1571}
@@ -1609,9 +1610,9 @@ u8 rtl8822be_get_txpower_index(struct ieee80211_hw *hw, u8 path, u8 rate,
1609 char limit; 1610 char limit;
1610 char powerdiff_byrate = 0; 1611 char powerdiff_byrate = 0;
1611 1612
1612 if (((rtlhal->current_bandtype == BAND_ON_2_4G) && 1613 if ((rtlhal->current_bandtype == BAND_ON_2_4G &&
1613 (channel > 14 || channel < 1)) || 1614 (channel > 14 || channel < 1)) ||
1614 ((rtlhal->current_bandtype == BAND_ON_5G) && (channel <= 14))) { 1615 (rtlhal->current_bandtype == BAND_ON_5G && channel <= 14)) {
1615 index = 0; 1616 index = 0;
1616 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1617 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1617 "Illegal channel!!\n"); 1618 "Illegal channel!!\n");
@@ -1755,9 +1756,9 @@ static void _rtl8822be_phy_set_txpower_index(struct ieee80211_hw *hw,
1755 static u32 index; 1756 static u32 index;
1756 1757
1757 /* 1758 /*
1758 * For 8822B, phydm api use 4 bytes txagc value 1759 * For 8822B, phydm api use 4 bytes txagc value driver must
1759 * driver must combine every four 1 byte to one 4 byte and send to phydm 1760 * combine every four 1 byte to one 4 byte and send to phydm
1760 */ 1761 */
1761 shift = rate & 0x03; 1762 shift = rate & 0x03;
1762 index |= ((u32)power_index << (shift * 8)); 1763 index |= ((u32)power_index << (shift * 8));
1763 1764
@@ -1912,8 +1913,8 @@ static u8 _rtl8822be_phy_get_pri_ch_id(struct rtl_priv *rtlpriv)
1912 1913
1913 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_80) { 1914 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_80) {
1914 /* primary channel is at lower subband of 80MHz & 40MHz */ 1915 /* primary channel is at lower subband of 80MHz & 40MHz */
1915 if ((mac->cur_40_prime_sc == HAL_PRIME_CHNL_OFFSET_LOWER) && 1916 if (mac->cur_40_prime_sc == HAL_PRIME_CHNL_OFFSET_LOWER &&
1916 (mac->cur_80_prime_sc == HAL_PRIME_CHNL_OFFSET_LOWER)) { 1917 mac->cur_80_prime_sc == HAL_PRIME_CHNL_OFFSET_LOWER) {
1917 pri_ch_idx = VHT_DATA_SC_20_LOWEST_OF_80MHZ; 1918 pri_ch_idx = VHT_DATA_SC_20_LOWEST_OF_80MHZ;
1918 /* primary channel is at 1919 /* primary channel is at
1919 * lower subband of 80MHz & upper subband of 40MHz 1920 * lower subband of 80MHz & upper subband of 40MHz
@@ -2141,7 +2142,7 @@ static bool _rtl8822be_phy_set_rf_power_state(struct ieee80211_hw *hw,
2141 2142
2142 switch (rfpwr_state) { 2143 switch (rfpwr_state) {
2143 case ERFON: 2144 case ERFON:
2144 if ((ppsc->rfpwr_state == ERFOFF) && 2145 if (ppsc->rfpwr_state == ERFOFF &&
2145 RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC)) { 2146 RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC)) {
2146 bool rtstatus = false; 2147 bool rtstatus = false;
2147 u32 initialize_count = 0; 2148 u32 initialize_count = 0;
diff --git a/drivers/staging/rtlwifi/rtl8822be/trx.c b/drivers/staging/rtlwifi/rtl8822be/trx.c
index 38f80e48a399..87e15e419252 100644
--- a/drivers/staging/rtlwifi/rtl8822be/trx.c
+++ b/drivers/staging/rtlwifi/rtl8822be/trx.c
@@ -165,7 +165,7 @@ static bool rtl8822be_get_rxdesc_is_ht(struct ieee80211_hw *hw, u8 *pdesc)
165 165
166 RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate); 166 RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate);
167 167
168 if ((rx_rate >= DESC_RATEMCS0) && (rx_rate <= DESC_RATEMCS15)) 168 if (rx_rate >= DESC_RATEMCS0 && rx_rate <= DESC_RATEMCS15)
169 return true; 169 return true;
170 else 170 else
171 return false; 171 return false;
@@ -193,8 +193,8 @@ static u8 rtl8822be_get_rx_vht_nss(struct ieee80211_hw *hw, u8 *pdesc)
193 193
194 rx_rate = GET_RX_DESC_RX_RATE(pdesc); 194 rx_rate = GET_RX_DESC_RX_RATE(pdesc);
195 195
196 if ((rx_rate >= DESC_RATEVHT1SS_MCS0) && 196 if (rx_rate >= DESC_RATEVHT1SS_MCS0 &&
197 (rx_rate <= DESC_RATEVHT1SS_MCS9)) 197 rx_rate <= DESC_RATEVHT1SS_MCS9)
198 vht_nss = 1; 198 vht_nss = 1;
199 else if ((rx_rate >= DESC_RATEVHT2SS_MCS0) && 199 else if ((rx_rate >= DESC_RATEVHT2SS_MCS0) &&
200 (rx_rate <= DESC_RATEVHT2SS_MCS9)) 200 (rx_rate <= DESC_RATEVHT2SS_MCS9))
@@ -510,8 +510,8 @@ static u8 rtl8822be_bw_mapping(struct ieee80211_hw *hw,
510 else 510 else
511 bw_setting_of_desc = 0; 511 bw_setting_of_desc = 0;
512 } else if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 512 } else if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
513 if ((ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) || 513 if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40 ||
514 (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_80)) 514 ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_80)
515 bw_setting_of_desc = 1; 515 bw_setting_of_desc = 1;
516 else 516 else
517 bw_setting_of_desc = 0; 517 bw_setting_of_desc = 0;
@@ -546,10 +546,10 @@ static u8 rtl8822be_sc_mapping(struct ieee80211_hw *hw,
546 "%s: Not Correct Primary40MHz Setting\n", 546 "%s: Not Correct Primary40MHz Setting\n",
547 __func__); 547 __func__);
548 } else { 548 } else {
549 if ((mac->cur_40_prime_sc == 549 if (mac->cur_40_prime_sc ==
550 HAL_PRIME_CHNL_OFFSET_LOWER) && 550 HAL_PRIME_CHNL_OFFSET_LOWER &&
551 (mac->cur_80_prime_sc == 551 mac->cur_80_prime_sc ==
552 HAL_PRIME_CHNL_OFFSET_LOWER)) 552 HAL_PRIME_CHNL_OFFSET_LOWER)
553 sc_setting_of_desc = 553 sc_setting_of_desc =
554 VHT_DATA_SC_20_LOWEST_OF_80MHZ; 554 VHT_DATA_SC_20_LOWEST_OF_80MHZ;
555 else if ((mac->cur_40_prime_sc == 555 else if ((mac->cur_40_prime_sc ==
@@ -571,9 +571,9 @@ static u8 rtl8822be_sc_mapping(struct ieee80211_hw *hw,
571 sc_setting_of_desc = 571 sc_setting_of_desc =
572 VHT_DATA_SC_20_UPPERST_OF_80MHZ; 572 VHT_DATA_SC_20_UPPERST_OF_80MHZ;
573 else 573 else
574 RT_TRACE( 574 RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD,
575 rtlpriv, COMP_SEND, DBG_LOUD, 575 "%s: Not Correct Primary40MHz Setting\n",
576 "rtl8822be_sc_mapping: Not Correct Primary40MHz Setting\n"); 576 __func__);
577 } 577 }
578 } else if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 578 } else if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
579 if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) { 579 if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) {
diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
index 4033a2cf7ac9..d548bc695f9e 100644
--- a/drivers/staging/rts5208/sd.c
+++ b/drivers/staging/rts5208/sd.c
@@ -4125,12 +4125,6 @@ RTY_SEND_CMD:
4125 rtsx_trace(chip); 4125 rtsx_trace(chip);
4126 return STATUS_FAIL; 4126 return STATUS_FAIL;
4127 } 4127 }
4128
4129 } else if (rsp_type == SD_RSP_TYPE_R0) {
4130 if ((ptr[3] & 0x1E) != 0x03) {
4131 rtsx_trace(chip);
4132 return STATUS_FAIL;
4133 }
4134 } 4128 }
4135 } 4129 }
4136 } 4130 }
diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 2c7a9b9a7c8a..d9d4c485e54c 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -17,7 +17,7 @@ static inline u32 peek32(u32 addr)
17 return readl(addr + mmio750); 17 return readl(addr + mmio750);
18} 18}
19 19
20static inline void poke32(u32 data, u32 addr) 20static inline void poke32(u32 addr, u32 data)
21{ 21{
22 writel(data, addr + mmio750); 22 writel(data, addr + mmio750);
23} 23}
diff --git a/drivers/staging/sm750fb/ddk750_dvi.c b/drivers/staging/sm750fb/ddk750_dvi.c
index 87a199d6cdaf..6ecdcf0afd14 100644
--- a/drivers/staging/sm750fb/ddk750_dvi.c
+++ b/drivers/staging/sm750fb/ddk750_dvi.c
@@ -10,7 +10,7 @@
10 * function API. Please set the function pointer to NULL whenever the function 10 * function API. Please set the function pointer to NULL whenever the function
11 * is not supported. 11 * is not supported.
12 */ 12 */
13static dvi_ctrl_device_t g_dcftSupportedDviController[] = { 13static struct dvi_ctrl_device g_dcftSupportedDviController[] = {
14#ifdef DVI_CTRL_SII164 14#ifdef DVI_CTRL_SII164
15 { 15 {
16 .pfnInit = sii164InitChip, 16 .pfnInit = sii164InitChip,
@@ -40,7 +40,7 @@ int dviInit(unsigned char edgeSelect,
40 unsigned char pllFilterEnable, 40 unsigned char pllFilterEnable,
41 unsigned char pllFilterValue) 41 unsigned char pllFilterValue)
42{ 42{
43 dvi_ctrl_device_t *pCurrentDviCtrl; 43 struct dvi_ctrl_device *pCurrentDviCtrl;
44 44
45 pCurrentDviCtrl = g_dcftSupportedDviController; 45 pCurrentDviCtrl = g_dcftSupportedDviController;
46 if (pCurrentDviCtrl->pfnInit) { 46 if (pCurrentDviCtrl->pfnInit) {
diff --git a/drivers/staging/sm750fb/ddk750_dvi.h b/drivers/staging/sm750fb/ddk750_dvi.h
index 4a8394561f76..692888ceee40 100644
--- a/drivers/staging/sm750fb/ddk750_dvi.h
+++ b/drivers/staging/sm750fb/ddk750_dvi.h
@@ -25,7 +25,7 @@ typedef unsigned char (*PFN_DVICTRL_CHECKINTERRUPT)(void);
25typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void); 25typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void);
26 26
27/* Structure to hold all the function pointer to the DVI Controller. */ 27/* Structure to hold all the function pointer to the DVI Controller. */
28typedef struct _dvi_ctrl_device_t { 28struct dvi_ctrl_device {
29 PFN_DVICTRL_INIT pfnInit; 29 PFN_DVICTRL_INIT pfnInit;
30 PFN_DVICTRL_RESETCHIP pfnResetChip; 30 PFN_DVICTRL_RESETCHIP pfnResetChip;
31 PFN_DVICTRL_GETCHIPSTRING pfnGetChipString; 31 PFN_DVICTRL_GETCHIPSTRING pfnGetChipString;
@@ -36,7 +36,7 @@ typedef struct _dvi_ctrl_device_t {
36 PFN_DVICTRL_ISCONNECTED pfnIsConnected; 36 PFN_DVICTRL_ISCONNECTED pfnIsConnected;
37 PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt; 37 PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt;
38 PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt; 38 PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt;
39} dvi_ctrl_device_t; 39};
40 40
41#define DVI_CTRL_SII164 41#define DVI_CTRL_SII164
42 42
diff --git a/drivers/staging/sm750fb/ddk750_power.c b/drivers/staging/sm750fb/ddk750_power.c
index 222ae1a06feb..6f82ab05fdb6 100644
--- a/drivers/staging/sm750fb/ddk750_power.c
+++ b/drivers/staging/sm750fb/ddk750_power.c
@@ -2,7 +2,7 @@
2#include "ddk750_reg.h" 2#include "ddk750_reg.h"
3#include "ddk750_power.h" 3#include "ddk750_power.h"
4 4
5void ddk750_set_dpms(DPMS_t state) 5void ddk750_set_dpms(enum dpms state)
6{ 6{
7 unsigned int value; 7 unsigned int value;
8 8
diff --git a/drivers/staging/sm750fb/ddk750_power.h b/drivers/staging/sm750fb/ddk750_power.h
index 44c4fc587e96..033889f63920 100644
--- a/drivers/staging/sm750fb/ddk750_power.h
+++ b/drivers/staging/sm750fb/ddk750_power.h
@@ -1,20 +1,19 @@
1#ifndef DDK750_POWER_H__ 1#ifndef DDK750_POWER_H__
2#define DDK750_POWER_H__ 2#define DDK750_POWER_H__
3 3
4typedef enum _DPMS_t { 4enum dpms {
5 crtDPMS_ON = 0x0, 5 crtDPMS_ON = 0x0,
6 crtDPMS_STANDBY = 0x1, 6 crtDPMS_STANDBY = 0x1,
7 crtDPMS_SUSPEND = 0x2, 7 crtDPMS_SUSPEND = 0x2,
8 crtDPMS_OFF = 0x3, 8 crtDPMS_OFF = 0x3,
9} 9};
10DPMS_t;
11 10
12#define setDAC(off) { \ 11#define setDAC(off) { \
13 poke32(MISC_CTRL, \ 12 poke32(MISC_CTRL, \
14 (peek32(MISC_CTRL) & ~MISC_CTRL_DAC_POWER_OFF) | (off)); \ 13 (peek32(MISC_CTRL) & ~MISC_CTRL_DAC_POWER_OFF) | (off)); \
15} 14}
16 15
17void ddk750_set_dpms(DPMS_t state); 16void ddk750_set_dpms(enum dpms state);
18void sm750_set_power_mode(unsigned int powerMode); 17void sm750_set_power_mode(unsigned int powerMode);
19void sm750_set_current_gate(unsigned int gate); 18void sm750_set_current_gate(unsigned int gate);
20 19
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c
index 0431833de781..3d68e1d00cb1 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -296,7 +296,8 @@ void sii164SetPower(unsigned char powerUp)
296 * sii164SelectHotPlugDetectionMode 296 * sii164SelectHotPlugDetectionMode
297 * This function selects the mode of the hot plug detection. 297 * This function selects the mode of the hot plug detection.
298 */ 298 */
299static void sii164SelectHotPlugDetectionMode(sii164_hot_plug_mode_t hotPlugMode) 299static
300void sii164SelectHotPlugDetectionMode(enum sii164_hot_plug_mode hotPlugMode)
300{ 301{
301 unsigned char detectReg; 302 unsigned char detectReg;
302 303
diff --git a/drivers/staging/sm750fb/ddk750_sii164.h b/drivers/staging/sm750fb/ddk750_sii164.h
index 6968cf532f16..e06ba729b4e2 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.h
+++ b/drivers/staging/sm750fb/ddk750_sii164.h
@@ -4,12 +4,12 @@
4#define USE_DVICHIP 4#define USE_DVICHIP
5 5
6/* Hot Plug detection mode structure */ 6/* Hot Plug detection mode structure */
7typedef enum _sii164_hot_plug_mode_t { 7enum sii164_hot_plug_mode {
8 SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit (always high). */ 8 SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit (always high). */
9 SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt bit. */ 9 SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt bit. */
10 SII164_HOTPLUG_USE_RSEN, /* Use Receiver Sense detect bit. */ 10 SII164_HOTPLUG_USE_RSEN, /* Use Receiver Sense detect bit. */
11 SII164_HOTPLUG_USE_HTPLG /* Use Hot Plug detect bit. */ 11 SII164_HOTPLUG_USE_HTPLG /* Use Hot Plug detect bit. */
12} sii164_hot_plug_mode_t; 12};
13 13
14 14
15/* Silicon Image SiI164 chip prototype */ 15/* Silicon Image SiI164 chip prototype */
diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c
index aa47a16ac75c..6b27b061d4cf 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -18,8 +18,6 @@
18#include "sm750.h" 18#include "sm750.h"
19#include "sm750_cursor.h" 19#include "sm750_cursor.h"
20 20
21
22
23#define poke32(addr, data) \ 21#define poke32(addr, data) \
24writel((data), cursor->mmio + (addr)) 22writel((data), cursor->mmio + (addr))
25 23
@@ -45,7 +43,6 @@ writel((data), cursor->mmio + (addr))
45#define HWC_COLOR_3 0xC 43#define HWC_COLOR_3 0xC
46#define HWC_COLOR_3_RGB565_MASK 0xffff 44#define HWC_COLOR_3_RGB565_MASK 0xffff
47 45
48
49/* hw_cursor_xxx works for voyager,718 and 750 */ 46/* hw_cursor_xxx works for voyager,718 and 750 */
50void sm750_hw_cursor_enable(struct lynx_cursor *cursor) 47void sm750_hw_cursor_enable(struct lynx_cursor *cursor)
51{ 48{
@@ -134,7 +131,6 @@ void sm750_hw_cursor_setData(struct lynx_cursor *cursor, u16 rop,
134 } 131 }
135} 132}
136 133
137
138void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop, 134void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop,
139 const u8 *pcol, const u8 *pmsk) 135 const u8 *pcol, const u8 *pmsk)
140{ 136{
diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c
index f459e4004bfa..6137fa83c609 100644
--- a/drivers/staging/speakup/buffers.c
+++ b/drivers/staging/speakup/buffers.c
@@ -27,7 +27,7 @@ void speakup_start_ttys(void)
27 for (i = 0; i < MAX_NR_CONSOLES; i++) { 27 for (i = 0; i < MAX_NR_CONSOLES; i++) {
28 if (speakup_console[i] && speakup_console[i]->tty_stopped) 28 if (speakup_console[i] && speakup_console[i]->tty_stopped)
29 continue; 29 continue;
30 if ((vc_cons[i].d) && (vc_cons[i].d->port.tty)) 30 if (vc_cons[i].d && vc_cons[i].d->port.tty)
31 start_tty(vc_cons[i].d->port.tty); 31 start_tty(vc_cons[i].d->port.tty);
32 } 32 }
33} 33}
@@ -38,7 +38,7 @@ static void speakup_stop_ttys(void)
38 int i; 38 int i;
39 39
40 for (i = 0; i < MAX_NR_CONSOLES; i++) 40 for (i = 0; i < MAX_NR_CONSOLES; i++)
41 if ((vc_cons[i].d && (vc_cons[i].d->port.tty))) 41 if (vc_cons[i].d && vc_cons[i].d->port.tty)
42 stop_tty(vc_cons[i].d->port.tty); 42 stop_tty(vc_cons[i].d->port.tty);
43} 43}
44 44
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 56f7be6af1f6..3809cd2ad838 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -447,7 +447,7 @@ static void speak_char(u16 ch)
447 447
448 cp = spk_characters[ch]; 448 cp = spk_characters[ch];
449 if (!cp) { 449 if (!cp) {
450 pr_info("speak_char: cp == NULL!\n"); 450 pr_info("%s: cp == NULL!\n", __func__);
451 return; 451 return;
452 } 452 }
453 if (IS_CHAR(ch, B_CAP)) { 453 if (IS_CHAR(ch, B_CAP)) {
@@ -2101,7 +2101,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
2101 u_char shift_info, offset; 2101 u_char shift_info, offset;
2102 int ret = 0; 2102 int ret = 0;
2103 2103
2104 if (synth == NULL) 2104 if (!synth)
2105 return 0; 2105 return 0;
2106 2106
2107 spin_lock_irqsave(&speakup_info.spinlock, flags); 2107 spin_lock_irqsave(&speakup_info.spinlock, flags);
diff --git a/drivers/staging/speakup/speakup_acntsa.c b/drivers/staging/speakup/speakup_acntsa.c
index 0e10404e2e8c..43315849b7b6 100644
--- a/drivers/staging/speakup/speakup_acntsa.c
+++ b/drivers/staging/speakup/speakup_acntsa.c
@@ -136,7 +136,7 @@ static int synth_probe(struct spk_synth *synth)
136} 136}
137 137
138module_param_named(ser, synth_acntsa.ser, int, 0444); 138module_param_named(ser, synth_acntsa.ser, int, 0444);
139module_param_named(dev, synth_acntsa.dev_name, charp, S_IRUGO); 139module_param_named(dev, synth_acntsa.dev_name, charp, 0444);
140module_param_named(start, synth_acntsa.startup, short, 0444); 140module_param_named(start, synth_acntsa.startup, short, 0444);
141 141
142MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 142MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c
index 2edb56c8a559..dcf0c3b59fdd 100644
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -200,7 +200,7 @@ static void do_catch_up(struct spk_synth *synth)
200} 200}
201 201
202module_param_named(ser, synth_apollo.ser, int, 0444); 202module_param_named(ser, synth_apollo.ser, int, 0444);
203module_param_named(dev, synth_apollo.dev_name, charp, S_IRUGO); 203module_param_named(dev, synth_apollo.dev_name, charp, 0444);
204module_param_named(start, synth_apollo.startup, short, 0444); 204module_param_named(start, synth_apollo.startup, short, 0444);
205 205
206MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 206MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c
index 8ae826eba71c..45b5721441ba 100644
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -163,7 +163,7 @@ static int synth_probe(struct spk_synth *synth)
163} 163}
164 164
165module_param_named(ser, synth_audptr.ser, int, 0444); 165module_param_named(ser, synth_audptr.ser, int, 0444);
166module_param_named(dev, synth_audptr.dev_name, charp, S_IRUGO); 166module_param_named(dev, synth_audptr.dev_name, charp, 0444);
167module_param_named(start, synth_audptr.startup, short, 0444); 167module_param_named(start, synth_audptr.startup, short, 0444);
168 168
169MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 169MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c
index 60bcf0df8123..402b0fbfb94d 100644
--- a/drivers/staging/speakup/speakup_bns.c
+++ b/drivers/staging/speakup/speakup_bns.c
@@ -120,7 +120,7 @@ static struct spk_synth synth_bns = {
120}; 120};
121 121
122module_param_named(ser, synth_bns.ser, int, 0444); 122module_param_named(ser, synth_bns.ser, int, 0444);
123module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO); 123module_param_named(dev, synth_bns.dev_name, charp, 0444);
124module_param_named(start, synth_bns.startup, short, 0444); 124module_param_named(start, synth_bns.startup, short, 0444);
125 125
126MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 126MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c
index 95f4b2116d0c..4310c2c276c4 100644
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -227,7 +227,7 @@ static void synth_flush(struct spk_synth *synth)
227} 227}
228 228
229module_param_named(ser, synth_decext.ser, int, 0444); 229module_param_named(ser, synth_decext.ser, int, 0444);
230module_param_named(dev, synth_decext.dev_name, charp, S_IRUGO); 230module_param_named(dev, synth_decext.dev_name, charp, 0444);
231module_param_named(start, synth_decext.startup, short, 0444); 231module_param_named(start, synth_decext.startup, short, 0444);
232 232
233MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 233MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c
index f06995480022..5d6a861c9b1e 100644
--- a/drivers/staging/speakup/speakup_dectlk.c
+++ b/drivers/staging/speakup/speakup_dectlk.c
@@ -299,7 +299,7 @@ static void synth_flush(struct spk_synth *synth)
299} 299}
300 300
301module_param_named(ser, synth_dectlk.ser, int, 0444); 301module_param_named(ser, synth_dectlk.ser, int, 0444);
302module_param_named(dev, synth_dectlk.dev_name, charp, S_IRUGO); 302module_param_named(dev, synth_dectlk.dev_name, charp, 0444);
303module_param_named(start, synth_dectlk.startup, short, 0444); 303module_param_named(start, synth_dectlk.startup, short, 0444);
304 304
305MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 305MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c
index 851953d5eefb..ea3b2911cab9 100644
--- a/drivers/staging/speakup/speakup_dummy.c
+++ b/drivers/staging/speakup/speakup_dummy.c
@@ -122,7 +122,7 @@ static struct spk_synth synth_dummy = {
122}; 122};
123 123
124module_param_named(ser, synth_dummy.ser, int, 0444); 124module_param_named(ser, synth_dummy.ser, int, 0444);
125module_param_named(dev, synth_dummy.dev_name, charp, S_IRUGO); 125module_param_named(dev, synth_dummy.dev_name, charp, 0444);
126module_param_named(start, synth_dummy.startup, short, 0444); 126module_param_named(start, synth_dummy.startup, short, 0444);
127 127
128MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 128MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_ltlk.c b/drivers/staging/speakup/speakup_ltlk.c
index 423795f88f53..95efaab73813 100644
--- a/drivers/staging/speakup/speakup_ltlk.c
+++ b/drivers/staging/speakup/speakup_ltlk.c
@@ -167,7 +167,7 @@ static int synth_probe(struct spk_synth *synth)
167} 167}
168 168
169module_param_named(ser, synth_ltlk.ser, int, 0444); 169module_param_named(ser, synth_ltlk.ser, int, 0444);
170module_param_named(dev, synth_ltlk.dev_name, charp, S_IRUGO); 170module_param_named(dev, synth_ltlk.dev_name, charp, 0444);
171module_param_named(start, synth_ltlk.startup, short, 0444); 171module_param_named(start, synth_ltlk.startup, short, 0444);
172 172
173MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 173MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_spkout.c b/drivers/staging/speakup/speakup_spkout.c
index 9ca21edc42ce..1037aa0d085a 100644
--- a/drivers/staging/speakup/speakup_spkout.c
+++ b/drivers/staging/speakup/speakup_spkout.c
@@ -131,7 +131,7 @@ static void synth_flush(struct spk_synth *synth)
131} 131}
132 132
133module_param_named(ser, synth_spkout.ser, int, 0444); 133module_param_named(ser, synth_spkout.ser, int, 0444);
134module_param_named(dev, synth_spkout.dev_name, charp, S_IRUGO); 134module_param_named(dev, synth_spkout.dev_name, charp, 0444);
135module_param_named(start, synth_spkout.startup, short, 0444); 135module_param_named(start, synth_spkout.startup, short, 0444);
136 136
137MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 137MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/speakup_txprt.c b/drivers/staging/speakup/speakup_txprt.c
index 831ee404e7a1..e160034e4a68 100644
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -119,7 +119,7 @@ static struct spk_synth synth_txprt = {
119}; 119};
120 120
121module_param_named(ser, synth_txprt.ser, int, 0444); 121module_param_named(ser, synth_txprt.ser, int, 0444);
122module_param_named(dev, synth_txprt.dev_name, charp, S_IRUGO); 122module_param_named(dev, synth_txprt.dev_name, charp, 0444);
123module_param_named(start, synth_txprt.startup, short, 0444); 123module_param_named(start, synth_txprt.startup, short, 0444);
124 124
125MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); 125MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c
index 4d7d8f2f66ea..513cebbd161c 100644
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -51,10 +51,8 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
51 speakup_tty = tty; 51 speakup_tty = tty;
52 52
53 ldisc_data = kmalloc(sizeof(struct spk_ldisc_data), GFP_KERNEL); 53 ldisc_data = kmalloc(sizeof(struct spk_ldisc_data), GFP_KERNEL);
54 if (!ldisc_data) { 54 if (!ldisc_data)
55 pr_err("speakup: Failed to allocate ldisc_data.\n");
56 return -ENOMEM; 55 return -ENOMEM;
57 }
58 56
59 sema_init(&ldisc_data->sem, 0); 57 sema_init(&ldisc_data->sem, 0);
60 ldisc_data->buf_free = true; 58 ldisc_data->buf_free = true;
@@ -90,7 +88,8 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,
90 return 0; 88 return 0;
91 89
92 /* Make sure the consumer has read buf before we have seen 90 /* Make sure the consumer has read buf before we have seen
93 * buf_free == true and overwrite buf */ 91 * buf_free == true and overwrite buf
92 */
94 mb(); 93 mb();
95 94
96 ldisc_data->buf = cp[0]; 95 ldisc_data->buf = cp[0];
@@ -276,7 +275,8 @@ static unsigned char ttyio_in(int timeout)
276 275
277 rv = ldisc_data->buf; 276 rv = ldisc_data->buf;
278 /* Make sure we have read buf before we set buf_free to let 277 /* Make sure we have read buf before we set buf_free to let
279 * the producer overwrite it */ 278 * the producer overwrite it
279 */
280 mb(); 280 mb();
281 ldisc_data->buf_free = true; 281 ldisc_data->buf_free = true;
282 /* Let TTY push more characters */ 282 /* Let TTY push more characters */
diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig
index 37a0781b0d0c..5359f556d203 100644
--- a/drivers/staging/typec/Kconfig
+++ b/drivers/staging/typec/Kconfig
@@ -1,13 +1,5 @@
1menu "USB Power Delivery and Type-C drivers" 1menu "USB Power Delivery and Type-C drivers"
2 2
3config TYPEC_TCPM
4 tristate "USB Type-C Port Controller Manager"
5 depends on USB
6 select TYPEC
7 help
8 The Type-C Port Controller Manager provides a USB PD and USB Type-C
9 state machine for use with Type-C Port Controllers.
10
11if TYPEC_TCPM 3if TYPEC_TCPM
12 4
13config TYPEC_TCPCI 5config TYPEC_TCPCI
@@ -17,8 +9,6 @@ config TYPEC_TCPCI
17 help 9 help
18 Type-C Port Controller driver for TCPCI-compliant controller. 10 Type-C Port Controller driver for TCPCI-compliant controller.
19 11
20source "drivers/staging/typec/fusb302/Kconfig"
21
22endif 12endif
23 13
24endmenu 14endmenu
diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile
index 30a7e29cbc9e..53d649abcb53 100644
--- a/drivers/staging/typec/Makefile
+++ b/drivers/staging/typec/Makefile
@@ -1,3 +1 @@
1obj-$(CONFIG_TYPEC_TCPM) += tcpm.o
2obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o
3obj-y += fusb302/
diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO
index bc1f97a2d1bf..53fe2f726c88 100644
--- a/drivers/staging/typec/TODO
+++ b/drivers/staging/typec/TODO
@@ -1,13 +1,3 @@
1tcpm:
2- Add documentation (at the very least for the API to low level drivers)
3- Split PD code into separate file
4- Check if it makes sense to use tracepoints instead of debugfs for debug logs
5- Implement Alternate Mode handling
6- Address "#if 0" code if not addressed with the above
7- Validate all comments marked with "XXX"; either address or remove comments
8- Add support for USB PD 3.0. While not mandatory, at least fast role swap
9 as well as authentication support would be very desirable.
10
11tcpci: 1tcpci:
12- Test with real hardware 2- Test with real hardware
13 3
diff --git a/drivers/staging/typec/fusb302/TODO b/drivers/staging/typec/fusb302/TODO
deleted file mode 100644
index 19b466eb585d..000000000000
--- a/drivers/staging/typec/fusb302/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
1fusb302:
2- Find a better logging scheme, at least not having the same debugging/logging
3 code replicated here and in tcpm
4- Find a non-hacky way to coordinate between PM and I2C access
5- Documentation? The FUSB302 datasheet provides information on the chip to help
6 understand the code. But it may still be helpful to have a documentation.
7- We may want to replace the "fcs,max-snk-microvolt", "fcs,max-snk-microamp",
8 "fcs,max-snk-microwatt" and "fcs,operating-snk-microwatt" device(tree)
9 properties with properties which are part of a generic type-c controller
10 devicetree binding.
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index df72d8b01e73..b6abaf79ef0b 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -20,11 +20,11 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/regmap.h> 22#include <linux/regmap.h>
23#include <linux/usb/pd.h>
24#include <linux/usb/tcpm.h>
23#include <linux/usb/typec.h> 25#include <linux/usb/typec.h>
24 26
25#include "pd.h"
26#include "tcpci.h" 27#include "tcpci.h"
27#include "tcpm.h"
28 28
29#define PD_RETRY_COUNT 3 29#define PD_RETRY_COUNT 3
30 30
@@ -139,6 +139,7 @@ static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink)
139 case 0x3: 139 case 0x3:
140 if (sink) 140 if (sink)
141 return TYPEC_CC_RP_3_0; 141 return TYPEC_CC_RP_3_0;
142 /* fall through */
142 case 0x0: 143 case 0x0:
143 default: 144 default:
144 return TYPEC_CC_OPEN; 145 return TYPEC_CC_OPEN;
diff --git a/drivers/staging/unisys/MAINTAINERS b/drivers/staging/unisys/MAINTAINERS
index 1f0425bf3583..aaddc619c329 100644
--- a/drivers/staging/unisys/MAINTAINERS
+++ b/drivers/staging/unisys/MAINTAINERS
@@ -1,5 +1,5 @@
1Unisys s-Par drivers 1Unisys s-Par drivers
2M: David Kershner <sparmaintainer@unisys.com> 2M: David Kershner <sparmaintainer@unisys.com>
3S: Maintained 3S: Maintained
4F: Documentation/s-Par/overview.txt 4F: drivers/staging/unisys/Documentation/overview.txt
5F: drivers/staging/unisys/ 5F: drivers/staging/unisys/
diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h
index a70760f48566..5cd407ca2251 100644
--- a/drivers/staging/unisys/include/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -44,7 +44,7 @@
44#include <linux/uuid.h> 44#include <linux/uuid.h>
45#include <linux/skbuff.h> 45#include <linux/skbuff.h>
46 46
47#include "channel.h" 47#include "visorchannel.h"
48 48
49/* 49/*
50 * Must increment these whenever you insert or delete fields within this channel 50 * Must increment these whenever you insert or delete fields within this channel
@@ -348,10 +348,9 @@ struct sense_data {
348 * the start of the NETWORK LAYER HEADER. 348 * the start of the NETWORK LAYER HEADER.
349 * 349 *
350 * NOTE: 350 * NOTE:
351 * The full packet is described in frags but the ethernet header is 351 * The full packet is described in frags but the ethernet header is separately
352 * separately kept in ethhdr so that uisnic doesn't have "MAP" the 352 * kept in ethhdr so that uisnic doesn't have "MAP" the guest memory to get to
353 * guest memory to get to the header. uisnic needs ethhdr to 353 * the header. uisnic needs ethhdr to determine how to route the packet.
354 * determine how to route the packet.
355 */ 354 */
356struct net_pkt_xmt { 355struct net_pkt_xmt {
357 int len; 356 int len;
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index e4ee38c3dbe4..1a0986ba3d24 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -28,87 +28,20 @@
28#define __VISORBUS_H__ 28#define __VISORBUS_H__
29 29
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/module.h>
32#include <linux/slab.h>
33 31
34#include "channel.h" 32#include "visorchannel.h"
35
36struct visor_device;
37extern struct bus_type visorbus_type;
38
39typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
40 int status);
41 33
42struct visorchipset_state { 34struct visorchipset_state {
43 u32 created:1; 35 u32 created:1;
44 u32 attached:1; 36 u32 attached:1;
45 u32 configured:1; 37 u32 configured:1;
46 u32 running:1; 38 u32 running:1;
47 /* Add new fields above. */ 39 /* Remaining bits in this 32-bit word are reserved. */
48 /* Remaining bits in this 32-bit word are unused. */
49};
50
51/*
52 * This struct describes a specific Supervisor channel, by providing its
53 * GUID, name, and sizes.
54 */
55struct visor_channeltype_descriptor {
56 const guid_t guid;
57 const char *name;
58}; 40};
59 41
60/** 42/**
61 * struct visor_driver - Information provided by each visor driver when it
62 * registers with the visorbus driver.
63 * @name: Name of the visor driver.
64 * @owner: The module owner.
65 * @channel_types: Types of channels handled by this driver, ending with
66 * a zero GUID. Our specialized BUS.match() method knows
67 * about this list, and uses it to determine whether this
68 * driver will in fact handle a new device that it has
69 * detected.
70 * @probe: Called when a new device comes online, by our probe()
71 * function specified by driver.probe() (triggered
72 * ultimately by some call to driver_register(),
73 * bus_add_driver(), or driver_attach()).
74 * @remove: Called when a new device is removed, by our remove()
75 * function specified by driver.remove() (triggered
76 * ultimately by some call to device_release_driver()).
77 * @channel_interrupt: Called periodically, whenever there is a possiblity
78 * that "something interesting" may have happened to the
79 * channel.
80 * @pause: Called to initiate a change of the device's state. If
81 * the return valu`e is < 0, there was an error and the
82 * state transition will NOT occur. If the return value
83 * is >= 0, then the state transition was INITIATED
84 * successfully, and complete_func() will be called (or
85 * was just called) with the final status when either the
86 * state transition fails or completes successfully.
87 * @resume: Behaves similar to pause.
88 * @driver: Private reference to the device driver. For use by bus
89 * driver only.
90 */
91struct visor_driver {
92 const char *name;
93 struct module *owner;
94 struct visor_channeltype_descriptor *channel_types;
95 int (*probe)(struct visor_device *dev);
96 void (*remove)(struct visor_device *dev);
97 void (*channel_interrupt)(struct visor_device *dev);
98 int (*pause)(struct visor_device *dev,
99 visorbus_state_complete_func complete_func);
100 int (*resume)(struct visor_device *dev,
101 visorbus_state_complete_func complete_func);
102
103 /* These fields are for private use by the bus driver only. */
104 struct device_driver driver;
105};
106
107#define to_visor_driver(x) (container_of(x, struct visor_driver, driver))
108
109/**
110 * struct visor_device - A device type for things "plugged" into the visorbus 43 * struct visor_device - A device type for things "plugged" into the visorbus
111 * bus 44 * bus
112 * @visorchannel: Points to the channel that the device is 45 * @visorchannel: Points to the channel that the device is
113 * associated with. 46 * associated with.
114 * @channel_type_guid: Identifies the channel type to the bus driver. 47 * @channel_type_guid: Identifies the channel type to the bus driver.
@@ -139,7 +72,6 @@ struct visor_driver {
139 * same across all visor_devices in the current 72 * same across all visor_devices in the current
140 * guest. Private use by bus driver only. 73 * guest. Private use by bus driver only.
141 */ 74 */
142
143struct visor_device { 75struct visor_device {
144 struct visorchannel *visorchannel; 76 struct visorchannel *visorchannel;
145 guid_t channel_type_guid; 77 guid_t channel_type_guid;
@@ -161,11 +93,74 @@ struct visor_device {
161 void *vbus_hdr_info; 93 void *vbus_hdr_info;
162 guid_t partition_guid; 94 guid_t partition_guid;
163 struct dentry *debugfs_dir; 95 struct dentry *debugfs_dir;
164 struct dentry *debugfs_client_bus_info; 96 struct dentry *debugfs_bus_info;
165}; 97};
166 98
167#define to_visor_device(x) container_of(x, struct visor_device, device) 99#define to_visor_device(x) container_of(x, struct visor_device, device)
168 100
101typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
102 int status);
103
104/*
105 * This struct describes a specific visor channel, by providing its GUID, name,
106 * and sizes.
107 */
108struct visor_channeltype_descriptor {
109 const guid_t guid;
110 const char *name;
111 u64 min_bytes;
112 u32 version;
113};
114
115/**
116 * struct visor_driver - Information provided by each visor driver when it
117 * registers with the visorbus driver
118 * @name: Name of the visor driver.
119 * @owner: The module owner.
120 * @channel_types: Types of channels handled by this driver, ending with
121 * a zero GUID. Our specialized BUS.match() method knows
122 * about this list, and uses it to determine whether this
123 * driver will in fact handle a new device that it has
124 * detected.
125 * @probe: Called when a new device comes online, by our probe()
126 * function specified by driver.probe() (triggered
127 * ultimately by some call to driver_register(),
128 * bus_add_driver(), or driver_attach()).
129 * @remove: Called when a new device is removed, by our remove()
130 * function specified by driver.remove() (triggered
131 * ultimately by some call to device_release_driver()).
132 * @channel_interrupt: Called periodically, whenever there is a possiblity
133 * that "something interesting" may have happened to the
134 * channel.
135 * @pause: Called to initiate a change of the device's state. If
136 * the return valu`e is < 0, there was an error and the
137 * state transition will NOT occur. If the return value
138 * is >= 0, then the state transition was INITIATED
139 * successfully, and complete_func() will be called (or
140 * was just called) with the final status when either the
141 * state transition fails or completes successfully.
142 * @resume: Behaves similar to pause.
143 * @driver: Private reference to the device driver. For use by bus
144 * driver only.
145 */
146struct visor_driver {
147 const char *name;
148 struct module *owner;
149 struct visor_channeltype_descriptor *channel_types;
150 int (*probe)(struct visor_device *dev);
151 void (*remove)(struct visor_device *dev);
152 void (*channel_interrupt)(struct visor_device *dev);
153 int (*pause)(struct visor_device *dev,
154 visorbus_state_complete_func complete_func);
155 int (*resume)(struct visor_device *dev,
156 visorbus_state_complete_func complete_func);
157
158 /* These fields are for private use by the bus driver only. */
159 struct device_driver driver;
160};
161
162#define to_visor_driver(x) (container_of(x, struct visor_driver, driver))
163
169int visor_check_channel(struct channel_header *ch, struct device *dev, 164int visor_check_channel(struct channel_header *ch, struct device *dev,
170 const guid_t *expected_uuid, char *chname, 165 const guid_t *expected_uuid, char *chname,
171 u64 expected_min_bytes, u32 expected_version, 166 u64 expected_min_bytes, u32 expected_version,
@@ -182,26 +177,6 @@ int visorbus_write_channel(struct visor_device *dev,
182int visorbus_enable_channel_interrupts(struct visor_device *dev); 177int visorbus_enable_channel_interrupts(struct visor_device *dev);
183void visorbus_disable_channel_interrupts(struct visor_device *dev); 178void visorbus_disable_channel_interrupts(struct visor_device *dev);
184 179
185/*
186 * Levels of severity for diagnostic events, in order from lowest severity to
187 * highest (i.e. fatal errors are the most severe, and should always be logged,
188 * but info events rarely need to be logged except during debugging). The
189 * values DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid
190 * severity values. They exist merely to dilineate the list, so that future
191 * additions won't require changes to the driver (i.e. when checking for
192 * out-of-range severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE
193 * and DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events
194 * but they are valid for controlling the amount of event data. Changes made
195 * to the enum, need to be reflected in s-Par.
196 */
197enum diag_severity {
198 DIAG_SEVERITY_VERBOSE = 0,
199 DIAG_SEVERITY_INFO = 1,
200 DIAG_SEVERITY_WARNING = 2,
201 DIAG_SEVERITY_ERR = 3,
202 DIAG_SEVERITY_PRINT = 4,
203};
204
205int visorchannel_signalremove(struct visorchannel *channel, u32 queue, 180int visorchannel_signalremove(struct visorchannel *channel, u32 queue,
206 void *msg); 181 void *msg);
207int visorchannel_signalinsert(struct visorchannel *channel, u32 queue, 182int visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
diff --git a/drivers/staging/unisys/include/channel.h b/drivers/staging/unisys/include/visorchannel.h
index 2babe93631f3..33945749c8b6 100644
--- a/drivers/staging/unisys/include/channel.h
+++ b/drivers/staging/unisys/include/visorchannel.h
@@ -14,17 +14,13 @@
14 * details. 14 * details.
15 */ 15 */
16 16
17#ifndef __CHANNEL_H__ 17#ifndef __VISORCHANNEL_H__
18#define __CHANNEL_H__ 18#define __VISORCHANNEL_H__
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/io.h>
22#include <linux/uuid.h> 21#include <linux/uuid.h>
23 22
24#define SIGNATURE_16(A, B) ((A) | ((B) << 8)) 23#define VISOR_CHANNEL_SIGNATURE ('L' << 24 | 'N' << 16 | 'C' << 8 | 'E')
25#define SIGNATURE_32(A, B, C, D) \
26 (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
27#define VISOR_CHANNEL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L')
28 24
29/* 25/*
30 * enum channel_serverstate 26 * enum channel_serverstate
@@ -183,7 +179,7 @@ struct signal_queue_header {
183 u8 filler[12]; 179 u8 filler[12];
184} __packed; 180} __packed;
185 181
186/* CHANNEL Guids */ 182/* VISORCHANNEL Guids */
187/* {414815ed-c58c-11da-95a9-00e08161165f} */ 183/* {414815ed-c58c-11da-95a9-00e08161165f} */
188#define VISOR_VHBA_CHANNEL_GUID \ 184#define VISOR_VHBA_CHANNEL_GUID \
189 GUID_INIT(0x414815ed, 0xc58c, 0x11da, \ 185 GUID_INIT(0x414815ed, 0xc58c, 0x11da, \
diff --git a/drivers/staging/unisys/visorbus/controlvmchannel.h b/drivers/staging/unisys/visorbus/controlvmchannel.h
index 32ff5c1bb6ba..9ee9886a9aed 100644
--- a/drivers/staging/unisys/visorbus/controlvmchannel.h
+++ b/drivers/staging/unisys/visorbus/controlvmchannel.h
@@ -17,7 +17,8 @@
17#define __CONTROLVMCHANNEL_H__ 17#define __CONTROLVMCHANNEL_H__
18 18
19#include <linux/uuid.h> 19#include <linux/uuid.h>
20#include "channel.h" 20
21#include "visorchannel.h"
21 22
22/* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ 23/* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
23#define VISOR_CONTROLVM_CHANNEL_GUID \ 24#define VISOR_CONTROLVM_CHANNEL_GUID \
diff --git a/drivers/staging/unisys/visorbus/vbuschannel.h b/drivers/staging/unisys/visorbus/vbuschannel.h
index 27e04de14818..981b180f3c4b 100644
--- a/drivers/staging/unisys/visorbus/vbuschannel.h
+++ b/drivers/staging/unisys/visorbus/vbuschannel.h
@@ -26,8 +26,7 @@
26 */ 26 */
27 27
28#include <linux/uuid.h> 28#include <linux/uuid.h>
29#include <linux/ctype.h> 29#include "visorchannel.h"
30#include "channel.h"
31 30
32/* {193b331b-c58f-11da-95a9-00e08161165f} */ 31/* {193b331b-c58f-11da-95a9-00e08161165f} */
33#define VISOR_VBUS_CHANNEL_GUID \ 32#define VISOR_VBUS_CHANNEL_GUID \
@@ -50,9 +49,9 @@
50 * @infostrs: Kernel vversion. 49 * @infostrs: Kernel vversion.
51 * @reserved: Pad size to 256 bytes. 50 * @reserved: Pad size to 256 bytes.
52 * 51 *
53 * An array of this struct is present in the channel area for each vbus. 52 * An array of this struct is present in the channel area for each vbus. It is
54 * (See vbuschannel.h.). It is filled in by the client side to provide info 53 * filled in by the client side to provide info about the device and driver from
55 * about the device and driver from the client's perspective. 54 * the client's perspective.
56 */ 55 */
57struct visor_vbus_deviceinfo { 56struct visor_vbus_deviceinfo {
58 u8 devtype[16]; 57 u8 devtype[16];
@@ -73,7 +72,7 @@ struct visor_vbus_deviceinfo {
73 * BusInfo struct. 72 * BusInfo struct.
74 * @dev_info_offset: Byte offset from beginning of this struct to the 73 * @dev_info_offset: Byte offset from beginning of this struct to the
75 * DevInfo array. 74 * DevInfo array.
76 * @reserved: Natural Alignment 75 * @reserved: Natural alignment.
77 */ 76 */
78struct visor_vbus_headerinfo { 77struct visor_vbus_headerinfo {
79 u32 struct_bytes; 78 u32 struct_bytes;
@@ -97,7 +96,6 @@ struct visor_vbus_headerinfo {
97struct visor_vbus_channel { 96struct visor_vbus_channel {
98 struct channel_header channel_header; 97 struct channel_header channel_header;
99 struct visor_vbus_headerinfo hdr_info; 98 struct visor_vbus_headerinfo hdr_info;
100 /* The remainder of this channel is filled in by the client */
101 struct visor_vbus_deviceinfo chp_info; 99 struct visor_vbus_deviceinfo chp_info;
102 struct visor_vbus_deviceinfo bus_info; 100 struct visor_vbus_deviceinfo bus_info;
103 struct visor_vbus_deviceinfo dev_info[0]; 101 struct visor_vbus_deviceinfo dev_info[0];
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 2bc7ff7bb96a..b604d0cccef1 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -13,7 +13,10 @@
13 * details. 13 * details.
14 */ 14 */
15 15
16#include <linux/ctype.h>
16#include <linux/debugfs.h> 17#include <linux/debugfs.h>
18#include <linux/module.h>
19#include <linux/slab.h>
17#include <linux/uuid.h> 20#include <linux/uuid.h>
18 21
19#include "visorbus.h" 22#include "visorbus.h"
@@ -69,12 +72,9 @@ static LIST_HEAD(list_all_device_instances);
69 * Note that <logCtx> is only needed for callers in the EFI environment, and 72 * Note that <logCtx> is only needed for callers in the EFI environment, and
70 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. 73 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
71 */ 74 */
72int visor_check_channel(struct channel_header *ch, 75int visor_check_channel(struct channel_header *ch, struct device *dev,
73 struct device *dev, 76 const guid_t *expected_guid, char *chname,
74 const guid_t *expected_guid, 77 u64 expected_min_bytes, u32 expected_version,
75 char *chname,
76 u64 expected_min_bytes,
77 u32 expected_version,
78 u64 expected_signature) 78 u64 expected_signature)
79{ 79{
80 if (!guid_is_null(expected_guid)) { 80 if (!guid_is_null(expected_guid)) {
@@ -125,7 +125,6 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env)
125 125
126 dev = to_visor_device(xdev); 126 dev = to_visor_device(xdev);
127 guid = visorchannel_get_guid(dev->visorchannel); 127 guid = visorchannel_get_guid(dev->visorchannel);
128
129 return add_uevent_var(env, "MODALIAS=visorbus:%pUl", guid); 128 return add_uevent_var(env, "MODALIAS=visorbus:%pUl", guid);
130} 129}
131 130
@@ -144,17 +143,24 @@ static int visorbus_match(struct device *xdev, struct device_driver *xdrv)
144 int i; 143 int i;
145 struct visor_device *dev; 144 struct visor_device *dev;
146 struct visor_driver *drv; 145 struct visor_driver *drv;
146 struct visorchannel *chan;
147 147
148 dev = to_visor_device(xdev); 148 dev = to_visor_device(xdev);
149 channel_type = visorchannel_get_guid(dev->visorchannel); 149 channel_type = visorchannel_get_guid(dev->visorchannel);
150 drv = to_visor_driver(xdrv); 150 drv = to_visor_driver(xdrv);
151 chan = dev->visorchannel;
151 if (!drv->channel_types) 152 if (!drv->channel_types)
152 return 0; 153 return 0;
153
154 for (i = 0; !guid_is_null(&drv->channel_types[i].guid); i++) 154 for (i = 0; !guid_is_null(&drv->channel_types[i].guid); i++)
155 if (guid_equal(&drv->channel_types[i].guid, channel_type)) 155 if (guid_equal(&drv->channel_types[i].guid, channel_type) &&
156 visor_check_channel(visorchannel_get_header(chan),
157 xdev,
158 &drv->channel_types[i].guid,
159 (char *)drv->channel_types[i].name,
160 drv->channel_types[i].min_bytes,
161 drv->channel_types[i].version,
162 VISOR_CHANNEL_SIGNATURE))
156 return i + 1; 163 return i + 1;
157
158 return 0; 164 return 0;
159} 165}
160 166
@@ -162,13 +168,48 @@ static int visorbus_match(struct device *xdev, struct device_driver *xdrv)
162 * This describes the TYPE of bus. 168 * This describes the TYPE of bus.
163 * (Don't confuse this with an INSTANCE of the bus.) 169 * (Don't confuse this with an INSTANCE of the bus.)
164 */ 170 */
165struct bus_type visorbus_type = { 171static struct bus_type visorbus_type = {
166 .name = "visorbus", 172 .name = "visorbus",
167 .match = visorbus_match, 173 .match = visorbus_match,
168 .uevent = visorbus_uevent, 174 .uevent = visorbus_uevent,
169 .dev_groups = visorbus_dev_groups, 175 .dev_groups = visorbus_dev_groups,
170}; 176};
171 177
178struct visor_busdev {
179 u32 bus_no;
180 u32 dev_no;
181};
182
183static int match_visorbus_dev_by_id(struct device *dev, void *data)
184{
185 struct visor_device *vdev = to_visor_device(dev);
186 struct visor_busdev *id = data;
187
188 if (vdev->chipset_bus_no == id->bus_no &&
189 vdev->chipset_dev_no == id->dev_no)
190 return 1;
191 return 0;
192}
193
194struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
195 struct visor_device *from)
196{
197 struct device *dev;
198 struct device *dev_start = NULL;
199 struct visor_busdev id = {
200 .bus_no = bus_no,
201 .dev_no = dev_no
202 };
203
204 if (from)
205 dev_start = &from->device;
206 dev = bus_find_device(&visorbus_type, dev_start, (void *)&id,
207 match_visorbus_dev_by_id);
208 if (!dev)
209 return NULL;
210 return to_visor_device(dev);
211}
212
172/* 213/*
173 * visorbus_release_busdevice() - called when device_unregister() is called for 214 * visorbus_release_busdevice() - called when device_unregister() is called for
174 * the bus device instance, after all other tasks 215 * the bus device instance, after all other tasks
@@ -179,8 +220,9 @@ static void visorbus_release_busdevice(struct device *xdev)
179{ 220{
180 struct visor_device *dev = dev_get_drvdata(xdev); 221 struct visor_device *dev = dev_get_drvdata(xdev);
181 222
182 debugfs_remove(dev->debugfs_client_bus_info); 223 debugfs_remove(dev->debugfs_bus_info);
183 debugfs_remove_recursive(dev->debugfs_dir); 224 debugfs_remove_recursive(dev->debugfs_dir);
225 visorchannel_destroy(dev->visorchannel);
184 kfree(dev); 226 kfree(dev);
185} 227}
186 228
@@ -198,7 +240,7 @@ static void visorbus_release_device(struct device *xdev)
198} 240}
199 241
200/* 242/*
201 * begin implementation of specific channel attributes to appear under 243 * BUS specific channel attributes to appear under
202 * /sys/bus/visorbus<x>/dev<y>/channel 244 * /sys/bus/visorbus<x>/dev<y>/channel
203 */ 245 */
204 246
@@ -218,7 +260,7 @@ static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr,
218 struct visor_device *vdev = to_visor_device(dev); 260 struct visor_device *vdev = to_visor_device(dev);
219 261
220 return sprintf(buf, "0x%lx\n", 262 return sprintf(buf, "0x%lx\n",
221 visorchannel_get_nbytes(vdev->visorchannel)); 263 visorchannel_get_nbytes(vdev->visorchannel));
222} 264}
223static DEVICE_ATTR_RO(nbytes); 265static DEVICE_ATTR_RO(nbytes);
224 266
@@ -284,18 +326,14 @@ static struct attribute *channel_attrs[] = {
284 326
285ATTRIBUTE_GROUPS(channel); 327ATTRIBUTE_GROUPS(channel);
286 328
287/* end implementation of specific channel attributes */
288
289/* 329/*
290 * BUS instance attributes 330 * BUS instance attributes
291 * 331 *
292 * define & implement display of bus attributes under 332 * define & implement display of bus attributes under
293 * /sys/bus/visorbus/devices/visorbus<n>. 333 * /sys/bus/visorbus/devices/visorbus<n>.
294 */ 334 */
295
296static ssize_t partition_handle_show(struct device *dev, 335static ssize_t partition_handle_show(struct device *dev,
297 struct device_attribute *attr, 336 struct device_attribute *attr, char *buf)
298 char *buf)
299{ 337{
300 struct visor_device *vdev = to_visor_device(dev); 338 struct visor_device *vdev = to_visor_device(dev);
301 u64 handle = visorchannel_get_clientpartition(vdev->visorchannel); 339 u64 handle = visorchannel_get_clientpartition(vdev->visorchannel);
@@ -305,8 +343,7 @@ static ssize_t partition_handle_show(struct device *dev,
305static DEVICE_ATTR_RO(partition_handle); 343static DEVICE_ATTR_RO(partition_handle);
306 344
307static ssize_t partition_guid_show(struct device *dev, 345static ssize_t partition_guid_show(struct device *dev,
308 struct device_attribute *attr, 346 struct device_attribute *attr, char *buf)
309 char *buf)
310{ 347{
311 struct visor_device *vdev = to_visor_device(dev); 348 struct visor_device *vdev = to_visor_device(dev);
312 349
@@ -315,8 +352,7 @@ static ssize_t partition_guid_show(struct device *dev,
315static DEVICE_ATTR_RO(partition_guid); 352static DEVICE_ATTR_RO(partition_guid);
316 353
317static ssize_t partition_name_show(struct device *dev, 354static ssize_t partition_name_show(struct device *dev,
318 struct device_attribute *attr, 355 struct device_attribute *attr, char *buf)
319 char *buf)
320{ 356{
321 struct visor_device *vdev = to_visor_device(dev); 357 struct visor_device *vdev = to_visor_device(dev);
322 358
@@ -325,8 +361,7 @@ static ssize_t partition_name_show(struct device *dev,
325static DEVICE_ATTR_RO(partition_name); 361static DEVICE_ATTR_RO(partition_name);
326 362
327static ssize_t channel_addr_show(struct device *dev, 363static ssize_t channel_addr_show(struct device *dev,
328 struct device_attribute *attr, 364 struct device_attribute *attr, char *buf)
329 char *buf)
330{ 365{
331 struct visor_device *vdev = to_visor_device(dev); 366 struct visor_device *vdev = to_visor_device(dev);
332 u64 addr = visorchannel_get_physaddr(vdev->visorchannel); 367 u64 addr = visorchannel_get_physaddr(vdev->visorchannel);
@@ -336,8 +371,7 @@ static ssize_t channel_addr_show(struct device *dev,
336static DEVICE_ATTR_RO(channel_addr); 371static DEVICE_ATTR_RO(channel_addr);
337 372
338static ssize_t channel_bytes_show(struct device *dev, 373static ssize_t channel_bytes_show(struct device *dev,
339 struct device_attribute *attr, 374 struct device_attribute *attr, char *buf)
340 char *buf)
341{ 375{
342 struct visor_device *vdev = to_visor_device(dev); 376 struct visor_device *vdev = to_visor_device(dev);
343 u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel); 377 u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel);
@@ -347,8 +381,7 @@ static ssize_t channel_bytes_show(struct device *dev,
347static DEVICE_ATTR_RO(channel_bytes); 381static DEVICE_ATTR_RO(channel_bytes);
348 382
349static ssize_t channel_id_show(struct device *dev, 383static ssize_t channel_id_show(struct device *dev,
350 struct device_attribute *attr, 384 struct device_attribute *attr, char *buf)
351 char *buf)
352{ 385{
353 struct visor_device *vdev = to_visor_device(dev); 386 struct visor_device *vdev = to_visor_device(dev);
354 int len = 0; 387 int len = 0;
@@ -356,7 +389,6 @@ static ssize_t channel_id_show(struct device *dev,
356 visorchannel_id(vdev->visorchannel, buf); 389 visorchannel_id(vdev->visorchannel, buf);
357 len = strlen(buf); 390 len = strlen(buf);
358 buf[len++] = '\n'; 391 buf[len++] = '\n';
359
360 return len; 392 return len;
361} 393}
362static DEVICE_ATTR_RO(channel_id); 394static DEVICE_ATTR_RO(channel_id);
@@ -396,13 +428,11 @@ static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo,
396 /* uninitialized vbus device entry */ 428 /* uninitialized vbus device entry */
397 if (!isprint(devinfo->devtype[0])) 429 if (!isprint(devinfo->devtype[0]))
398 return; 430 return;
399
400 if (devix >= 0) 431 if (devix >= 0)
401 seq_printf(seq, "[%d]", devix); 432 seq_printf(seq, "[%d]", devix);
402 else 433 else
403 /* vbus device entry is for bus or chipset */ 434 /* vbus device entry is for bus or chipset */
404 seq_puts(seq, " "); 435 seq_puts(seq, " ");
405
406 /* 436 /*
407 * Note: because the s-Par back-end is free to scribble in this area, 437 * Note: because the s-Par back-end is free to scribble in this area,
408 * we never assume '\0'-termination. 438 * we never assume '\0'-termination.
@@ -415,7 +445,7 @@ static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo,
415 devinfo->infostrs); 445 devinfo->infostrs);
416} 446}
417 447
418static int client_bus_info_debugfs_show(struct seq_file *seq, void *v) 448static int bus_info_debugfs_show(struct seq_file *seq, void *v)
419{ 449{
420 int i = 0; 450 int i = 0;
421 unsigned long off; 451 unsigned long off;
@@ -427,10 +457,9 @@ static int client_bus_info_debugfs_show(struct seq_file *seq, void *v)
427 return 0; 457 return 0;
428 458
429 seq_printf(seq, 459 seq_printf(seq,
430 "Client device / client driver info for %s partition (vbus #%u):\n", 460 "Client device/driver info for %s partition (vbus #%u):\n",
431 ((vdev->name) ? (char *)(vdev->name) : ""), 461 ((vdev->name) ? (char *)(vdev->name) : ""),
432 vdev->chipset_bus_no); 462 vdev->chipset_bus_no);
433
434 if (visorchannel_read(channel, 463 if (visorchannel_read(channel,
435 offsetof(struct visor_vbus_channel, chp_info), 464 offsetof(struct visor_vbus_channel, chp_info),
436 &dev_info, sizeof(dev_info)) >= 0) 465 &dev_info, sizeof(dev_info)) >= 0)
@@ -448,19 +477,17 @@ static int client_bus_info_debugfs_show(struct seq_file *seq, void *v)
448 off += sizeof(dev_info); 477 off += sizeof(dev_info);
449 i++; 478 i++;
450 } 479 }
451
452 return 0; 480 return 0;
453} 481}
454 482
455static int client_bus_info_debugfs_open(struct inode *inode, struct file *file) 483static int bus_info_debugfs_open(struct inode *inode, struct file *file)
456{ 484{
457 return single_open(file, client_bus_info_debugfs_show, 485 return single_open(file, bus_info_debugfs_show, inode->i_private);
458 inode->i_private);
459} 486}
460 487
461static const struct file_operations client_bus_info_debugfs_fops = { 488static const struct file_operations bus_info_debugfs_fops = {
462 .owner = THIS_MODULE, 489 .owner = THIS_MODULE,
463 .open = client_bus_info_debugfs_open, 490 .open = bus_info_debugfs_open,
464 .read = seq_read, 491 .read = seq_read,
465 .llseek = seq_lseek, 492 .llseek = seq_lseek,
466 .release = single_release, 493 .release = single_release,
@@ -479,6 +506,7 @@ static int dev_start_periodic_work(struct visor_device *dev)
479{ 506{
480 if (dev->being_removed || dev->timer_active) 507 if (dev->being_removed || dev->timer_active)
481 return -EINVAL; 508 return -EINVAL;
509
482 /* now up by at least 2 */ 510 /* now up by at least 2 */
483 get_device(&dev->device); 511 get_device(&dev->device);
484 dev->timer.expires = jiffies + POLLJIFFIES_NORMALCHANNEL; 512 dev->timer.expires = jiffies + POLLJIFFIES_NORMALCHANNEL;
@@ -491,6 +519,7 @@ static void dev_stop_periodic_work(struct visor_device *dev)
491{ 519{
492 if (!dev->timer_active) 520 if (!dev->timer_active)
493 return; 521 return;
522
494 del_timer_sync(&dev->timer); 523 del_timer_sync(&dev->timer);
495 dev->timer_active = false; 524 dev->timer_active = false;
496 put_device(&dev->device); 525 put_device(&dev->device);
@@ -508,20 +537,15 @@ static void dev_stop_periodic_work(struct visor_device *dev)
508 */ 537 */
509static int visordriver_remove_device(struct device *xdev) 538static int visordriver_remove_device(struct device *xdev)
510{ 539{
511 struct visor_device *dev; 540 struct visor_device *dev = to_visor_device(xdev);
512 struct visor_driver *drv; 541 struct visor_driver *drv = to_visor_driver(xdev->driver);
513
514 dev = to_visor_device(xdev);
515 drv = to_visor_driver(xdev->driver);
516 542
517 mutex_lock(&dev->visordriver_callback_lock); 543 mutex_lock(&dev->visordriver_callback_lock);
518 dev->being_removed = true; 544 dev->being_removed = true;
519 drv->remove(dev); 545 drv->remove(dev);
520 mutex_unlock(&dev->visordriver_callback_lock); 546 mutex_unlock(&dev->visordriver_callback_lock);
521
522 dev_stop_periodic_work(dev); 547 dev_stop_periodic_work(dev);
523 put_device(&dev->device); 548 put_device(&dev->device);
524
525 return 0; 549 return 0;
526} 550}
527 551
@@ -546,8 +570,7 @@ EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver);
546 * @dest: the destination buffer that is written into from the channel 570 * @dest: the destination buffer that is written into from the channel
547 * @nbytes: the number of bytes to read from the channel 571 * @nbytes: the number of bytes to read from the channel
548 * 572 *
549 * If receiving a message, use the visorchannel_signalremove() 573 * If receiving a message, use the visorchannel_signalremove() function instead.
550 * function instead.
551 * 574 *
552 * Return: integer indicating success (zero) or failure (non-zero) 575 * Return: integer indicating success (zero) or failure (non-zero)
553 */ 576 */
@@ -566,8 +589,7 @@ EXPORT_SYMBOL_GPL(visorbus_read_channel);
566 * @src: the source buffer that is written into the channel 589 * @src: the source buffer that is written into the channel
567 * @nbytes: the number of bytes to write into the channel 590 * @nbytes: the number of bytes to write into the channel
568 * 591 *
569 * If sending a message, use the visorchannel_signalinsert() 592 * If sending a message, use the visorchannel_signalinsert() function instead.
570 * function instead.
571 * 593 *
572 * Return: integer indicating success (zero) or failure (non-zero) 594 * Return: integer indicating success (zero) or failure (non-zero)
573 */ 595 */
@@ -618,17 +640,16 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
618 * 640 *
619 * This is how everything starts from the device end. 641 * This is how everything starts from the device end.
620 * This function is called when a channel first appears via a ControlVM 642 * This function is called when a channel first appears via a ControlVM
621 * message. In response, this function allocates a visor_device to 643 * message. In response, this function allocates a visor_device to correspond
622 * correspond to the new channel, and attempts to connect it the appropriate 644 * to the new channel, and attempts to connect it the appropriate * driver. If
623 * driver. If the appropriate driver is found, the visor_driver.probe() 645 * the appropriate driver is found, the visor_driver.probe() function for that
624 * function for that driver will be called, and will be passed the new 646 * driver will be called, and will be passed the new * visor_device that we
625 * visor_device that we just created. 647 * just created.
626 * 648 *
627 * It's ok if the appropriate driver is not yet loaded, because in that case 649 * It's ok if the appropriate driver is not yet loaded, because in that case
628 * the new device struct will just stick around in the bus' list of devices. 650 * the new device struct will just stick around in the bus' list of devices.
629 * When the appropriate driver calls visorbus_register_visor_driver(), the 651 * When the appropriate driver calls visorbus_register_visor_driver(), the
630 * visor_driver.probe() for the new driver will be called with the new 652 * visor_driver.probe() for the new driver will be called with the new device.
631 * device.
632 * 653 *
633 * Return: 0 if successful, otherwise the negative value returned by 654 * Return: 0 if successful, otherwise the negative value returned by
634 * device_add() indicating the reason for failure 655 * device_add() indicating the reason for failure
@@ -647,17 +668,15 @@ int create_visor_device(struct visor_device *dev)
647 /* keep a reference just for us (now 2) */ 668 /* keep a reference just for us (now 2) */
648 get_device(&dev->device); 669 get_device(&dev->device);
649 setup_timer(&dev->timer, dev_periodic_work, (unsigned long)dev); 670 setup_timer(&dev->timer, dev_periodic_work, (unsigned long)dev);
650
651 /* 671 /*
652 * bus_id must be a unique name with respect to this bus TYPE 672 * bus_id must be a unique name with respect to this bus TYPE (NOT bus
653 * (NOT bus instance). That's why we need to include the bus 673 * instance). That's why we need to include the bus number within the
654 * number within the name. 674 * name.
655 */ 675 */
656 err = dev_set_name(&dev->device, "vbus%u:dev%u", 676 err = dev_set_name(&dev->device, "vbus%u:dev%u",
657 chipset_bus_no, chipset_dev_no); 677 chipset_bus_no, chipset_dev_no);
658 if (err) 678 if (err)
659 goto err_put; 679 goto err_put;
660
661 /* 680 /*
662 * device_add does this: 681 * device_add does this:
663 * bus_add_device(dev) 682 * bus_add_device(dev)
@@ -671,14 +690,13 @@ int create_visor_device(struct visor_device *dev)
671 * if (!drv.probe(dev)) [visordriver_probe_device] 690 * if (!drv.probe(dev)) [visordriver_probe_device]
672 * dev.drv = NULL 691 * dev.drv = NULL
673 * 692 *
674 * Note that device_add does NOT fail if no driver failed to 693 * Note that device_add does NOT fail if no driver failed to claim the
675 * claim the device. The device will be linked onto 694 * device. The device will be linked onto bus_type.klist_devices
676 * bus_type.klist_devices regardless (use bus_for_each_dev). 695 * regardless (use bus_for_each_dev).
677 */ 696 */
678 err = device_add(&dev->device); 697 err = device_add(&dev->device);
679 if (err < 0) 698 if (err < 0)
680 goto err_put; 699 goto err_put;
681
682 list_add_tail(&dev->list_all, &list_all_device_instances); 700 list_add_tail(&dev->list_all, &list_all_device_instances);
683 dev->state.created = 1; 701 dev->state.created = 1;
684 visorbus_response(dev, err, CONTROLVM_DEVICE_CREATE); 702 visorbus_response(dev, err, CONTROLVM_DEVICE_CREATE);
@@ -695,8 +713,9 @@ void remove_visor_device(struct visor_device *dev)
695{ 713{
696 list_del(&dev->list_all); 714 list_del(&dev->list_all);
697 put_device(&dev->device); 715 put_device(&dev->device);
716 if (dev->pending_msg_hdr)
717 visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY);
698 device_unregister(&dev->device); 718 device_unregister(&dev->device);
699 visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY);
700} 719}
701 720
702static int get_vbus_header_info(struct visorchannel *chan, 721static int get_vbus_header_info(struct visorchannel *chan,
@@ -718,14 +737,11 @@ static int get_vbus_header_info(struct visorchannel *chan,
718 sizeof(*hdr_info)); 737 sizeof(*hdr_info));
719 if (err < 0) 738 if (err < 0)
720 return err; 739 return err;
721
722 if (hdr_info->struct_bytes < sizeof(struct visor_vbus_headerinfo)) 740 if (hdr_info->struct_bytes < sizeof(struct visor_vbus_headerinfo))
723 return -EINVAL; 741 return -EINVAL;
724
725 if (hdr_info->device_info_struct_bytes < 742 if (hdr_info->device_info_struct_bytes <
726 sizeof(struct visor_vbus_deviceinfo)) 743 sizeof(struct visor_vbus_deviceinfo))
727 return -EINVAL; 744 return -EINVAL;
728
729 return 0; 745 return 0;
730} 746}
731 747
@@ -746,11 +762,12 @@ static void write_vbus_chp_info(struct visorchannel *chan,
746 struct visor_vbus_headerinfo *hdr_info, 762 struct visor_vbus_headerinfo *hdr_info,
747 struct visor_vbus_deviceinfo *info) 763 struct visor_vbus_deviceinfo *info)
748{ 764{
749 int off = sizeof(struct channel_header) + hdr_info->chp_info_offset; 765 int off;
750 766
751 if (hdr_info->chp_info_offset == 0) 767 if (hdr_info->chp_info_offset == 0)
752 return; 768 return;
753 769
770 off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
754 visorchannel_write(chan, off, info, sizeof(*info)); 771 visorchannel_write(chan, off, info, sizeof(*info));
755} 772}
756 773
@@ -771,11 +788,12 @@ static void write_vbus_bus_info(struct visorchannel *chan,
771 struct visor_vbus_headerinfo *hdr_info, 788 struct visor_vbus_headerinfo *hdr_info,
772 struct visor_vbus_deviceinfo *info) 789 struct visor_vbus_deviceinfo *info)
773{ 790{
774 int off = sizeof(struct channel_header) + hdr_info->bus_info_offset; 791 int off;
775 792
776 if (hdr_info->bus_info_offset == 0) 793 if (hdr_info->bus_info_offset == 0)
777 return; 794 return;
778 795
796 off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
779 visorchannel_write(chan, off, info, sizeof(*info)); 797 visorchannel_write(chan, off, info, sizeof(*info));
780} 798}
781 799
@@ -798,13 +816,12 @@ static void write_vbus_dev_info(struct visorchannel *chan,
798 struct visor_vbus_deviceinfo *info, 816 struct visor_vbus_deviceinfo *info,
799 unsigned int devix) 817 unsigned int devix)
800{ 818{
801 int off = 819 int off;
802 (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
803 (hdr_info->device_info_struct_bytes * devix);
804 820
805 if (hdr_info->dev_info_offset == 0) 821 if (hdr_info->dev_info_offset == 0)
806 return; 822 return;
807 823 off = (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
824 (hdr_info->device_info_struct_bytes * devix);
808 visorchannel_write(chan, off, info, sizeof(*info)); 825 visorchannel_write(chan, off, info, sizeof(*info));
809} 826}
810 827
@@ -844,7 +861,6 @@ static void publish_vbus_dev_info(struct visor_device *visordev)
844 861
845 if (!visordev->device.driver) 862 if (!visordev->device.driver)
846 return; 863 return;
847
848 bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); 864 bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL);
849 if (!bdev) 865 if (!bdev)
850 return; 866 return;
@@ -860,14 +876,12 @@ static void publish_vbus_dev_info(struct visor_device *visordev)
860 * type name 876 * type name
861 */ 877 */
862 for (i = 0; visordrv->channel_types[i].name; i++) { 878 for (i = 0; visordrv->channel_types[i].name; i++) {
863 if (memcmp(&visordrv->channel_types[i].guid, 879 if (guid_equal(&visordrv->channel_types[i].guid,
864 &visordev->channel_type_guid, 880 &visordev->channel_type_guid)) {
865 sizeof(visordrv->channel_types[i].guid)) == 0) {
866 chan_type_name = visordrv->channel_types[i].name; 881 chan_type_name = visordrv->channel_types[i].name;
867 break; 882 break;
868 } 883 }
869 } 884 }
870
871 bus_device_info_init(&dev_info, chan_type_name, visordrv->name); 885 bus_device_info_init(&dev_info, chan_type_name, visordrv->name);
872 write_vbus_dev_info(bdev->visorchannel, hdr_info, &dev_info, dev_no); 886 write_vbus_dev_info(bdev->visorchannel, hdr_info, &dev_info, dev_no);
873 write_vbus_chp_info(bdev->visorchannel, hdr_info, &chipset_driverinfo); 887 write_vbus_chp_info(bdev->visorchannel, hdr_info, &chipset_driverinfo);
@@ -892,36 +906,32 @@ static void publish_vbus_dev_info(struct visor_device *visordev)
892 */ 906 */
893static int visordriver_probe_device(struct device *xdev) 907static int visordriver_probe_device(struct device *xdev)
894{ 908{
895 int res; 909 int err;
896 struct visor_driver *drv; 910 struct visor_driver *drv = to_visor_driver(xdev->driver);
897 struct visor_device *dev; 911 struct visor_device *dev = to_visor_device(xdev);
898
899 dev = to_visor_device(xdev);
900 drv = to_visor_driver(xdev->driver);
901 912
902 mutex_lock(&dev->visordriver_callback_lock); 913 mutex_lock(&dev->visordriver_callback_lock);
903 dev->being_removed = false; 914 dev->being_removed = false;
904 915 err = drv->probe(dev);
905 res = drv->probe(dev); 916 if (err) {
906 if (res >= 0) { 917 mutex_unlock(&dev->visordriver_callback_lock);
907 /* success: reference kept via unmatched get_device() */ 918 return err;
908 get_device(&dev->device);
909 publish_vbus_dev_info(dev);
910 } 919 }
911 920 /* success: reference kept via unmatched get_device() */
921 get_device(&dev->device);
922 publish_vbus_dev_info(dev);
912 mutex_unlock(&dev->visordriver_callback_lock); 923 mutex_unlock(&dev->visordriver_callback_lock);
913 return res; 924 return 0;
914} 925}
915 926
916/* 927/*
917 * visorbus_register_visor_driver() - registers the provided visor driver 928 * visorbus_register_visor_driver() - registers the provided visor driver for
918 * for handling one or more visor device 929 * handling one or more visor device
919 * types (channel_types) 930 * types (channel_types)
920 * @drv: the driver to register 931 * @drv: the driver to register
921 * 932 *
922 * A visor function driver calls this function to register 933 * A visor function driver calls this function to register the driver. The
923 * the driver. The caller MUST fill in the following fields within the 934 * caller MUST fill in the following fields within the #drv structure:
924 * #drv structure:
925 * name, version, owner, channel_types, probe, remove 935 * name, version, owner, channel_types, probe, remove
926 * 936 *
927 * Here's how the whole Linux bus / driver / device model works. 937 * Here's how the whole Linux bus / driver / device model works.
@@ -967,16 +977,12 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
967 /* can't register on a nonexistent bus */ 977 /* can't register on a nonexistent bus */
968 if (!initialized) 978 if (!initialized)
969 return -ENODEV; 979 return -ENODEV;
970
971 if (!drv->probe) 980 if (!drv->probe)
972 return -EINVAL; 981 return -EINVAL;
973
974 if (!drv->remove) 982 if (!drv->remove)
975 return -EINVAL; 983 return -EINVAL;
976
977 if (!drv->pause) 984 if (!drv->pause)
978 return -EINVAL; 985 return -EINVAL;
979
980 if (!drv->resume) 986 if (!drv->resume)
981 return -EINVAL; 987 return -EINVAL;
982 988
@@ -985,7 +991,6 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
985 drv->driver.probe = visordriver_probe_device; 991 drv->driver.probe = visordriver_probe_device;
986 drv->driver.remove = visordriver_remove_device; 992 drv->driver.remove = visordriver_remove_device;
987 drv->driver.owner = drv->owner; 993 drv->driver.owner = drv->owner;
988
989 /* 994 /*
990 * driver_register does this: 995 * driver_register does this:
991 * bus_add_driver(drv) 996 * bus_add_driver(drv)
@@ -998,7 +1003,6 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
998 * if (!drv.probe(dev)) [visordriver_probe_device] 1003 * if (!drv.probe(dev)) [visordriver_probe_device]
999 * dev.drv = NULL 1004 * dev.drv = NULL
1000 */ 1005 */
1001
1002 return driver_register(&drv->driver); 1006 return driver_register(&drv->driver);
1003} 1007}
1004EXPORT_SYMBOL_GPL(visorbus_register_visor_driver); 1008EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
@@ -1019,39 +1023,28 @@ int visorbus_create_instance(struct visor_device *dev)
1019 hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); 1023 hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL);
1020 if (!hdr_info) 1024 if (!hdr_info)
1021 return -ENOMEM; 1025 return -ENOMEM;
1022
1023 dev_set_name(&dev->device, "visorbus%d", id); 1026 dev_set_name(&dev->device, "visorbus%d", id);
1024 dev->device.bus = &visorbus_type; 1027 dev->device.bus = &visorbus_type;
1025 dev->device.groups = visorbus_groups; 1028 dev->device.groups = visorbus_groups;
1026 dev->device.release = visorbus_release_busdevice; 1029 dev->device.release = visorbus_release_busdevice;
1027
1028 dev->debugfs_dir = debugfs_create_dir(dev_name(&dev->device), 1030 dev->debugfs_dir = debugfs_create_dir(dev_name(&dev->device),
1029 visorbus_debugfs_dir); 1031 visorbus_debugfs_dir);
1030 dev->debugfs_client_bus_info = 1032 dev->debugfs_bus_info = debugfs_create_file("client_bus_info", 0440,
1031 debugfs_create_file("client_bus_info", 0440, 1033 dev->debugfs_dir, dev,
1032 dev->debugfs_dir, dev, 1034 &bus_info_debugfs_fops);
1033 &client_bus_info_debugfs_fops);
1034
1035 dev_set_drvdata(&dev->device, dev); 1035 dev_set_drvdata(&dev->device, dev);
1036 err = get_vbus_header_info(dev->visorchannel, &dev->device, hdr_info); 1036 err = get_vbus_header_info(dev->visorchannel, &dev->device, hdr_info);
1037 if (err < 0) 1037 if (err < 0)
1038 goto err_debugfs_dir; 1038 goto err_debugfs_dir;
1039
1040 err = device_register(&dev->device); 1039 err = device_register(&dev->device);
1041 if (err < 0) 1040 if (err < 0)
1042 goto err_debugfs_dir; 1041 goto err_debugfs_dir;
1043
1044 list_add_tail(&dev->list_all, &list_all_bus_instances); 1042 list_add_tail(&dev->list_all, &list_all_bus_instances);
1045
1046 dev->state.created = 1; 1043 dev->state.created = 1;
1047 dev->vbus_hdr_info = (void *)hdr_info; 1044 dev->vbus_hdr_info = (void *)hdr_info;
1048 write_vbus_chp_info(dev->visorchannel, hdr_info, 1045 write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo);
1049 &chipset_driverinfo); 1046 write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo);
1050 write_vbus_bus_info(dev->visorchannel, hdr_info,
1051 &clientbus_driverinfo);
1052
1053 visorbus_response(dev, err, CONTROLVM_BUS_CREATE); 1047 visorbus_response(dev, err, CONTROLVM_BUS_CREATE);
1054
1055 return 0; 1048 return 0;
1056 1049
1057err_debugfs_dir: 1050err_debugfs_dir:
@@ -1075,11 +1068,11 @@ void visorbus_remove_instance(struct visor_device *dev)
1075 * successfully been able to trace thru the code to see where/how 1068 * successfully been able to trace thru the code to see where/how
1076 * release() gets called. But I know it does. 1069 * release() gets called. But I know it does.
1077 */ 1070 */
1078 visorchannel_destroy(dev->visorchannel);
1079 kfree(dev->vbus_hdr_info); 1071 kfree(dev->vbus_hdr_info);
1080 list_del(&dev->list_all); 1072 list_del(&dev->list_all);
1073 if (dev->pending_msg_hdr)
1074 visorbus_response(dev, 0, CONTROLVM_BUS_DESTROY);
1081 device_unregister(&dev->device); 1075 device_unregister(&dev->device);
1082 visorbus_response(dev, 0, CONTROLVM_BUS_DESTROY);
1083} 1076}
1084 1077
1085/* 1078/*
@@ -1090,9 +1083,9 @@ static void remove_all_visor_devices(void)
1090 struct list_head *listentry, *listtmp; 1083 struct list_head *listentry, *listtmp;
1091 1084
1092 list_for_each_safe(listentry, listtmp, &list_all_device_instances) { 1085 list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
1093 struct visor_device *dev = list_entry(listentry, 1086 struct visor_device *dev;
1094 struct visor_device, 1087
1095 list_all); 1088 dev = list_entry(listentry, struct visor_device, list_all);
1096 remove_visor_device(dev); 1089 remove_visor_device(dev);
1097 } 1090 }
1098} 1091}
@@ -1131,7 +1124,6 @@ static void resume_state_change_complete(struct visor_device *dev, int status)
1131 return; 1124 return;
1132 1125
1133 dev->resuming = false; 1126 dev->resuming = false;
1134
1135 /* 1127 /*
1136 * Notify the chipset driver that the resume is complete, 1128 * Notify the chipset driver that the resume is complete,
1137 * which will presumably want to send some sort of response to 1129 * which will presumably want to send some sort of response to
@@ -1156,7 +1148,7 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev,
1156 bool is_pause) 1148 bool is_pause)
1157{ 1149{
1158 int err; 1150 int err;
1159 struct visor_driver *drv = NULL; 1151 struct visor_driver *drv;
1160 1152
1161 /* If no driver associated with the device nothing to pause/resume */ 1153 /* If no driver associated with the device nothing to pause/resume */
1162 if (!dev->device.driver) 1154 if (!dev->device.driver)
@@ -1177,7 +1169,6 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev,
1177 dev->resuming = true; 1169 dev->resuming = true;
1178 err = drv->resume(dev, resume_state_change_complete); 1170 err = drv->resume(dev, resume_state_change_complete);
1179 } 1171 }
1180
1181 return err; 1172 return err;
1182} 1173}
1183 1174
@@ -1198,7 +1189,6 @@ int visorchipset_device_pause(struct visor_device *dev_info)
1198 dev_info->pausing = false; 1189 dev_info->pausing = false;
1199 return err; 1190 return err;
1200 } 1191 }
1201
1202 return 0; 1192 return 0;
1203} 1193}
1204 1194
@@ -1219,7 +1209,6 @@ int visorchipset_device_resume(struct visor_device *dev_info)
1219 dev_info->resuming = false; 1209 dev_info->resuming = false;
1220 return err; 1210 return err;
1221 } 1211 }
1222
1223 return 0; 1212 return 0;
1224} 1213}
1225 1214
@@ -1228,18 +1217,12 @@ int visorbus_init(void)
1228 int err; 1217 int err;
1229 1218
1230 visorbus_debugfs_dir = debugfs_create_dir("visorbus", NULL); 1219 visorbus_debugfs_dir = debugfs_create_dir("visorbus", NULL);
1231 if (!visorbus_debugfs_dir)
1232 return -ENOMEM;
1233
1234 bus_device_info_init(&clientbus_driverinfo, "clientbus", "visorbus"); 1220 bus_device_info_init(&clientbus_driverinfo, "clientbus", "visorbus");
1235
1236 err = bus_register(&visorbus_type); 1221 err = bus_register(&visorbus_type);
1237 if (err < 0) 1222 if (err < 0)
1238 return err; 1223 return err;
1239
1240 initialized = true; 1224 initialized = true;
1241 bus_device_info_init(&chipset_driverinfo, "chipset", "visorchipset"); 1225 bus_device_info_init(&chipset_driverinfo, "chipset", "visorchipset");
1242
1243 return 0; 1226 return 0;
1244} 1227}
1245 1228
@@ -1248,14 +1231,12 @@ void visorbus_exit(void)
1248 struct list_head *listentry, *listtmp; 1231 struct list_head *listentry, *listtmp;
1249 1232
1250 remove_all_visor_devices(); 1233 remove_all_visor_devices();
1251
1252 list_for_each_safe(listentry, listtmp, &list_all_bus_instances) { 1234 list_for_each_safe(listentry, listtmp, &list_all_bus_instances) {
1253 struct visor_device *dev = list_entry(listentry, 1235 struct visor_device *dev;
1254 struct visor_device, 1236
1255 list_all); 1237 dev = list_entry(listentry, struct visor_device, list_all);
1256 visorbus_remove_instance(dev); 1238 visorbus_remove_instance(dev);
1257 } 1239 }
1258
1259 bus_unregister(&visorbus_type); 1240 bus_unregister(&visorbus_type);
1260 initialized = false; 1241 initialized = false;
1261 debugfs_remove_recursive(visorbus_debugfs_dir); 1242 debugfs_remove_recursive(visorbus_debugfs_dir);
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index e878d65ab668..4a8b12d7cfaa 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -23,25 +23,23 @@
23#include "vbuschannel.h" 23#include "vbuschannel.h"
24#include "visorbus.h" 24#include "visorbus.h"
25 25
26struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
27 struct visor_device *from);
26int visorbus_create_instance(struct visor_device *dev); 28int visorbus_create_instance(struct visor_device *dev);
27void visorbus_remove_instance(struct visor_device *bus_info); 29void visorbus_remove_instance(struct visor_device *bus_info);
28int create_visor_device(struct visor_device *dev_info); 30int create_visor_device(struct visor_device *dev_info);
29void remove_visor_device(struct visor_device *dev_info); 31void remove_visor_device(struct visor_device *dev_info);
30int visorchipset_device_pause(struct visor_device *dev_info); 32int visorchipset_device_pause(struct visor_device *dev_info);
31int visorchipset_device_resume(struct visor_device *dev_info); 33int visorchipset_device_resume(struct visor_device *dev_info);
32
33void visorbus_response(struct visor_device *p, int response, int controlvm_id); 34void visorbus_response(struct visor_device *p, int response, int controlvm_id);
34void visorbus_device_changestate_response(struct visor_device *p, int response, 35void visorbus_device_changestate_response(struct visor_device *p, int response,
35 struct visor_segment_state state); 36 struct visor_segment_state state);
36
37int visorbus_init(void); 37int visorbus_init(void);
38void visorbus_exit(void); 38void visorbus_exit(void);
39 39
40/* visorchannel access functions */ 40/* visorchannel access functions */
41struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp, 41struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp,
42 const guid_t *guid); 42 const guid_t *guid, bool needs_lock);
43struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp,
44 const guid_t *guid);
45void visorchannel_destroy(struct visorchannel *channel); 43void visorchannel_destroy(struct visorchannel *channel);
46int visorchannel_read(struct visorchannel *channel, ulong offset, 44int visorchannel_read(struct visorchannel *channel, ulong offset,
47 void *dest, ulong nbytes); 45 void *dest, ulong nbytes);
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 2a000fee3119..aae16073ba03 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/uuid.h> 21#include <linux/uuid.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/slab.h>
23 24
24#include "visorbus.h" 25#include "visorbus.h"
25#include "visorbus_private.h" 26#include "visorbus_private.h"
@@ -41,8 +42,8 @@ struct visorchannel {
41 struct channel_header chan_hdr; 42 struct channel_header chan_hdr;
42 guid_t guid; 43 guid_t guid;
43 /* 44 /*
44 * channel creator knows if more than one 45 * channel creator knows if more than one thread will be inserting or
45 * thread will be inserting or removing 46 * removing
46 */ 47 */
47 bool needs_lock; 48 bool needs_lock;
48 /* protect head writes in chan_hdr */ 49 /* protect head writes in chan_hdr */
@@ -57,6 +58,7 @@ void visorchannel_destroy(struct visorchannel *channel)
57{ 58{
58 if (!channel) 59 if (!channel)
59 return; 60 return;
61
60 if (channel->mapped) { 62 if (channel->mapped) {
61 memunmap(channel->mapped); 63 memunmap(channel->mapped);
62 if (channel->requested) 64 if (channel->requested)
@@ -122,7 +124,6 @@ int visorchannel_read(struct visorchannel *channel, ulong offset, void *dest,
122 return -EIO; 124 return -EIO;
123 125
124 memcpy(dest, channel->mapped + offset, nbytes); 126 memcpy(dest, channel->mapped + offset, nbytes);
125
126 return 0; 127 return 0;
127} 128}
128 129
@@ -140,9 +141,7 @@ int visorchannel_write(struct visorchannel *channel, ulong offset, void *dest,
140 memcpy(((char *)(&channel->chan_hdr)) + offset, 141 memcpy(((char *)(&channel->chan_hdr)) + offset,
141 dest, copy_size); 142 dest, copy_size);
142 } 143 }
143
144 memcpy(channel->mapped + offset, dest, nbytes); 144 memcpy(channel->mapped + offset, dest, nbytes);
145
146 return 0; 145 return 0;
147} 146}
148 147
@@ -173,8 +172,8 @@ static int sig_data_offset(struct channel_header *chan_hdr, int q,
173} 172}
174 173
175/* 174/*
176 * Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back 175 * Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back into
177 * into host memory 176 * host memory
178 */ 177 */
179#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ 178#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
180 visorchannel_write(channel, \ 179 visorchannel_write(channel, \
@@ -226,32 +225,25 @@ static int signalremove_inner(struct visorchannel *channel, u32 queue,
226 error = sig_read_header(channel, queue, &sig_hdr); 225 error = sig_read_header(channel, queue, &sig_hdr);
227 if (error) 226 if (error)
228 return error; 227 return error;
229
230 /* No signals to remove; have caller try again. */ 228 /* No signals to remove; have caller try again. */
231 if (sig_hdr.head == sig_hdr.tail) 229 if (sig_hdr.head == sig_hdr.tail)
232 return -EAGAIN; 230 return -EAGAIN;
233
234 sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; 231 sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
235
236 error = sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg); 232 error = sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg);
237 if (error) 233 if (error)
238 return error; 234 return error;
239
240 sig_hdr.num_received++; 235 sig_hdr.num_received++;
241
242 /* 236 /*
243 * For each data field in SIGNAL_QUEUE_HEADER that was modified, 237 * For each data field in SIGNAL_QUEUE_HEADER that was modified, update
244 * update host memory. Required for channel sync. 238 * host memory. Required for channel sync.
245 */ 239 */
246 mb(); 240 mb();
247
248 error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail); 241 error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail);
249 if (error) 242 if (error)
250 return error; 243 return error;
251 error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received); 244 error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received);
252 if (error) 245 if (error)
253 return error; 246 return error;
254
255 return 0; 247 return 0;
256} 248}
257 249
@@ -288,13 +280,12 @@ static bool queue_empty(struct visorchannel *channel, u32 queue)
288 280
289 if (sig_read_header(channel, queue, &sig_hdr)) 281 if (sig_read_header(channel, queue, &sig_hdr))
290 return true; 282 return true;
291
292 return (sig_hdr.head == sig_hdr.tail); 283 return (sig_hdr.head == sig_hdr.tail);
293} 284}
294 285
295/** 286/**
296 * visorchannel_signalempty() - checks if the designated channel/queue 287 * visorchannel_signalempty() - checks if the designated channel/queue contains
297 * contains any messages 288 * any messages
298 * @channel: the channel to query 289 * @channel: the channel to query
299 * @queue: the queue in the channel to query 290 * @queue: the queue in the channel to query
300 * 291 *
@@ -308,11 +299,9 @@ bool visorchannel_signalempty(struct visorchannel *channel, u32 queue)
308 299
309 if (!channel->needs_lock) 300 if (!channel->needs_lock)
310 return queue_empty(channel, queue); 301 return queue_empty(channel, queue);
311
312 spin_lock_irqsave(&channel->remove_lock, flags); 302 spin_lock_irqsave(&channel->remove_lock, flags);
313 rc = queue_empty(channel, queue); 303 rc = queue_empty(channel, queue);
314 spin_unlock_irqrestore(&channel->remove_lock, flags); 304 spin_unlock_irqrestore(&channel->remove_lock, flags);
315
316 return rc; 305 return rc;
317} 306}
318EXPORT_SYMBOL_GPL(visorchannel_signalempty); 307EXPORT_SYMBOL_GPL(visorchannel_signalempty);
@@ -326,7 +315,6 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue,
326 err = sig_read_header(channel, queue, &sig_hdr); 315 err = sig_read_header(channel, queue, &sig_hdr);
327 if (err) 316 if (err)
328 return err; 317 return err;
329
330 sig_hdr.head = (sig_hdr.head + 1) % sig_hdr.max_slots; 318 sig_hdr.head = (sig_hdr.head + 1) % sig_hdr.max_slots;
331 if (sig_hdr.head == sig_hdr.tail) { 319 if (sig_hdr.head == sig_hdr.tail) {
332 sig_hdr.num_overflows++; 320 sig_hdr.num_overflows++;
@@ -335,33 +323,28 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue,
335 return err; 323 return err;
336 return -EIO; 324 return -EIO;
337 } 325 }
338
339 err = sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg); 326 err = sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg);
340 if (err) 327 if (err)
341 return err; 328 return err;
342
343 sig_hdr.num_sent++; 329 sig_hdr.num_sent++;
344
345 /* 330 /*
346 * For each data field in SIGNAL_QUEUE_HEADER that was modified, 331 * For each data field in SIGNAL_QUEUE_HEADER that was modified, update
347 * update host memory. Required for channel sync. 332 * host memory. Required for channel sync.
348 */ 333 */
349 mb(); 334 mb();
350
351 err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, head); 335 err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, head);
352 if (err) 336 if (err)
353 return err; 337 return err;
354 err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent); 338 err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent);
355 if (err) 339 if (err)
356 return err; 340 return err;
357
358 return 0; 341 return 0;
359} 342}
360 343
361/* 344/*
362 * visorchannel_create_guts() - creates the struct visorchannel abstraction 345 * visorchannel_create() - creates the struct visorchannel abstraction for a
363 * for a data area in memory, but does NOT modify 346 * data area in memory, but does NOT modify this data
364 * this data area 347 * area
365 * @physaddr: physical address of start of channel 348 * @physaddr: physical address of start of channel
366 * @gfp: gfp_t to use when allocating memory for the data struct 349 * @gfp: gfp_t to use when allocating memory for the data struct
367 * @guid: GUID that identifies channel type; 350 * @guid: GUID that identifies channel type;
@@ -372,9 +355,8 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue,
372 * Return: pointer to visorchannel that was created if successful, 355 * Return: pointer to visorchannel that was created if successful,
373 * otherwise NULL 356 * otherwise NULL
374 */ 357 */
375static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp, 358struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp,
376 const guid_t *guid, 359 const guid_t *guid, bool needs_lock)
377 bool needs_lock)
378{ 360{
379 struct visorchannel *channel; 361 struct visorchannel *channel;
380 int err; 362 int err;
@@ -386,37 +368,30 @@ static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp,
386 channel = kzalloc(sizeof(*channel), gfp); 368 channel = kzalloc(sizeof(*channel), gfp);
387 if (!channel) 369 if (!channel)
388 return NULL; 370 return NULL;
389
390 channel->needs_lock = needs_lock; 371 channel->needs_lock = needs_lock;
391 spin_lock_init(&channel->insert_lock); 372 spin_lock_init(&channel->insert_lock);
392 spin_lock_init(&channel->remove_lock); 373 spin_lock_init(&channel->remove_lock);
393
394 /* 374 /*
395 * Video driver constains the efi framebuffer so it will get a 375 * Video driver constains the efi framebuffer so it will get a conflict
396 * conflict resource when requesting its full mem region. Since 376 * resource when requesting its full mem region. Since we are only
397 * we are only using the efi framebuffer for video we can ignore 377 * using the efi framebuffer for video we can ignore this. Remember that
398 * this. Remember that we haven't requested it so we don't try to 378 * we haven't requested it so we don't try to release later on.
399 * release later on.
400 */ 379 */
401 channel->requested = request_mem_region(physaddr, size, VISOR_DRV_NAME); 380 channel->requested = request_mem_region(physaddr, size, VISOR_DRV_NAME);
402 if (!channel->requested && !guid_equal(guid, &visor_video_guid)) 381 if (!channel->requested && !guid_equal(guid, &visor_video_guid))
403 /* we only care about errors if this is not the video channel */ 382 /* we only care about errors if this is not the video channel */
404 goto err_destroy_channel; 383 goto err_destroy_channel;
405
406 channel->mapped = memremap(physaddr, size, MEMREMAP_WB); 384 channel->mapped = memremap(physaddr, size, MEMREMAP_WB);
407 if (!channel->mapped) { 385 if (!channel->mapped) {
408 release_mem_region(physaddr, size); 386 release_mem_region(physaddr, size);
409 goto err_destroy_channel; 387 goto err_destroy_channel;
410 } 388 }
411
412 channel->physaddr = physaddr; 389 channel->physaddr = physaddr;
413 channel->nbytes = size; 390 channel->nbytes = size;
414
415 err = visorchannel_read(channel, 0, &channel->chan_hdr, size); 391 err = visorchannel_read(channel, 0, &channel->chan_hdr, size);
416 if (err) 392 if (err)
417 goto err_destroy_channel; 393 goto err_destroy_channel;
418 size = (ulong)channel->chan_hdr.size; 394 size = (ulong)channel->chan_hdr.size;
419
420 memunmap(channel->mapped); 395 memunmap(channel->mapped);
421 if (channel->requested) 396 if (channel->requested)
422 release_mem_region(channel->physaddr, channel->nbytes); 397 release_mem_region(channel->physaddr, channel->nbytes);
@@ -426,13 +401,11 @@ static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp,
426 if (!channel->requested && !guid_equal(guid, &visor_video_guid)) 401 if (!channel->requested && !guid_equal(guid, &visor_video_guid))
427 /* we only care about errors if this is not the video channel */ 402 /* we only care about errors if this is not the video channel */
428 goto err_destroy_channel; 403 goto err_destroy_channel;
429
430 channel->mapped = memremap(channel->physaddr, size, MEMREMAP_WB); 404 channel->mapped = memremap(channel->physaddr, size, MEMREMAP_WB);
431 if (!channel->mapped) { 405 if (!channel->mapped) {
432 release_mem_region(channel->physaddr, size); 406 release_mem_region(channel->physaddr, size);
433 goto err_destroy_channel; 407 goto err_destroy_channel;
434 } 408 }
435
436 channel->nbytes = size; 409 channel->nbytes = size;
437 guid_copy(&channel->guid, guid); 410 guid_copy(&channel->guid, guid);
438 return channel; 411 return channel;
@@ -442,18 +415,6 @@ err_destroy_channel:
442 return NULL; 415 return NULL;
443} 416}
444 417
445struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp,
446 const guid_t *guid)
447{
448 return visorchannel_create_guts(physaddr, gfp, guid, false);
449}
450
451struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp,
452 const guid_t *guid)
453{
454 return visorchannel_create_guts(physaddr, gfp, guid, true);
455}
456
457/** 418/**
458 * visorchannel_signalinsert() - inserts a message into the designated 419 * visorchannel_signalinsert() - inserts a message into the designated
459 * channel/queue 420 * channel/queue
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 27ecf6fb49fd..fed554a43151 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -27,8 +27,8 @@ static const guid_t visor_vhba_channel_guid = VISOR_VHBA_CHANNEL_GUID;
27static const guid_t visor_siovm_guid = VISOR_SIOVM_GUID; 27static const guid_t visor_siovm_guid = VISOR_SIOVM_GUID;
28static const guid_t visor_controlvm_channel_guid = VISOR_CONTROLVM_CHANNEL_GUID; 28static const guid_t visor_controlvm_channel_guid = VISOR_CONTROLVM_CHANNEL_GUID;
29 29
30#define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 30#define POLLJIFFIES_CONTROLVM_FAST 1
31#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 31#define POLLJIFFIES_CONTROLVM_SLOW 100
32 32
33#define MAX_CONTROLVM_PAYLOAD_BYTES (1024 * 128) 33#define MAX_CONTROLVM_PAYLOAD_BYTES (1024 * 128)
34 34
@@ -128,7 +128,6 @@ static ssize_t toolaction_show(struct device *dev,
128 &tool_action, sizeof(u8)); 128 &tool_action, sizeof(u8));
129 if (err) 129 if (err)
130 return err; 130 return err;
131
132 return sprintf(buf, "%u\n", tool_action); 131 return sprintf(buf, "%u\n", tool_action);
133} 132}
134 133
@@ -141,7 +140,6 @@ static ssize_t toolaction_store(struct device *dev,
141 140
142 if (kstrtou8(buf, 10, &tool_action)) 141 if (kstrtou8(buf, 10, &tool_action))
143 return -EINVAL; 142 return -EINVAL;
144
145 err = visorchannel_write(chipset_dev->controlvm_channel, 143 err = visorchannel_write(chipset_dev->controlvm_channel,
146 offsetof(struct visor_controlvm_channel, 144 offsetof(struct visor_controlvm_channel,
147 tool_action), 145 tool_action),
@@ -178,7 +176,6 @@ static ssize_t boottotool_store(struct device *dev,
178 176
179 if (kstrtoint(buf, 10, &val)) 177 if (kstrtoint(buf, 10, &val))
180 return -EINVAL; 178 return -EINVAL;
181
182 efi_visor_indication.boot_to_tool = val; 179 efi_visor_indication.boot_to_tool = val;
183 err = visorchannel_write(chipset_dev->controlvm_channel, 180 err = visorchannel_write(chipset_dev->controlvm_channel,
184 offsetof(struct visor_controlvm_channel, 181 offsetof(struct visor_controlvm_channel,
@@ -214,7 +211,6 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
214 211
215 if (kstrtou32(buf, 10, &error)) 212 if (kstrtou32(buf, 10, &error))
216 return -EINVAL; 213 return -EINVAL;
217
218 err = visorchannel_write(chipset_dev->controlvm_channel, 214 err = visorchannel_write(chipset_dev->controlvm_channel,
219 offsetof(struct visor_controlvm_channel, 215 offsetof(struct visor_controlvm_channel,
220 installation_error), 216 installation_error),
@@ -237,7 +233,6 @@ static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
237 &text_id, sizeof(u32)); 233 &text_id, sizeof(u32));
238 if (err) 234 if (err)
239 return err; 235 return err;
240
241 return sprintf(buf, "%u\n", text_id); 236 return sprintf(buf, "%u\n", text_id);
242} 237}
243 238
@@ -249,7 +244,6 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
249 244
250 if (kstrtou32(buf, 10, &text_id)) 245 if (kstrtou32(buf, 10, &text_id))
251 return -EINVAL; 246 return -EINVAL;
252
253 err = visorchannel_write(chipset_dev->controlvm_channel, 247 err = visorchannel_write(chipset_dev->controlvm_channel,
254 offsetof(struct visor_controlvm_channel, 248 offsetof(struct visor_controlvm_channel,
255 installation_text_id), 249 installation_text_id),
@@ -272,7 +266,6 @@ static ssize_t remaining_steps_show(struct device *dev,
272 &remaining_steps, sizeof(u16)); 266 &remaining_steps, sizeof(u16));
273 if (err) 267 if (err)
274 return err; 268 return err;
275
276 return sprintf(buf, "%hu\n", remaining_steps); 269 return sprintf(buf, "%hu\n", remaining_steps);
277} 270}
278 271
@@ -285,7 +278,6 @@ static ssize_t remaining_steps_store(struct device *dev,
285 278
286 if (kstrtou16(buf, 10, &remaining_steps)) 279 if (kstrtou16(buf, 10, &remaining_steps))
287 return -EINVAL; 280 return -EINVAL;
288
289 err = visorchannel_write(chipset_dev->controlvm_channel, 281 err = visorchannel_write(chipset_dev->controlvm_channel,
290 offsetof(struct visor_controlvm_channel, 282 offsetof(struct visor_controlvm_channel,
291 installation_remaining_steps), 283 installation_remaining_steps),
@@ -296,43 +288,6 @@ static ssize_t remaining_steps_store(struct device *dev,
296} 288}
297static DEVICE_ATTR_RW(remaining_steps); 289static DEVICE_ATTR_RW(remaining_steps);
298 290
299struct visor_busdev {
300 u32 bus_no;
301 u32 dev_no;
302};
303
304static int match_visorbus_dev_by_id(struct device *dev, void *data)
305{
306 struct visor_device *vdev = to_visor_device(dev);
307 struct visor_busdev *id = data;
308
309 if ((vdev->chipset_bus_no == id->bus_no) &&
310 (vdev->chipset_dev_no == id->dev_no))
311 return 1;
312
313 return 0;
314}
315
316struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
317 struct visor_device *from)
318{
319 struct device *dev;
320 struct device *dev_start = NULL;
321 struct visor_device *vdev = NULL;
322 struct visor_busdev id = {
323 .bus_no = bus_no,
324 .dev_no = dev_no
325 };
326
327 if (from)
328 dev_start = &from->device;
329 dev = bus_find_device(&visorbus_type, dev_start, (void *)&id,
330 match_visorbus_dev_by_id);
331 if (dev)
332 vdev = to_visor_device(dev);
333 return vdev;
334}
335
336static void controlvm_init_response(struct controlvm_message *msg, 291static void controlvm_init_response(struct controlvm_message *msg,
337 struct controlvm_message_header *msg_hdr, 292 struct controlvm_message_header *msg_hdr,
338 int response) 293 int response)
@@ -374,18 +329,13 @@ static int chipset_init(struct controlvm_message *inmsg)
374 goto out_respond; 329 goto out_respond;
375 } 330 }
376 chipset_inited = 1; 331 chipset_inited = 1;
377
378 /* 332 /*
379 * Set features to indicate we support parahotplug (if Command also 333 * Set features to indicate we support parahotplug (if Command also
380 * supports it). 334 * supports it). Set the "reply" bit so Command knows this is a
335 * features-aware driver.
381 */ 336 */
382 features = inmsg->cmd.init_chipset.features & 337 features = inmsg->cmd.init_chipset.features &
383 VISOR_CHIPSET_FEATURE_PARA_HOTPLUG; 338 VISOR_CHIPSET_FEATURE_PARA_HOTPLUG;
384
385 /*
386 * Set the "reply" bit so Command knows this is a features-aware
387 * driver.
388 */
389 features |= VISOR_CHIPSET_FEATURE_REPLY; 339 features |= VISOR_CHIPSET_FEATURE_REPLY;
390 340
391out_respond: 341out_respond:
@@ -396,20 +346,17 @@ out_respond:
396} 346}
397 347
398static int controlvm_respond(struct controlvm_message_header *msg_hdr, 348static int controlvm_respond(struct controlvm_message_header *msg_hdr,
399 int response, 349 int response, struct visor_segment_state *state)
400 struct visor_segment_state *state)
401{ 350{
402 struct controlvm_message outmsg; 351 struct controlvm_message outmsg;
403 352
404 controlvm_init_response(&outmsg, msg_hdr, response); 353 controlvm_init_response(&outmsg, msg_hdr, response);
405 if (outmsg.hdr.flags.test_message == 1) 354 if (outmsg.hdr.flags.test_message == 1)
406 return -EINVAL; 355 return -EINVAL;
407
408 if (state) { 356 if (state) {
409 outmsg.cmd.device_change_state.state = *state; 357 outmsg.cmd.device_change_state.state = *state;
410 outmsg.cmd.device_change_state.flags.phys_device = 1; 358 outmsg.cmd.device_change_state.flags.phys_device = 1;
411 } 359 }
412
413 return visorchannel_signalinsert(chipset_dev->controlvm_channel, 360 return visorchannel_signalinsert(chipset_dev->controlvm_channel,
414 CONTROLVM_QUEUE_REQUEST, &outmsg); 361 CONTROLVM_QUEUE_REQUEST, &outmsg);
415} 362}
@@ -435,13 +382,11 @@ static int save_crash_message(struct controlvm_message *msg,
435 "failed to read message count\n"); 382 "failed to read message count\n");
436 return err; 383 return err;
437 } 384 }
438
439 if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { 385 if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
440 dev_err(&chipset_dev->acpi_device->dev, 386 dev_err(&chipset_dev->acpi_device->dev,
441 "invalid number of messages\n"); 387 "invalid number of messages\n");
442 return -EIO; 388 return -EIO;
443 } 389 }
444
445 err = visorchannel_read(chipset_dev->controlvm_channel, 390 err = visorchannel_read(chipset_dev->controlvm_channel,
446 offsetof(struct visor_controlvm_channel, 391 offsetof(struct visor_controlvm_channel,
447 saved_crash_message_offset), 392 saved_crash_message_offset),
@@ -451,13 +396,11 @@ static int save_crash_message(struct controlvm_message *msg,
451 "failed to read offset\n"); 396 "failed to read offset\n");
452 return err; 397 return err;
453 } 398 }
454
455 switch (cr_type) { 399 switch (cr_type) {
456 case CRASH_DEV: 400 case CRASH_DEV:
457 local_crash_msg_offset += sizeof(struct controlvm_message); 401 local_crash_msg_offset += sizeof(struct controlvm_message);
458 err = visorchannel_write(chipset_dev->controlvm_channel, 402 err = visorchannel_write(chipset_dev->controlvm_channel,
459 local_crash_msg_offset, 403 local_crash_msg_offset, msg,
460 msg,
461 sizeof(struct controlvm_message)); 404 sizeof(struct controlvm_message));
462 if (err) { 405 if (err) {
463 dev_err(&chipset_dev->acpi_device->dev, 406 dev_err(&chipset_dev->acpi_device->dev,
@@ -467,8 +410,7 @@ static int save_crash_message(struct controlvm_message *msg,
467 break; 410 break;
468 case CRASH_BUS: 411 case CRASH_BUS:
469 err = visorchannel_write(chipset_dev->controlvm_channel, 412 err = visorchannel_write(chipset_dev->controlvm_channel,
470 local_crash_msg_offset, 413 local_crash_msg_offset, msg,
471 msg,
472 sizeof(struct controlvm_message)); 414 sizeof(struct controlvm_message));
473 if (err) { 415 if (err) {
474 dev_err(&chipset_dev->acpi_device->dev, 416 dev_err(&chipset_dev->acpi_device->dev,
@@ -488,33 +430,25 @@ static int controlvm_responder(enum controlvm_id cmd_id,
488 struct controlvm_message_header *pending_msg_hdr, 430 struct controlvm_message_header *pending_msg_hdr,
489 int response) 431 int response)
490{ 432{
491 if (!pending_msg_hdr)
492 return -EIO;
493
494 if (pending_msg_hdr->id != (u32)cmd_id) 433 if (pending_msg_hdr->id != (u32)cmd_id)
495 return -EINVAL; 434 return -EINVAL;
496 435
497 return controlvm_respond(pending_msg_hdr, response, NULL); 436 return controlvm_respond(pending_msg_hdr, response, NULL);
498} 437}
499 438
500static int device_changestate_responder( 439static int device_changestate_responder(enum controlvm_id cmd_id,
501 enum controlvm_id cmd_id, 440 struct visor_device *p, int response,
502 struct visor_device *p, int response, 441 struct visor_segment_state state)
503 struct visor_segment_state response_state)
504{ 442{
505 struct controlvm_message outmsg; 443 struct controlvm_message outmsg;
506 444
507 if (!p->pending_msg_hdr)
508 return -EIO;
509 if (p->pending_msg_hdr->id != cmd_id) 445 if (p->pending_msg_hdr->id != cmd_id)
510 return -EINVAL; 446 return -EINVAL;
511 447
512 controlvm_init_response(&outmsg, p->pending_msg_hdr, response); 448 controlvm_init_response(&outmsg, p->pending_msg_hdr, response);
513
514 outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no; 449 outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no;
515 outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no; 450 outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no;
516 outmsg.cmd.device_change_state.state = response_state; 451 outmsg.cmd.device_change_state.state = state;
517
518 return visorchannel_signalinsert(chipset_dev->controlvm_channel, 452 return visorchannel_signalinsert(chipset_dev->controlvm_channel,
519 CONTROLVM_QUEUE_REQUEST, &outmsg); 453 CONTROLVM_QUEUE_REQUEST, &outmsg);
520} 454}
@@ -522,64 +456,55 @@ static int device_changestate_responder(
522static int visorbus_create(struct controlvm_message *inmsg) 456static int visorbus_create(struct controlvm_message *inmsg)
523{ 457{
524 struct controlvm_message_packet *cmd = &inmsg->cmd; 458 struct controlvm_message_packet *cmd = &inmsg->cmd;
525 struct controlvm_message_header *pmsg_hdr = NULL; 459 struct controlvm_message_header *pmsg_hdr;
526 u32 bus_no = cmd->create_bus.bus_no; 460 u32 bus_no = cmd->create_bus.bus_no;
527 struct visor_device *bus_info; 461 struct visor_device *bus_info;
528 struct visorchannel *visorchannel; 462 struct visorchannel *visorchannel;
529 int err; 463 int err;
530 464
531 bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); 465 bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL);
532 if (bus_info && (bus_info->state.created == 1)) { 466 if (bus_info && bus_info->state.created == 1) {
533 dev_err(&chipset_dev->acpi_device->dev, 467 dev_err(&chipset_dev->acpi_device->dev,
534 "failed %s: already exists\n", __func__); 468 "failed %s: already exists\n", __func__);
535 err = -EEXIST; 469 err = -EEXIST;
536 goto err_respond; 470 goto err_respond;
537 } 471 }
538
539 bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL); 472 bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
540 if (!bus_info) { 473 if (!bus_info) {
541 err = -ENOMEM; 474 err = -ENOMEM;
542 goto err_respond; 475 goto err_respond;
543 } 476 }
544
545 INIT_LIST_HEAD(&bus_info->list_all); 477 INIT_LIST_HEAD(&bus_info->list_all);
546 bus_info->chipset_bus_no = bus_no; 478 bus_info->chipset_bus_no = bus_no;
547 bus_info->chipset_dev_no = BUS_ROOT_DEVICE; 479 bus_info->chipset_dev_no = BUS_ROOT_DEVICE;
548
549 if (guid_equal(&cmd->create_bus.bus_inst_guid, &visor_siovm_guid)) { 480 if (guid_equal(&cmd->create_bus.bus_inst_guid, &visor_siovm_guid)) {
550 err = save_crash_message(inmsg, CRASH_BUS); 481 err = save_crash_message(inmsg, CRASH_BUS);
551 if (err) 482 if (err)
552 goto err_free_bus_info; 483 goto err_free_bus_info;
553 } 484 }
554
555 if (inmsg->hdr.flags.response_expected == 1) { 485 if (inmsg->hdr.flags.response_expected == 1) {
556 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), 486 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
557 GFP_KERNEL);
558 if (!pmsg_hdr) { 487 if (!pmsg_hdr) {
559 err = -ENOMEM; 488 err = -ENOMEM;
560 goto err_free_bus_info; 489 goto err_free_bus_info;
561 } 490 }
562
563 memcpy(pmsg_hdr, &inmsg->hdr, 491 memcpy(pmsg_hdr, &inmsg->hdr,
564 sizeof(struct controlvm_message_header)); 492 sizeof(struct controlvm_message_header));
565 bus_info->pending_msg_hdr = pmsg_hdr; 493 bus_info->pending_msg_hdr = pmsg_hdr;
566 } 494 }
567
568 visorchannel = visorchannel_create(cmd->create_bus.channel_addr, 495 visorchannel = visorchannel_create(cmd->create_bus.channel_addr,
569 GFP_KERNEL, 496 GFP_KERNEL,
570 &cmd->create_bus.bus_data_type_guid); 497 &cmd->create_bus.bus_data_type_guid,
498 false);
571 if (!visorchannel) { 499 if (!visorchannel) {
572 err = -ENOMEM; 500 err = -ENOMEM;
573 goto err_free_pending_msg; 501 goto err_free_pending_msg;
574 } 502 }
575
576 bus_info->visorchannel = visorchannel; 503 bus_info->visorchannel = visorchannel;
577
578 /* Response will be handled by visorbus_create_instance on success */ 504 /* Response will be handled by visorbus_create_instance on success */
579 err = visorbus_create_instance(bus_info); 505 err = visorbus_create_instance(bus_info);
580 if (err) 506 if (err)
581 goto err_destroy_channel; 507 goto err_destroy_channel;
582
583 return 0; 508 return 0;
584 509
585err_destroy_channel: 510err_destroy_channel:
@@ -599,9 +524,8 @@ err_respond:
599 524
600static int visorbus_destroy(struct controlvm_message *inmsg) 525static int visorbus_destroy(struct controlvm_message *inmsg)
601{ 526{
602 struct controlvm_message_packet *cmd = &inmsg->cmd; 527 struct controlvm_message_header *pmsg_hdr;
603 struct controlvm_message_header *pmsg_hdr = NULL; 528 u32 bus_no = inmsg->cmd.destroy_bus.bus_no;
604 u32 bus_no = cmd->destroy_bus.bus_no;
605 struct visor_device *bus_info; 529 struct visor_device *bus_info;
606 int err; 530 int err;
607 531
@@ -625,12 +549,10 @@ static int visorbus_destroy(struct controlvm_message *inmsg)
625 err = -ENOMEM; 549 err = -ENOMEM;
626 goto err_respond; 550 goto err_respond;
627 } 551 }
628
629 memcpy(pmsg_hdr, &inmsg->hdr, 552 memcpy(pmsg_hdr, &inmsg->hdr,
630 sizeof(struct controlvm_message_header)); 553 sizeof(struct controlvm_message_header));
631 bus_info->pending_msg_hdr = pmsg_hdr; 554 bus_info->pending_msg_hdr = pmsg_hdr;
632 } 555 }
633
634 /* Response will be handled by visorbus_remove_instance */ 556 /* Response will be handled by visorbus_remove_instance */
635 visorbus_remove_instance(bus_info); 557 visorbus_remove_instance(bus_info);
636 return 0; 558 return 0;
@@ -646,51 +568,33 @@ static const guid_t *parser_id_get(struct parser_context *ctx)
646 return &ctx->data.id; 568 return &ctx->data.id;
647} 569}
648 570
649static void *parser_string_get(struct parser_context *ctx) 571static void *parser_string_get(u8 *pscan, int nscan)
650{ 572{
651 u8 *pscan;
652 unsigned long nscan;
653 int value_length; 573 int value_length;
654 void *value; 574 void *value;
655 int i;
656 575
657 pscan = ctx->curr;
658 if (!pscan)
659 return NULL;
660 nscan = ctx->bytes_remaining;
661 if (nscan == 0) 576 if (nscan == 0)
662 return NULL; 577 return NULL;
663 578
664 for (i = 0, value_length = -1; i < nscan; i++) 579 value_length = strnlen(pscan, nscan);
665 if (pscan[i] == '\0') { 580 value = kzalloc(value_length + 1, GFP_KERNEL);
666 value_length = i;
667 break;
668 }
669 /* '\0' was not included in the length */
670 if (value_length < 0)
671 value_length = nscan;
672
673 value = kmalloc(value_length + 1, GFP_KERNEL);
674 if (!value) 581 if (!value)
675 return NULL; 582 return NULL;
676 if (value_length > 0) 583 if (value_length > 0)
677 memcpy(value, pscan, value_length); 584 memcpy(value, pscan, value_length);
678 ((u8 *)(value))[value_length] = '\0';
679 return value; 585 return value;
680} 586}
681 587
682static void *parser_name_get(struct parser_context *ctx) 588static void *parser_name_get(struct parser_context *ctx)
683{ 589{
684 struct visor_controlvm_parameters_header *phdr = NULL; 590 struct visor_controlvm_parameters_header *phdr;
685 591
686 phdr = &ctx->data; 592 phdr = &ctx->data;
687
688 if (phdr->name_offset + phdr->name_length > ctx->param_bytes) 593 if (phdr->name_offset + phdr->name_length > ctx->param_bytes)
689 return NULL; 594 return NULL;
690
691 ctx->curr = (char *)&phdr + phdr->name_offset; 595 ctx->curr = (char *)&phdr + phdr->name_offset;
692 ctx->bytes_remaining = phdr->name_length; 596 ctx->bytes_remaining = phdr->name_length;
693 return parser_string_get(ctx); 597 return parser_string_get(ctx->curr, phdr->name_length);
694} 598}
695 599
696static int visorbus_configure(struct controlvm_message *inmsg, 600static int visorbus_configure(struct controlvm_message *inmsg,
@@ -715,20 +619,16 @@ static int visorbus_configure(struct controlvm_message *inmsg,
715 err = -EIO; 619 err = -EIO;
716 goto err_respond; 620 goto err_respond;
717 } 621 }
718 622 err = visorchannel_set_clientpartition(bus_info->visorchannel,
719 err = visorchannel_set_clientpartition 623 cmd->configure_bus.guest_handle);
720 (bus_info->visorchannel,
721 cmd->configure_bus.guest_handle);
722 if (err) 624 if (err)
723 goto err_respond; 625 goto err_respond;
724
725 if (parser_ctx) { 626 if (parser_ctx) {
726 const guid_t *partition_guid = parser_id_get(parser_ctx); 627 const guid_t *partition_guid = parser_id_get(parser_ctx);
727 628
728 guid_copy(&bus_info->partition_guid, partition_guid); 629 guid_copy(&bus_info->partition_guid, partition_guid);
729 bus_info->name = parser_name_get(parser_ctx); 630 bus_info->name = parser_name_get(parser_ctx);
730 } 631 }
731
732 if (inmsg->hdr.flags.response_expected == 1) 632 if (inmsg->hdr.flags.response_expected == 1)
733 controlvm_responder(inmsg->hdr.id, &inmsg->hdr, err); 633 controlvm_responder(inmsg->hdr.id, &inmsg->hdr, err);
734 return 0; 634 return 0;
@@ -744,10 +644,10 @@ err_respond:
744static int visorbus_device_create(struct controlvm_message *inmsg) 644static int visorbus_device_create(struct controlvm_message *inmsg)
745{ 645{
746 struct controlvm_message_packet *cmd = &inmsg->cmd; 646 struct controlvm_message_packet *cmd = &inmsg->cmd;
747 struct controlvm_message_header *pmsg_hdr = NULL; 647 struct controlvm_message_header *pmsg_hdr;
748 u32 bus_no = cmd->create_device.bus_no; 648 u32 bus_no = cmd->create_device.bus_no;
749 u32 dev_no = cmd->create_device.dev_no; 649 u32 dev_no = cmd->create_device.dev_no;
750 struct visor_device *dev_info = NULL; 650 struct visor_device *dev_info;
751 struct visor_device *bus_info; 651 struct visor_device *bus_info;
752 struct visorchannel *visorchannel; 652 struct visorchannel *visorchannel;
753 int err; 653 int err;
@@ -765,9 +665,8 @@ static int visorbus_device_create(struct controlvm_message *inmsg)
765 err = -EINVAL; 665 err = -EINVAL;
766 goto err_respond; 666 goto err_respond;
767 } 667 }
768
769 dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); 668 dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
770 if (dev_info && (dev_info->state.created == 1)) { 669 if (dev_info && dev_info->state.created == 1) {
771 dev_err(&chipset_dev->acpi_device->dev, 670 dev_err(&chipset_dev->acpi_device->dev,
772 "failed to get bus by id: %d/%d\n", bus_no, dev_no); 671 "failed to get bus by id: %d/%d\n", bus_no, dev_no);
773 err = -EEXIST; 672 err = -EEXIST;
@@ -779,16 +678,14 @@ static int visorbus_device_create(struct controlvm_message *inmsg)
779 err = -ENOMEM; 678 err = -ENOMEM;
780 goto err_respond; 679 goto err_respond;
781 } 680 }
782
783 dev_info->chipset_bus_no = bus_no; 681 dev_info->chipset_bus_no = bus_no;
784 dev_info->chipset_dev_no = dev_no; 682 dev_info->chipset_dev_no = dev_no;
785 guid_copy(&dev_info->inst, &cmd->create_device.dev_inst_guid); 683 guid_copy(&dev_info->inst, &cmd->create_device.dev_inst_guid);
786 dev_info->device.parent = &bus_info->device; 684 dev_info->device.parent = &bus_info->device;
787 685 visorchannel = visorchannel_create(cmd->create_device.channel_addr,
788 visorchannel = 686 GFP_KERNEL,
789 visorchannel_create_with_lock(cmd->create_device.channel_addr, 687 &cmd->create_device.data_type_guid,
790 GFP_KERNEL, 688 true);
791 &cmd->create_device.data_type_guid);
792 if (!visorchannel) { 689 if (!visorchannel) {
793 dev_err(&chipset_dev->acpi_device->dev, 690 dev_err(&chipset_dev->acpi_device->dev,
794 "failed to create visorchannel: %d/%d\n", 691 "failed to create visorchannel: %d/%d\n",
@@ -797,20 +694,20 @@ static int visorbus_device_create(struct controlvm_message *inmsg)
797 goto err_free_dev_info; 694 goto err_free_dev_info;
798 } 695 }
799 dev_info->visorchannel = visorchannel; 696 dev_info->visorchannel = visorchannel;
800 guid_copy(&dev_info->channel_type_guid, &cmd->create_device.data_type_guid); 697 guid_copy(&dev_info->channel_type_guid,
801 if (guid_equal(&cmd->create_device.data_type_guid, &visor_vhba_channel_guid)) { 698 &cmd->create_device.data_type_guid);
699 if (guid_equal(&cmd->create_device.data_type_guid,
700 &visor_vhba_channel_guid)) {
802 err = save_crash_message(inmsg, CRASH_DEV); 701 err = save_crash_message(inmsg, CRASH_DEV);
803 if (err) 702 if (err)
804 goto err_destroy_visorchannel; 703 goto err_destroy_visorchannel;
805 } 704 }
806
807 if (inmsg->hdr.flags.response_expected == 1) { 705 if (inmsg->hdr.flags.response_expected == 1) {
808 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); 706 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
809 if (!pmsg_hdr) { 707 if (!pmsg_hdr) {
810 err = -ENOMEM; 708 err = -ENOMEM;
811 goto err_destroy_visorchannel; 709 goto err_destroy_visorchannel;
812 } 710 }
813
814 memcpy(pmsg_hdr, &inmsg->hdr, 711 memcpy(pmsg_hdr, &inmsg->hdr,
815 sizeof(struct controlvm_message_header)); 712 sizeof(struct controlvm_message_header));
816 dev_info->pending_msg_hdr = pmsg_hdr; 713 dev_info->pending_msg_hdr = pmsg_hdr;
@@ -837,7 +734,7 @@ err_respond:
837static int visorbus_device_changestate(struct controlvm_message *inmsg) 734static int visorbus_device_changestate(struct controlvm_message *inmsg)
838{ 735{
839 struct controlvm_message_packet *cmd = &inmsg->cmd; 736 struct controlvm_message_packet *cmd = &inmsg->cmd;
840 struct controlvm_message_header *pmsg_hdr = NULL; 737 struct controlvm_message_header *pmsg_hdr;
841 u32 bus_no = cmd->device_change_state.bus_no; 738 u32 bus_no = cmd->device_change_state.bus_no;
842 u32 dev_no = cmd->device_change_state.dev_no; 739 u32 dev_no = cmd->device_change_state.dev_no;
843 struct visor_segment_state state = cmd->device_change_state.state; 740 struct visor_segment_state state = cmd->device_change_state.state;
@@ -858,18 +755,17 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg)
858 err = -EIO; 755 err = -EIO;
859 goto err_respond; 756 goto err_respond;
860 } 757 }
758
861 if (inmsg->hdr.flags.response_expected == 1) { 759 if (inmsg->hdr.flags.response_expected == 1) {
862 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); 760 pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
863 if (!pmsg_hdr) { 761 if (!pmsg_hdr) {
864 err = -ENOMEM; 762 err = -ENOMEM;
865 goto err_respond; 763 goto err_respond;
866 } 764 }
867
868 memcpy(pmsg_hdr, &inmsg->hdr, 765 memcpy(pmsg_hdr, &inmsg->hdr,
869 sizeof(struct controlvm_message_header)); 766 sizeof(struct controlvm_message_header));
870 dev_info->pending_msg_hdr = pmsg_hdr; 767 dev_info->pending_msg_hdr = pmsg_hdr;
871 } 768 }
872
873 if (state.alive == segment_state_running.alive && 769 if (state.alive == segment_state_running.alive &&
874 state.operating == segment_state_running.operating) 770 state.operating == segment_state_running.operating)
875 /* Response will be sent from visorchipset_device_resume */ 771 /* Response will be sent from visorchipset_device_resume */
@@ -884,7 +780,6 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg)
884 err = visorchipset_device_pause(dev_info); 780 err = visorchipset_device_pause(dev_info);
885 if (err) 781 if (err)
886 goto err_respond; 782 goto err_respond;
887
888 return 0; 783 return 0;
889 784
890err_respond: 785err_respond:
@@ -897,7 +792,7 @@ err_respond:
897static int visorbus_device_destroy(struct controlvm_message *inmsg) 792static int visorbus_device_destroy(struct controlvm_message *inmsg)
898{ 793{
899 struct controlvm_message_packet *cmd = &inmsg->cmd; 794 struct controlvm_message_packet *cmd = &inmsg->cmd;
900 struct controlvm_message_header *pmsg_hdr = NULL; 795 struct controlvm_message_header *pmsg_hdr;
901 u32 bus_no = cmd->destroy_device.bus_no; 796 u32 bus_no = cmd->destroy_device.bus_no;
902 u32 dev_no = cmd->destroy_device.dev_no; 797 u32 dev_no = cmd->destroy_device.dev_no;
903 struct visor_device *dev_info; 798 struct visor_device *dev_info;
@@ -928,7 +823,6 @@ static int visorbus_device_destroy(struct controlvm_message *inmsg)
928 sizeof(struct controlvm_message_header)); 823 sizeof(struct controlvm_message_header));
929 dev_info->pending_msg_hdr = pmsg_hdr; 824 dev_info->pending_msg_hdr = pmsg_hdr;
930 } 825 }
931
932 kfree(dev_info->name); 826 kfree(dev_info->name);
933 remove_visor_device(dev_info); 827 remove_visor_device(dev_info);
934 return 0; 828 return 0;
@@ -995,11 +889,9 @@ static struct parahotplug_request *parahotplug_request_create(
995 req = kmalloc(sizeof(*req), GFP_KERNEL); 889 req = kmalloc(sizeof(*req), GFP_KERNEL);
996 if (!req) 890 if (!req)
997 return NULL; 891 return NULL;
998
999 req->id = parahotplug_next_id(); 892 req->id = parahotplug_next_id();
1000 req->expiration = parahotplug_next_expiration(); 893 req->expiration = parahotplug_next_expiration();
1001 req->msg = *msg; 894 req->msg = *msg;
1002
1003 return req; 895 return req;
1004} 896}
1005 897
@@ -1031,13 +923,12 @@ static int parahotplug_request_complete(int id, u16 active)
1031{ 923{
1032 struct list_head *pos; 924 struct list_head *pos;
1033 struct list_head *tmp; 925 struct list_head *tmp;
926 struct parahotplug_request *req;
1034 927
1035 spin_lock(&parahotplug_request_list_lock); 928 spin_lock(&parahotplug_request_list_lock);
1036
1037 /* Look for a request matching "id". */ 929 /* Look for a request matching "id". */
1038 list_for_each_safe(pos, tmp, &parahotplug_request_list) { 930 list_for_each_safe(pos, tmp, &parahotplug_request_list) {
1039 struct parahotplug_request *req = 931 req = list_entry(pos, struct parahotplug_request, list);
1040 list_entry(pos, struct parahotplug_request, list);
1041 if (req->id == id) { 932 if (req->id == id) {
1042 /* 933 /*
1043 * Found a match. Remove it from the list and 934 * Found a match. Remove it from the list and
@@ -1054,7 +945,6 @@ static int parahotplug_request_complete(int id, u16 active)
1054 return 0; 945 return 0;
1055 } 946 }
1056 } 947 }
1057
1058 spin_unlock(&parahotplug_request_list_lock); 948 spin_unlock(&parahotplug_request_list_lock);
1059 return -EINVAL; 949 return -EINVAL;
1060} 950}
@@ -1081,7 +971,6 @@ static ssize_t devicedisabled_store(struct device *dev,
1081 971
1082 if (kstrtouint(buf, 10, &id)) 972 if (kstrtouint(buf, 10, &id))
1083 return -EINVAL; 973 return -EINVAL;
1084
1085 err = parahotplug_request_complete(id, 0); 974 err = parahotplug_request_complete(id, 0);
1086 if (err < 0) 975 if (err < 0)
1087 return err; 976 return err;
@@ -1110,7 +999,6 @@ static ssize_t deviceenabled_store(struct device *dev,
1110 999
1111 if (kstrtouint(buf, 10, &id)) 1000 if (kstrtouint(buf, 10, &id))
1112 return -EINVAL; 1001 return -EINVAL;
1113
1114 parahotplug_request_complete(id, 1); 1002 parahotplug_request_complete(id, 1);
1115 return count; 1003 return count;
1116} 1004}
@@ -1158,9 +1046,9 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req)
1158{ 1046{
1159 struct controlvm_message_packet *cmd = &req->msg.cmd; 1047 struct controlvm_message_packet *cmd = &req->msg.cmd;
1160 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40], 1048 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
1161 env_func[40]; 1049 env_func[40];
1162 char *envp[] = { 1050 char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
1163 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL 1051 env_func, NULL
1164 }; 1052 };
1165 1053
1166 sprintf(env_cmd, "VISOR_PARAHOTPLUG=1"); 1054 sprintf(env_cmd, "VISOR_PARAHOTPLUG=1");
@@ -1173,7 +1061,6 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req)
1173 cmd->device_change_state.dev_no >> 3); 1061 cmd->device_change_state.dev_no >> 3);
1174 sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d", 1062 sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d",
1175 cmd->device_change_state.dev_no & 0x7); 1063 cmd->device_change_state.dev_no & 0x7);
1176
1177 return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, 1064 return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj,
1178 KOBJ_CHANGE, envp); 1065 KOBJ_CHANGE, envp);
1179} 1066}
@@ -1191,7 +1078,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg)
1191 req = parahotplug_request_create(inmsg); 1078 req = parahotplug_request_create(inmsg);
1192 if (!req) 1079 if (!req)
1193 return -ENOMEM; 1080 return -ENOMEM;
1194
1195 /* 1081 /*
1196 * For enable messages, just respond with success right away, we don't 1082 * For enable messages, just respond with success right away, we don't
1197 * need to wait to see if the enable was successful. 1083 * need to wait to see if the enable was successful.
@@ -1205,7 +1091,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg)
1205 parahotplug_request_destroy(req); 1091 parahotplug_request_destroy(req);
1206 return 0; 1092 return 0;
1207 } 1093 }
1208
1209 /* 1094 /*
1210 * For disable messages, add the request to the request list before 1095 * For disable messages, add the request to the request list before
1211 * kicking off the udev script. It won't get responded to until the 1096 * kicking off the udev script. It won't get responded to until the
@@ -1214,7 +1099,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg)
1214 spin_lock(&parahotplug_request_list_lock); 1099 spin_lock(&parahotplug_request_list_lock);
1215 list_add_tail(&req->list, &parahotplug_request_list); 1100 list_add_tail(&req->list, &parahotplug_request_list);
1216 spin_unlock(&parahotplug_request_list_lock); 1101 spin_unlock(&parahotplug_request_list_lock);
1217
1218 err = parahotplug_request_kickoff(req); 1102 err = parahotplug_request_kickoff(req);
1219 if (err) 1103 if (err)
1220 goto err_respond; 1104 goto err_respond;
@@ -1237,12 +1121,9 @@ static int chipset_ready_uevent(struct controlvm_message_header *msg_hdr)
1237{ 1121{
1238 int res; 1122 int res;
1239 1123
1240 res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, 1124 res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, KOBJ_ONLINE);
1241 KOBJ_ONLINE);
1242
1243 if (msg_hdr->flags.response_expected) 1125 if (msg_hdr->flags.response_expected)
1244 controlvm_respond(msg_hdr, res, NULL); 1126 controlvm_respond(msg_hdr, res, NULL);
1245
1246 return res; 1127 return res;
1247} 1128}
1248 1129
@@ -1262,10 +1143,8 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr)
1262 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); 1143 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
1263 res = kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, 1144 res = kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj,
1264 KOBJ_CHANGE, envp); 1145 KOBJ_CHANGE, envp);
1265
1266 if (msg_hdr->flags.response_expected) 1146 if (msg_hdr->flags.response_expected)
1267 controlvm_respond(msg_hdr, res, NULL); 1147 controlvm_respond(msg_hdr, res, NULL);
1268
1269 return res; 1148 return res;
1270} 1149}
1271 1150
@@ -1279,11 +1158,10 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr)
1279static int chipset_notready_uevent(struct controlvm_message_header *msg_hdr) 1158static int chipset_notready_uevent(struct controlvm_message_header *msg_hdr)
1280{ 1159{
1281 int res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, 1160 int res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj,
1282 KOBJ_OFFLINE); 1161 KOBJ_OFFLINE);
1283 1162
1284 if (msg_hdr->flags.response_expected) 1163 if (msg_hdr->flags.response_expected)
1285 controlvm_respond(msg_hdr, res, NULL); 1164 controlvm_respond(msg_hdr, res, NULL);
1286
1287 return res; 1165 return res;
1288} 1166}
1289 1167
@@ -1296,17 +1174,15 @@ static int unisys_vmcall(unsigned long tuple, unsigned long param)
1296 1174
1297 reg_ebx = param & 0xFFFFFFFF; 1175 reg_ebx = param & 0xFFFFFFFF;
1298 reg_ecx = param >> 32; 1176 reg_ecx = param >> 32;
1299
1300 cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); 1177 cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
1301 if (!(cpuid_ecx & 0x80000000)) 1178 if (!(cpuid_ecx & 0x80000000))
1302 return -EPERM; 1179 return -EPERM;
1303
1304 __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : 1180 __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
1305 "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); 1181 "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
1306 if (result) 1182 if (result)
1307 goto error; 1183 goto error;
1308
1309 return 0; 1184 return 0;
1185
1310/* Need to convert from VMCALL error codes to Linux */ 1186/* Need to convert from VMCALL error codes to Linux */
1311error: 1187error:
1312 switch (result) { 1188 switch (result) {
@@ -1330,8 +1206,8 @@ static int controlvm_channel_create(struct visorchipset_device *dev)
1330 if (err) 1206 if (err)
1331 return err; 1207 return err;
1332 addr = dev->controlvm_params.address; 1208 addr = dev->controlvm_params.address;
1333 chan = visorchannel_create_with_lock(addr, GFP_KERNEL, 1209 chan = visorchannel_create(addr, GFP_KERNEL,
1334 &visor_controlvm_channel_guid); 1210 &visor_controlvm_channel_guid, true);
1335 if (!chan) 1211 if (!chan)
1336 return -ENOMEM; 1212 return -ENOMEM;
1337 dev->controlvm_channel = chan; 1213 dev->controlvm_channel = chan;
@@ -1350,9 +1226,7 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1350 msg.hdr.id = CONTROLVM_CHIPSET_INIT; 1226 msg.hdr.id = CONTROLVM_CHIPSET_INIT;
1351 msg.cmd.init_chipset.bus_count = 23; 1227 msg.cmd.init_chipset.bus_count = 23;
1352 msg.cmd.init_chipset.switch_count = 0; 1228 msg.cmd.init_chipset.switch_count = 0;
1353
1354 chipset_init(&msg); 1229 chipset_init(&msg);
1355
1356 /* get saved message count */ 1230 /* get saved message count */
1357 if (visorchannel_read(chipset_dev->controlvm_channel, 1231 if (visorchannel_read(chipset_dev->controlvm_channel,
1358 offsetof(struct visor_controlvm_channel, 1232 offsetof(struct visor_controlvm_channel,
@@ -1362,13 +1236,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1362 "failed to read channel\n"); 1236 "failed to read channel\n");
1363 return; 1237 return;
1364 } 1238 }
1365
1366 if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { 1239 if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
1367 dev_err(&chipset_dev->acpi_device->dev, 1240 dev_err(&chipset_dev->acpi_device->dev, "invalid count\n");
1368 "invalid count\n");
1369 return; 1241 return;
1370 } 1242 }
1371
1372 /* get saved crash message offset */ 1243 /* get saved crash message offset */
1373 if (visorchannel_read(chipset_dev->controlvm_channel, 1244 if (visorchannel_read(chipset_dev->controlvm_channel,
1374 offsetof(struct visor_controlvm_channel, 1245 offsetof(struct visor_controlvm_channel,
@@ -1378,7 +1249,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1378 "failed to read channel\n"); 1249 "failed to read channel\n");
1379 return; 1250 return;
1380 } 1251 }
1381
1382 /* read create device message for storage bus offset */ 1252 /* read create device message for storage bus offset */
1383 if (visorchannel_read(chipset_dev->controlvm_channel, 1253 if (visorchannel_read(chipset_dev->controlvm_channel,
1384 local_crash_msg_offset, 1254 local_crash_msg_offset,
@@ -1388,7 +1258,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1388 "failed to read channel\n"); 1258 "failed to read channel\n");
1389 return; 1259 return;
1390 } 1260 }
1391
1392 /* read create device message for storage device */ 1261 /* read create device message for storage device */
1393 if (visorchannel_read(chipset_dev->controlvm_channel, 1262 if (visorchannel_read(chipset_dev->controlvm_channel,
1394 local_crash_msg_offset + 1263 local_crash_msg_offset +
@@ -1399,7 +1268,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1399 "failed to read channel\n"); 1268 "failed to read channel\n");
1400 return; 1269 return;
1401 } 1270 }
1402
1403 /* reuse IOVM create bus message */ 1271 /* reuse IOVM create bus message */
1404 if (!local_crash_bus_msg.cmd.create_bus.channel_addr) { 1272 if (!local_crash_bus_msg.cmd.create_bus.channel_addr) {
1405 dev_err(&chipset_dev->acpi_device->dev, 1273 dev_err(&chipset_dev->acpi_device->dev,
@@ -1407,7 +1275,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1407 return; 1275 return;
1408 } 1276 }
1409 visorbus_create(&local_crash_bus_msg); 1277 visorbus_create(&local_crash_bus_msg);
1410
1411 /* reuse create device message for storage device */ 1278 /* reuse create device message for storage device */
1412 if (!local_crash_dev_msg.cmd.create_device.channel_addr) { 1279 if (!local_crash_dev_msg.cmd.create_device.channel_addr) {
1413 dev_err(&chipset_dev->acpi_device->dev, 1280 dev_err(&chipset_dev->acpi_device->dev,
@@ -1420,8 +1287,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
1420void visorbus_response(struct visor_device *bus_info, int response, 1287void visorbus_response(struct visor_device *bus_info, int response,
1421 int controlvm_id) 1288 int controlvm_id)
1422{ 1289{
1423 controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response); 1290 if (!bus_info->pending_msg_hdr)
1291 return;
1424 1292
1293 controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response);
1425 kfree(bus_info->pending_msg_hdr); 1294 kfree(bus_info->pending_msg_hdr);
1426 bus_info->pending_msg_hdr = NULL; 1295 bus_info->pending_msg_hdr = NULL;
1427} 1296}
@@ -1430,9 +1299,11 @@ void visorbus_device_changestate_response(struct visor_device *dev_info,
1430 int response, 1299 int response,
1431 struct visor_segment_state state) 1300 struct visor_segment_state state)
1432{ 1301{
1433 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, 1302 if (!dev_info->pending_msg_hdr)
1434 dev_info, response, state); 1303 return;
1435 1304
1305 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info,
1306 response, state);
1436 kfree(dev_info->pending_msg_hdr); 1307 kfree(dev_info->pending_msg_hdr);
1437 dev_info->pending_msg_hdr = NULL; 1308 dev_info->pending_msg_hdr = NULL;
1438} 1309}
@@ -1451,12 +1322,11 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes,
1451 void *mapping; 1322 void *mapping;
1452 1323
1453 *retry = false; 1324 *retry = false;
1454
1455 /* alloc an extra byte to ensure payload is \0 terminated */ 1325 /* alloc an extra byte to ensure payload is \0 terminated */
1456 allocbytes = bytes + 1 + (sizeof(struct parser_context) - 1326 allocbytes = bytes + 1 + (sizeof(struct parser_context) -
1457 sizeof(struct visor_controlvm_parameters_header)); 1327 sizeof(struct visor_controlvm_parameters_header));
1458 if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) 1328 if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) >
1459 > MAX_CONTROLVM_PAYLOAD_BYTES) { 1329 MAX_CONTROLVM_PAYLOAD_BYTES) {
1460 *retry = true; 1330 *retry = true;
1461 return NULL; 1331 return NULL;
1462 } 1332 }
@@ -1465,7 +1335,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes,
1465 *retry = true; 1335 *retry = true;
1466 return NULL; 1336 return NULL;
1467 } 1337 }
1468
1469 ctx->allocbytes = allocbytes; 1338 ctx->allocbytes = allocbytes;
1470 ctx->param_bytes = bytes; 1339 ctx->param_bytes = bytes;
1471 mapping = memremap(addr, bytes, MEMREMAP_WB); 1340 mapping = memremap(addr, bytes, MEMREMAP_WB);
@@ -1475,7 +1344,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes,
1475 memunmap(mapping); 1344 memunmap(mapping);
1476 ctx->byte_stream = true; 1345 ctx->byte_stream = true;
1477 chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes; 1346 chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes;
1478
1479 return ctx; 1347 return ctx;
1480 1348
1481err_finish_ctx: 1349err_finish_ctx:
@@ -1508,14 +1376,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr)
1508 /* create parsing context if necessary */ 1376 /* create parsing context if necessary */
1509 parm_addr = channel_addr + inmsg.hdr.payload_vm_offset; 1377 parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
1510 parm_bytes = inmsg.hdr.payload_bytes; 1378 parm_bytes = inmsg.hdr.payload_bytes;
1511
1512 /* 1379 /*
1513 * Parameter and channel addresses within test messages actually lie 1380 * Parameter and channel addresses within test messages actually lie
1514 * within our OS-controlled memory. We need to know that, because it 1381 * within our OS-controlled memory. We need to know that, because it
1515 * makes a difference in how we compute the virtual address. 1382 * makes a difference in how we compute the virtual address.
1516 */ 1383 */
1517 if (parm_bytes) { 1384 if (parm_bytes) {
1518 bool retry = false; 1385 bool retry;
1519 1386
1520 parser_ctx = parser_init_stream(parm_addr, parm_bytes, &retry); 1387 parser_ctx = parser_init_stream(parm_addr, parm_bytes, &retry);
1521 if (!parser_ctx && retry) 1388 if (!parser_ctx && retry)
@@ -1526,7 +1393,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr)
1526 CONTROLVM_QUEUE_ACK, &ackmsg); 1393 CONTROLVM_QUEUE_ACK, &ackmsg);
1527 if (err) 1394 if (err)
1528 return err; 1395 return err;
1529
1530 switch (inmsg.hdr.id) { 1396 switch (inmsg.hdr.id) {
1531 case CONTROLVM_CHIPSET_INIT: 1397 case CONTROLVM_CHIPSET_INIT:
1532 err = chipset_init(&inmsg); 1398 err = chipset_init(&inmsg);
@@ -1580,7 +1446,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr)
1580 -CONTROLVM_RESP_ID_UNKNOWN, NULL); 1446 -CONTROLVM_RESP_ID_UNKNOWN, NULL);
1581 break; 1447 break;
1582 } 1448 }
1583
1584 if (parser_ctx) { 1449 if (parser_ctx) {
1585 parser_done(parser_ctx); 1450 parser_done(parser_ctx);
1586 parser_ctx = NULL; 1451 parser_ctx = NULL;
@@ -1599,14 +1464,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr)
1599static int read_controlvm_event(struct controlvm_message *msg) 1464static int read_controlvm_event(struct controlvm_message *msg)
1600{ 1465{
1601 int err = visorchannel_signalremove(chipset_dev->controlvm_channel, 1466 int err = visorchannel_signalremove(chipset_dev->controlvm_channel,
1602 CONTROLVM_QUEUE_EVENT, msg); 1467 CONTROLVM_QUEUE_EVENT, msg);
1468
1603 if (err) 1469 if (err)
1604 return err; 1470 return err;
1605
1606 /* got a message */ 1471 /* got a message */
1607 if (msg->hdr.flags.test_message == 1) 1472 if (msg->hdr.flags.test_message == 1)
1608 return -EINVAL; 1473 return -EINVAL;
1609
1610 return 0; 1474 return 0;
1611} 1475}
1612 1476
@@ -1620,14 +1484,12 @@ static void parahotplug_process_list(void)
1620 struct list_head *tmp; 1484 struct list_head *tmp;
1621 1485
1622 spin_lock(&parahotplug_request_list_lock); 1486 spin_lock(&parahotplug_request_list_lock);
1623
1624 list_for_each_safe(pos, tmp, &parahotplug_request_list) { 1487 list_for_each_safe(pos, tmp, &parahotplug_request_list) {
1625 struct parahotplug_request *req = 1488 struct parahotplug_request *req =
1626 list_entry(pos, struct parahotplug_request, list); 1489 list_entry(pos, struct parahotplug_request, list);
1627 1490
1628 if (!time_after_eq(jiffies, req->expiration)) 1491 if (!time_after_eq(jiffies, req->expiration))
1629 continue; 1492 continue;
1630
1631 list_del(pos); 1493 list_del(pos);
1632 if (req->msg.hdr.flags.response_expected) 1494 if (req->msg.hdr.flags.response_expected)
1633 controlvm_respond( 1495 controlvm_respond(
@@ -1636,7 +1498,6 @@ static void parahotplug_process_list(void)
1636 &req->msg.cmd.device_change_state.state); 1498 &req->msg.cmd.device_change_state.state);
1637 parahotplug_request_destroy(req); 1499 parahotplug_request_destroy(req);
1638 } 1500 }
1639
1640 spin_unlock(&parahotplug_request_list_lock); 1501 spin_unlock(&parahotplug_request_list_lock);
1641} 1502}
1642 1503
@@ -1652,10 +1513,8 @@ static void controlvm_periodic_work(struct work_struct *work)
1652 CONTROLVM_QUEUE_RESPONSE, 1513 CONTROLVM_QUEUE_RESPONSE,
1653 &inmsg); 1514 &inmsg);
1654 } while ((!err) && (++count < CONTROLVM_MESSAGE_MAX)); 1515 } while ((!err) && (++count < CONTROLVM_MESSAGE_MAX));
1655
1656 if (err != -EAGAIN) 1516 if (err != -EAGAIN)
1657 goto schedule_out; 1517 goto schedule_out;
1658
1659 if (chipset_dev->controlvm_pending_msg_valid) { 1518 if (chipset_dev->controlvm_pending_msg_valid) {
1660 /* 1519 /*
1661 * we throttled processing of a prior msg, so try to process 1520 * we throttled processing of a prior msg, so try to process
@@ -1667,7 +1526,6 @@ static void controlvm_periodic_work(struct work_struct *work)
1667 } else { 1526 } else {
1668 err = read_controlvm_event(&inmsg); 1527 err = read_controlvm_event(&inmsg);
1669 } 1528 }
1670
1671 while (!err) { 1529 while (!err) {
1672 chipset_dev->most_recent_message_jiffies = jiffies; 1530 chipset_dev->most_recent_message_jiffies = jiffies;
1673 err = handle_command(inmsg, 1531 err = handle_command(inmsg,
@@ -1681,7 +1539,6 @@ static void controlvm_periodic_work(struct work_struct *work)
1681 1539
1682 err = read_controlvm_event(&inmsg); 1540 err = read_controlvm_event(&inmsg);
1683 } 1541 }
1684
1685 /* parahotplug_worker */ 1542 /* parahotplug_worker */
1686 parahotplug_process_list(); 1543 parahotplug_process_list();
1687 1544
@@ -1697,17 +1554,12 @@ schedule_out:
1697 * it's been longer than MIN_IDLE_SECONDS since we processed 1554 * it's been longer than MIN_IDLE_SECONDS since we processed
1698 * our last controlvm message; slow down the polling 1555 * our last controlvm message; slow down the polling
1699 */ 1556 */
1700 if (chipset_dev->poll_jiffies != 1557 if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_SLOW)
1701 POLLJIFFIES_CONTROLVMCHANNEL_SLOW) 1558 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_SLOW;
1702 chipset_dev->poll_jiffies =
1703 POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
1704 } else { 1559 } else {
1705 if (chipset_dev->poll_jiffies != 1560 if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_FAST)
1706 POLLJIFFIES_CONTROLVMCHANNEL_FAST) 1561 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST;
1707 chipset_dev->poll_jiffies =
1708 POLLJIFFIES_CONTROLVMCHANNEL_FAST;
1709 } 1562 }
1710
1711 schedule_delayed_work(&chipset_dev->periodic_controlvm_work, 1563 schedule_delayed_work(&chipset_dev->periodic_controlvm_work,
1712 chipset_dev->poll_jiffies); 1564 chipset_dev->poll_jiffies);
1713} 1565}
@@ -1720,20 +1572,16 @@ static int visorchipset_init(struct acpi_device *acpi_device)
1720 chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL); 1572 chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL);
1721 if (!chipset_dev) 1573 if (!chipset_dev)
1722 goto error; 1574 goto error;
1723
1724 err = controlvm_channel_create(chipset_dev); 1575 err = controlvm_channel_create(chipset_dev);
1725 if (err) 1576 if (err)
1726 goto error_free_chipset_dev; 1577 goto error_free_chipset_dev;
1727
1728 acpi_device->driver_data = chipset_dev; 1578 acpi_device->driver_data = chipset_dev;
1729 chipset_dev->acpi_device = acpi_device; 1579 chipset_dev->acpi_device = acpi_device;
1730 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; 1580 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST;
1731
1732 err = sysfs_create_groups(&chipset_dev->acpi_device->dev.kobj, 1581 err = sysfs_create_groups(&chipset_dev->acpi_device->dev.kobj,
1733 visorchipset_dev_groups); 1582 visorchipset_dev_groups);
1734 if (err < 0) 1583 if (err < 0)
1735 goto error_destroy_channel; 1584 goto error_destroy_channel;
1736
1737 controlvm_channel = chipset_dev->controlvm_channel; 1585 controlvm_channel = chipset_dev->controlvm_channel;
1738 if (!visor_check_channel(visorchannel_get_header(controlvm_channel), 1586 if (!visor_check_channel(visorchannel_get_header(controlvm_channel),
1739 &chipset_dev->acpi_device->dev, 1587 &chipset_dev->acpi_device->dev,
@@ -1743,7 +1591,6 @@ static int visorchipset_init(struct acpi_device *acpi_device)
1743 VISOR_CONTROLVM_CHANNEL_VERSIONID, 1591 VISOR_CONTROLVM_CHANNEL_VERSIONID,
1744 VISOR_CHANNEL_SIGNATURE)) 1592 VISOR_CHANNEL_SIGNATURE))
1745 goto error_delete_groups; 1593 goto error_delete_groups;
1746
1747 /* if booting in a crash kernel */ 1594 /* if booting in a crash kernel */
1748 if (is_kdump_kernel()) 1595 if (is_kdump_kernel())
1749 INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, 1596 INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work,
@@ -1751,16 +1598,13 @@ static int visorchipset_init(struct acpi_device *acpi_device)
1751 else 1598 else
1752 INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, 1599 INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work,
1753 controlvm_periodic_work); 1600 controlvm_periodic_work);
1754
1755 chipset_dev->most_recent_message_jiffies = jiffies; 1601 chipset_dev->most_recent_message_jiffies = jiffies;
1756 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; 1602 chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST;
1757 schedule_delayed_work(&chipset_dev->periodic_controlvm_work, 1603 schedule_delayed_work(&chipset_dev->periodic_controlvm_work,
1758 chipset_dev->poll_jiffies); 1604 chipset_dev->poll_jiffies);
1759
1760 err = visorbus_init(); 1605 err = visorbus_init();
1761 if (err < 0) 1606 if (err < 0)
1762 goto error_cancel_work; 1607 goto error_cancel_work;
1763
1764 return 0; 1608 return 0;
1765 1609
1766error_cancel_work: 1610error_cancel_work:
@@ -1787,10 +1631,8 @@ static int visorchipset_exit(struct acpi_device *acpi_device)
1787 cancel_delayed_work_sync(&chipset_dev->periodic_controlvm_work); 1631 cancel_delayed_work_sync(&chipset_dev->periodic_controlvm_work);
1788 sysfs_remove_groups(&chipset_dev->acpi_device->dev.kobj, 1632 sysfs_remove_groups(&chipset_dev->acpi_device->dev.kobj,
1789 visorchipset_dev_groups); 1633 visorchipset_dev_groups);
1790
1791 visorchannel_destroy(chipset_dev->controlvm_channel); 1634 visorchannel_destroy(chipset_dev->controlvm_channel);
1792 kfree(chipset_dev); 1635 kfree(chipset_dev);
1793
1794 return 0; 1636 return 0;
1795} 1637}
1796 1638
@@ -1832,11 +1674,9 @@ static int __init init_unisys(void)
1832 1674
1833 if (!visorutil_spar_detect()) 1675 if (!visorutil_spar_detect())
1834 return -ENODEV; 1676 return -ENODEV;
1835
1836 result = acpi_bus_register_driver(&unisys_acpi_driver); 1677 result = acpi_bus_register_driver(&unisys_acpi_driver);
1837 if (result) 1678 if (result)
1838 return -ENODEV; 1679 return -ENODEV;
1839
1840 pr_info("Unisys Visorchipset Driver Loaded.\n"); 1680 pr_info("Unisys Visorchipset Driver Loaded.\n");
1841 return 0; 1681 return 0;
1842}; 1682};
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 419dba89af06..0bcd3acb7b0c 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -17,6 +17,7 @@
17#include <linux/debugfs.h> 17#include <linux/debugfs.h>
18#include <linux/kthread.h> 18#include <linux/kthread.h>
19#include <linux/idr.h> 19#include <linux/idr.h>
20#include <linux/module.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
21#include <scsi/scsi.h> 22#include <scsi/scsi.h>
22#include <scsi/scsi_host.h> 23#include <scsi/scsi_host.h>
@@ -39,7 +40,8 @@ static struct visor_channeltype_descriptor visorhba_channel_types[] = {
39 /* Note that the only channel type we expect to be reported by the 40 /* Note that the only channel type we expect to be reported by the
40 * bus driver is the VISOR_VHBA channel. 41 * bus driver is the VISOR_VHBA channel.
41 */ 42 */
42 { VISOR_VHBA_CHANNEL_GUID, "sparvhba" }, 43 { VISOR_VHBA_CHANNEL_GUID, "sparvhba", sizeof(struct channel_header),
44 VISOR_VHBA_CHANNEL_VERSIONID },
43 {} 45 {}
44}; 46};
45 47
@@ -818,9 +820,9 @@ static void do_scsi_linuxstat(struct uiscmdrsp *cmdrsp,
818 memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE); 820 memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE);
819 821
820 /* Do not log errors for disk-not-present inquiries */ 822 /* Do not log errors for disk-not-present inquiries */
821 if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && 823 if (cmdrsp->scsi.cmnd[0] == INQUIRY &&
822 (host_byte(cmdrsp->scsi.linuxstat) == DID_NO_CONNECT) && 824 (host_byte(cmdrsp->scsi.linuxstat) == DID_NO_CONNECT) &&
823 (cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT)) 825 cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT)
824 return; 826 return;
825 /* Okay see what our error_count is here.... */ 827 /* Okay see what our error_count is here.... */
826 vdisk = scsidev->hostdata; 828 vdisk = scsidev->hostdata;
@@ -868,8 +870,8 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp,
868 struct visordisk_info *vdisk; 870 struct visordisk_info *vdisk;
869 871
870 scsidev = scsicmd->device; 872 scsidev = scsicmd->device;
871 if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && 873 if (cmdrsp->scsi.cmnd[0] == INQUIRY &&
872 (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) { 874 cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN) {
873 if (cmdrsp->scsi.no_disk_result == 0) 875 if (cmdrsp->scsi.no_disk_result == 0)
874 return; 876 return;
875 877
diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c
index 9d8cbc52de8b..450f003743c0 100644
--- a/drivers/staging/unisys/visorinput/visorinput.c
+++ b/drivers/staging/unisys/visorinput/visorinput.c
@@ -23,6 +23,7 @@
23#include <linux/fb.h> 23#include <linux/fb.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h>
26#include <linux/uuid.h> 27#include <linux/uuid.h>
27 28
28#include "visorbus.h" 29#include "visorbus.h"
@@ -711,8 +712,9 @@ out:
711 712
712/* GUIDS for all channel types supported by this driver. */ 713/* GUIDS for all channel types supported by this driver. */
713static struct visor_channeltype_descriptor visorinput_channel_types[] = { 714static struct visor_channeltype_descriptor visorinput_channel_types[] = {
714 { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard"}, 715 { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard",
715 { VISOR_MOUSE_CHANNEL_GUID, "mouse"}, 716 sizeof(struct channel_header), 0 },
717 { VISOR_MOUSE_CHANNEL_GUID, "mouse", sizeof(struct channel_header), 0 },
716 {} 718 {}
717}; 719};
718 720
diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
index dc390eae2960..735d7e5fa86b 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/debugfs.h> 21#include <linux/debugfs.h>
22#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
23#include <linux/module.h>
23#include <linux/netdevice.h> 24#include <linux/netdevice.h>
24#include <linux/kthread.h> 25#include <linux/kthread.h>
25#include <linux/skbuff.h> 26#include <linux/skbuff.h>
@@ -48,7 +49,8 @@ static struct visor_channeltype_descriptor visornic_channel_types[] = {
48 /* Note that the only channel type we expect to be reported by the 49 /* Note that the only channel type we expect to be reported by the
49 * bus driver is the VISOR_VNIC channel. 50 * bus driver is the VISOR_VNIC channel.
50 */ 51 */
51 { VISOR_VNIC_CHANNEL_GUID, "ultravnic" }, 52 { VISOR_VNIC_CHANNEL_GUID, "ultravnic", sizeof(struct channel_header),
53 VISOR_VNIC_CHANNEL_VERSIONID },
52 {} 54 {}
53}; 55};
54MODULE_DEVICE_TABLE(visorbus, visornic_channel_types); 56MODULE_DEVICE_TABLE(visorbus, visornic_channel_types);
@@ -899,7 +901,7 @@ static int visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
899 return NETDEV_TX_OK; 901 return NETDEV_TX_OK;
900 } 902 }
901 903
902 if ((len < ETH_MIN_PACKET_SIZE) && 904 if (len < ETH_MIN_PACKET_SIZE &&
903 ((skb_end_pointer(skb) - skb->data) >= ETH_MIN_PACKET_SIZE)) { 905 ((skb_end_pointer(skb) - skb->data) >= ETH_MIN_PACKET_SIZE)) {
904 /* pad the packet out to minimum size */ 906 /* pad the packet out to minimum size */
905 padlen = ETH_MIN_PACKET_SIZE - len; 907 padlen = ETH_MIN_PACKET_SIZE - len;
@@ -1450,7 +1452,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
1450 rcu_read_lock(); 1452 rcu_read_lock();
1451 for_each_netdev_rcu(current->nsproxy->net_ns, dev) { 1453 for_each_netdev_rcu(current->nsproxy->net_ns, dev) {
1452 /* Only consider netdevs that are visornic, and are open */ 1454 /* Only consider netdevs that are visornic, and are open */
1453 if ((dev->netdev_ops != &visornic_dev_ops) || 1455 if (dev->netdev_ops != &visornic_dev_ops ||
1454 (!netif_queue_stopped(dev))) 1456 (!netif_queue_stopped(dev)))
1455 continue; 1457 continue;
1456 1458
@@ -1680,7 +1682,7 @@ static void service_resp_queue(struct uiscmdrsp *cmdrsp,
1680 /* only call queue wake if we stopped it */ 1682 /* only call queue wake if we stopped it */
1681 netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev; 1683 netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev;
1682 /* ASSERT netdev == vnicinfo->netdev; */ 1684 /* ASSERT netdev == vnicinfo->netdev; */
1683 if ((netdev == devdata->netdev) && 1685 if (netdev == devdata->netdev &&
1684 netif_queue_stopped(netdev)) { 1686 netif_queue_stopped(netdev)) {
1685 /* check if we have crossed the lower watermark 1687 /* check if we have crossed the lower watermark
1686 * for netif_wake_queue() 1688 * for netif_wake_queue()
diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h
index 4b9302703b36..eeac4f0cb2c6 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -137,8 +137,8 @@ struct vbox_connector {
137 char name[32]; 137 char name[32];
138 struct vbox_crtc *vbox_crtc; 138 struct vbox_crtc *vbox_crtc;
139 struct { 139 struct {
140 u16 width; 140 u32 width;
141 u16 height; 141 u32 height;
142 bool disconnected; 142 bool disconnected;
143 } mode_hint; 143 } mode_hint;
144}; 144};
@@ -150,8 +150,8 @@ struct vbox_crtc {
150 unsigned int crtc_id; 150 unsigned int crtc_id;
151 u32 fb_offset; 151 u32 fb_offset;
152 bool cursor_enabled; 152 bool cursor_enabled;
153 u16 x_hint; 153 u32 x_hint;
154 u16 y_hint; 154 u32 y_hint;
155}; 155};
156 156
157struct vbox_encoder { 157struct vbox_encoder {
diff --git a/drivers/staging/vboxvideo/vbox_irq.c b/drivers/staging/vboxvideo/vbox_irq.c
index 3ca8bec62ac4..74abdf02d9fd 100644
--- a/drivers/staging/vboxvideo/vbox_irq.c
+++ b/drivers/staging/vboxvideo/vbox_irq.c
@@ -150,8 +150,8 @@ static void vbox_update_mode_hints(struct vbox_private *vbox)
150 150
151 disconnected = !(hints->enabled); 151 disconnected = !(hints->enabled);
152 crtc_id = vbox_conn->vbox_crtc->crtc_id; 152 crtc_id = vbox_conn->vbox_crtc->crtc_id;
153 vbox_conn->mode_hint.width = hints->cx & 0x8fff; 153 vbox_conn->mode_hint.width = hints->cx;
154 vbox_conn->mode_hint.height = hints->cy & 0x8fff; 154 vbox_conn->mode_hint.height = hints->cy;
155 vbox_conn->vbox_crtc->x_hint = hints->dx; 155 vbox_conn->vbox_crtc->x_hint = hints->dx;
156 vbox_conn->vbox_crtc->y_hint = hints->dy; 156 vbox_conn->vbox_crtc->y_hint = hints->dy;
157 vbox_conn->mode_hint.disconnected = disconnected; 157 vbox_conn->mode_hint.disconnected = disconnected;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 257a77830410..6f08dc966719 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -553,12 +553,22 @@ static int vbox_get_modes(struct drm_connector *connector)
553 ++num_modes; 553 ++num_modes;
554 } 554 }
555 vbox_set_edid(connector, preferred_width, preferred_height); 555 vbox_set_edid(connector, preferred_width, preferred_height);
556 drm_object_property_set_value( 556
557 &connector->base, vbox->dev->mode_config.suggested_x_property, 557 if (vbox_connector->vbox_crtc->x_hint != -1)
558 vbox_connector->vbox_crtc->x_hint); 558 drm_object_property_set_value(&connector->base,
559 drm_object_property_set_value( 559 vbox->dev->mode_config.suggested_x_property,
560 &connector->base, vbox->dev->mode_config.suggested_y_property, 560 vbox_connector->vbox_crtc->x_hint);
561 vbox_connector->vbox_crtc->y_hint); 561 else
562 drm_object_property_set_value(&connector->base,
563 vbox->dev->mode_config.suggested_x_property, 0);
564
565 if (vbox_connector->vbox_crtc->y_hint != -1)
566 drm_object_property_set_value(&connector->base,
567 vbox->dev->mode_config.suggested_y_property,
568 vbox_connector->vbox_crtc->y_hint);
569 else
570 drm_object_property_set_value(&connector->base,
571 vbox->dev->mode_config.suggested_y_property, 0);
562 572
563 return num_modes; 573 return num_modes;
564} 574}
@@ -640,9 +650,9 @@ static int vbox_connector_init(struct drm_device *dev,
640 650
641 drm_mode_create_suggested_offset_properties(dev); 651 drm_mode_create_suggested_offset_properties(dev);
642 drm_object_attach_property(&connector->base, 652 drm_object_attach_property(&connector->base,
643 dev->mode_config.suggested_x_property, -1); 653 dev->mode_config.suggested_x_property, 0);
644 drm_object_attach_property(&connector->base, 654 drm_object_attach_property(&connector->base,
645 dev->mode_config.suggested_y_property, -1); 655 dev->mode_config.suggested_y_property, 0);
646 drm_connector_register(connector); 656 drm_connector_register(connector);
647 657
648 drm_mode_connector_attach_encoder(connector, encoder); 658 drm_mode_connector_attach_encoder(connector, encoder);
diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig
index 9e2763663ab8..f5aaf7d629f0 100644
--- a/drivers/staging/vc04_services/Kconfig
+++ b/drivers/staging/vc04_services/Kconfig
@@ -19,18 +19,6 @@ config BCM2835_VCHIQ
19 Defaults to Y when the Broadcom Videocore services 19 Defaults to Y when the Broadcom Videocore services
20 are included in the build, N otherwise. 20 are included in the build, N otherwise.
21 21
22if BCM2835_VCHIQ
23
24config BCM2835_VCHIQ_SUPPORT_MEMDUMP
25 bool "Support dumping memory contents to debug log"
26 help
27 BCM2835 VCHIQ supports the ability to dump the
28 contents of memory to the debug log. This
29 is typically only needed by diagnostic tools used
30 to debug issues with VideoCore.
31
32endif
33
34source "drivers/staging/vc04_services/bcm2835-audio/Kconfig" 22source "drivers/staging/vc04_services/bcm2835-audio/Kconfig"
35 23
36source "drivers/staging/vc04_services/bcm2835-camera/Kconfig" 24source "drivers/staging/vc04_services/bcm2835-camera/Kconfig"
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
index 94654c0c7bba..7e68b3e28246 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
@@ -65,7 +65,6 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream *alsa_stream)
65 unsigned int consumed = 0; 65 unsigned int consumed = 0;
66 int new_period = 0; 66 int new_period = 0;
67 67
68
69 audio_info("alsa_stream=%p substream=%p\n", alsa_stream, 68 audio_info("alsa_stream=%p substream=%p\n", alsa_stream,
70 alsa_stream ? alsa_stream->substream : 0); 69 alsa_stream ? alsa_stream->substream : 0);
71 70
@@ -111,7 +110,6 @@ static int snd_bcm2835_playback_open_generic(
111 int idx; 110 int idx;
112 int err; 111 int err;
113 112
114
115 if (mutex_lock_interruptible(&chip->audio_mutex)) { 113 if (mutex_lock_interruptible(&chip->audio_mutex)) {
116 audio_error("Interrupted whilst waiting for lock\n"); 114 audio_error("Interrupted whilst waiting for lock\n");
117 return -EINTR; 115 return -EINTR;
@@ -184,7 +182,6 @@ static int snd_bcm2835_playback_open_generic(
184out: 182out:
185 mutex_unlock(&chip->audio_mutex); 183 mutex_unlock(&chip->audio_mutex);
186 184
187
188 return err; 185 return err;
189} 186}
190 187
@@ -207,7 +204,6 @@ static int snd_bcm2835_playback_close(struct snd_pcm_substream *substream)
207 struct snd_pcm_runtime *runtime; 204 struct snd_pcm_runtime *runtime;
208 struct bcm2835_alsa_stream *alsa_stream; 205 struct bcm2835_alsa_stream *alsa_stream;
209 206
210
211 chip = snd_pcm_substream_chip(substream); 207 chip = snd_pcm_substream_chip(substream);
212 if (mutex_lock_interruptible(&chip->audio_mutex)) { 208 if (mutex_lock_interruptible(&chip->audio_mutex)) {
213 audio_error("Interrupted whilst waiting for lock\n"); 209 audio_error("Interrupted whilst waiting for lock\n");
@@ -259,7 +255,6 @@ static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream,
259 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; 255 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
260 int err; 256 int err;
261 257
262
263 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 258 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
264 if (err < 0) { 259 if (err < 0) {
265 audio_error 260 audio_error
@@ -289,7 +284,6 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream)
289 int channels; 284 int channels;
290 int err; 285 int err;
291 286
292
293 if (mutex_lock_interruptible(&chip->audio_mutex)) 287 if (mutex_lock_interruptible(&chip->audio_mutex))
294 return -EINTR; 288 return -EINTR;
295 289
@@ -307,13 +301,11 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream)
307 if (err < 0) 301 if (err < 0)
308 audio_error(" error setting hw params\n"); 302 audio_error(" error setting hw params\n");
309 303
310
311 bcm2835_audio_setup(alsa_stream); 304 bcm2835_audio_setup(alsa_stream);
312 305
313 /* in preparation of the stream, set the controls (volume level) of the stream */ 306 /* in preparation of the stream, set the controls (volume level) of the stream */
314 bcm2835_audio_set_ctls(alsa_stream->chip); 307 bcm2835_audio_set_ctls(alsa_stream->chip);
315 308
316
317 memset(&alsa_stream->pcm_indirect, 0, sizeof(alsa_stream->pcm_indirect)); 309 memset(&alsa_stream->pcm_indirect, 0, sizeof(alsa_stream->pcm_indirect));
318 310
319 alsa_stream->pcm_indirect.hw_buffer_size = 311 alsa_stream->pcm_indirect.hw_buffer_size =
@@ -364,7 +356,6 @@ static int snd_bcm2835_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
364 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; 356 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
365 int err = 0; 357 int err = 0;
366 358
367
368 switch (cmd) { 359 switch (cmd) {
369 case SNDRV_PCM_TRIGGER_START: 360 case SNDRV_PCM_TRIGGER_START:
370 audio_debug("bcm2835_AUDIO_TRIGGER_START running=%d\n", 361 audio_debug("bcm2835_AUDIO_TRIGGER_START running=%d\n",
@@ -416,7 +407,6 @@ snd_bcm2835_pcm_pointer(struct snd_pcm_substream *substream)
416 struct snd_pcm_runtime *runtime = substream->runtime; 407 struct snd_pcm_runtime *runtime = substream->runtime;
417 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; 408 struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
418 409
419
420 audio_debug("pcm_pointer... (%d) hwptr=%d appl=%d pos=%d\n", 0, 410 audio_debug("pcm_pointer... (%d) hwptr=%d appl=%d pos=%d\n", 0,
421 frames_to_bytes(runtime, runtime->status->hw_ptr), 411 frames_to_bytes(runtime, runtime->status->hw_ptr),
422 frames_to_bytes(runtime, runtime->control->appl_ptr), 412 frames_to_bytes(runtime, runtime->control->appl_ptr),
@@ -493,7 +483,6 @@ int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, u32 numchannels)
493 snd_bcm2835_playback_hw.buffer_bytes_max, 483 snd_bcm2835_playback_hw.buffer_bytes_max,
494 snd_bcm2835_playback_hw.buffer_bytes_max); 484 snd_bcm2835_playback_hw.buffer_bytes_max);
495 485
496
497out: 486out:
498 mutex_unlock(&chip->audio_mutex); 487 mutex_unlock(&chip->audio_mutex);
499 488
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
index 5f3d8f2339e3..3c6f1d91d22d 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
@@ -337,7 +337,6 @@ static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance)
337{ 337{
338 unsigned int i; 338 unsigned int i;
339 339
340
341 if (!instance) { 340 if (!instance) {
342 LOG_ERR("%s: invalid handle %p\n", __func__, instance); 341 LOG_ERR("%s: invalid handle %p\n", __func__, instance);
343 342
@@ -369,7 +368,6 @@ static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance)
369 368
370 kfree(instance); 369 kfree(instance);
371 370
372
373 return 0; 371 return 0;
374} 372}
375 373
@@ -382,7 +380,6 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
382 (struct bcm2835_audio_instance *)alsa_stream->instance; 380 (struct bcm2835_audio_instance *)alsa_stream->instance;
383 int ret; 381 int ret;
384 382
385
386 LOG_INFO("%s: start\n", __func__); 383 LOG_INFO("%s: start\n", __func__);
387 BUG_ON(instance); 384 BUG_ON(instance);
388 if (instance) { 385 if (instance) {
@@ -390,8 +387,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
390 __func__, instance); 387 __func__, instance);
391 instance->alsa_stream = alsa_stream; 388 instance->alsa_stream = alsa_stream;
392 alsa_stream->instance = instance; 389 alsa_stream->instance = instance;
393 ret = 0; // xxx todo -1; 390 return 0;
394 goto err_free_mem;
395 } 391 }
396 392
397 /* Initialize and create a VCHI connection */ 393 /* Initialize and create a VCHI connection */
@@ -401,16 +397,15 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
401 LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n", 397 LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
402 __func__, ret); 398 __func__, ret);
403 399
404 ret = -EIO; 400 return -EIO;
405 goto err_free_mem;
406 } 401 }
407 ret = vchi_connect(NULL, 0, vchi_instance); 402 ret = vchi_connect(NULL, 0, vchi_instance);
408 if (ret) { 403 if (ret) {
409 LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n", 404 LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
410 __func__, ret); 405 __func__, ret);
411 406
412 ret = -EIO; 407 kfree(vchi_instance);
413 goto err_free_mem; 408 return -EIO;
414 } 409 }
415 initted = 1; 410 initted = 1;
416 } 411 }
@@ -421,19 +416,16 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
421 if (IS_ERR(instance)) { 416 if (IS_ERR(instance)) {
422 LOG_ERR("%s: failed to initialize audio service\n", __func__); 417 LOG_ERR("%s: failed to initialize audio service\n", __func__);
423 418
424 ret = PTR_ERR(instance); 419 /* vchi_instance is retained for use the next time. */
425 goto err_free_mem; 420 return PTR_ERR(instance);
426 } 421 }
427 422
428 instance->alsa_stream = alsa_stream; 423 instance->alsa_stream = alsa_stream;
429 alsa_stream->instance = instance; 424 alsa_stream->instance = instance;
430 425
431 LOG_DBG(" success !\n"); 426 LOG_DBG(" success !\n");
432 ret = 0;
433err_free_mem:
434 kfree(vchi_instance);
435 427
436 return ret; 428 return 0;
437} 429}
438 430
439int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) 431int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
@@ -443,7 +435,6 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
443 int status; 435 int status;
444 int ret; 436 int ret;
445 437
446
447 my_workqueue_init(alsa_stream); 438 my_workqueue_init(alsa_stream);
448 439
449 ret = bcm2835_audio_open_connection(alsa_stream); 440 ret = bcm2835_audio_open_connection(alsa_stream);
@@ -491,7 +482,6 @@ static int bcm2835_audio_set_ctls_chan(struct bcm2835_alsa_stream *alsa_stream,
491 int status; 482 int status;
492 int ret; 483 int ret;
493 484
494
495 LOG_INFO(" Setting ALSA dest(%d), volume(%d)\n", 485 LOG_INFO(" Setting ALSA dest(%d), volume(%d)\n",
496 chip->dest, chip->volume); 486 chip->dest, chip->volume);
497 487
@@ -575,7 +565,6 @@ int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream,
575 int status; 565 int status;
576 int ret; 566 int ret;
577 567
578
579 LOG_INFO(" Setting ALSA channels(%d), samplerate(%d), bits-per-sample(%d)\n", 568 LOG_INFO(" Setting ALSA channels(%d), samplerate(%d), bits-per-sample(%d)\n",
580 channels, samplerate, bps); 569 channels, samplerate, bps);
581 570
@@ -636,7 +625,6 @@ unlock:
636int bcm2835_audio_setup(struct bcm2835_alsa_stream *alsa_stream) 625int bcm2835_audio_setup(struct bcm2835_alsa_stream *alsa_stream)
637{ 626{
638 627
639
640 return 0; 628 return 0;
641} 629}
642 630
@@ -647,7 +635,6 @@ static int bcm2835_audio_start_worker(struct bcm2835_alsa_stream *alsa_stream)
647 int status; 635 int status;
648 int ret; 636 int ret;
649 637
650
651 if (mutex_lock_interruptible(&instance->vchi_mutex)) { 638 if (mutex_lock_interruptible(&instance->vchi_mutex)) {
652 LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", 639 LOG_DBG("Interrupted whilst waiting for lock on (%d)\n",
653 instance->num_connections); 640 instance->num_connections);
@@ -684,7 +671,6 @@ static int bcm2835_audio_stop_worker(struct bcm2835_alsa_stream *alsa_stream)
684 int status; 671 int status;
685 int ret; 672 int ret;
686 673
687
688 if (mutex_lock_interruptible(&instance->vchi_mutex)) { 674 if (mutex_lock_interruptible(&instance->vchi_mutex)) {
689 LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", 675 LOG_DBG("Interrupted whilst waiting for lock on (%d)\n",
690 instance->num_connections); 676 instance->num_connections);
@@ -722,7 +708,6 @@ int bcm2835_audio_close(struct bcm2835_alsa_stream *alsa_stream)
722 int status; 708 int status;
723 int ret; 709 int ret;
724 710
725
726 my_workqueue_quit(alsa_stream); 711 my_workqueue_quit(alsa_stream);
727 712
728 if (mutex_lock_interruptible(&instance->vchi_mutex)) { 713 if (mutex_lock_interruptible(&instance->vchi_mutex)) {
@@ -780,7 +765,6 @@ static int bcm2835_audio_write_worker(struct bcm2835_alsa_stream *alsa_stream,
780 int status; 765 int status;
781 int ret; 766 int ret;
782 767
783
784 LOG_INFO(" Writing %d bytes from %p\n", count, src); 768 LOG_INFO(" Writing %d bytes from %p\n", count, src);
785 769
786 if (mutex_lock_interruptible(&instance->vchi_mutex)) { 770 if (mutex_lock_interruptible(&instance->vchi_mutex)) {
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
index 379604d3554e..f1e43e45fd67 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
@@ -123,8 +123,6 @@ struct bcm2835_alsa_stream {
123 struct snd_pcm_indirect pcm_indirect; 123 struct snd_pcm_indirect pcm_indirect;
124 124
125 spinlock_t lock; 125 spinlock_t lock;
126 volatile unsigned int control;
127 volatile unsigned int status;
128 126
129 int open; 127 int open;
130 int running; 128 int running;
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
index 52cdf4da1b47..5a1b2a7d8eb0 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
@@ -70,7 +70,7 @@ enum mmal_msg_type {
70 70
71/* port action request messages differ depending on the action type */ 71/* port action request messages differ depending on the action type */
72enum mmal_msg_port_action_type { 72enum mmal_msg_port_action_type {
73 MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unkown action */ 73 MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
74 MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */ 74 MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
75 MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */ 75 MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
76 MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */ 76 MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
@@ -217,36 +217,36 @@ struct mmal_msg_port_action_reply {
217#define MMAL_VC_SHORT_DATA 128 217#define MMAL_VC_SHORT_DATA 128
218 218
219/** Signals that the current payload is the end of the stream of data */ 219/** Signals that the current payload is the end of the stream of data */
220#define MMAL_BUFFER_HEADER_FLAG_EOS (1<<0) 220#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
221/** Signals that the start of the current payload starts a frame */ 221/** Signals that the start of the current payload starts a frame */
222#define MMAL_BUFFER_HEADER_FLAG_FRAME_START (1<<1) 222#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
223/** Signals that the end of the current payload ends a frame */ 223/** Signals that the end of the current payload ends a frame */
224#define MMAL_BUFFER_HEADER_FLAG_FRAME_END (1<<2) 224#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
225/** Signals that the current payload contains only complete frames (>1) */ 225/** Signals that the current payload contains only complete frames (>1) */
226#define MMAL_BUFFER_HEADER_FLAG_FRAME \ 226#define MMAL_BUFFER_HEADER_FLAG_FRAME \
227 (MMAL_BUFFER_HEADER_FLAG_FRAME_START|MMAL_BUFFER_HEADER_FLAG_FRAME_END) 227 (MMAL_BUFFER_HEADER_FLAG_FRAME_START|MMAL_BUFFER_HEADER_FLAG_FRAME_END)
228/** Signals that the current payload is a keyframe (i.e. self decodable) */ 228/** Signals that the current payload is a keyframe (i.e. self decodable) */
229#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME (1<<3) 229#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
230/** Signals a discontinuity in the stream of data (e.g. after a seek). 230/** Signals a discontinuity in the stream of data (e.g. after a seek).
231 * Can be used for instance by a decoder to reset its state 231 * Can be used for instance by a decoder to reset its state
232 */ 232 */
233#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY (1<<4) 233#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
234/** Signals a buffer containing some kind of config data for the component 234/** Signals a buffer containing some kind of config data for the component
235 * (e.g. codec config data) 235 * (e.g. codec config data)
236 */ 236 */
237#define MMAL_BUFFER_HEADER_FLAG_CONFIG (1<<5) 237#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
238/** Signals an encrypted payload */ 238/** Signals an encrypted payload */
239#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED (1<<6) 239#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
240/** Signals a buffer containing side information */ 240/** Signals a buffer containing side information */
241#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO (1<<7) 241#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
242/** Signals a buffer which is the snapshot/postview image from a stills 242/** Signals a buffer which is the snapshot/postview image from a stills
243 * capture 243 * capture
244 */ 244 */
245#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT (1<<8) 245#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
246/** Signals a buffer which contains data known to be corrupted */ 246/** Signals a buffer which contains data known to be corrupted */
247#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED (1<<9) 247#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
248/** Signals that a buffer failed to be transmitted */ 248/** Signals that a buffer failed to be transmitted */
249#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED (1<<10) 249#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
250 250
251struct mmal_driver_buffer { 251struct mmal_driver_buffer {
252 u32 magic; 252 u32 magic;
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 4360db6d4392..6ea7fb0ea50e 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -1963,7 +1963,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
1963 1963
1964 status = vchi_service_close(instance->handle); 1964 status = vchi_service_close(instance->handle);
1965 if (status != 0) 1965 if (status != 0)
1966 pr_err("mmal-vchiq: VCHIQ close failed"); 1966 pr_err("mmal-vchiq: VCHIQ close failed\n");
1967 1967
1968 mutex_unlock(&instance->vchiq_mutex); 1968 mutex_unlock(&instance->vchiq_mutex);
1969 1969
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
index 63db053532bf..db39900c9d91 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
@@ -130,7 +130,7 @@ int vchiq_mmal_component_disable(
130/* enable a mmal port 130/* enable a mmal port
131 * 131 *
132 * enables a port and if a buffer callback provided enque buffer 132 * enables a port and if a buffer callback provided enque buffer
133 * headers as apropriate for the port. 133 * headers as appropriate for the port.
134 */ 134 */
135int vchiq_mmal_port_enable( 135int vchiq_mmal_port_enable(
136 struct vchiq_mmal_instance *instance, 136 struct vchiq_mmal_instance *instance,
diff --git a/drivers/staging/vc04_services/interface/vchi/connections/connection.h b/drivers/staging/vc04_services/interface/vchi/connections/connection.h
index e793cdf2847c..67c84386c65a 100644
--- a/drivers/staging/vc04_services/interface/vchi/connections/connection.h
+++ b/drivers/staging/vc04_services/interface/vchi/connections/connection.h
@@ -54,7 +54,6 @@ typedef struct opaque_vchi_connection_info_t VCHI_CONNECTION_STATE_T;
54 54
55typedef struct vchi_connection_t VCHI_CONNECTION_T; 55typedef struct vchi_connection_t VCHI_CONNECTION_T;
56 56
57
58/****************************************************************************** 57/******************************************************************************
59 API 58 API
60 *****************************************************************************/ 59 *****************************************************************************/
@@ -212,7 +211,6 @@ typedef void * (*VCHI_BUFFER_ALLOCATE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_
212// free memory allocated by buffer_allocate 211// free memory allocated by buffer_allocate
213typedef void (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address); 212typedef void (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address);
214 213
215
216/****************************************************************************** 214/******************************************************************************
217 System driver struct 215 System driver struct
218 *****************************************************************************/ 216 *****************************************************************************/
@@ -321,7 +319,6 @@ struct vchi_connection_t {
321#endif 319#endif
322}; 320};
323 321
324
325#endif /* CONNECTION_H_ */ 322#endif /* CONNECTION_H_ */
326 323
327/****************************** End of file **********************************/ 324/****************************** End of file **********************************/
diff --git a/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h b/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h
index a7740a425388..834263f278cf 100644
--- a/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h
+++ b/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h
@@ -41,7 +41,6 @@
41#include "interface/vchi/vchi_cfg_internal.h" 41#include "interface/vchi/vchi_cfg_internal.h"
42#include "interface/vchi/vchi_common.h" 42#include "interface/vchi/vchi_common.h"
43 43
44
45typedef enum message_event_type { 44typedef enum message_event_type {
46 MESSAGE_EVENT_NONE, 45 MESSAGE_EVENT_NONE,
47 MESSAGE_EVENT_NOP, 46 MESSAGE_EVENT_NOP,
@@ -111,7 +110,6 @@ typedef struct rx_bulk_slotinfo_t {
111 VCHI_FLAGS_T flags; 110 VCHI_FLAGS_T flags;
112} RX_BULK_SLOTINFO_T; 111} RX_BULK_SLOTINFO_T;
113 112
114
115/* ---------------------------------------------------------------------- 113/* ----------------------------------------------------------------------
116 * each connection driver will have a pool of the following struct. 114 * each connection driver will have a pool of the following struct.
117 * 115 *
@@ -155,7 +153,6 @@ typedef struct {
155 153
156} MESSAGE_EVENT_T; 154} MESSAGE_EVENT_T;
157 155
158
159// callbacks 156// callbacks
160typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state ); 157typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state );
161 158
@@ -163,7 +160,6 @@ typedef struct {
163 VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback; 160 VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback;
164} VCHI_MESSAGE_DRIVER_OPEN_T; 161} VCHI_MESSAGE_DRIVER_OPEN_T;
165 162
166
167// handle to this instance of message driver (as returned by ->open) 163// handle to this instance of message driver (as returned by ->open)
168typedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T; 164typedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T;
169 165
@@ -195,7 +191,6 @@ struct opaque_vchi_message_driver_t {
195 void (*debug)( VCHI_MDRIVER_HANDLE_T *handle ); 191 void (*debug)( VCHI_MDRIVER_HANDLE_T *handle );
196}; 192};
197 193
198
199#endif // _VCHI_MESSAGE_H_ 194#endif // _VCHI_MESSAGE_H_
200 195
201/****************************** End of file ***********************************/ 196/****************************** End of file ***********************************/
diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h
index addb7b00b688..66a3a060fad2 100644
--- a/drivers/staging/vc04_services/interface/vchi/vchi.h
+++ b/drivers/staging/vc04_services/interface/vchi/vchi.h
@@ -39,7 +39,6 @@
39#include "interface/vchi/connections/connection.h" 39#include "interface/vchi/connections/connection.h"
40#include "vchi_mh.h" 40#include "vchi_mh.h"
41 41
42
43/****************************************************************************** 42/******************************************************************************
44 Global defs 43 Global defs
45 *****************************************************************************/ 44 *****************************************************************************/
@@ -92,7 +91,6 @@ typedef struct vchi_msg_vector_ex {
92 } u; 91 } u;
93} VCHI_MSG_VECTOR_EX_T; 92} VCHI_MSG_VECTOR_EX_T;
94 93
95
96// Construct an entry in a msg vector for a pointer (p) of length (l) 94// Construct an entry in a msg vector for a pointer (p) of length (l)
97#define VCHI_VEC_POINTER(p,l) VCHI_VEC_POINTER, { { (VCHI_MEM_HANDLE_T)(p), (l) } } 95#define VCHI_VEC_POINTER(p,l) VCHI_VEC_POINTER, { { (VCHI_MEM_HANDLE_T)(p), (l) } }
98 96
@@ -103,7 +101,6 @@ typedef struct vchi_msg_vector_ex {
103#define MAKE_FOURCC(x) ((int32_t)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] )) 101#define MAKE_FOURCC(x) ((int32_t)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] ))
104#define FOURCC_TO_CHAR(x) (x >> 24) & 0xFF,(x >> 16) & 0xFF,(x >> 8) & 0xFF, x & 0xFF 102#define FOURCC_TO_CHAR(x) (x >> 24) & 0xFF,(x >> 16) & 0xFF,(x >> 8) & 0xFF, x & 0xFF
105 103
106
107// Opaque service information 104// Opaque service information
108struct opaque_vchi_service_t; 105struct opaque_vchi_service_t;
109 106
@@ -114,8 +111,6 @@ typedef struct {
114 void *message; 111 void *message;
115} VCHI_HELD_MSG_T; 112} VCHI_HELD_MSG_T;
116 113
117
118
119// structure used to provide the information needed to open a server or a client 114// structure used to provide the information needed to open a server or a client
120typedef struct { 115typedef struct {
121 struct vchi_version version; 116 struct vchi_version version;
@@ -162,7 +157,6 @@ extern "C" {
162extern /*@observer@*/ VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table, 157extern /*@observer@*/ VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table,
163 const VCHI_MESSAGE_DRIVER_T * low_level); 158 const VCHI_MESSAGE_DRIVER_T * low_level);
164 159
165
166// Routine used to initialise the vchi on both local + remote connections 160// Routine used to initialise the vchi on both local + remote connections
167extern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle ); 161extern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle );
168 162
@@ -185,7 +179,6 @@ extern void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *lengt
185extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address); 179extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);
186extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); 180extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);
187 181
188
189/****************************************************************************** 182/******************************************************************************
190 Global service API 183 Global service API
191 *****************************************************************************/ 184 *****************************************************************************/
@@ -194,7 +187,7 @@ extern int32_t vchi_service_create( VCHI_INSTANCE_T instance_handle,
194 SERVICE_CREATION_T *setup, 187 SERVICE_CREATION_T *setup,
195 VCHI_SERVICE_HANDLE_T *handle ); 188 VCHI_SERVICE_HANDLE_T *handle );
196 189
197// Routine to destory a service 190// Routine to destroy a service
198extern int32_t vchi_service_destroy( const VCHI_SERVICE_HANDLE_T handle ); 191extern int32_t vchi_service_destroy( const VCHI_SERVICE_HANDLE_T handle );
199 192
200// Routine to open a named service 193// Routine to open a named service
@@ -307,7 +300,6 @@ extern int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter,
307 uint32_t *msg_size, // } 300 uint32_t *msg_size, // }
308 VCHI_HELD_MSG_T *message ); 301 VCHI_HELD_MSG_T *message );
309 302
310
311/****************************************************************************** 303/******************************************************************************
312 Global bulk API 304 Global bulk API
313 *****************************************************************************/ 305 *****************************************************************************/
@@ -319,7 +311,6 @@ extern int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle,
319 VCHI_FLAGS_T flags, 311 VCHI_FLAGS_T flags,
320 void *transfer_handle ); 312 void *transfer_handle );
321 313
322
323// Prepare interface for a transfer from the other side into relocatable memory. 314// Prepare interface for a transfer from the other side into relocatable memory.
324int32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle, 315int32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle,
325 VCHI_MEM_HANDLE_T h_dst, 316 VCHI_MEM_HANDLE_T h_dst,
@@ -335,7 +326,6 @@ extern int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle,
335 VCHI_FLAGS_T flags, 326 VCHI_FLAGS_T flags,
336 void *transfer_handle ); 327 void *transfer_handle );
337 328
338
339/****************************************************************************** 329/******************************************************************************
340 Configuration plumbing 330 Configuration plumbing
341 *****************************************************************************/ 331 *****************************************************************************/
diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h
index 45c2070d46b0..76e10fe65d9b 100644
--- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h
+++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h
@@ -34,7 +34,6 @@
34#ifndef VCHI_COMMON_H_ 34#ifndef VCHI_COMMON_H_
35#define VCHI_COMMON_H_ 35#define VCHI_COMMON_H_
36 36
37
38//flags used when sending messages (must be bitmapped) 37//flags used when sending messages (must be bitmapped)
39typedef enum { 38typedef enum {
40 VCHI_FLAGS_NONE = 0x0, 39 VCHI_FLAGS_NONE = 0x0,
@@ -118,14 +117,11 @@ typedef enum {
118 VCHI_SERVICE_OPTION_MAX 117 VCHI_SERVICE_OPTION_MAX
119} VCHI_SERVICE_OPTION_T; 118} VCHI_SERVICE_OPTION_T;
120 119
121
122//Callback used by all services / bulk transfers 120//Callback used by all services / bulk transfers
123typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param 121typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param
124 VCHI_CALLBACK_REASON_T reason, 122 VCHI_CALLBACK_REASON_T reason,
125 void *handle); //for transmitting msg's only 123 void *handle); //for transmitting msg's only
126 124
127
128
129/* 125/*
130 * Define vector struct for scatter-gather (vector) operations 126 * Define vector struct for scatter-gather (vector) operations
131 * Vectors can be nested - if a vector element has negative length, then 127 * Vectors can be nested - if a vector element has negative length, then
@@ -154,7 +150,6 @@ typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T;
154// Opaque type for a message driver 150// Opaque type for a message driver
155typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; 151typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T;
156 152
157
158// Iterator structure for reading ahead through received message queue. Allocated by client, 153// Iterator structure for reading ahead through received message queue. Allocated by client,
159// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only. 154// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only.
160// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead - 155// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead -
@@ -168,5 +163,4 @@ typedef struct {
168 void *remove; 163 void *remove;
169} VCHI_MSG_ITER_T; 164} VCHI_MSG_ITER_T;
170 165
171
172#endif // VCHI_COMMON_H_ 166#endif // VCHI_COMMON_H_
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index be08849175ea..eea2d78b0ec6 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -59,10 +59,10 @@
59#define BELL0 0x00 59#define BELL0 0x00
60#define BELL2 0x08 60#define BELL2 0x08
61 61
62typedef struct vchiq_2835_state_struct { 62struct vchiq_2835_state {
63 int inited; 63 int inited;
64 VCHIQ_ARM_STATE_T arm_state; 64 VCHIQ_ARM_STATE_T arm_state;
65} VCHIQ_2835_ARM_STATE_T; 65};
66 66
67struct vchiq_pagelist_info { 67struct vchiq_pagelist_info {
68 PAGELIST_T *pagelist; 68 PAGELIST_T *pagelist;
@@ -84,8 +84,6 @@ static char *g_free_fragments;
84static struct semaphore g_free_fragments_sema; 84static struct semaphore g_free_fragments_sema;
85static struct device *g_dev; 85static struct device *g_dev;
86 86
87extern int vchiq_arm_log_level;
88
89static DEFINE_SEMAPHORE(g_free_fragments_mutex); 87static DEFINE_SEMAPHORE(g_free_fragments_mutex);
90 88
91static irqreturn_t 89static irqreturn_t
@@ -206,25 +204,31 @@ VCHIQ_STATUS_T
206vchiq_platform_init_state(VCHIQ_STATE_T *state) 204vchiq_platform_init_state(VCHIQ_STATE_T *state)
207{ 205{
208 VCHIQ_STATUS_T status = VCHIQ_SUCCESS; 206 VCHIQ_STATUS_T status = VCHIQ_SUCCESS;
207 struct vchiq_2835_state *platform_state;
208
209 state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
210 platform_state = (struct vchiq_2835_state *)state->platform_state;
211
212 platform_state->inited = 1;
213 status = vchiq_arm_init_state(state, &platform_state->arm_state);
209 214
210 state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), GFP_KERNEL);
211 ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 1;
212 status = vchiq_arm_init_state(state, &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state);
213 if (status != VCHIQ_SUCCESS) 215 if (status != VCHIQ_SUCCESS)
214 { 216 platform_state->inited = 0;
215 ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 0; 217
216 }
217 return status; 218 return status;
218} 219}
219 220
220VCHIQ_ARM_STATE_T* 221VCHIQ_ARM_STATE_T*
221vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) 222vchiq_platform_get_arm_state(VCHIQ_STATE_T *state)
222{ 223{
223 if (!((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited) 224 struct vchiq_2835_state *platform_state;
224 { 225
226 platform_state = (struct vchiq_2835_state *)state->platform_state;
227
228 if (!platform_state->inited)
225 BUG(); 229 BUG();
226 } 230
227 return &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state; 231 return &platform_state->arm_state;
228} 232}
229 233
230void 234void
@@ -383,12 +387,12 @@ cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo)
383} 387}
384 388
385/* There is a potential problem with partial cache lines (pages?) 389/* There is a potential problem with partial cache lines (pages?)
386** at the ends of the block when reading. If the CPU accessed anything in 390 * at the ends of the block when reading. If the CPU accessed anything in
387** the same line (page?) then it may have pulled old data into the cache, 391 * the same line (page?) then it may have pulled old data into the cache,
388** obscuring the new data underneath. We can solve this by transferring the 392 * obscuring the new data underneath. We can solve this by transferring the
389** partial cache lines separately, and allowing the ARM to copy into the 393 * partial cache lines separately, and allowing the ARM to copy into the
390** cached area. 394 * cached area.
391*/ 395 */
392 396
393static struct vchiq_pagelist_info * 397static struct vchiq_pagelist_info *
394create_pagelist(char __user *buf, size_t count, unsigned short type, 398create_pagelist(char __user *buf, size_t count, unsigned short type,
@@ -415,15 +419,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
415 sizeof(struct vchiq_pagelist_info); 419 sizeof(struct vchiq_pagelist_info);
416 420
417 /* Allocate enough storage to hold the page pointers and the page 421 /* Allocate enough storage to hold the page pointers and the page
418 ** list 422 * list
419 */ 423 */
420 pagelist = dma_zalloc_coherent(g_dev, 424 pagelist = dma_zalloc_coherent(g_dev,
421 pagelist_size, 425 pagelist_size,
422 &dma_addr, 426 &dma_addr,
423 GFP_KERNEL); 427 GFP_KERNEL);
424 428
425 vchiq_log_trace(vchiq_arm_log_level, "create_pagelist - %pK", 429 vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist);
426 pagelist); 430
427 if (!pagelist) 431 if (!pagelist)
428 return NULL; 432 return NULL;
429 433
@@ -483,9 +487,8 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
483 487
484 if (actual_pages != num_pages) { 488 if (actual_pages != num_pages) {
485 vchiq_log_info(vchiq_arm_log_level, 489 vchiq_log_info(vchiq_arm_log_level,
486 "create_pagelist - only %d/%d pages locked", 490 "%s - only %d/%d pages locked",
487 actual_pages, 491 __func__, actual_pages, num_pages);
488 num_pages);
489 492
490 /* This is probably due to the process being killed */ 493 /* This is probably due to the process being killed */
491 while (actual_pages > 0) 494 while (actual_pages > 0)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 314ffac50bb8..411539f8ff8c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -109,9 +109,7 @@ static const char *const resume_state_names[] = {
109 * requested */ 109 * requested */
110#define FORCE_SUSPEND_TIMEOUT_MS 200 110#define FORCE_SUSPEND_TIMEOUT_MS 200
111 111
112 112static void suspend_timer_callback(struct timer_list *t);
113static void suspend_timer_callback(unsigned long context);
114
115 113
116typedef struct user_service_struct { 114typedef struct user_service_struct {
117 VCHIQ_SERVICE_T *service; 115 VCHIQ_SERVICE_T *service;
@@ -195,11 +193,6 @@ static const char *const ioctl_names[] = {
195vchiq_static_assert(ARRAY_SIZE(ioctl_names) == 193vchiq_static_assert(ARRAY_SIZE(ioctl_names) ==
196 (VCHIQ_IOC_MAX + 1)); 194 (VCHIQ_IOC_MAX + 1));
197 195
198#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP)
199static void
200dump_phys_mem(void *virt_addr, u32 num_bytes);
201#endif
202
203/**************************************************************************** 196/****************************************************************************
204* 197*
205* add_completion 198* add_completion
@@ -1161,20 +1154,6 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1161 args.handle, args.option, args.value); 1154 args.handle, args.option, args.value);
1162 } break; 1155 } break;
1163 1156
1164#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP)
1165 case VCHIQ_IOC_DUMP_PHYS_MEM: {
1166 VCHIQ_DUMP_MEM_T args;
1167
1168 if (copy_from_user
1169 (&args, (const void __user *)arg,
1170 sizeof(args)) != 0) {
1171 ret = -EFAULT;
1172 break;
1173 }
1174 dump_phys_mem(args.virt_addr, args.num_bytes);
1175 } break;
1176#endif
1177
1178 case VCHIQ_IOC_LIB_VERSION: { 1157 case VCHIQ_IOC_LIB_VERSION: {
1179 unsigned int lib_version = (unsigned int)arg; 1158 unsigned int lib_version = (unsigned int)arg;
1180 1159
@@ -1654,42 +1633,6 @@ vchiq_compat_ioctl_get_config(struct file *file,
1654 return vchiq_ioctl(file, VCHIQ_IOC_GET_CONFIG, (unsigned long)args); 1633 return vchiq_ioctl(file, VCHIQ_IOC_GET_CONFIG, (unsigned long)args);
1655} 1634}
1656 1635
1657#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP)
1658
1659struct vchiq_dump_mem32 {
1660 compat_uptr_t virt_addr;
1661 u32 num_bytes;
1662};
1663
1664#define VCHIQ_IOC_DUMP_PHYS_MEM32 \
1665 _IOW(VCHIQ_IOC_MAGIC, 15, struct vchiq_dump_mem32)
1666
1667static long
1668vchiq_compat_ioctl_dump_phys_mem(struct file *file,
1669 unsigned int cmd,
1670 unsigned long arg)
1671{
1672 VCHIQ_DUMP_MEM_T *args;
1673 struct vchiq_dump_mem32 args32;
1674
1675 args = compat_alloc_user_space(sizeof(*args));
1676 if (!args)
1677 return -EFAULT;
1678
1679 if (copy_from_user(&args32,
1680 (struct vchiq_dump_mem32 *)arg,
1681 sizeof(args32)))
1682 return -EFAULT;
1683
1684 if (put_user(compat_ptr(args32.virt_addr), &args->virt_addr) ||
1685 put_user(args32.num_bytes, &args->num_bytes))
1686 return -EFAULT;
1687
1688 return vchiq_ioctl(file, VCHIQ_IOC_DUMP_PHYS_MEM, (unsigned long)args);
1689}
1690
1691#endif
1692
1693static long 1636static long
1694vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1637vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1695{ 1638{
@@ -1707,10 +1650,6 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1707 return vchiq_compat_ioctl_dequeue_message(file, cmd, arg); 1650 return vchiq_compat_ioctl_dequeue_message(file, cmd, arg);
1708 case VCHIQ_IOC_GET_CONFIG32: 1651 case VCHIQ_IOC_GET_CONFIG32:
1709 return vchiq_compat_ioctl_get_config(file, cmd, arg); 1652 return vchiq_compat_ioctl_get_config(file, cmd, arg);
1710#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP)
1711 case VCHIQ_IOC_DUMP_PHYS_MEM32:
1712 return vchiq_compat_ioctl_dump_phys_mem(file, cmd, arg);
1713#endif
1714 default: 1653 default:
1715 return vchiq_ioctl(file, cmd, arg); 1654 return vchiq_ioctl(file, cmd, arg);
1716 } 1655 }
@@ -2050,98 +1989,6 @@ vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service)
2050 1989
2051/**************************************************************************** 1990/****************************************************************************
2052* 1991*
2053* dump_user_mem
2054*
2055***************************************************************************/
2056
2057#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP)
2058
2059static void
2060dump_phys_mem(void *virt_addr, u32 num_bytes)
2061{
2062 int rc;
2063 u8 *end_virt_addr = virt_addr + num_bytes;
2064 int num_pages;
2065 int offset;
2066 int end_offset;
2067 int page_idx;
2068 int prev_idx;
2069 struct page *page;
2070 struct page **pages;
2071 u8 *kmapped_virt_ptr;
2072
2073 /* Align virt_addr and end_virt_addr to 16 byte boundaries. */
2074
2075 virt_addr = (void *)((unsigned long)virt_addr & ~0x0fuL);
2076 end_virt_addr = (void *)(((unsigned long)end_virt_addr + 15uL) &
2077 ~0x0fuL);
2078
2079 offset = (int)(long)virt_addr & (PAGE_SIZE - 1);
2080 end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1);
2081
2082 num_pages = DIV_ROUND_UP(offset + num_bytes, PAGE_SIZE);
2083
2084 pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
2085 if (!pages) {
2086 vchiq_log_error(vchiq_arm_log_level,
2087 "Unable to allocation memory for %d pages\n",
2088 num_pages);
2089 return;
2090 }
2091
2092 down_read(&current->mm->mmap_sem);
2093 rc = get_user_pages(
2094 (unsigned long)virt_addr, /* start */
2095 num_pages, /* len */
2096 0, /* gup_flags */
2097 pages, /* pages (array of page pointers) */
2098 NULL); /* vmas */
2099 up_read(&current->mm->mmap_sem);
2100
2101 prev_idx = -1;
2102 page = NULL;
2103
2104 if (rc < 0) {
2105 vchiq_log_error(vchiq_arm_log_level,
2106 "Failed to get user pages: %d\n", rc);
2107 goto out;
2108 }
2109
2110 while (offset < end_offset) {
2111 int page_offset = offset % PAGE_SIZE;
2112
2113 page_idx = offset / PAGE_SIZE;
2114 if (page_idx != prev_idx) {
2115 if (page != NULL)
2116 kunmap(page);
2117 page = pages[page_idx];
2118 kmapped_virt_ptr = kmap(page);
2119 prev_idx = page_idx;
2120 }
2121
2122 if (vchiq_arm_log_level >= VCHIQ_LOG_TRACE)
2123 vchiq_log_dump_mem("ph",
2124 (u32)(unsigned long)&kmapped_virt_ptr[
2125 page_offset],
2126 &kmapped_virt_ptr[page_offset], 16);
2127
2128 offset += 16;
2129 }
2130
2131out:
2132 if (page != NULL)
2133 kunmap(page);
2134
2135 for (page_idx = 0; page_idx < num_pages; page_idx++)
2136 put_page(pages[page_idx]);
2137
2138 kfree(pages);
2139}
2140
2141#endif
2142
2143/****************************************************************************
2144*
2145* vchiq_read 1992* vchiq_read
2146* 1993*
2147***************************************************************************/ 1994***************************************************************************/
@@ -2307,8 +2154,6 @@ exit:
2307 return 0; 2154 return 0;
2308} 2155}
2309 2156
2310
2311
2312VCHIQ_STATUS_T 2157VCHIQ_STATUS_T
2313vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state) 2158vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state)
2314{ 2159{
@@ -2339,8 +2184,9 @@ vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state)
2339 2184
2340 arm_state->suspend_timer_timeout = SUSPEND_TIMER_TIMEOUT_MS; 2185 arm_state->suspend_timer_timeout = SUSPEND_TIMER_TIMEOUT_MS;
2341 arm_state->suspend_timer_running = 0; 2186 arm_state->suspend_timer_running = 0;
2342 setup_timer(&arm_state->suspend_timer, suspend_timer_callback, 2187 arm_state->state = state;
2343 (unsigned long)(state)); 2188 timer_setup(&arm_state->suspend_timer, suspend_timer_callback,
2189 0);
2344 2190
2345 arm_state->first_connect = 0; 2191 arm_state->first_connect = 0;
2346 2192
@@ -2469,7 +2315,6 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state,
2469 } 2315 }
2470} 2316}
2471 2317
2472
2473/* should be called with the write lock held */ 2318/* should be called with the write lock held */
2474inline void 2319inline void
2475start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) 2320start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state)
@@ -2589,7 +2434,6 @@ vchiq_arm_vcsuspend(VCHIQ_STATE_T *state)
2589 vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); 2434 vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
2590 status = VCHIQ_SUCCESS; 2435 status = VCHIQ_SUCCESS;
2591 2436
2592
2593 switch (arm_state->vc_suspend_state) { 2437 switch (arm_state->vc_suspend_state) {
2594 case VC_SUSPEND_REQUESTED: 2438 case VC_SUSPEND_REQUESTED:
2595 vchiq_log_info(vchiq_susp_log_level, "%s: suspend already " 2439 vchiq_log_info(vchiq_susp_log_level, "%s: suspend already "
@@ -2654,7 +2498,6 @@ out:
2654 return; 2498 return;
2655} 2499}
2656 2500
2657
2658static void 2501static void
2659output_timeout_error(VCHIQ_STATE_T *state) 2502output_timeout_error(VCHIQ_STATE_T *state)
2660{ 2503{
@@ -2834,7 +2677,6 @@ out:
2834 return; 2677 return;
2835} 2678}
2836 2679
2837
2838int 2680int
2839vchiq_arm_allow_resume(VCHIQ_STATE_T *state) 2681vchiq_arm_allow_resume(VCHIQ_STATE_T *state)
2840{ 2682{
@@ -2996,7 +2838,6 @@ vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service,
2996 "%s %s count %d, state count %d", 2838 "%s %s count %d, state count %d",
2997 __func__, entity, *entity_uc, local_uc); 2839 __func__, entity, *entity_uc, local_uc);
2998 2840
2999
3000 write_unlock_bh(&arm_state->susp_res_lock); 2841 write_unlock_bh(&arm_state->susp_res_lock);
3001 2842
3002 /* Completion is in a done state when we're not suspended, so this won't 2843 /* Completion is in a done state when we're not suspended, so this won't
@@ -3177,18 +3018,14 @@ vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace)
3177 instance->trace = (trace != 0); 3018 instance->trace = (trace != 0);
3178} 3019}
3179 3020
3180static void suspend_timer_callback(unsigned long context) 3021static void suspend_timer_callback(struct timer_list *t)
3181{ 3022{
3182 VCHIQ_STATE_T *state = (VCHIQ_STATE_T *)context; 3023 VCHIQ_ARM_STATE_T *arm_state = from_timer(arm_state, t, suspend_timer);
3183 VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); 3024 VCHIQ_STATE_T *state = arm_state->state;
3184 3025
3185 if (!arm_state)
3186 goto out;
3187 vchiq_log_info(vchiq_susp_log_level, 3026 vchiq_log_info(vchiq_susp_log_level,
3188 "%s - suspend timer expired - check suspend", __func__); 3027 "%s - suspend timer expired - check suspend", __func__);
3189 vchiq_check_suspend(state); 3028 vchiq_check_suspend(state);
3190out:
3191 return;
3192} 3029}
3193 3030
3194VCHIQ_STATUS_T 3031VCHIQ_STATUS_T
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
index bfbd81d9db33..40bb0c63b1a9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
@@ -42,7 +42,6 @@
42#include "vchiq_core.h" 42#include "vchiq_core.h"
43#include "vchiq_debugfs.h" 43#include "vchiq_debugfs.h"
44 44
45
46enum vc_suspend_status { 45enum vc_suspend_status {
47 VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */ 46 VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */
48 VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */ 47 VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */
@@ -61,15 +60,12 @@ enum vc_resume_status {
61 VC_RESUME_RESUMED /* Videocore resumed successfully (active) */ 60 VC_RESUME_RESUMED /* Videocore resumed successfully (active) */
62}; 61};
63 62
64
65enum USE_TYPE_E { 63enum USE_TYPE_E {
66 USE_TYPE_SERVICE, 64 USE_TYPE_SERVICE,
67 USE_TYPE_SERVICE_NO_RESUME, 65 USE_TYPE_SERVICE_NO_RESUME,
68 USE_TYPE_VCHIQ 66 USE_TYPE_VCHIQ
69}; 67};
70 68
71
72
73typedef struct vchiq_arm_state_struct { 69typedef struct vchiq_arm_state_struct {
74 /* Keepalive-related data */ 70 /* Keepalive-related data */
75 struct task_struct *ka_thread; 71 struct task_struct *ka_thread;
@@ -87,6 +83,7 @@ typedef struct vchiq_arm_state_struct {
87 83
88 unsigned int wake_address; 84 unsigned int wake_address;
89 85
86 VCHIQ_STATE_T *state;
90 struct timer_list suspend_timer; 87 struct timer_list suspend_timer;
91 int suspend_timer_timeout; 88 int suspend_timer_timeout;
92 int suspend_timer_running; 89 int suspend_timer_running;
@@ -216,5 +213,4 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state,
216extern void 213extern void
217start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state); 214start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state);
218 215
219
220#endif /* VCHIQ_ARM_H */ 216#endif /* VCHIQ_ARM_H */
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 486be990d7fc..ecff92bae200 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -130,7 +130,6 @@ static const char *const conn_state_names[] = {
130 "RESUME_TIMEOUT" 130 "RESUME_TIMEOUT"
131}; 131};
132 132
133
134static void 133static void
135release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header); 134release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header);
136 135
@@ -2168,7 +2167,6 @@ slot_handler_func(void *v)
2168 break; 2167 break;
2169 } 2168 }
2170 2169
2171
2172 } 2170 }
2173 2171
2174 DEBUG_TRACE(SLOT_HANDLER_LINE); 2172 DEBUG_TRACE(SLOT_HANDLER_LINE);
@@ -2177,7 +2175,6 @@ slot_handler_func(void *v)
2177 return 0; 2175 return 0;
2178} 2176}
2179 2177
2180
2181/* Called by the recycle thread */ 2178/* Called by the recycle thread */
2182static int 2179static int
2183recycle_func(void *v) 2180recycle_func(void *v)
@@ -2193,7 +2190,6 @@ recycle_func(void *v)
2193 return 0; 2190 return 0;
2194} 2191}
2195 2192
2196
2197/* Called by the sync thread */ 2193/* Called by the sync thread */
2198static int 2194static int
2199sync_func(void *v) 2195sync_func(void *v)
@@ -2301,7 +2297,6 @@ sync_func(void *v)
2301 return 0; 2297 return 0;
2302} 2298}
2303 2299
2304
2305static void 2300static void
2306init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue) 2301init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue)
2307{ 2302{
@@ -2312,14 +2307,12 @@ init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue)
2312 queue->remove = 0; 2307 queue->remove = 0;
2313} 2308}
2314 2309
2315
2316inline const char * 2310inline const char *
2317get_conn_state_name(VCHIQ_CONNSTATE_T conn_state) 2311get_conn_state_name(VCHIQ_CONNSTATE_T conn_state)
2318{ 2312{
2319 return conn_state_names[conn_state]; 2313 return conn_state_names[conn_state];
2320} 2314}
2321 2315
2322
2323VCHIQ_SLOT_ZERO_T * 2316VCHIQ_SLOT_ZERO_T *
2324vchiq_init_slots(void *mem_base, int mem_size) 2317vchiq_init_slots(void *mem_base, int mem_size)
2325{ 2318{
@@ -2958,8 +2951,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd)
2958 2951
2959 case VCHIQ_SRVSTATE_OPENSYNC: 2952 case VCHIQ_SRVSTATE_OPENSYNC:
2960 mutex_lock(&state->sync_mutex); 2953 mutex_lock(&state->sync_mutex);
2961 /* Drop through */ 2954 /* fall through */
2962
2963 case VCHIQ_SRVSTATE_OPEN: 2955 case VCHIQ_SRVSTATE_OPEN:
2964 if (state->is_master || close_recvd) { 2956 if (state->is_master || close_recvd) {
2965 if (!do_abort_bulks(service)) 2957 if (!do_abort_bulks(service))
@@ -3296,7 +3288,6 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle)
3296 return status; 3288 return status;
3297} 3289}
3298 3290
3299
3300/* This function may be called by kernel threads or user threads. 3291/* This function may be called by kernel threads or user threads.
3301 * User threads may receive VCHIQ_RETRY to indicate that a signal has been 3292 * User threads may receive VCHIQ_RETRY to indicate that a signal has been
3302 * received and the call should be retried after being returned to user 3293 * received and the call should be retried after being returned to user
@@ -3876,7 +3867,6 @@ vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service)
3876 vchiq_dump_platform_service_state(dump_context, service); 3867 vchiq_dump_platform_service_state(dump_context, service);
3877} 3868}
3878 3869
3879
3880void 3870void
3881vchiq_loud_error_header(void) 3871vchiq_loud_error_header(void)
3882{ 3872{
@@ -3901,7 +3891,6 @@ vchiq_loud_error_footer(void)
3901 "================"); 3891 "================");
3902} 3892}
3903 3893
3904
3905VCHIQ_STATUS_T vchiq_send_remote_use(VCHIQ_STATE_T *state) 3894VCHIQ_STATUS_T vchiq_send_remote_use(VCHIQ_STATE_T *state)
3906{ 3895{
3907 VCHIQ_STATUS_T status = VCHIQ_RETRY; 3896 VCHIQ_STATUS_T status = VCHIQ_RETRY;
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
index 9e164652548a..afc1d8144a84 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
@@ -702,7 +702,6 @@ vchiq_platform_handle_timeout(VCHIQ_STATE_T *state);
702extern void 702extern void
703vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate); 703vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate);
704 704
705
706extern void 705extern void
707vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, 706vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem,
708 size_t numBytes); 707 size_t numBytes);
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 9367a9a5aa3c..766b4fe5f32c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -32,7 +32,6 @@
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35
36#include <linux/debugfs.h> 35#include <linux/debugfs.h>
37#include "vchiq_core.h" 36#include "vchiq_core.h"
38#include "vchiq_arm.h" 37#include "vchiq_arm.h"
@@ -52,7 +51,6 @@
52#define VCHIQ_LOG_INFO_STR "info" 51#define VCHIQ_LOG_INFO_STR "info"
53#define VCHIQ_LOG_TRACE_STR "trace" 52#define VCHIQ_LOG_TRACE_STR "trace"
54 53
55
56/* Top-level debug info */ 54/* Top-level debug info */
57struct vchiq_debugfs_info { 55struct vchiq_debugfs_info {
58 /* Global 'vchiq' debugfs entry used by all instances */ 56 /* Global 'vchiq' debugfs entry used by all instances */
@@ -316,7 +314,6 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
316 debugfs_remove_recursive(node->dentry); 314 debugfs_remove_recursive(node->dentry);
317} 315}
318 316
319
320int vchiq_debugfs_init(void) 317int vchiq_debugfs_init(void)
321{ 318{
322 BUG_ON(debugfs_info.vchiq_cfg_dir != NULL); 319 BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
index 8af95fc361ed..d465e1cf5db9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
@@ -41,14 +41,14 @@
41 41
42#define vchiq_status_to_vchi(status) ((int32_t)status) 42#define vchiq_status_to_vchi(status) ((int32_t)status)
43 43
44typedef struct { 44struct shim_service {
45 VCHIQ_SERVICE_HANDLE_T handle; 45 VCHIQ_SERVICE_HANDLE_T handle;
46 46
47 VCHIU_QUEUE_T queue; 47 VCHIU_QUEUE_T queue;
48 48
49 VCHI_CALLBACK_T callback; 49 VCHI_CALLBACK_T callback;
50 void *callback_param; 50 void *callback_param;
51} SHIM_SERVICE_T; 51};
52 52
53/* ---------------------------------------------------------------------- 53/* ----------------------------------------------------------------------
54 * return pointer to the mphi message driver function table 54 * return pointer to the mphi message driver function table
@@ -84,7 +84,6 @@ VCHI_CONNECTION_T *vchi_create_connection(
84 * void **data, 84 * void **data,
85 * uint32_t *msg_size, 85 * uint32_t *msg_size,
86 86
87
88 * VCHI_FLAGS_T flags 87 * VCHI_FLAGS_T flags
89 * 88 *
90 * Description: Routine to return a pointer to the current message (to allow in 89 * Description: Routine to return a pointer to the current message (to allow in
@@ -99,7 +98,7 @@ int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle,
99 uint32_t *msg_size, 98 uint32_t *msg_size,
100 VCHI_FLAGS_T flags) 99 VCHI_FLAGS_T flags)
101{ 100{
102 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 101 struct shim_service *service = (struct shim_service *)handle;
103 VCHIQ_HEADER_T *header; 102 VCHIQ_HEADER_T *header;
104 103
105 WARN_ON((flags != VCHI_FLAGS_NONE) && 104 WARN_ON((flags != VCHI_FLAGS_NONE) &&
@@ -131,7 +130,7 @@ EXPORT_SYMBOL(vchi_msg_peek);
131 ***********************************************************/ 130 ***********************************************************/
132int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle) 131int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle)
133{ 132{
134 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 133 struct shim_service *service = (struct shim_service *)handle;
135 VCHIQ_HEADER_T *header; 134 VCHIQ_HEADER_T *header;
136 135
137 header = vchiu_queue_pop(&service->queue); 136 header = vchiu_queue_pop(&service->queue);
@@ -163,7 +162,7 @@ int32_t vchi_msg_queue(VCHI_SERVICE_HANDLE_T handle,
163 void *context, 162 void *context,
164 uint32_t data_size) 163 uint32_t data_size)
165{ 164{
166 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 165 struct shim_service *service = (struct shim_service *)handle;
167 VCHIQ_STATUS_T status; 166 VCHIQ_STATUS_T status;
168 167
169 while (1) { 168 while (1) {
@@ -262,7 +261,7 @@ int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle,
262 VCHI_FLAGS_T flags, 261 VCHI_FLAGS_T flags,
263 void *bulk_handle) 262 void *bulk_handle)
264{ 263{
265 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 264 struct shim_service *service = (struct shim_service *)handle;
266 VCHIQ_BULK_MODE_T mode; 265 VCHIQ_BULK_MODE_T mode;
267 VCHIQ_STATUS_T status; 266 VCHIQ_STATUS_T status;
268 267
@@ -322,7 +321,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
322 VCHI_FLAGS_T flags, 321 VCHI_FLAGS_T flags,
323 void *bulk_handle) 322 void *bulk_handle)
324{ 323{
325 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 324 struct shim_service *service = (struct shim_service *)handle;
326 VCHIQ_BULK_MODE_T mode; 325 VCHIQ_BULK_MODE_T mode;
327 VCHIQ_STATUS_T status; 326 VCHIQ_STATUS_T status;
328 327
@@ -384,7 +383,7 @@ int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle,
384 uint32_t *actual_msg_size, 383 uint32_t *actual_msg_size,
385 VCHI_FLAGS_T flags) 384 VCHI_FLAGS_T flags)
386{ 385{
387 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 386 struct shim_service *service = (struct shim_service *)handle;
388 VCHIQ_HEADER_T *header; 387 VCHIQ_HEADER_T *header;
389 388
390 WARN_ON((flags != VCHI_FLAGS_NONE) && 389 WARN_ON((flags != VCHI_FLAGS_NONE) &&
@@ -458,7 +457,7 @@ int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle,
458 VCHI_FLAGS_T flags, 457 VCHI_FLAGS_T flags,
459 VCHI_HELD_MSG_T *message_handle) 458 VCHI_HELD_MSG_T *message_handle)
460{ 459{
461 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 460 struct shim_service *service = (struct shim_service *)handle;
462 VCHIQ_HEADER_T *header; 461 VCHIQ_HEADER_T *header;
463 462
464 WARN_ON((flags != VCHI_FLAGS_NONE) && 463 WARN_ON((flags != VCHI_FLAGS_NONE) &&
@@ -541,7 +540,6 @@ int32_t vchi_connect(VCHI_CONNECTION_T **connections,
541} 540}
542EXPORT_SYMBOL(vchi_connect); 541EXPORT_SYMBOL(vchi_connect);
543 542
544
545/*********************************************************** 543/***********************************************************
546 * Name: vchi_disconnect 544 * Name: vchi_disconnect
547 * 545 *
@@ -561,7 +559,6 @@ int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle)
561} 559}
562EXPORT_SYMBOL(vchi_disconnect); 560EXPORT_SYMBOL(vchi_disconnect);
563 561
564
565/*********************************************************** 562/***********************************************************
566 * Name: vchi_service_open 563 * Name: vchi_service_open
567 * Name: vchi_service_create 564 * Name: vchi_service_create
@@ -579,8 +576,8 @@ EXPORT_SYMBOL(vchi_disconnect);
579static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason, 576static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason,
580 VCHIQ_HEADER_T *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user) 577 VCHIQ_HEADER_T *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user)
581{ 578{
582 SHIM_SERVICE_T *service = 579 struct shim_service *service =
583 (SHIM_SERVICE_T *)VCHIQ_GET_SERVICE_USERDATA(handle); 580 (struct shim_service *)VCHIQ_GET_SERVICE_USERDATA(handle);
584 581
585 if (!service->callback) 582 if (!service->callback)
586 goto release; 583 goto release;
@@ -637,10 +634,10 @@ done:
637 return VCHIQ_SUCCESS; 634 return VCHIQ_SUCCESS;
638} 635}
639 636
640static SHIM_SERVICE_T *service_alloc(VCHIQ_INSTANCE_T instance, 637static struct shim_service *service_alloc(VCHIQ_INSTANCE_T instance,
641 SERVICE_CREATION_T *setup) 638 SERVICE_CREATION_T *setup)
642{ 639{
643 SHIM_SERVICE_T *service = kzalloc(sizeof(SHIM_SERVICE_T), GFP_KERNEL); 640 struct shim_service *service = kzalloc(sizeof(struct shim_service), GFP_KERNEL);
644 641
645 (void)instance; 642 (void)instance;
646 643
@@ -657,7 +654,7 @@ static SHIM_SERVICE_T *service_alloc(VCHIQ_INSTANCE_T instance,
657 return service; 654 return service;
658} 655}
659 656
660static void service_free(SHIM_SERVICE_T *service) 657static void service_free(struct shim_service *service)
661{ 658{
662 if (service) { 659 if (service) {
663 vchiu_queue_delete(&service->queue); 660 vchiu_queue_delete(&service->queue);
@@ -670,7 +667,7 @@ int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle,
670 VCHI_SERVICE_HANDLE_T *handle) 667 VCHI_SERVICE_HANDLE_T *handle)
671{ 668{
672 VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; 669 VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle;
673 SHIM_SERVICE_T *service = service_alloc(instance, setup); 670 struct shim_service *service = service_alloc(instance, setup);
674 671
675 *handle = (VCHI_SERVICE_HANDLE_T)service; 672 *handle = (VCHI_SERVICE_HANDLE_T)service;
676 673
@@ -703,7 +700,7 @@ int32_t vchi_service_create(VCHI_INSTANCE_T instance_handle,
703 VCHI_SERVICE_HANDLE_T *handle) 700 VCHI_SERVICE_HANDLE_T *handle)
704{ 701{
705 VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; 702 VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle;
706 SHIM_SERVICE_T *service = service_alloc(instance, setup); 703 struct shim_service *service = service_alloc(instance, setup);
707 704
708 *handle = (VCHI_SERVICE_HANDLE_T)service; 705 *handle = (VCHI_SERVICE_HANDLE_T)service;
709 706
@@ -733,7 +730,7 @@ EXPORT_SYMBOL(vchi_service_create);
733int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) 730int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle)
734{ 731{
735 int32_t ret = -1; 732 int32_t ret = -1;
736 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 733 struct shim_service *service = (struct shim_service *)handle;
737 734
738 if (service) { 735 if (service) {
739 VCHIQ_STATUS_T status = vchiq_close_service(service->handle); 736 VCHIQ_STATUS_T status = vchiq_close_service(service->handle);
@@ -751,7 +748,7 @@ EXPORT_SYMBOL(vchi_service_close);
751int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) 748int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle)
752{ 749{
753 int32_t ret = -1; 750 int32_t ret = -1;
754 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 751 struct shim_service *service = (struct shim_service *)handle;
755 752
756 if (service) { 753 if (service) {
757 VCHIQ_STATUS_T status = vchiq_remove_service(service->handle); 754 VCHIQ_STATUS_T status = vchiq_remove_service(service->handle);
@@ -772,7 +769,7 @@ int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle,
772 int value) 769 int value)
773{ 770{
774 int32_t ret = -1; 771 int32_t ret = -1;
775 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 772 struct shim_service *service = (struct shim_service *)handle;
776 VCHIQ_SERVICE_OPTION_T vchiq_option; 773 VCHIQ_SERVICE_OPTION_T vchiq_option;
777 774
778 switch (option) { 775 switch (option) {
@@ -801,7 +798,7 @@ EXPORT_SYMBOL(vchi_service_set_option);
801int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, short *peer_version) 798int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, short *peer_version)
802{ 799{
803 int32_t ret = -1; 800 int32_t ret = -1;
804 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 801 struct shim_service *service = (struct shim_service *)handle;
805 802
806 if (service) 803 if (service)
807 { 804 {
@@ -828,7 +825,7 @@ int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle)
828{ 825{
829 int32_t ret = -1; 826 int32_t ret = -1;
830 827
831 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 828 struct shim_service *service = (struct shim_service *)handle;
832 if (service) 829 if (service)
833 ret = vchiq_status_to_vchi(vchiq_use_service(service->handle)); 830 ret = vchiq_status_to_vchi(vchiq_use_service(service->handle));
834 return ret; 831 return ret;
@@ -849,7 +846,7 @@ int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle)
849{ 846{
850 int32_t ret = -1; 847 int32_t ret = -1;
851 848
852 SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; 849 struct shim_service *service = (struct shim_service *)handle;
853 if (service) 850 if (service)
854 ret = vchiq_status_to_vchi( 851 ret = vchiq_status_to_vchi(
855 vchiq_release_service(service->handle)); 852 vchiq_release_service(service->handle));
diff --git a/drivers/staging/vme/devices/Kconfig b/drivers/staging/vme/devices/Kconfig
index 1d2ff0cc41f1..c548dd8c91e1 100644
--- a/drivers/staging/vme/devices/Kconfig
+++ b/drivers/staging/vme/devices/Kconfig
@@ -10,16 +10,3 @@ config VME_USER
10 10
11 To compile this driver as a module, choose M here. The module will 11 To compile this driver as a module, choose M here. The module will
12 be called vme_user. If unsure, say N. 12 be called vme_user. If unsure, say N.
13
14config VME_PIO2
15 tristate "GE PIO2 VME"
16 depends on STAGING && GPIOLIB
17 help
18 Say Y here to include support for the GE PIO2. The PIO2 is a 6U VME
19 slave card, implementing 32 solid-state relay switched IO lines, in
20 4 groups of 8. Each bank of IO lines is built to function as input,
21 output or both depending on the variant of the card.
22
23 To compile this driver as a module, choose M here. The module will
24 be called vme_pio2. If unsure, say N.
25
diff --git a/drivers/staging/vme/devices/Makefile b/drivers/staging/vme/devices/Makefile
index 172512cb5dbf..459742a75283 100644
--- a/drivers/staging/vme/devices/Makefile
+++ b/drivers/staging/vme/devices/Makefile
@@ -3,6 +3,3 @@
3# 3#
4 4
5obj-$(CONFIG_VME_USER) += vme_user.o 5obj-$(CONFIG_VME_USER) += vme_user.o
6
7vme_pio2-objs := vme_pio2_cntr.o vme_pio2_gpio.o vme_pio2_core.o
8obj-$(CONFIG_VME_PIO2) += vme_pio2.o
diff --git a/drivers/staging/vme/devices/vme_pio2.h b/drivers/staging/vme/devices/vme_pio2.h
deleted file mode 100644
index ac4a4bad4091..000000000000
--- a/drivers/staging/vme/devices/vme_pio2.h
+++ /dev/null
@@ -1,244 +0,0 @@
1#ifndef _VME_PIO2_H_
2#define _VME_PIO2_H_
3
4#define PIO2_CARDS_MAX 32
5
6#define PIO2_VARIANT_LENGTH 5
7
8#define PIO2_NUM_CHANNELS 32
9#define PIO2_NUM_IRQS 11
10#define PIO2_NUM_CNTRS 6
11
12#define PIO2_REGS_SIZE 0x40
13
14#define PIO2_REGS_DATA0 0x0
15#define PIO2_REGS_DATA1 0x1
16#define PIO2_REGS_DATA2 0x2
17#define PIO2_REGS_DATA3 0x3
18
19static const int PIO2_REGS_DATA[4] = { PIO2_REGS_DATA0, PIO2_REGS_DATA1,
20 PIO2_REGS_DATA2, PIO2_REGS_DATA3 };
21
22#define PIO2_REGS_INT_STAT0 0x8
23#define PIO2_REGS_INT_STAT1 0x9
24#define PIO2_REGS_INT_STAT2 0xa
25#define PIO2_REGS_INT_STAT3 0xb
26
27static const int PIO2_REGS_INT_STAT[4] = { PIO2_REGS_INT_STAT0,
28 PIO2_REGS_INT_STAT1,
29 PIO2_REGS_INT_STAT2,
30 PIO2_REGS_INT_STAT3 };
31
32#define PIO2_REGS_INT_STAT_CNTR 0xc
33#define PIO2_REGS_INT_MASK0 0x10
34#define PIO2_REGS_INT_MASK1 0x11
35#define PIO2_REGS_INT_MASK2 0x12
36#define PIO2_REGS_INT_MASK3 0x13
37#define PIO2_REGS_INT_MASK4 0x14
38#define PIO2_REGS_INT_MASK5 0x15
39#define PIO2_REGS_INT_MASK6 0x16
40#define PIO2_REGS_INT_MASK7 0x17
41
42static const int PIO2_REGS_INT_MASK[8] = { PIO2_REGS_INT_MASK0,
43 PIO2_REGS_INT_MASK1,
44 PIO2_REGS_INT_MASK2,
45 PIO2_REGS_INT_MASK3,
46 PIO2_REGS_INT_MASK4,
47 PIO2_REGS_INT_MASK5,
48 PIO2_REGS_INT_MASK6,
49 PIO2_REGS_INT_MASK7 };
50
51#define PIO2_REGS_CTRL 0x18
52#define PIO2_REGS_VME_VECTOR 0x19
53#define PIO2_REGS_CNTR0 0x20
54#define PIO2_REGS_CNTR1 0x22
55#define PIO2_REGS_CNTR2 0x24
56#define PIO2_REGS_CTRL_WRD0 0x26
57#define PIO2_REGS_CNTR3 0x28
58#define PIO2_REGS_CNTR4 0x2a
59#define PIO2_REGS_CNTR5 0x2c
60#define PIO2_REGS_CTRL_WRD1 0x2e
61
62#define PIO2_REGS_ID 0x30
63
64/* PIO2_REGS_DATAx (0x0 - 0x3) */
65
66static const int PIO2_CHANNEL_BANK[32] = { 0, 0, 0, 0, 0, 0, 0, 0,
67 1, 1, 1, 1, 1, 1, 1, 1,
68 2, 2, 2, 2, 2, 2, 2, 2,
69 3, 3, 3, 3, 3, 3, 3, 3 };
70
71#define PIO2_CHANNEL0_BIT BIT(0)
72#define PIO2_CHANNEL1_BIT BIT(1)
73#define PIO2_CHANNEL2_BIT BIT(2)
74#define PIO2_CHANNEL3_BIT BIT(3)
75#define PIO2_CHANNEL4_BIT BIT(4)
76#define PIO2_CHANNEL5_BIT BIT(5)
77#define PIO2_CHANNEL6_BIT BIT(6)
78#define PIO2_CHANNEL7_BIT BIT(7)
79#define PIO2_CHANNEL8_BIT BIT(0)
80#define PIO2_CHANNEL9_BIT BIT(1)
81#define PIO2_CHANNEL10_BIT BIT(2)
82#define PIO2_CHANNEL11_BIT BIT(3)
83#define PIO2_CHANNEL12_BIT BIT(4)
84#define PIO2_CHANNEL13_BIT BIT(5)
85#define PIO2_CHANNEL14_BIT BIT(6)
86#define PIO2_CHANNEL15_BIT BIT(7)
87#define PIO2_CHANNEL16_BIT BIT(0)
88#define PIO2_CHANNEL17_BIT BIT(1)
89#define PIO2_CHANNEL18_BIT BIT(2)
90#define PIO2_CHANNEL19_BIT BIT(3)
91#define PIO2_CHANNEL20_BIT BIT(4)
92#define PIO2_CHANNEL21_BIT BIT(5)
93#define PIO2_CHANNEL22_BIT BIT(6)
94#define PIO2_CHANNEL23_BIT BIT(7)
95#define PIO2_CHANNEL24_BIT BIT(0)
96#define PIO2_CHANNEL25_BIT BIT(1)
97#define PIO2_CHANNEL26_BIT BIT(2)
98#define PIO2_CHANNEL27_BIT BIT(3)
99#define PIO2_CHANNEL28_BIT BIT(4)
100#define PIO2_CHANNEL29_BIT BIT(5)
101#define PIO2_CHANNEL30_BIT BIT(6)
102#define PIO2_CHANNEL31_BIT BIT(7)
103
104static const int PIO2_CHANNEL_BIT[32] = { PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
105 PIO2_CHANNEL2_BIT, PIO2_CHANNEL3_BIT,
106 PIO2_CHANNEL4_BIT, PIO2_CHANNEL5_BIT,
107 PIO2_CHANNEL6_BIT, PIO2_CHANNEL7_BIT,
108 PIO2_CHANNEL8_BIT, PIO2_CHANNEL9_BIT,
109 PIO2_CHANNEL10_BIT, PIO2_CHANNEL11_BIT,
110 PIO2_CHANNEL12_BIT, PIO2_CHANNEL13_BIT,
111 PIO2_CHANNEL14_BIT, PIO2_CHANNEL15_BIT,
112 PIO2_CHANNEL16_BIT, PIO2_CHANNEL17_BIT,
113 PIO2_CHANNEL18_BIT, PIO2_CHANNEL19_BIT,
114 PIO2_CHANNEL20_BIT, PIO2_CHANNEL21_BIT,
115 PIO2_CHANNEL22_BIT, PIO2_CHANNEL23_BIT,
116 PIO2_CHANNEL24_BIT, PIO2_CHANNEL25_BIT,
117 PIO2_CHANNEL26_BIT, PIO2_CHANNEL27_BIT,
118 PIO2_CHANNEL28_BIT, PIO2_CHANNEL29_BIT,
119 PIO2_CHANNEL30_BIT, PIO2_CHANNEL31_BIT
120 };
121
122/* PIO2_REGS_INT_STAT_CNTR (0xc) */
123#define PIO2_COUNTER0 BIT(0)
124#define PIO2_COUNTER1 BIT(1)
125#define PIO2_COUNTER2 BIT(2)
126#define PIO2_COUNTER3 BIT(3)
127#define PIO2_COUNTER4 BIT(4)
128#define PIO2_COUNTER5 BIT(5)
129
130static const int PIO2_COUNTER[6] = { PIO2_COUNTER0, PIO2_COUNTER1,
131 PIO2_COUNTER2, PIO2_COUNTER3,
132 PIO2_COUNTER4, PIO2_COUNTER5 };
133
134/* PIO2_REGS_CTRL (0x18) */
135#define PIO2_VME_INT_MASK 0x7
136#define PIO2_LED BIT(6)
137#define PIO2_LOOP BIT(7)
138
139/* PIO2_REGS_VME_VECTOR (0x19) */
140#define PIO2_VME_VECTOR_SPUR 0x0
141#define PIO2_VME_VECTOR_BANK0 0x1
142#define PIO2_VME_VECTOR_BANK1 0x2
143#define PIO2_VME_VECTOR_BANK2 0x3
144#define PIO2_VME_VECTOR_BANK3 0x4
145#define PIO2_VME_VECTOR_CNTR0 0x5
146#define PIO2_VME_VECTOR_CNTR1 0x6
147#define PIO2_VME_VECTOR_CNTR2 0x7
148#define PIO2_VME_VECTOR_CNTR3 0x8
149#define PIO2_VME_VECTOR_CNTR4 0x9
150#define PIO2_VME_VECTOR_CNTR5 0xa
151
152#define PIO2_VME_VECTOR_MASK 0xf0
153
154static const int PIO2_VECTOR_BANK[4] = { PIO2_VME_VECTOR_BANK0,
155 PIO2_VME_VECTOR_BANK1,
156 PIO2_VME_VECTOR_BANK2,
157 PIO2_VME_VECTOR_BANK3 };
158
159static const int PIO2_VECTOR_CNTR[6] = { PIO2_VME_VECTOR_CNTR0,
160 PIO2_VME_VECTOR_CNTR1,
161 PIO2_VME_VECTOR_CNTR2,
162 PIO2_VME_VECTOR_CNTR3,
163 PIO2_VME_VECTOR_CNTR4,
164 PIO2_VME_VECTOR_CNTR5 };
165
166/* PIO2_REGS_CNTRx (0x20 - 0x24 & 0x28 - 0x2c) */
167
168static const int PIO2_CNTR_DATA[6] = { PIO2_REGS_CNTR0, PIO2_REGS_CNTR1,
169 PIO2_REGS_CNTR2, PIO2_REGS_CNTR3,
170 PIO2_REGS_CNTR4, PIO2_REGS_CNTR5 };
171
172/* PIO2_REGS_CTRL_WRDx (0x26 & 0x2e) */
173
174static const int PIO2_CNTR_CTRL[6] = { PIO2_REGS_CTRL_WRD0,
175 PIO2_REGS_CTRL_WRD0,
176 PIO2_REGS_CTRL_WRD0,
177 PIO2_REGS_CTRL_WRD1,
178 PIO2_REGS_CTRL_WRD1,
179 PIO2_REGS_CTRL_WRD1 };
180
181#define PIO2_CNTR_SC_DEV0 0
182#define PIO2_CNTR_SC_DEV1 (1 << 6)
183#define PIO2_CNTR_SC_DEV2 (2 << 6)
184#define PIO2_CNTR_SC_RDBACK (3 << 6)
185
186static const int PIO2_CNTR_SC_DEV[6] = { PIO2_CNTR_SC_DEV0, PIO2_CNTR_SC_DEV1,
187 PIO2_CNTR_SC_DEV2, PIO2_CNTR_SC_DEV0,
188 PIO2_CNTR_SC_DEV1, PIO2_CNTR_SC_DEV2 };
189
190#define PIO2_CNTR_RW_LATCH 0
191#define PIO2_CNTR_RW_LSB (1 << 4)
192#define PIO2_CNTR_RW_MSB (2 << 4)
193#define PIO2_CNTR_RW_BOTH (3 << 4)
194
195#define PIO2_CNTR_MODE0 0
196#define PIO2_CNTR_MODE1 (1 << 1)
197#define PIO2_CNTR_MODE2 (2 << 1)
198#define PIO2_CNTR_MODE3 (3 << 1)
199#define PIO2_CNTR_MODE4 (4 << 1)
200#define PIO2_CNTR_MODE5 (5 << 1)
201
202#define PIO2_CNTR_BCD 1
203
204enum pio2_bank_config { NOFIT, INPUT, OUTPUT, BOTH };
205enum pio2_int_config { NONE = 0, LOW2HIGH = 1, HIGH2LOW = 2, EITHER = 4 };
206
207/* Bank configuration structure */
208struct pio2_io_bank {
209 enum pio2_bank_config config;
210 u8 value;
211 enum pio2_int_config irq[8];
212};
213
214/* Counter configuration structure */
215struct pio2_cntr {
216 int mode;
217 int count;
218};
219
220struct pio2_card {
221 int id;
222 int bus;
223 long base;
224 int irq_vector;
225 int irq_level;
226 char variant[6];
227 int led;
228
229 struct vme_dev *vdev;
230 struct vme_resource *window;
231
232 struct gpio_chip gc;
233 struct pio2_io_bank bank[4];
234
235 struct pio2_cntr cntr[6];
236};
237
238int pio2_cntr_reset(struct pio2_card *card);
239
240int pio2_gpio_reset(struct pio2_card *card);
241int pio2_gpio_init(struct pio2_card *card);
242void pio2_gpio_exit(struct pio2_card *card);
243
244#endif /* _VME_PIO2_H_ */
diff --git a/drivers/staging/vme/devices/vme_pio2_cntr.c b/drivers/staging/vme/devices/vme_pio2_cntr.c
deleted file mode 100644
index 486c30c4956f..000000000000
--- a/drivers/staging/vme/devices/vme_pio2_cntr.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * GE PIO2 Counter Driver
3 *
4 * Author: Martyn Welch <martyn.welch@ge.com>
5 * Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * The PIO-2 has 6 counters, currently this code just disables the interrupts
13 * and leaves them alone.
14 *
15 */
16
17#include <linux/device.h>
18#include <linux/types.h>
19#include <linux/gpio.h>
20#include <linux/vme.h>
21
22#include "vme_pio2.h"
23
24static int pio2_cntr_irq_set(struct pio2_card *card, int id)
25{
26 int retval;
27 u8 data;
28
29 data = PIO2_CNTR_SC_DEV[id] | PIO2_CNTR_RW_BOTH | card->cntr[id].mode;
30 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_CTRL[id]);
31 if (retval < 0)
32 return retval;
33
34 data = card->cntr[id].count & 0xFF;
35 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]);
36 if (retval < 0)
37 return retval;
38
39 data = (card->cntr[id].count >> 8) & 0xFF;
40 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]);
41 if (retval < 0)
42 return retval;
43
44 return 0;
45}
46
47int pio2_cntr_reset(struct pio2_card *card)
48{
49 int i, retval = 0;
50 u8 reg;
51
52 /* Clear down all timers */
53 for (i = 0; i < 6; i++) {
54 card->cntr[i].mode = PIO2_CNTR_MODE5;
55 card->cntr[i].count = 0;
56 retval = pio2_cntr_irq_set(card, i);
57 if (retval < 0)
58 return retval;
59 }
60
61 /* Ensure all counter interrupts are cleared */
62 do {
63 retval = vme_master_read(card->window, &reg, 1,
64 PIO2_REGS_INT_STAT_CNTR);
65 if (retval < 0)
66 return retval;
67 } while (reg != 0);
68
69 return retval;
70}
71
diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c
deleted file mode 100644
index 367535b4b77f..000000000000
--- a/drivers/staging/vme/devices/vme_pio2_core.c
+++ /dev/null
@@ -1,493 +0,0 @@
1/*
2 * GE PIO2 6U VME I/O Driver
3 *
4 * Author: Martyn Welch <martyn.welch@ge.com>
5 * Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14
15#include <linux/module.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/device.h>
20#include <linux/ctype.h>
21#include <linux/gpio.h>
22#include <linux/slab.h>
23#include <linux/vme.h>
24
25#include "vme_pio2.h"
26
27static const char driver_name[] = "pio2";
28
29static int bus[PIO2_CARDS_MAX];
30static int bus_num;
31static long base[PIO2_CARDS_MAX];
32static int base_num;
33static int vector[PIO2_CARDS_MAX];
34static int vector_num;
35static int level[PIO2_CARDS_MAX];
36static int level_num;
37static char *variant[PIO2_CARDS_MAX];
38static int variant_num;
39
40static bool loopback;
41
42static int pio2_match(struct vme_dev *);
43static int pio2_probe(struct vme_dev *);
44static int pio2_remove(struct vme_dev *);
45
46static int pio2_get_led(struct pio2_card *card)
47{
48 /* Can't read hardware, state saved in structure */
49 return card->led;
50}
51
52static int pio2_set_led(struct pio2_card *card, int state)
53{
54 u8 reg;
55 int retval;
56
57 reg = card->irq_level;
58
59 /* Register state inverse of led state */
60 if (!state)
61 reg |= PIO2_LED;
62
63 if (loopback)
64 reg |= PIO2_LOOP;
65
66 retval = vme_master_write(card->window, &reg, 1, PIO2_REGS_CTRL);
67 if (retval < 0)
68 return retval;
69
70 card->led = state ? 1 : 0;
71
72 return 0;
73}
74
75static void pio2_int(int level, int vector, void *ptr)
76{
77 int vec, i, channel, retval;
78 u8 reg;
79 struct pio2_card *card = ptr;
80
81 vec = vector & ~PIO2_VME_VECTOR_MASK;
82
83 switch (vec) {
84 case 0:
85 dev_warn(&card->vdev->dev, "Spurious Interrupt\n");
86 break;
87 case 1:
88 case 2:
89 case 3:
90 case 4:
91 /* Channels 0 to 7 */
92 retval = vme_master_read(card->window, &reg, 1,
93 PIO2_REGS_INT_STAT[vec - 1]);
94 if (retval < 0) {
95 dev_err(&card->vdev->dev,
96 "Unable to read IRQ status register\n");
97 return;
98 }
99 for (i = 0; i < 8; i++) {
100 channel = ((vec - 1) * 8) + i;
101 if (reg & PIO2_CHANNEL_BIT[channel])
102 dev_info(&card->vdev->dev,
103 "Interrupt on I/O channel %d\n",
104 channel);
105 }
106 break;
107 case 5:
108 case 6:
109 case 7:
110 case 8:
111 case 9:
112 case 10:
113 /* Counters are dealt with by their own handler */
114 dev_err(&card->vdev->dev,
115 "Counter interrupt\n");
116 break;
117 }
118}
119
120/*
121 * We return whether this has been successful - this is used in the probe to
122 * ensure we have a valid card.
123 */
124static int pio2_reset_card(struct pio2_card *card)
125{
126 int retval = 0;
127 u8 data = 0;
128
129 /* Clear main register*/
130 retval = vme_master_write(card->window, &data, 1, PIO2_REGS_CTRL);
131 if (retval < 0)
132 return retval;
133
134 /* Clear VME vector */
135 retval = vme_master_write(card->window, &data, 1, PIO2_REGS_VME_VECTOR);
136 if (retval < 0)
137 return retval;
138
139 /* Reset GPIO */
140 retval = pio2_gpio_reset(card);
141 if (retval < 0)
142 return retval;
143
144 /* Reset counters */
145 retval = pio2_cntr_reset(card);
146 if (retval < 0)
147 return retval;
148
149 return 0;
150}
151
152static struct vme_driver pio2_driver = {
153 .name = driver_name,
154 .match = pio2_match,
155 .probe = pio2_probe,
156 .remove = pio2_remove,
157};
158
159static int __init pio2_init(void)
160{
161 if (bus_num == 0) {
162 pr_err("No cards, skipping registration\n");
163 return -ENODEV;
164 }
165
166 if (bus_num > PIO2_CARDS_MAX) {
167 pr_err("Driver only able to handle %d PIO2 Cards\n",
168 PIO2_CARDS_MAX);
169 bus_num = PIO2_CARDS_MAX;
170 }
171
172 /* Register the PIO2 driver */
173 return vme_register_driver(&pio2_driver, bus_num);
174}
175
176static int pio2_match(struct vme_dev *vdev)
177{
178 if (vdev->num >= bus_num) {
179 dev_err(&vdev->dev,
180 "The enumeration of the VMEbus to which the board is connected must be specified\n");
181 return 0;
182 }
183
184 if (vdev->num >= base_num) {
185 dev_err(&vdev->dev,
186 "The VME address for the cards registers must be specified\n");
187 return 0;
188 }
189
190 if (vdev->num >= vector_num) {
191 dev_err(&vdev->dev,
192 "The IRQ vector used by the card must be specified\n");
193 return 0;
194 }
195
196 if (vdev->num >= level_num) {
197 dev_err(&vdev->dev,
198 "The IRQ level used by the card must be specified\n");
199 return 0;
200 }
201
202 if (vdev->num >= variant_num) {
203 dev_err(&vdev->dev, "The variant of the card must be specified\n");
204 return 0;
205 }
206
207 return 1;
208}
209
210static int pio2_probe(struct vme_dev *vdev)
211{
212 struct pio2_card *card;
213 int retval;
214 int i;
215 u8 reg;
216 int vec;
217
218 card = devm_kzalloc(&vdev->dev, sizeof(*card), GFP_KERNEL);
219 if (!card)
220 return -ENOMEM;
221
222 card->id = vdev->num;
223 card->bus = bus[card->id];
224 card->base = base[card->id];
225 card->irq_vector = vector[card->id];
226 card->irq_level = level[card->id] & PIO2_VME_INT_MASK;
227 strncpy(card->variant, variant[card->id], PIO2_VARIANT_LENGTH);
228 card->vdev = vdev;
229
230 for (i = 0; i < PIO2_VARIANT_LENGTH; i++) {
231 if (!isdigit(card->variant[i])) {
232 dev_err(&card->vdev->dev, "Variant invalid\n");
233 return -EINVAL;
234 }
235 }
236
237 /*
238 * Bottom 4 bits of VME interrupt vector used to determine source,
239 * provided vector should only use upper 4 bits.
240 */
241 if (card->irq_vector & ~PIO2_VME_VECTOR_MASK) {
242 dev_err(&card->vdev->dev,
243 "Invalid VME IRQ Vector, vector must not use lower 4 bits\n");
244 return -EINVAL;
245 }
246
247 /*
248 * There is no way to determine the build variant or whether each bank
249 * is input, output or both at run time. The inputs are also inverted
250 * if configured as both.
251 *
252 * We pass in the board variant and use that to determine the
253 * configuration of the banks.
254 */
255 for (i = 1; i < PIO2_VARIANT_LENGTH; i++) {
256 switch (card->variant[i]) {
257 case '0':
258 card->bank[i - 1].config = NOFIT;
259 break;
260 case '1':
261 case '2':
262 case '3':
263 case '4':
264 card->bank[i - 1].config = INPUT;
265 break;
266 case '5':
267 card->bank[i - 1].config = OUTPUT;
268 break;
269 case '6':
270 case '7':
271 case '8':
272 case '9':
273 card->bank[i - 1].config = BOTH;
274 break;
275 }
276 }
277
278 /* Get a master window and position over regs */
279 card->window = vme_master_request(vdev, VME_A24, VME_SCT, VME_D16);
280 if (!card->window) {
281 dev_err(&card->vdev->dev,
282 "Unable to assign VME master resource\n");
283 return -EIO;
284 }
285
286 retval = vme_master_set(card->window, 1, card->base, 0x10000, VME_A24,
287 VME_SCT | VME_USER | VME_DATA, VME_D16);
288 if (retval) {
289 dev_err(&card->vdev->dev,
290 "Unable to configure VME master resource\n");
291 goto err_set;
292 }
293
294 /*
295 * There is also no obvious register which we can probe to determine
296 * whether the provided base is valid. If we can read the "ID Register"
297 * offset and the reset function doesn't error, assume we have a valid
298 * location.
299 */
300 retval = vme_master_read(card->window, &reg, 1, PIO2_REGS_ID);
301 if (retval < 0) {
302 dev_err(&card->vdev->dev, "Unable to read from device\n");
303 goto err_read;
304 }
305
306 dev_dbg(&card->vdev->dev, "ID Register:%x\n", reg);
307
308 /*
309 * Ensure all the I/O is cleared. We can't read back the states, so
310 * this is the only method we have to ensure that the I/O is in a known
311 * state.
312 */
313 retval = pio2_reset_card(card);
314 if (retval) {
315 dev_err(&card->vdev->dev,
316 "Failed to reset card, is location valid?\n");
317 retval = -ENODEV;
318 goto err_reset;
319 }
320
321 /* Configure VME Interrupts */
322 reg = card->irq_level;
323 if (pio2_get_led(card))
324 reg |= PIO2_LED;
325 if (loopback)
326 reg |= PIO2_LOOP;
327 retval = vme_master_write(card->window, &reg, 1, PIO2_REGS_CTRL);
328 if (retval < 0)
329 return retval;
330
331 /* Set VME vector */
332 retval = vme_master_write(card->window, &card->irq_vector, 1,
333 PIO2_REGS_VME_VECTOR);
334 if (retval < 0)
335 return retval;
336
337 /* Attach spurious interrupt handler. */
338 vec = card->irq_vector | PIO2_VME_VECTOR_SPUR;
339
340 retval = vme_irq_request(vdev, card->irq_level, vec,
341 &pio2_int, card);
342 if (retval < 0) {
343 dev_err(&card->vdev->dev,
344 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
345 vec, card->irq_level);
346 goto err_irq;
347 }
348
349 /* Attach GPIO interrupt handlers. */
350 for (i = 0; i < 4; i++) {
351 vec = card->irq_vector | PIO2_VECTOR_BANK[i];
352
353 retval = vme_irq_request(vdev, card->irq_level, vec,
354 &pio2_int, card);
355 if (retval < 0) {
356 dev_err(&card->vdev->dev,
357 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
358 vec, card->irq_level);
359 goto err_gpio_irq;
360 }
361 }
362
363 /* Attach counter interrupt handlers. */
364 for (i = 0; i < 6; i++) {
365 vec = card->irq_vector | PIO2_VECTOR_CNTR[i];
366
367 retval = vme_irq_request(vdev, card->irq_level, vec,
368 &pio2_int, card);
369 if (retval < 0) {
370 dev_err(&card->vdev->dev,
371 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
372 vec, card->irq_level);
373 goto err_cntr_irq;
374 }
375 }
376
377 /* Register IO */
378 retval = pio2_gpio_init(card);
379 if (retval < 0) {
380 dev_err(&card->vdev->dev,
381 "Unable to register with GPIO framework\n");
382 goto err_gpio;
383 }
384
385 /* Set LED - This also sets interrupt level */
386 retval = pio2_set_led(card, 0);
387 if (retval < 0) {
388 dev_err(&card->vdev->dev, "Unable to set LED\n");
389 goto err_led;
390 }
391
392 dev_set_drvdata(&card->vdev->dev, card);
393
394 dev_info(&card->vdev->dev,
395 "PIO2 (variant %s) configured at 0x%lx\n", card->variant,
396 card->base);
397
398 return 0;
399
400err_led:
401 pio2_gpio_exit(card);
402err_gpio:
403 i = 6;
404err_cntr_irq:
405 while (i > 0) {
406 i--;
407 vec = card->irq_vector | PIO2_VECTOR_CNTR[i];
408 vme_irq_free(vdev, card->irq_level, vec);
409 }
410
411 i = 4;
412err_gpio_irq:
413 while (i > 0) {
414 i--;
415 vec = card->irq_vector | PIO2_VECTOR_BANK[i];
416 vme_irq_free(vdev, card->irq_level, vec);
417 }
418
419 vec = (card->irq_vector & PIO2_VME_VECTOR_MASK) | PIO2_VME_VECTOR_SPUR;
420 vme_irq_free(vdev, card->irq_level, vec);
421err_irq:
422 pio2_reset_card(card);
423err_reset:
424err_read:
425 vme_master_set(card->window, 0, 0, 0, VME_A16, 0, VME_D16);
426err_set:
427 vme_master_free(card->window);
428 return retval;
429}
430
431static int pio2_remove(struct vme_dev *vdev)
432{
433 int vec;
434 int i;
435
436 struct pio2_card *card = dev_get_drvdata(&vdev->dev);
437
438 pio2_gpio_exit(card);
439
440 for (i = 0; i < 6; i++) {
441 vec = card->irq_vector | PIO2_VECTOR_CNTR[i];
442 vme_irq_free(vdev, card->irq_level, vec);
443 }
444
445 for (i = 0; i < 4; i++) {
446 vec = card->irq_vector | PIO2_VECTOR_BANK[i];
447 vme_irq_free(vdev, card->irq_level, vec);
448 }
449
450 vec = (card->irq_vector & PIO2_VME_VECTOR_MASK) | PIO2_VME_VECTOR_SPUR;
451 vme_irq_free(vdev, card->irq_level, vec);
452
453 pio2_reset_card(card);
454
455 vme_master_set(card->window, 0, 0, 0, VME_A16, 0, VME_D16);
456
457 vme_master_free(card->window);
458
459 return 0;
460}
461
462static void __exit pio2_exit(void)
463{
464 vme_unregister_driver(&pio2_driver);
465}
466
467/* These are required for each board */
468MODULE_PARM_DESC(bus, "Enumeration of VMEbus to which the board is connected");
469module_param_hw_array(bus, int, other, &bus_num, 0444);
470
471MODULE_PARM_DESC(base, "Base VME address for PIO2 Registers");
472module_param_hw_array(base, long, other, &base_num, 0444);
473
474MODULE_PARM_DESC(vector, "VME IRQ Vector (Lower 4 bits masked)");
475module_param_hw_array(vector, int, other, &vector_num, 0444);
476
477MODULE_PARM_DESC(level, "VME IRQ Level");
478module_param_hw_array(level, int, other, &level_num, 0444);
479
480MODULE_PARM_DESC(variant, "Last 4 characters of PIO2 board variant");
481module_param_array(variant, charp, &variant_num, 0444);
482
483/* This is for debugging */
484MODULE_PARM_DESC(loopback, "Enable loopback mode on all cards");
485module_param(loopback, bool, 0444);
486
487MODULE_DESCRIPTION("GE PIO2 6U VME I/O Driver");
488MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com");
489MODULE_LICENSE("GPL");
490
491module_init(pio2_init);
492module_exit(pio2_exit);
493
diff --git a/drivers/staging/vme/devices/vme_pio2_gpio.c b/drivers/staging/vme/devices/vme_pio2_gpio.c
deleted file mode 100644
index ba9fe3bc2642..000000000000
--- a/drivers/staging/vme/devices/vme_pio2_gpio.c
+++ /dev/null
@@ -1,220 +0,0 @@
1/*
2 * GE PIO2 GPIO Driver
3 *
4 * Author: Martyn Welch <martyn.welch@ge.com>
5 * Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/device.h>
18#include <linux/platform_device.h>
19#include <linux/ctype.h>
20#include <linux/gpio/driver.h>
21#include <linux/slab.h>
22#include <linux/vme.h>
23
24#include "vme_pio2.h"
25
26static const char driver_name[] = "pio2_gpio";
27
28static int pio2_gpio_get(struct gpio_chip *chip, unsigned int offset)
29{
30 u8 reg;
31 int retval;
32 struct pio2_card *card = gpiochip_get_data(chip);
33
34 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) |
35 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
36 dev_err(&card->vdev->dev, "Channel not available as input\n");
37 return 0;
38 }
39
40 retval = vme_master_read(card->window, &reg, 1,
41 PIO2_REGS_DATA[PIO2_CHANNEL_BANK[offset]]);
42 if (retval < 0) {
43 dev_err(&card->vdev->dev, "Unable to read from GPIO\n");
44 return 0;
45 }
46
47 /*
48 * Remember, input on channels configured as both input and output
49 * are inverted!
50 */
51 if (reg & PIO2_CHANNEL_BIT[offset]) {
52 if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH)
53 return 0;
54
55 return 1;
56 }
57
58 if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH)
59 return 1;
60
61 return 0;
62}
63
64static void pio2_gpio_set(struct gpio_chip *chip,
65 unsigned int offset, int value)
66{
67 u8 reg;
68 int retval;
69 struct pio2_card *card = gpiochip_get_data(chip);
70
71 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
72 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
73 dev_err(&card->vdev->dev, "Channel not available as output\n");
74 return;
75 }
76
77 if (value)
78 reg = card->bank[PIO2_CHANNEL_BANK[offset]].value |
79 PIO2_CHANNEL_BIT[offset];
80 else
81 reg = card->bank[PIO2_CHANNEL_BANK[offset]].value &
82 ~PIO2_CHANNEL_BIT[offset];
83
84 retval = vme_master_write(card->window, &reg, 1,
85 PIO2_REGS_DATA[PIO2_CHANNEL_BANK[offset]]);
86 if (retval < 0) {
87 dev_err(&card->vdev->dev, "Unable to write to GPIO\n");
88 return;
89 }
90
91 card->bank[PIO2_CHANNEL_BANK[offset]].value = reg;
92}
93
94/* Directionality configured at board build - send appropriate response */
95static int pio2_gpio_dir_in(struct gpio_chip *chip, unsigned int offset)
96{
97 int data;
98 struct pio2_card *card = gpiochip_get_data(chip);
99
100 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) |
101 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
102 dev_err(&card->vdev->dev,
103 "Channel directionality not configurable at runtime\n");
104
105 data = -EINVAL;
106 } else {
107 data = 0;
108 }
109
110 return data;
111}
112
113/* Directionality configured at board build - send appropriate response */
114static int pio2_gpio_dir_out(struct gpio_chip *chip,
115 unsigned int offset, int value)
116{
117 int data;
118 struct pio2_card *card = gpiochip_get_data(chip);
119
120 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
121 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
122 dev_err(&card->vdev->dev,
123 "Channel directionality not configurable at runtime\n");
124
125 data = -EINVAL;
126 } else {
127 data = 0;
128 }
129
130 return data;
131}
132
133/*
134 * We return whether this has been successful - this is used in the probe to
135 * ensure we have a valid card.
136 */
137int pio2_gpio_reset(struct pio2_card *card)
138{
139 int retval = 0;
140 int i, j;
141
142 u8 data = 0;
143
144 /* Zero output registers */
145 for (i = 0; i < 4; i++) {
146 retval = vme_master_write(card->window, &data, 1,
147 PIO2_REGS_DATA[i]);
148 if (retval < 0)
149 return retval;
150 card->bank[i].value = 0;
151 }
152
153 /* Set input interrupt masks */
154 for (i = 0; i < 4; i++) {
155 retval = vme_master_write(card->window, &data, 1,
156 PIO2_REGS_INT_MASK[i * 2]);
157 if (retval < 0)
158 return retval;
159
160 retval = vme_master_write(card->window, &data, 1,
161 PIO2_REGS_INT_MASK[(i * 2) + 1]);
162 if (retval < 0)
163 return retval;
164
165 for (j = 0; j < 8; j++)
166 card->bank[i].irq[j] = NONE;
167 }
168
169 /* Ensure all I/O interrupts are cleared */
170 for (i = 0; i < 4; i++) {
171 do {
172 retval = vme_master_read(card->window, &data, 1,
173 PIO2_REGS_INT_STAT[i]);
174 if (retval < 0)
175 return retval;
176 } while (data != 0);
177 }
178
179 return 0;
180}
181
182int pio2_gpio_init(struct pio2_card *card)
183{
184 int retval = 0;
185 char *label;
186
187 label = kasprintf(GFP_KERNEL,
188 "%s@%s", driver_name, dev_name(&card->vdev->dev));
189 if (!label)
190 return -ENOMEM;
191
192 card->gc.label = label;
193
194 card->gc.ngpio = PIO2_NUM_CHANNELS;
195 /* Dynamic allocation of base */
196 card->gc.base = -1;
197 /* Setup pointers to chip functions */
198 card->gc.direction_input = pio2_gpio_dir_in;
199 card->gc.direction_output = pio2_gpio_dir_out;
200 card->gc.get = pio2_gpio_get;
201 card->gc.set = pio2_gpio_set;
202
203 /* This function adds a memory mapped GPIO chip */
204 retval = gpiochip_add_data(&card->gc, card);
205 if (retval) {
206 dev_err(&card->vdev->dev, "Unable to register GPIO\n");
207 kfree(card->gc.label);
208 }
209
210 return retval;
211};
212
213void pio2_gpio_exit(struct pio2_card *card)
214{
215 const char *label = card->gc.label;
216
217 gpiochip_remove(&card->gc);
218 kfree(label);
219}
220
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 9fcf2e223f71..1123b4f1e1d6 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1693,10 +1693,11 @@ static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state)
1693 MACbShutdown(priv); 1693 MACbShutdown(priv);
1694 1694
1695 pci_disable_device(pcid); 1695 pci_disable_device(pcid);
1696 pci_set_power_state(pcid, pci_choose_state(pcid, state));
1697 1696
1698 spin_unlock_irqrestore(&priv->lock, flags); 1697 spin_unlock_irqrestore(&priv->lock, flags);
1699 1698
1699 pci_set_power_state(pcid, pci_choose_state(pcid, state));
1700
1700 return 0; 1701 return 0;
1701} 1702}
1702 1703
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
index d7ede73a1a01..d891993b20cf 100644
--- a/drivers/staging/vt6655/key.c
+++ b/drivers/staging/vt6655/key.c
@@ -56,17 +56,19 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
56 } 56 }
57 57
58 switch (key_type) { 58 switch (key_type) {
59 /* fallthrough */
60 case VNT_KEY_DEFAULTKEY: 59 case VNT_KEY_DEFAULTKEY:
61 /* default key last entry */ 60 /* default key last entry */
62 entry = MAX_KEY_TABLE - 1; 61 entry = MAX_KEY_TABLE - 1;
63 key->hw_key_idx = entry; 62 key->hw_key_idx = entry;
63 /* fall through */
64 case VNT_KEY_ALLGROUP: 64 case VNT_KEY_ALLGROUP:
65 key_mode |= VNT_KEY_ALLGROUP; 65 key_mode |= VNT_KEY_ALLGROUP;
66 if (onfly_latch) 66 if (onfly_latch)
67 key_mode |= VNT_KEY_ONFLY_ALL; 67 key_mode |= VNT_KEY_ONFLY_ALL;
68 /* fall through */
68 case VNT_KEY_GROUP_ADDRESS: 69 case VNT_KEY_GROUP_ADDRESS:
69 key_mode |= mode; 70 key_mode |= mode;
71 /* fall through */
70 case VNT_KEY_GROUP: 72 case VNT_KEY_GROUP:
71 key_mode |= (mode << 4); 73 key_mode |= (mode << 4);
72 key_mode |= VNT_KEY_GROUP; 74 key_mode |= VNT_KEY_GROUP;
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index c61422ea8846..4fd9cd64c6e8 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -382,11 +382,13 @@ void vnt_update_ifs(struct vnt_private *priv)
382 priv->difs -= 1; 382 priv->difs -= 1;
383 break; 383 break;
384 } 384 }
385 /* fall through */
385 case RF_AIROHA7230: 386 case RF_AIROHA7230:
386 case RF_AL2230: 387 case RF_AL2230:
387 case RF_AL2230S: 388 case RF_AL2230S:
388 if (priv->bb_type != BB_TYPE_11B) 389 if (priv->bb_type != BB_TYPE_11B)
389 break; 390 break;
391 /* fall through */
390 case RF_RFMD2959: 392 case RF_RFMD2959:
391 case RF_VT3226: 393 case RF_VT3226:
392 case RF_VT3342A0: 394 case RF_VT3342A0:
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 7b620658ec38..5b4e9dd16b77 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -238,6 +238,7 @@ static struct completion hif_driver_comp;
238static struct completion hif_wait_response; 238static struct completion hif_wait_response;
239static struct mutex hif_deinit_lock; 239static struct mutex hif_deinit_lock;
240static struct timer_list periodic_rssi; 240static struct timer_list periodic_rssi;
241static struct wilc_vif *periodic_rssi_vif;
241 242
242u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; 243u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
243 244
@@ -2272,7 +2273,7 @@ static int Handle_RemainOnChan(struct wilc_vif *vif,
2272ERRORHANDLER: 2273ERRORHANDLER:
2273 { 2274 {
2274 P2P_LISTEN_STATE = 1; 2275 P2P_LISTEN_STATE = 1;
2275 hif_drv->remain_on_ch_timer.data = (unsigned long)vif; 2276 hif_drv->remain_on_ch_timer_vif = vif;
2276 mod_timer(&hif_drv->remain_on_ch_timer, 2277 mod_timer(&hif_drv->remain_on_ch_timer,
2277 jiffies + 2278 jiffies +
2278 msecs_to_jiffies(pstrHostIfRemainOnChan->duration)); 2279 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
@@ -2360,11 +2361,13 @@ _done_:
2360 return result; 2361 return result;
2361} 2362}
2362 2363
2363static void ListenTimerCB(unsigned long arg) 2364static void ListenTimerCB(struct timer_list *t)
2364{ 2365{
2366 struct host_if_drv *hif_drv = from_timer(hif_drv, t,
2367 remain_on_ch_timer);
2368 struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif;
2365 s32 result = 0; 2369 s32 result = 0;
2366 struct host_if_msg msg; 2370 struct host_if_msg msg;
2367 struct wilc_vif *vif = (struct wilc_vif *)arg;
2368 2371
2369 del_timer(&vif->hif_drv->remain_on_ch_timer); 2372 del_timer(&vif->hif_drv->remain_on_ch_timer);
2370 2373
@@ -2417,9 +2420,9 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2417 2420
2418 pu8CurrByte = wid.val; 2421 pu8CurrByte = wid.val;
2419 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF); 2422 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2420 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF); 2423 *pu8CurrByte++ = 0;
2421 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF); 2424 *pu8CurrByte++ = 0;
2422 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF); 2425 *pu8CurrByte++ = 0;
2423 2426
2424 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF); 2427 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2425 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF); 2428 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
@@ -2643,9 +2646,10 @@ free_msg:
2643 complete(&hif_thread_comp); 2646 complete(&hif_thread_comp);
2644} 2647}
2645 2648
2646static void TimerCB_Scan(unsigned long arg) 2649static void TimerCB_Scan(struct timer_list *t)
2647{ 2650{
2648 struct wilc_vif *vif = (struct wilc_vif *)arg; 2651 struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer);
2652 struct wilc_vif *vif = hif_drv->scan_timer_vif;
2649 struct host_if_msg msg; 2653 struct host_if_msg msg;
2650 2654
2651 memset(&msg, 0, sizeof(struct host_if_msg)); 2655 memset(&msg, 0, sizeof(struct host_if_msg));
@@ -2655,9 +2659,11 @@ static void TimerCB_Scan(unsigned long arg)
2655 wilc_enqueue_cmd(&msg); 2659 wilc_enqueue_cmd(&msg);
2656} 2660}
2657 2661
2658static void TimerCB_Connect(unsigned long arg) 2662static void TimerCB_Connect(struct timer_list *t)
2659{ 2663{
2660 struct wilc_vif *vif = (struct wilc_vif *)arg; 2664 struct host_if_drv *hif_drv = from_timer(hif_drv, t,
2665 connect_timer);
2666 struct wilc_vif *vif = hif_drv->connect_timer_vif;
2661 struct host_if_msg msg; 2667 struct host_if_msg msg;
2662 2668
2663 memset(&msg, 0, sizeof(struct host_if_msg)); 2669 memset(&msg, 0, sizeof(struct host_if_msg));
@@ -3040,7 +3046,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
3040 return -EFAULT; 3046 return -EFAULT;
3041 } 3047 }
3042 3048
3043 hif_drv->connect_timer.data = (unsigned long)vif; 3049 hif_drv->connect_timer_vif = vif;
3044 mod_timer(&hif_drv->connect_timer, 3050 mod_timer(&hif_drv->connect_timer,
3045 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT)); 3051 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3046 3052
@@ -3283,7 +3289,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3283 return -EINVAL; 3289 return -EINVAL;
3284 } 3290 }
3285 3291
3286 hif_drv->scan_timer.data = (unsigned long)vif; 3292 hif_drv->scan_timer_vif = vif;
3287 mod_timer(&hif_drv->scan_timer, 3293 mod_timer(&hif_drv->scan_timer,
3288 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); 3294 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3289 3295
@@ -3309,9 +3315,9 @@ int wilc_hif_set_cfg(struct wilc_vif *vif,
3309 return wilc_enqueue_cmd(&msg); 3315 return wilc_enqueue_cmd(&msg);
3310} 3316}
3311 3317
3312static void GetPeriodicRSSI(unsigned long arg) 3318static void GetPeriodicRSSI(struct timer_list *unused)
3313{ 3319{
3314 struct wilc_vif *vif = (struct wilc_vif *)arg; 3320 struct wilc_vif *vif = periodic_rssi_vif;
3315 3321
3316 if (!vif->hif_drv) { 3322 if (!vif->hif_drv) {
3317 netdev_err(vif->ndev, "Driver handler is NULL\n"); 3323 netdev_err(vif->ndev, "Driver handler is NULL\n");
@@ -3321,7 +3327,6 @@ static void GetPeriodicRSSI(unsigned long arg)
3321 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) 3327 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3322 wilc_get_statistics(vif, &vif->wilc->dummy_statistics); 3328 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3323 3329
3324 periodic_rssi.data = (unsigned long)vif;
3325 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); 3330 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3326} 3331}
3327 3332
@@ -3374,14 +3379,14 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3374 goto _fail_; 3379 goto _fail_;
3375 } 3380 }
3376 3381
3377 setup_timer(&periodic_rssi, GetPeriodicRSSI, 3382 periodic_rssi_vif = vif;
3378 (unsigned long)vif); 3383 timer_setup(&periodic_rssi, GetPeriodicRSSI, 0);
3379 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); 3384 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3380 } 3385 }
3381 3386
3382 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0); 3387 timer_setup(&hif_drv->scan_timer, TimerCB_Scan, 0);
3383 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0); 3388 timer_setup(&hif_drv->connect_timer, TimerCB_Connect, 0);
3384 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0); 3389 timer_setup(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3385 3390
3386 mutex_init(&hif_drv->cfg_values_lock); 3391 mutex_init(&hif_drv->cfg_values_lock);
3387 mutex_lock(&hif_drv->cfg_values_lock); 3392 mutex_lock(&hif_drv->cfg_values_lock);
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 1ce5ead318c7..65734c38bf43 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -279,8 +279,13 @@ struct host_if_drv {
279 struct completion comp_inactive_time; 279 struct completion comp_inactive_time;
280 280
281 struct timer_list scan_timer; 281 struct timer_list scan_timer;
282 struct wilc_vif *scan_timer_vif;
283
282 struct timer_list connect_timer; 284 struct timer_list connect_timer;
285 struct wilc_vif *connect_timer_vif;
286
283 struct timer_list remain_on_ch_timer; 287 struct timer_list remain_on_ch_timer;
288 struct wilc_vif *remain_on_ch_timer_vif;
284 289
285 bool IFC_UP; 290 bool IFC_UP;
286 int driver_handler_id; 291 int driver_handler_id;
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index ac5aaafa461c..9241a387f528 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -266,7 +266,7 @@ static void update_scan_time(void)
266 last_scanned_shadow[i].time_scan = jiffies; 266 last_scanned_shadow[i].time_scan = jiffies;
267} 267}
268 268
269static void remove_network_from_shadow(unsigned long arg) 269static void remove_network_from_shadow(unsigned long unused)
270{ 270{
271 unsigned long now = jiffies; 271 unsigned long now = jiffies;
272 int i, j; 272 int i, j;
@@ -287,7 +287,6 @@ static void remove_network_from_shadow(unsigned long arg)
287 } 287 }
288 288
289 if (last_scanned_cnt != 0) { 289 if (last_scanned_cnt != 0) {
290 hAgingTimer.data = arg;
291 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); 290 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
292 } 291 }
293} 292}
@@ -304,7 +303,6 @@ static int is_network_in_shadow(struct network_info *pstrNetworkInfo,
304 int i; 303 int i;
305 304
306 if (last_scanned_cnt == 0) { 305 if (last_scanned_cnt == 0) {
307 hAgingTimer.data = (unsigned long)user_void;
308 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); 306 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
309 state = -1; 307 state = -1;
310 } else { 308 } else {
@@ -1111,7 +1109,6 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1111 g_key_gtk_params.key = NULL; 1109 g_key_gtk_params.key = NULL;
1112 kfree(g_key_gtk_params.seq); 1110 kfree(g_key_gtk_params.seq);
1113 g_key_gtk_params.seq = NULL; 1111 g_key_gtk_params.seq = NULL;
1114
1115 } 1112 }
1116 1113
1117 if (key_index >= 0 && key_index <= 3) { 1114 if (key_index >= 0 && key_index <= 3) {
@@ -1617,7 +1614,7 @@ static int mgmt_tx(struct wiphy *wiphy,
1617 1614
1618 *cookie = (unsigned long)buf; 1615 *cookie = (unsigned long)buf;
1619 priv->u64tx_cookie = *cookie; 1616 priv->u64tx_cookie = *cookie;
1620 mgmt = (const struct ieee80211_mgmt *) buf; 1617 mgmt = (const struct ieee80211_mgmt *)buf;
1621 1618
1622 if (ieee80211_is_mgmt(mgmt->frame_control)) { 1619 if (ieee80211_is_mgmt(mgmt->frame_control)) {
1623 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); 1620 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 9addef1f1e12..f49dfa82f1b8 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -714,7 +714,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
714 char *bssid = ((struct tx_complete_data *)(tqe->priv))->bssid; 714 char *bssid = ((struct tx_complete_data *)(tqe->priv))->bssid;
715 715
716 buffer_offset = ETH_ETHERNET_HDR_OFFSET; 716 buffer_offset = ETH_ETHERNET_HDR_OFFSET;
717 memcpy(&txb[offset + 4], bssid, 6); 717 memcpy(&txb[offset + 8], bssid, 6);
718 } else { 718 } else {
719 buffer_offset = HOST_HDR_OFFSET; 719 buffer_offset = HOST_HDR_OFFSET;
720 } 720 }
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index d1e8218f96fb..5975d47dfa71 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -184,11 +184,11 @@ static void hfa384x_usbin_ctlx(struct hfa384x *hw, union hfa384x_usbin *usbin,
184 184
185static void hfa384x_usbctlxq_run(struct hfa384x *hw); 185static void hfa384x_usbctlxq_run(struct hfa384x *hw);
186 186
187static void hfa384x_usbctlx_reqtimerfn(unsigned long data); 187static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t);
188 188
189static void hfa384x_usbctlx_resptimerfn(unsigned long data); 189static void hfa384x_usbctlx_resptimerfn(struct timer_list *t);
190 190
191static void hfa384x_usb_throttlefn(unsigned long data); 191static void hfa384x_usb_throttlefn(struct timer_list *t);
192 192
193static void hfa384x_usbctlx_completion_task(unsigned long data); 193static void hfa384x_usbctlx_completion_task(unsigned long data);
194 194
@@ -558,13 +558,11 @@ void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
558 INIT_WORK(&hw->link_bh, prism2sta_processing_defer); 558 INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
559 INIT_WORK(&hw->usb_work, hfa384x_usb_defer); 559 INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
560 560
561 setup_timer(&hw->throttle, hfa384x_usb_throttlefn, (unsigned long)hw); 561 timer_setup(&hw->throttle, hfa384x_usb_throttlefn, 0);
562 562
563 setup_timer(&hw->resptimer, hfa384x_usbctlx_resptimerfn, 563 timer_setup(&hw->resptimer, hfa384x_usbctlx_resptimerfn, 0);
564 (unsigned long)hw);
565 564
566 setup_timer(&hw->reqtimer, hfa384x_usbctlx_reqtimerfn, 565 timer_setup(&hw->reqtimer, hfa384x_usbctlx_reqtimerfn, 0);
567 (unsigned long)hw);
568 566
569 usb_init_urb(&hw->rx_urb); 567 usb_init_urb(&hw->rx_urb);
570 usb_init_urb(&hw->tx_urb); 568 usb_init_urb(&hw->tx_urb);
@@ -574,8 +572,7 @@ void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
574 hw->state = HFA384x_STATE_INIT; 572 hw->state = HFA384x_STATE_INIT;
575 573
576 INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer); 574 INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
577 setup_timer(&hw->commsqual_timer, prism2sta_commsqual_timer, 575 timer_setup(&hw->commsqual_timer, prism2sta_commsqual_timer, 0);
578 (unsigned long)hw);
579} 576}
580 577
581/*---------------------------------------------------------------- 578/*----------------------------------------------------------------
@@ -3800,9 +3797,9 @@ delresp:
3800 * interrupt 3797 * interrupt
3801 *---------------------------------------------------------------- 3798 *----------------------------------------------------------------
3802 */ 3799 */
3803static void hfa384x_usbctlx_reqtimerfn(unsigned long data) 3800static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t)
3804{ 3801{
3805 struct hfa384x *hw = (struct hfa384x *)data; 3802 struct hfa384x *hw = from_timer(hw, t, reqtimer);
3806 unsigned long flags; 3803 unsigned long flags;
3807 3804
3808 spin_lock_irqsave(&hw->ctlxq.lock, flags); 3805 spin_lock_irqsave(&hw->ctlxq.lock, flags);
@@ -3859,9 +3856,9 @@ static void hfa384x_usbctlx_reqtimerfn(unsigned long data)
3859 * interrupt 3856 * interrupt
3860 *---------------------------------------------------------------- 3857 *----------------------------------------------------------------
3861 */ 3858 */
3862static void hfa384x_usbctlx_resptimerfn(unsigned long data) 3859static void hfa384x_usbctlx_resptimerfn(struct timer_list *t)
3863{ 3860{
3864 struct hfa384x *hw = (struct hfa384x *)data; 3861 struct hfa384x *hw = from_timer(hw, t, resptimer);
3865 unsigned long flags; 3862 unsigned long flags;
3866 3863
3867 spin_lock_irqsave(&hw->ctlxq.lock, flags); 3864 spin_lock_irqsave(&hw->ctlxq.lock, flags);
@@ -3899,9 +3896,9 @@ static void hfa384x_usbctlx_resptimerfn(unsigned long data)
3899 * Interrupt 3896 * Interrupt
3900 *---------------------------------------------------------------- 3897 *----------------------------------------------------------------
3901 */ 3898 */
3902static void hfa384x_usb_throttlefn(unsigned long data) 3899static void hfa384x_usb_throttlefn(struct timer_list *t)
3903{ 3900{
3904 struct hfa384x *hw = (struct hfa384x *)data; 3901 struct hfa384x *hw = from_timer(hw, t, throttle);
3905 unsigned long flags; 3902 unsigned long flags;
3906 3903
3907 spin_lock_irqsave(&hw->ctlxq.lock, flags); 3904 spin_lock_irqsave(&hw->ctlxq.lock, flags);
diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
index c4aa9e7e7003..72070593394a 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -394,8 +394,9 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp)
394 count = HFA384x_SCANRESULT_MAX; 394 count = HFA384x_SCANRESULT_MAX;
395 395
396 if (req->bssindex.data >= count) { 396 if (req->bssindex.data >= count) {
397 pr_debug("requested index (%d) out of range (%d)\n", 397 netdev_dbg(wlandev->netdev,
398 req->bssindex.data, count); 398 "requested index (%d) out of range (%d)\n",
399 req->bssindex.data, count);
399 result = 2; 400 result = 2;
400 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; 401 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
401 goto exit; 402 goto exit;
@@ -684,7 +685,8 @@ int prism2mgmt_start(struct wlandevice *wlandev, void *msgp)
684 685
685 goto done; 686 goto done;
686failed: 687failed:
687 pr_debug("Failed to set a config option, result=%d\n", result); 688 netdev_dbg(wlandev->netdev,
689 "Failed to set a config option, result=%d\n", result);
688 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; 690 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
689 691
690done: 692done:
@@ -1120,15 +1122,17 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1120 /* Disable monitor mode */ 1122 /* Disable monitor mode */
1121 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE); 1123 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
1122 if (result) { 1124 if (result) {
1123 pr_debug("failed to disable monitor mode, result=%d\n", 1125 netdev_dbg(wlandev->netdev,
1124 result); 1126 "failed to disable monitor mode, result=%d\n",
1127 result);
1125 goto failed; 1128 goto failed;
1126 } 1129 }
1127 /* Disable port 0 */ 1130 /* Disable port 0 */
1128 result = hfa384x_drvr_disable(hw, 0); 1131 result = hfa384x_drvr_disable(hw, 0);
1129 if (result) { 1132 if (result) {
1130 pr_debug 1133 netdev_dbg
1131 ("failed to disable port 0 after sniffing, result=%d\n", 1134 (wlandev->netdev,
1135 "failed to disable port 0 after sniffing, result=%d\n",
1132 result); 1136 result);
1133 goto failed; 1137 goto failed;
1134 } 1138 }
@@ -1140,8 +1144,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1140 HFA384x_RID_CNFWEPFLAGS, 1144 HFA384x_RID_CNFWEPFLAGS,
1141 hw->presniff_wepflags); 1145 hw->presniff_wepflags);
1142 if (result) { 1146 if (result) {
1143 pr_debug 1147 netdev_dbg
1144 ("failed to restore wepflags=0x%04x, result=%d\n", 1148 (wlandev->netdev,
1149 "failed to restore wepflags=0x%04x, result=%d\n",
1145 hw->presniff_wepflags, result); 1150 hw->presniff_wepflags, result);
1146 goto failed; 1151 goto failed;
1147 } 1152 }
@@ -1153,8 +1158,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1153 HFA384x_RID_CNFPORTTYPE, 1158 HFA384x_RID_CNFPORTTYPE,
1154 word); 1159 word);
1155 if (result) { 1160 if (result) {
1156 pr_debug 1161 netdev_dbg
1157 ("failed to restore porttype, result=%d\n", 1162 (wlandev->netdev,
1163 "failed to restore porttype, result=%d\n",
1158 result); 1164 result);
1159 goto failed; 1165 goto failed;
1160 } 1166 }
@@ -1162,8 +1168,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1162 /* Enable the port */ 1168 /* Enable the port */
1163 result = hfa384x_drvr_enable(hw, 0); 1169 result = hfa384x_drvr_enable(hw, 0);
1164 if (result) { 1170 if (result) {
1165 pr_debug("failed to enable port to presniff setting, result=%d\n", 1171 netdev_dbg(wlandev->netdev,
1166 result); 1172 "failed to enable port to presniff setting, result=%d\n",
1173 result);
1167 goto failed; 1174 goto failed;
1168 } 1175 }
1169 } else { 1176 } else {
@@ -1182,8 +1189,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1182 HFA384x_RID_CNFPORTTYPE, 1189 HFA384x_RID_CNFPORTTYPE,
1183 &(hw->presniff_port_type)); 1190 &(hw->presniff_port_type));
1184 if (result) { 1191 if (result) {
1185 pr_debug 1192 netdev_dbg
1186 ("failed to read porttype, result=%d\n", 1193 (wlandev->netdev,
1194 "failed to read porttype, result=%d\n",
1187 result); 1195 result);
1188 goto failed; 1196 goto failed;
1189 } 1197 }
@@ -1192,24 +1200,27 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1192 HFA384x_RID_CNFWEPFLAGS, 1200 HFA384x_RID_CNFWEPFLAGS,
1193 &(hw->presniff_wepflags)); 1201 &(hw->presniff_wepflags));
1194 if (result) { 1202 if (result) {
1195 pr_debug 1203 netdev_dbg
1196 ("failed to read wepflags, result=%d\n", 1204 (wlandev->netdev,
1205 "failed to read wepflags, result=%d\n",
1197 result); 1206 result);
1198 goto failed; 1207 goto failed;
1199 } 1208 }
1200 hfa384x_drvr_stop(hw); 1209 hfa384x_drvr_stop(hw);
1201 result = hfa384x_drvr_start(hw); 1210 result = hfa384x_drvr_start(hw);
1202 if (result) { 1211 if (result) {
1203 pr_debug("failed to restart the card for sniffing, result=%d\n", 1212 netdev_dbg(wlandev->netdev,
1204 result); 1213 "failed to restart the card for sniffing, result=%d\n",
1214 result);
1205 goto failed; 1215 goto failed;
1206 } 1216 }
1207 } else { 1217 } else {
1208 /* Disable the port */ 1218 /* Disable the port */
1209 result = hfa384x_drvr_disable(hw, 0); 1219 result = hfa384x_drvr_disable(hw, 0);
1210 if (result) { 1220 if (result) {
1211 pr_debug("failed to enable port for sniffing, result=%d\n", 1221 netdev_dbg(wlandev->netdev,
1212 result); 1222 "failed to enable port for sniffing, result=%d\n",
1223 result);
1213 goto failed; 1224 goto failed;
1214 } 1225 }
1215 } 1226 }
@@ -1225,8 +1236,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1225 hw->sniff_channel = word; 1236 hw->sniff_channel = word;
1226 1237
1227 if (result) { 1238 if (result) {
1228 pr_debug("failed to set channel %d, result=%d\n", 1239 netdev_dbg(wlandev->netdev,
1229 word, result); 1240 "failed to set channel %d, result=%d\n",
1241 word, result);
1230 goto failed; 1242 goto failed;
1231 } 1243 }
1232 1244
@@ -1238,8 +1250,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1238 HFA384x_RID_CNFPORTTYPE, 1250 HFA384x_RID_CNFPORTTYPE,
1239 word); 1251 word);
1240 if (result) { 1252 if (result) {
1241 pr_debug 1253 netdev_dbg
1242 ("failed to set porttype %d, result=%d\n", 1254 (wlandev->netdev,
1255 "failed to set porttype %d, result=%d\n",
1243 word, result); 1256 word, result);
1244 goto failed; 1257 goto failed;
1245 } 1258 }
@@ -1257,8 +1270,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1257 } 1270 }
1258 1271
1259 if (result) { 1272 if (result) {
1260 pr_debug 1273 netdev_dbg
1261 ("failed to set wepflags=0x%04x, result=%d\n", 1274 (wlandev->netdev,
1275 "failed to set wepflags=0x%04x, result=%d\n",
1262 word, result); 1276 word, result);
1263 goto failed; 1277 goto failed;
1264 } 1278 }
@@ -1283,16 +1297,18 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
1283 /* Enable the port */ 1297 /* Enable the port */
1284 result = hfa384x_drvr_enable(hw, 0); 1298 result = hfa384x_drvr_enable(hw, 0);
1285 if (result) { 1299 if (result) {
1286 pr_debug 1300 netdev_dbg
1287 ("failed to enable port for sniffing, result=%d\n", 1301 (wlandev->netdev,
1302 "failed to enable port for sniffing, result=%d\n",
1288 result); 1303 result);
1289 goto failed; 1304 goto failed;
1290 } 1305 }
1291 /* Enable monitor mode */ 1306 /* Enable monitor mode */
1292 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE); 1307 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
1293 if (result) { 1308 if (result) {
1294 pr_debug("failed to enable monitor mode, result=%d\n", 1309 netdev_dbg(wlandev->netdev,
1295 result); 1310 "failed to enable monitor mode, result=%d\n",
1311 result);
1296 goto failed; 1312 goto failed;
1297 } 1313 }
1298 1314
diff --git a/drivers/staging/wlan-ng/prism2mgmt.h b/drivers/staging/wlan-ng/prism2mgmt.h
index 88b979ff68b3..c062418f1202 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.h
+++ b/drivers/staging/wlan-ng/prism2mgmt.h
@@ -109,7 +109,7 @@ int prism2mgmt_get_grpaddr_index(u32 did);
109void prism2sta_processing_defer(struct work_struct *data); 109void prism2sta_processing_defer(struct work_struct *data);
110 110
111void prism2sta_commsqual_defer(struct work_struct *data); 111void prism2sta_commsqual_defer(struct work_struct *data);
112void prism2sta_commsqual_timer(unsigned long data); 112void prism2sta_commsqual_timer(struct timer_list *t);
113 113
114/* Interface callback functions, passing data back up to the cfg80211 layer */ 114/* Interface callback functions, passing data back up to the cfg80211 layer */
115void prism2_connect_result(struct wlandevice *wlandev, u8 failed); 115void prism2_connect_result(struct wlandevice *wlandev, u8 failed);
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index c9df45063ab3..99316b9a4e49 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1447,7 +1447,7 @@ static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
1447{ 1447{
1448 struct hfa384x *hw = wlandev->priv; 1448 struct hfa384x *hw = wlandev->priv;
1449 1449
1450 hw->link_status_new = inf->info.linkstatus.linkstatus; 1450 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
1451 1451
1452 schedule_work(&hw->link_bh); 1452 schedule_work(&hw->link_bh);
1453} 1453}
@@ -2004,9 +2004,9 @@ void prism2sta_commsqual_defer(struct work_struct *data)
2004 mod_timer(&hw->commsqual_timer, jiffies + HZ); 2004 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2005} 2005}
2006 2006
2007void prism2sta_commsqual_timer(unsigned long data) 2007void prism2sta_commsqual_timer(struct timer_list *t)
2008{ 2008{
2009 struct hfa384x *hw = (struct hfa384x *)data; 2009 struct hfa384x *hw = from_timer(hw, t, commsqual_timer);
2010 2010
2011 schedule_work(&hw->commsqual_bh); 2011 schedule_work(&hw->commsqual_bh);
2012} 2012}
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index b450c740f626..b813f1d460ce 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -1697,7 +1697,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1697 1697
1698 if (XGIfb_get_dram_size(xgifb_info)) { 1698 if (XGIfb_get_dram_size(xgifb_info)) {
1699 xgifb_info->video_size = min_t(unsigned long, video_size_max, 1699 xgifb_info->video_size = min_t(unsigned long, video_size_max,
1700 SZ_16M); 1700 SZ_16M);
1701 } else if (xgifb_info->video_size > video_size_max) { 1701 } else if (xgifb_info->video_size > video_size_max) {
1702 xgifb_info->video_size = video_size_max; 1702 xgifb_info->video_size = video_size_max;
1703 } 1703 }
@@ -1736,7 +1736,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1736 hw_info->pjVideoMemoryAddress = 1736 hw_info->pjVideoMemoryAddress =
1737 ioremap_wc(xgifb_info->video_base, xgifb_info->video_size); 1737 ioremap_wc(xgifb_info->video_base, xgifb_info->video_size);
1738 xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, 1738 xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
1739 xgifb_info->mmio_size); 1739 xgifb_info->mmio_size);
1740 1740
1741 dev_info(&pdev->dev, 1741 dev_info(&pdev->dev,
1742 "Framebuffer at 0x%llx, mapped to 0x%p, size %dk\n", 1742 "Framebuffer at 0x%llx, mapped to 0x%p, size %dk\n",
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index cea128bede52..a6cd0a1e8c05 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -5046,7 +5046,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
5046 unsigned short ModeIdIndex, 5046 unsigned short ModeIdIndex,
5047 struct vb_device_info *pVBInfo) 5047 struct vb_device_info *pVBInfo)
5048{ 5048{
5049 const u8 LCDARefreshIndex[] = { 5049 static const u8 LCDARefreshIndex[] = {
5050 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; 5050 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
5051 5051
5052 unsigned short RefreshRateTableIndex, i, index, temp; 5052 unsigned short RefreshRateTableIndex, i, index, temp;
@@ -5479,8 +5479,9 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
5479 ModeIdIndex)) 5479 ModeIdIndex))
5480 return 0; 5480 return 0;
5481 5481
5482 pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. 5482 pVBInfo->ModeType =
5483 Ext_ModeFlag & ModeTypeMask; 5483 XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag
5484 & ModeTypeMask;
5484 5485
5485 pVBInfo->SetFlag = 0; 5486 pVBInfo->SetFlag = 0;
5486 pVBInfo->VBInfo = DisableCRT2Display; 5487 pVBInfo->VBInfo = DisableCRT2Display;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 5e056064259c..18c923a4c16e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1832,6 +1832,9 @@ static const struct usb_device_id acm_ids[] = {
1832 { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */ 1832 { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */
1833 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ 1833 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1834 }, 1834 },
1835 { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */
1836 .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */
1837 },
1835 1838
1836 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ 1839 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
1837 .driver_info = CLEAR_HALT_CONDITIONS, 1840 .driver_info = CLEAR_HALT_CONDITIONS,
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 68b54bd88d1e..883549ee946c 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -960,10 +960,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
960 for (i = 0; i < num; i++) { 960 for (i = 0; i < num; i++) {
961 buffer += length; 961 buffer += length;
962 cap = (struct usb_dev_cap_header *)buffer; 962 cap = (struct usb_dev_cap_header *)buffer;
963 length = cap->bLength;
964 963
965 if (total_len < length) 964 if (total_len < sizeof(*cap) || total_len < cap->bLength) {
965 dev->bos->desc->bNumDeviceCaps = i;
966 break; 966 break;
967 }
968 length = cap->bLength;
967 total_len -= length; 969 total_len -= length;
968 970
969 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { 971 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 4664e543cf2f..e9326f31db8d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1576,11 +1576,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1576 totlen += isopkt[u].length; 1576 totlen += isopkt[u].length;
1577 } 1577 }
1578 u *= sizeof(struct usb_iso_packet_descriptor); 1578 u *= sizeof(struct usb_iso_packet_descriptor);
1579 if (totlen <= uurb->buffer_length) 1579 uurb->buffer_length = totlen;
1580 uurb->buffer_length = totlen;
1581 else
1582 WARN_ONCE(1, "uurb->buffer_length is too short %d vs %d",
1583 totlen, uurb->buffer_length);
1584 break; 1580 break;
1585 1581
1586 default: 1582 default:
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b5c733613823..e9ce6bb0b22d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2710,13 +2710,16 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
2710 if (!(portstatus & USB_PORT_STAT_CONNECTION)) 2710 if (!(portstatus & USB_PORT_STAT_CONNECTION))
2711 return -ENOTCONN; 2711 return -ENOTCONN;
2712 2712
2713 /* bomb out completely if the connection bounced. A USB 3.0 2713 /* Retry if connect change is set but status is still connected.
2714 * connection may bounce if multiple warm resets were issued, 2714 * A USB 3.0 connection may bounce if multiple warm resets were issued,
2715 * but the device may have successfully re-connected. Ignore it. 2715 * but the device may have successfully re-connected. Ignore it.
2716 */ 2716 */
2717 if (!hub_is_superspeed(hub->hdev) && 2717 if (!hub_is_superspeed(hub->hdev) &&
2718 (portchange & USB_PORT_STAT_C_CONNECTION)) 2718 (portchange & USB_PORT_STAT_C_CONNECTION)) {
2719 return -ENOTCONN; 2719 usb_clear_port_feature(hub->hdev, port1,
2720 USB_PORT_FEAT_C_CONNECTION);
2721 return -EAGAIN;
2722 }
2720 2723
2721 if (!(portstatus & USB_PORT_STAT_ENABLE)) 2724 if (!(portstatus & USB_PORT_STAT_ENABLE))
2722 return -EBUSY; 2725 return -EBUSY;
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 82806e311202..a6aaf2f193a4 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -221,6 +221,10 @@ static const struct usb_device_id usb_quirk_list[] = {
221 /* Corsair Strafe RGB */ 221 /* Corsair Strafe RGB */
222 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, 222 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
223 223
224 /* MIDI keyboard WORLDE MINI */
225 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
226 USB_QUIRK_CONFIG_INTF_STRINGS },
227
224 /* Acer C120 LED Projector */ 228 /* Acer C120 LED Projector */
225 { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, 229 { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
226 230
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index da9158f171cb..a2336deb5e36 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -420,14 +420,25 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
420 GFP_NOWAIT); 420 GFP_NOWAIT);
421 if (!command) { 421 if (!command) {
422 spin_unlock_irqrestore(&xhci->lock, flags); 422 spin_unlock_irqrestore(&xhci->lock, flags);
423 xhci_free_command(xhci, cmd); 423 ret = -ENOMEM;
424 return -ENOMEM; 424 goto cmd_cleanup;
425 }
426
427 ret = xhci_queue_stop_endpoint(xhci, command, slot_id,
428 i, suspend);
429 if (ret) {
430 spin_unlock_irqrestore(&xhci->lock, flags);
431 xhci_free_command(xhci, command);
432 goto cmd_cleanup;
425 } 433 }
426 xhci_queue_stop_endpoint(xhci, command, slot_id, i,
427 suspend);
428 } 434 }
429 } 435 }
430 xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); 436 ret = xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend);
437 if (ret) {
438 spin_unlock_irqrestore(&xhci->lock, flags);
439 goto cmd_cleanup;
440 }
441
431 xhci_ring_cmd_db(xhci); 442 xhci_ring_cmd_db(xhci);
432 spin_unlock_irqrestore(&xhci->lock, flags); 443 spin_unlock_irqrestore(&xhci->lock, flags);
433 444
@@ -439,6 +450,8 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
439 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); 450 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n");
440 ret = -ETIME; 451 ret = -ETIME;
441 } 452 }
453
454cmd_cleanup:
442 xhci_free_command(xhci, cmd); 455 xhci_free_command(xhci, cmd);
443 return ret; 456 return ret;
444} 457}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a9443651ce0f..82c746e2d85c 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1309,6 +1309,7 @@ static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 status)
1309void xhci_cleanup_command_queue(struct xhci_hcd *xhci) 1309void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
1310{ 1310{
1311 struct xhci_command *cur_cmd, *tmp_cmd; 1311 struct xhci_command *cur_cmd, *tmp_cmd;
1312 xhci->current_cmd = NULL;
1312 list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list) 1313 list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list)
1313 xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED); 1314 xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED);
1314} 1315}
@@ -2579,15 +2580,21 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2579 (struct xhci_generic_trb *) ep_trb); 2580 (struct xhci_generic_trb *) ep_trb);
2580 2581
2581 /* 2582 /*
2582 * No-op TRB should not trigger interrupts. 2583 * No-op TRB could trigger interrupts in a case where
2583 * If ep_trb is a no-op TRB, it means the 2584 * a URB was killed and a STALL_ERROR happens right
2584 * corresponding TD has been cancelled. Just ignore 2585 * after the endpoint ring stopped. Reset the halted
2585 * the TD. 2586 * endpoint. Otherwise, the endpoint remains stalled
2587 * indefinitely.
2586 */ 2588 */
2587 if (trb_is_noop(ep_trb)) { 2589 if (trb_is_noop(ep_trb)) {
2588 xhci_dbg(xhci, 2590 if (trb_comp_code == COMP_STALL_ERROR ||
2589 "ep_trb is a no-op TRB. Skip it for slot %u ep %u\n", 2591 xhci_requires_manual_halt_cleanup(xhci, ep_ctx,
2590 slot_id, ep_index); 2592 trb_comp_code))
2593 xhci_cleanup_halted_endpoint(xhci, slot_id,
2594 ep_index,
2595 ep_ring->stream_id,
2596 td, ep_trb,
2597 EP_HARD_RESET);
2591 goto cleanup; 2598 goto cleanup;
2592 } 2599 }
2593 2600
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index ee198ea47f49..51535ba2bcd4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4805,7 +4805,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4805 */ 4805 */
4806 hcd->has_tt = 1; 4806 hcd->has_tt = 1;
4807 } else { 4807 } else {
4808 if (xhci->sbrn == 0x31) { 4808 /* Some 3.1 hosts return sbrn 0x30, can't rely on sbrn alone */
4809 if (xhci->sbrn == 0x31 || xhci->usb3_rhub.min_rev >= 1) {
4809 xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n"); 4810 xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n");
4810 hcd->speed = HCD_USB31; 4811 hcd->speed = HCD_USB31;
4811 hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; 4812 hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 029692053dd3..ff5a1a8989d5 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -906,7 +906,7 @@ b_host:
906 */ 906 */
907 if (int_usb & MUSB_INTR_RESET) { 907 if (int_usb & MUSB_INTR_RESET) {
908 handled = IRQ_HANDLED; 908 handled = IRQ_HANDLED;
909 if (devctl & MUSB_DEVCTL_HM) { 909 if (is_host_active(musb)) {
910 /* 910 /*
911 * When BABBLE happens what we can depends on which 911 * When BABBLE happens what we can depends on which
912 * platform MUSB is running, because some platforms 912 * platform MUSB is running, because some platforms
@@ -916,9 +916,7 @@ b_host:
916 * drop the session. 916 * drop the session.
917 */ 917 */
918 dev_err(musb->controller, "Babble\n"); 918 dev_err(musb->controller, "Babble\n");
919 919 musb_recover_from_babble(musb);
920 if (is_host_active(musb))
921 musb_recover_from_babble(musb);
922 } else { 920 } else {
923 musb_dbg(musb, "BUS RESET as %s", 921 musb_dbg(musb, "BUS RESET as %s",
924 usb_otg_state_string(musb->xceiv->otg->state)); 922 usb_otg_state_string(musb->xceiv->otg->state));
@@ -1861,22 +1859,22 @@ static void musb_pm_runtime_check_session(struct musb *musb)
1861 MUSB_DEVCTL_HR; 1859 MUSB_DEVCTL_HR;
1862 switch (devctl & ~s) { 1860 switch (devctl & ~s) {
1863 case MUSB_QUIRK_B_INVALID_VBUS_91: 1861 case MUSB_QUIRK_B_INVALID_VBUS_91:
1864 if (musb->quirk_retries--) { 1862 if (musb->quirk_retries && !musb->flush_irq_work) {
1865 musb_dbg(musb, 1863 musb_dbg(musb,
1866 "Poll devctl on invalid vbus, assume no session"); 1864 "Poll devctl on invalid vbus, assume no session");
1867 schedule_delayed_work(&musb->irq_work, 1865 schedule_delayed_work(&musb->irq_work,
1868 msecs_to_jiffies(1000)); 1866 msecs_to_jiffies(1000));
1869 1867 musb->quirk_retries--;
1870 return; 1868 return;
1871 } 1869 }
1872 /* fall through */ 1870 /* fall through */
1873 case MUSB_QUIRK_A_DISCONNECT_19: 1871 case MUSB_QUIRK_A_DISCONNECT_19:
1874 if (musb->quirk_retries--) { 1872 if (musb->quirk_retries && !musb->flush_irq_work) {
1875 musb_dbg(musb, 1873 musb_dbg(musb,
1876 "Poll devctl on possible host mode disconnect"); 1874 "Poll devctl on possible host mode disconnect");
1877 schedule_delayed_work(&musb->irq_work, 1875 schedule_delayed_work(&musb->irq_work,
1878 msecs_to_jiffies(1000)); 1876 msecs_to_jiffies(1000));
1879 1877 musb->quirk_retries--;
1880 return; 1878 return;
1881 } 1879 }
1882 if (!musb->session) 1880 if (!musb->session)
@@ -2681,8 +2679,15 @@ static int musb_suspend(struct device *dev)
2681 2679
2682 musb_platform_disable(musb); 2680 musb_platform_disable(musb);
2683 musb_disable_interrupts(musb); 2681 musb_disable_interrupts(musb);
2682
2683 musb->flush_irq_work = true;
2684 while (flush_delayed_work(&musb->irq_work))
2685 ;
2686 musb->flush_irq_work = false;
2687
2684 if (!(musb->io.quirks & MUSB_PRESERVE_SESSION)) 2688 if (!(musb->io.quirks & MUSB_PRESERVE_SESSION))
2685 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2689 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
2690
2686 WARN_ON(!list_empty(&musb->pending_list)); 2691 WARN_ON(!list_empty(&musb->pending_list));
2687 2692
2688 spin_lock_irqsave(&musb->lock, flags); 2693 spin_lock_irqsave(&musb->lock, flags);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index c748f4ac1154..20f4614178d9 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -428,6 +428,8 @@ struct musb {
428 unsigned test_mode:1; 428 unsigned test_mode:1;
429 unsigned softconnect:1; 429 unsigned softconnect:1;
430 430
431 unsigned flush_irq_work:1;
432
431 u8 address; 433 u8 address;
432 u8 test_mode_nr; 434 u8 test_mode_nr;
433 u16 ackpend; /* ep0 */ 435 u16 ackpend; /* ep0 */
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ba255280a624..1ec0a4947b6b 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,15 +26,28 @@
26 26
27#define MUSB_DMA_NUM_CHANNELS 15 27#define MUSB_DMA_NUM_CHANNELS 15
28 28
29#define DA8XX_USB_MODE 0x10
30#define DA8XX_USB_AUTOREQ 0x14
31#define DA8XX_USB_TEARDOWN 0x1c
32
33#define DA8XX_DMA_NUM_CHANNELS 4
34
29struct cppi41_dma_controller { 35struct cppi41_dma_controller {
30 struct dma_controller controller; 36 struct dma_controller controller;
31 struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; 37 struct cppi41_dma_channel *rx_channel;
32 struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; 38 struct cppi41_dma_channel *tx_channel;
33 struct hrtimer early_tx; 39 struct hrtimer early_tx;
34 struct list_head early_tx_list; 40 struct list_head early_tx_list;
35 u32 rx_mode; 41 u32 rx_mode;
36 u32 tx_mode; 42 u32 tx_mode;
37 u32 auto_req; 43 u32 auto_req;
44
45 u32 tdown_reg;
46 u32 autoreq_reg;
47
48 void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
49 unsigned int mode);
50 u8 num_channels;
38}; 51};
39 52
40static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) 53static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -349,6 +362,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
349 } 362 }
350} 363}
351 364
365static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
366 unsigned int mode)
367{
368 struct cppi41_dma_controller *controller = cppi41_channel->controller;
369 struct musb *musb = controller->controller.musb;
370 unsigned int shift;
371 u32 port;
372 u32 new_mode;
373 u32 old_mode;
374
375 old_mode = controller->tx_mode;
376 port = cppi41_channel->port_num;
377
378 shift = (port - 1) * 4;
379 if (!cppi41_channel->is_tx)
380 shift += 16;
381 new_mode = old_mode & ~(3 << shift);
382 new_mode |= mode << shift;
383
384 if (new_mode == old_mode)
385 return;
386 controller->tx_mode = new_mode;
387 musb_writel(musb->ctrl_base, DA8XX_USB_MODE, new_mode);
388}
389
390
352static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, 391static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
353 unsigned mode) 392 unsigned mode)
354{ 393{
@@ -364,8 +403,8 @@ static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
364 if (new_mode == old_mode) 403 if (new_mode == old_mode)
365 return; 404 return;
366 controller->auto_req = new_mode; 405 controller->auto_req = new_mode;
367 musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ, 406 musb_writel(controller->controller.musb->ctrl_base,
368 new_mode); 407 controller->autoreq_reg, new_mode);
369} 408}
370 409
371static bool cppi41_configure_channel(struct dma_channel *channel, 410static bool cppi41_configure_channel(struct dma_channel *channel,
@@ -373,6 +412,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
373 dma_addr_t dma_addr, u32 len) 412 dma_addr_t dma_addr, u32 len)
374{ 413{
375 struct cppi41_dma_channel *cppi41_channel = channel->private_data; 414 struct cppi41_dma_channel *cppi41_channel = channel->private_data;
415 struct cppi41_dma_controller *controller = cppi41_channel->controller;
376 struct dma_chan *dc = cppi41_channel->dc; 416 struct dma_chan *dc = cppi41_channel->dc;
377 struct dma_async_tx_descriptor *dma_desc; 417 struct dma_async_tx_descriptor *dma_desc;
378 enum dma_transfer_direction direction; 418 enum dma_transfer_direction direction;
@@ -398,7 +438,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
398 musb_writel(musb->ctrl_base, 438 musb_writel(musb->ctrl_base,
399 RNDIS_REG(cppi41_channel->port_num), len); 439 RNDIS_REG(cppi41_channel->port_num), len);
400 /* gen rndis */ 440 /* gen rndis */
401 cppi41_set_dma_mode(cppi41_channel, 441 controller->set_dma_mode(cppi41_channel,
402 EP_MODE_DMA_GEN_RNDIS); 442 EP_MODE_DMA_GEN_RNDIS);
403 443
404 /* auto req */ 444 /* auto req */
@@ -407,14 +447,15 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
407 } else { 447 } else {
408 musb_writel(musb->ctrl_base, 448 musb_writel(musb->ctrl_base,
409 RNDIS_REG(cppi41_channel->port_num), 0); 449 RNDIS_REG(cppi41_channel->port_num), 0);
410 cppi41_set_dma_mode(cppi41_channel, 450 controller->set_dma_mode(cppi41_channel,
411 EP_MODE_DMA_TRANSPARENT); 451 EP_MODE_DMA_TRANSPARENT);
412 cppi41_set_autoreq_mode(cppi41_channel, 452 cppi41_set_autoreq_mode(cppi41_channel,
413 EP_MODE_AUTOREQ_NONE); 453 EP_MODE_AUTOREQ_NONE);
414 } 454 }
415 } else { 455 } else {
416 /* fallback mode */ 456 /* fallback mode */
417 cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); 457 controller->set_dma_mode(cppi41_channel,
458 EP_MODE_DMA_TRANSPARENT);
418 cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); 459 cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE);
419 len = min_t(u32, packet_sz, len); 460 len = min_t(u32, packet_sz, len);
420 } 461 }
@@ -445,7 +486,7 @@ static struct dma_channel *cppi41_dma_channel_allocate(struct dma_controller *c,
445 struct cppi41_dma_channel *cppi41_channel = NULL; 486 struct cppi41_dma_channel *cppi41_channel = NULL;
446 u8 ch_num = hw_ep->epnum - 1; 487 u8 ch_num = hw_ep->epnum - 1;
447 488
448 if (ch_num >= MUSB_DMA_NUM_CHANNELS) 489 if (ch_num >= controller->num_channels)
449 return NULL; 490 return NULL;
450 491
451 if (is_tx) 492 if (is_tx)
@@ -581,12 +622,13 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel)
581 622
582 do { 623 do {
583 if (is_tx) 624 if (is_tx)
584 musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); 625 musb_writel(musb->ctrl_base, controller->tdown_reg,
626 tdbit);
585 ret = dmaengine_terminate_all(cppi41_channel->dc); 627 ret = dmaengine_terminate_all(cppi41_channel->dc);
586 } while (ret == -EAGAIN); 628 } while (ret == -EAGAIN);
587 629
588 if (is_tx) { 630 if (is_tx) {
589 musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); 631 musb_writel(musb->ctrl_base, controller->tdown_reg, tdbit);
590 632
591 csr = musb_readw(epio, MUSB_TXCSR); 633 csr = musb_readw(epio, MUSB_TXCSR);
592 if (csr & MUSB_TXCSR_TXPKTRDY) { 634 if (csr & MUSB_TXCSR_TXPKTRDY) {
@@ -604,7 +646,7 @@ static void cppi41_release_all_dma_chans(struct cppi41_dma_controller *ctrl)
604 struct dma_chan *dc; 646 struct dma_chan *dc;
605 int i; 647 int i;
606 648
607 for (i = 0; i < MUSB_DMA_NUM_CHANNELS; i++) { 649 for (i = 0; i < ctrl->num_channels; i++) {
608 dc = ctrl->tx_channel[i].dc; 650 dc = ctrl->tx_channel[i].dc;
609 if (dc) 651 if (dc)
610 dma_release_channel(dc); 652 dma_release_channel(dc);
@@ -656,7 +698,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
656 goto err; 698 goto err;
657 699
658 ret = -EINVAL; 700 ret = -EINVAL;
659 if (port > MUSB_DMA_NUM_CHANNELS || !port) 701 if (port > controller->num_channels || !port)
660 goto err; 702 goto err;
661 if (is_tx) 703 if (is_tx)
662 cppi41_channel = &controller->tx_channel[port - 1]; 704 cppi41_channel = &controller->tx_channel[port - 1];
@@ -697,6 +739,8 @@ void cppi41_dma_controller_destroy(struct dma_controller *c)
697 739
698 hrtimer_cancel(&controller->early_tx); 740 hrtimer_cancel(&controller->early_tx);
699 cppi41_dma_controller_stop(controller); 741 cppi41_dma_controller_stop(controller);
742 kfree(controller->rx_channel);
743 kfree(controller->tx_channel);
700 kfree(controller); 744 kfree(controller);
701} 745}
702EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy); 746EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy);
@@ -705,6 +749,7 @@ struct dma_controller *
705cppi41_dma_controller_create(struct musb *musb, void __iomem *base) 749cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
706{ 750{
707 struct cppi41_dma_controller *controller; 751 struct cppi41_dma_controller *controller;
752 int channel_size;
708 int ret = 0; 753 int ret = 0;
709 754
710 if (!musb->controller->parent->of_node) { 755 if (!musb->controller->parent->of_node) {
@@ -727,12 +772,37 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
727 controller->controller.is_compatible = cppi41_is_compatible; 772 controller->controller.is_compatible = cppi41_is_compatible;
728 controller->controller.musb = musb; 773 controller->controller.musb = musb;
729 774
775 if (musb->io.quirks & MUSB_DA8XX) {
776 controller->tdown_reg = DA8XX_USB_TEARDOWN;
777 controller->autoreq_reg = DA8XX_USB_AUTOREQ;
778 controller->set_dma_mode = da8xx_set_dma_mode;
779 controller->num_channels = DA8XX_DMA_NUM_CHANNELS;
780 } else {
781 controller->tdown_reg = USB_TDOWN;
782 controller->autoreq_reg = USB_CTRL_AUTOREQ;
783 controller->set_dma_mode = cppi41_set_dma_mode;
784 controller->num_channels = MUSB_DMA_NUM_CHANNELS;
785 }
786
787 channel_size = controller->num_channels *
788 sizeof(struct cppi41_dma_channel);
789 controller->rx_channel = kzalloc(channel_size, GFP_KERNEL);
790 if (!controller->rx_channel)
791 goto rx_channel_alloc_fail;
792 controller->tx_channel = kzalloc(channel_size, GFP_KERNEL);
793 if (!controller->tx_channel)
794 goto tx_channel_alloc_fail;
795
730 ret = cppi41_dma_controller_start(controller); 796 ret = cppi41_dma_controller_start(controller);
731 if (ret) 797 if (ret)
732 goto plat_get_fail; 798 goto plat_get_fail;
733 return &controller->controller; 799 return &controller->controller;
734 800
735plat_get_fail: 801plat_get_fail:
802 kfree(controller->tx_channel);
803tx_channel_alloc_fail:
804 kfree(controller->rx_channel);
805rx_channel_alloc_fail:
736 kfree(controller); 806 kfree(controller);
737kzalloc_fail: 807kzalloc_fail:
738 if (ret == -EPROBE_DEFER) 808 if (ret == -EPROBE_DEFER)
diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index c9a09b5bb6e5..dc353e24d53c 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
297 if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) 297 if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
298 sunxi_sram_release(musb->controller->parent); 298 sunxi_sram_release(musb->controller->parent);
299 299
300 devm_usb_put_phy(glue->dev, glue->xceiv);
301
300 return 0; 302 return 0;
301} 303}
302 304
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index cc84da8dbb84..14511d6a7d44 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -45,6 +45,7 @@ struct metrousb_private {
45static const struct usb_device_id id_table[] = { 45static const struct usb_device_id id_table[] = {
46 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_BI) }, 46 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_BI) },
47 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) }, 47 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) },
48 { USB_DEVICE_INTERFACE_CLASS(0x0c2e, 0x0730, 0xff) }, /* MS7820 */
48 { }, /* Terminating entry. */ 49 { }, /* Terminating entry. */
49}; 50};
50MODULE_DEVICE_TABLE(usb, id_table); 51MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index bc1b7745f1d4..819c0ed2b200 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -4,6 +4,20 @@ menu "USB Power Delivery and Type-C drivers"
4config TYPEC 4config TYPEC
5 tristate 5 tristate
6 6
7config TYPEC_TCPM
8 tristate "USB Type-C Port Controller Manager"
9 depends on USB
10 select TYPEC
11 help
12 The Type-C Port Controller Manager provides a USB PD and USB Type-C
13 state machine for use with Type-C Port Controllers.
14
15if TYPEC_TCPM
16
17source "drivers/usb/typec/fusb302/Kconfig"
18
19endif
20
7config TYPEC_WCOVE 21config TYPEC_WCOVE
8 tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver" 22 tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver"
9 depends on ACPI 23 depends on ACPI
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index bc214f15f1b5..b77688ce1f16 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,3 +1,5 @@
1obj-$(CONFIG_TYPEC) += typec.o 1obj-$(CONFIG_TYPEC) += typec.o
2obj-$(CONFIG_TYPEC_TCPM) += tcpm.o
3obj-y += fusb302/
2obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o 4obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o
3obj-$(CONFIG_TYPEC_UCSI) += ucsi/ 5obj-$(CONFIG_TYPEC_UCSI) += ucsi/
diff --git a/drivers/staging/typec/fusb302/Kconfig b/drivers/usb/typec/fusb302/Kconfig
index 48a4f2fcee03..48a4f2fcee03 100644
--- a/drivers/staging/typec/fusb302/Kconfig
+++ b/drivers/usb/typec/fusb302/Kconfig
diff --git a/drivers/staging/typec/fusb302/Makefile b/drivers/usb/typec/fusb302/Makefile
index 207efa5fbab8..207efa5fbab8 100644
--- a/drivers/staging/typec/fusb302/Makefile
+++ b/drivers/usb/typec/fusb302/Makefile
diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index fc6a3cf74eb3..e790b67d4953 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -37,11 +37,11 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/usb/typec.h> 39#include <linux/usb/typec.h>
40#include <linux/usb/tcpm.h>
41#include <linux/usb/pd.h>
40#include <linux/workqueue.h> 42#include <linux/workqueue.h>
41 43
42#include "fusb302_reg.h" 44#include "fusb302_reg.h"
43#include "../tcpm.h"
44#include "../pd.h"
45 45
46/* 46/*
47 * When the device is SNK, BC_LVL interrupt is used to monitor cc pins 47 * When the device is SNK, BC_LVL interrupt is used to monitor cc pins
diff --git a/drivers/staging/typec/fusb302/fusb302_reg.h b/drivers/usb/typec/fusb302/fusb302_reg.h
index 0682e63de773..0682e63de773 100644
--- a/drivers/staging/typec/fusb302/fusb302_reg.h
+++ b/drivers/usb/typec/fusb302/fusb302_reg.h
diff --git a/drivers/staging/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 8af62e74d54c..f557c479fdc2 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -26,14 +26,13 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/usb/pd.h>
30#include <linux/usb/pd_bdo.h>
31#include <linux/usb/pd_vdo.h>
32#include <linux/usb/tcpm.h>
29#include <linux/usb/typec.h> 33#include <linux/usb/typec.h>
30#include <linux/workqueue.h> 34#include <linux/workqueue.h>
31 35
32#include "pd.h"
33#include "pd_vdo.h"
34#include "pd_bdo.h"
35#include "tcpm.h"
36
37#define FOREACH_STATE(S) \ 36#define FOREACH_STATE(S) \
38 S(INVALID_STATE), \ 37 S(INVALID_STATE), \
39 S(DRP_TOGGLING), \ 38 S(DRP_TOGGLING), \
@@ -908,27 +907,6 @@ static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload,
908 907
909 memset(&port->mode_data, 0, sizeof(port->mode_data)); 908 memset(&port->mode_data, 0, sizeof(port->mode_data));
910 909
911#if 0 /* Not really a match */
912 switch (PD_IDH_PTYPE(vdo)) {
913 case IDH_PTYPE_UNDEF:
914 port->partner.type = TYPEC_PARTNER_NONE; /* no longer exists */
915 break;
916 case IDH_PTYPE_HUB:
917 break;
918 case IDH_PTYPE_PERIPH:
919 break;
920 case IDH_PTYPE_PCABLE:
921 break;
922 case IDH_PTYPE_ACABLE:
923 break;
924 case IDH_PTYPE_AMA:
925 port->partner.type = TYPEC_PARTNER_ALTMODE;
926 break;
927 default:
928 break;
929 }
930#endif
931
932 port->partner_ident.id_header = vdo; 910 port->partner_ident.id_header = vdo;
933 port->partner_ident.cert_stat = le32_to_cpu(payload[VDO_INDEX_CSTAT]); 911 port->partner_ident.cert_stat = le32_to_cpu(payload[VDO_INDEX_CSTAT]);
934 port->partner_ident.product = product; 912 port->partner_ident.product = product;
@@ -1103,11 +1081,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
1103 response[0] = VDO(svid, 1, CMD_DISCOVER_MODES); 1081 response[0] = VDO(svid, 1, CMD_DISCOVER_MODES);
1104 rlen = 1; 1082 rlen = 1;
1105 } else { 1083 } else {
1106#if 0 1084 /* enter alternate mode if/when implemented */
1107 response[0] = pd_dfp_enter_mode(port, 0, 0);
1108 if (response[0])
1109 rlen = 1;
1110#endif
1111 } 1085 }
1112 break; 1086 break;
1113 case CMD_ENTER_MODE: 1087 case CMD_ENTER_MODE:
@@ -1145,10 +1119,6 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
1145 1119
1146 if (PD_VDO_SVDM(p0)) 1120 if (PD_VDO_SVDM(p0))
1147 rlen = tcpm_pd_svdm(port, payload, cnt, response); 1121 rlen = tcpm_pd_svdm(port, payload, cnt, response);
1148#if 0
1149 else
1150 rlen = tcpm_pd_custom_vdm(port, cnt, payload, response);
1151#endif
1152 1122
1153 if (rlen > 0) { 1123 if (rlen > 0) {
1154 tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); 1124 tcpm_queue_vdm(port, response[0], &response[1], rlen - 1);
@@ -2442,7 +2412,6 @@ static void run_state_machine(struct tcpm_port *port)
2442 tcpm_set_state(port, SNK_STARTUP, 0); 2412 tcpm_set_state(port, SNK_STARTUP, 0);
2443 break; 2413 break;
2444 case SNK_STARTUP: 2414 case SNK_STARTUP:
2445 /* XXX: callback into infrastructure */
2446 opmode = tcpm_get_pwr_opmode(port->polarity ? 2415 opmode = tcpm_get_pwr_opmode(port->polarity ?
2447 port->cc2 : port->cc1); 2416 port->cc2 : port->cc1);
2448 typec_set_pwr_opmode(port->typec_port, opmode); 2417 typec_set_pwr_opmode(port->typec_port, opmode);
@@ -3589,11 +3558,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
3589 3558
3590 port->partner_desc.identity = &port->partner_ident; 3559 port->partner_desc.identity = &port->partner_ident;
3591 port->port_type = tcpc->config->type; 3560 port->port_type = tcpc->config->type;
3592 /*
3593 * TODO:
3594 * - alt_modes, set_alt_mode
3595 * - {debug,audio}_accessory
3596 */
3597 3561
3598 port->typec_port = typec_register_port(port->dev, &port->typec_caps); 3562 port->typec_port = typec_register_port(port->dev, &port->typec_caps);
3599 if (!port->typec_port) { 3563 if (!port->typec_port) {
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 35a128acfbd1..161694b66038 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1135,7 +1135,7 @@ static int btrfs_fill_super(struct super_block *sb,
1135#ifdef CONFIG_BTRFS_FS_POSIX_ACL 1135#ifdef CONFIG_BTRFS_FS_POSIX_ACL
1136 sb->s_flags |= MS_POSIXACL; 1136 sb->s_flags |= MS_POSIXACL;
1137#endif 1137#endif
1138 sb->s_flags |= MS_I_VERSION; 1138 sb->s_flags |= SB_I_VERSION;
1139 sb->s_iflags |= SB_I_CGROUPWB; 1139 sb->s_iflags |= SB_I_CGROUPWB;
1140 1140
1141 err = super_setup_bdi(sb); 1141 err = super_setup_bdi(sb);
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 018c588c7ac3..8e704d12a1cf 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -109,6 +109,11 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
109 goto out; 109 goto out;
110 } 110 }
111 ukp = user_key_payload_locked(keyring_key); 111 ukp = user_key_payload_locked(keyring_key);
112 if (!ukp) {
113 /* key was revoked before we acquired its semaphore */
114 res = -EKEYREVOKED;
115 goto out;
116 }
112 if (ukp->datalen != sizeof(struct fscrypt_key)) { 117 if (ukp->datalen != sizeof(struct fscrypt_key)) {
113 res = -EINVAL; 118 res = -EINVAL;
114 goto out; 119 goto out;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 96415c65bbdc..b53e66d9abd7 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -45,6 +45,12 @@
45#define DIO_PAGES 64 45#define DIO_PAGES 64
46 46
47/* 47/*
48 * Flags for dio_complete()
49 */
50#define DIO_COMPLETE_ASYNC 0x01 /* This is async IO */
51#define DIO_COMPLETE_INVALIDATE 0x02 /* Can invalidate pages */
52
53/*
48 * This code generally works in units of "dio_blocks". A dio_block is 54 * This code generally works in units of "dio_blocks". A dio_block is
49 * somewhere between the hard sector size and the filesystem block size. it 55 * somewhere between the hard sector size and the filesystem block size. it
50 * is determined on a per-invocation basis. When talking to the filesystem 56 * is determined on a per-invocation basis. When talking to the filesystem
@@ -225,7 +231,7 @@ static inline struct page *dio_get_page(struct dio *dio,
225 * filesystems can use it to hold additional state between get_block calls and 231 * filesystems can use it to hold additional state between get_block calls and
226 * dio_complete. 232 * dio_complete.
227 */ 233 */
228static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async) 234static ssize_t dio_complete(struct dio *dio, ssize_t ret, unsigned int flags)
229{ 235{
230 loff_t offset = dio->iocb->ki_pos; 236 loff_t offset = dio->iocb->ki_pos;
231 ssize_t transferred = 0; 237 ssize_t transferred = 0;
@@ -259,14 +265,27 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
259 if (ret == 0) 265 if (ret == 0)
260 ret = transferred; 266 ret = transferred;
261 267
268 if (dio->end_io) {
269 // XXX: ki_pos??
270 err = dio->end_io(dio->iocb, offset, ret, dio->private);
271 if (err)
272 ret = err;
273 }
274
262 /* 275 /*
263 * Try again to invalidate clean pages which might have been cached by 276 * Try again to invalidate clean pages which might have been cached by
264 * non-direct readahead, or faulted in by get_user_pages() if the source 277 * non-direct readahead, or faulted in by get_user_pages() if the source
265 * of the write was an mmap'ed region of the file we're writing. Either 278 * of the write was an mmap'ed region of the file we're writing. Either
266 * one is a pretty crazy thing to do, so we don't support it 100%. If 279 * one is a pretty crazy thing to do, so we don't support it 100%. If
267 * this invalidation fails, tough, the write still worked... 280 * this invalidation fails, tough, the write still worked...
281 *
282 * And this page cache invalidation has to be after dio->end_io(), as
283 * some filesystems convert unwritten extents to real allocations in
284 * end_io() when necessary, otherwise a racing buffer read would cache
285 * zeros from unwritten extents.
268 */ 286 */
269 if (ret > 0 && dio->op == REQ_OP_WRITE && 287 if (flags & DIO_COMPLETE_INVALIDATE &&
288 ret > 0 && dio->op == REQ_OP_WRITE &&
270 dio->inode->i_mapping->nrpages) { 289 dio->inode->i_mapping->nrpages) {
271 err = invalidate_inode_pages2_range(dio->inode->i_mapping, 290 err = invalidate_inode_pages2_range(dio->inode->i_mapping,
272 offset >> PAGE_SHIFT, 291 offset >> PAGE_SHIFT,
@@ -274,18 +293,10 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
274 WARN_ON_ONCE(err); 293 WARN_ON_ONCE(err);
275 } 294 }
276 295
277 if (dio->end_io) {
278
279 // XXX: ki_pos??
280 err = dio->end_io(dio->iocb, offset, ret, dio->private);
281 if (err)
282 ret = err;
283 }
284
285 if (!(dio->flags & DIO_SKIP_DIO_COUNT)) 296 if (!(dio->flags & DIO_SKIP_DIO_COUNT))
286 inode_dio_end(dio->inode); 297 inode_dio_end(dio->inode);
287 298
288 if (is_async) { 299 if (flags & DIO_COMPLETE_ASYNC) {
289 /* 300 /*
290 * generic_write_sync expects ki_pos to have been updated 301 * generic_write_sync expects ki_pos to have been updated
291 * already, but the submission path only does this for 302 * already, but the submission path only does this for
@@ -306,7 +317,7 @@ static void dio_aio_complete_work(struct work_struct *work)
306{ 317{
307 struct dio *dio = container_of(work, struct dio, complete_work); 318 struct dio *dio = container_of(work, struct dio, complete_work);
308 319
309 dio_complete(dio, 0, true); 320 dio_complete(dio, 0, DIO_COMPLETE_ASYNC | DIO_COMPLETE_INVALIDATE);
310} 321}
311 322
312static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio); 323static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio);
@@ -348,7 +359,7 @@ static void dio_bio_end_aio(struct bio *bio)
348 queue_work(dio->inode->i_sb->s_dio_done_wq, 359 queue_work(dio->inode->i_sb->s_dio_done_wq,
349 &dio->complete_work); 360 &dio->complete_work);
350 } else { 361 } else {
351 dio_complete(dio, 0, true); 362 dio_complete(dio, 0, DIO_COMPLETE_ASYNC);
352 } 363 }
353 } 364 }
354} 365}
@@ -1360,7 +1371,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
1360 dio_await_completion(dio); 1371 dio_await_completion(dio);
1361 1372
1362 if (drop_refcount(dio) == 0) { 1373 if (drop_refcount(dio) == 0) {
1363 retval = dio_complete(dio, retval, false); 1374 retval = dio_complete(dio, retval, DIO_COMPLETE_INVALIDATE);
1364 } else 1375 } else
1365 BUG_ON(retval != -EIOCBQUEUED); 1376 BUG_ON(retval != -EIOCBQUEUED);
1366 1377
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 9c351bf757b2..3fbc0ff79699 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -84,11 +84,16 @@ struct ecryptfs_page_crypt_context {
84static inline struct ecryptfs_auth_tok * 84static inline struct ecryptfs_auth_tok *
85ecryptfs_get_encrypted_key_payload_data(struct key *key) 85ecryptfs_get_encrypted_key_payload_data(struct key *key)
86{ 86{
87 if (key->type == &key_type_encrypted) 87 struct encrypted_key_payload *payload;
88 return (struct ecryptfs_auth_tok *) 88
89 (&((struct encrypted_key_payload *)key->payload.data[0])->payload_data); 89 if (key->type != &key_type_encrypted)
90 else
91 return NULL; 90 return NULL;
91
92 payload = key->payload.data[0];
93 if (!payload)
94 return ERR_PTR(-EKEYREVOKED);
95
96 return (struct ecryptfs_auth_tok *)payload->payload_data;
92} 97}
93 98
94static inline struct key *ecryptfs_get_encrypted_key(char *sig) 99static inline struct key *ecryptfs_get_encrypted_key(char *sig)
@@ -114,12 +119,17 @@ static inline struct ecryptfs_auth_tok *
114ecryptfs_get_key_payload_data(struct key *key) 119ecryptfs_get_key_payload_data(struct key *key)
115{ 120{
116 struct ecryptfs_auth_tok *auth_tok; 121 struct ecryptfs_auth_tok *auth_tok;
122 struct user_key_payload *ukp;
117 123
118 auth_tok = ecryptfs_get_encrypted_key_payload_data(key); 124 auth_tok = ecryptfs_get_encrypted_key_payload_data(key);
119 if (!auth_tok) 125 if (auth_tok)
120 return (struct ecryptfs_auth_tok *)user_key_payload_locked(key)->data;
121 else
122 return auth_tok; 126 return auth_tok;
127
128 ukp = user_key_payload_locked(key);
129 if (!ukp)
130 return ERR_PTR(-EKEYREVOKED);
131
132 return (struct ecryptfs_auth_tok *)ukp->data;
123} 133}
124 134
125#define ECRYPTFS_MAX_KEYSET_SIZE 1024 135#define ECRYPTFS_MAX_KEYSET_SIZE 1024
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 3cf1546dca82..fa218cd64f74 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -459,7 +459,8 @@ out:
459 * @auth_tok_key: key containing the authentication token 459 * @auth_tok_key: key containing the authentication token
460 * @auth_tok: authentication token 460 * @auth_tok: authentication token
461 * 461 *
462 * Returns zero on valid auth tok; -EINVAL otherwise 462 * Returns zero on valid auth tok; -EINVAL if the payload is invalid; or
463 * -EKEYREVOKED if the key was revoked before we acquired its semaphore.
463 */ 464 */
464static int 465static int
465ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key, 466ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
@@ -468,6 +469,12 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
468 int rc = 0; 469 int rc = 0;
469 470
470 (*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key); 471 (*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key);
472 if (IS_ERR(*auth_tok)) {
473 rc = PTR_ERR(*auth_tok);
474 *auth_tok = NULL;
475 goto out;
476 }
477
471 if (ecryptfs_verify_version((*auth_tok)->version)) { 478 if (ecryptfs_verify_version((*auth_tok)->version)) {
472 printk(KERN_ERR "Data structure version mismatch. Userspace " 479 printk(KERN_ERR "Data structure version mismatch. Userspace "
473 "tools must match eCryptfs kernel module with major " 480 "tools must match eCryptfs kernel module with major "
diff --git a/fs/exec.c b/fs/exec.c
index 5470d3c1892a..3e14ba25f678 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1802,6 +1802,7 @@ static int do_execveat_common(int fd, struct filename *filename,
1802 /* execve succeeded */ 1802 /* execve succeeded */
1803 current->fs->in_exec = 0; 1803 current->fs->in_exec = 0;
1804 current->in_execve = 0; 1804 current->in_execve = 0;
1805 membarrier_execve(current);
1805 acct_update_integrals(current); 1806 acct_update_integrals(current);
1806 task_numa_free(current); 1807 task_numa_free(current);
1807 free_bprm(bprm); 1808 free_bprm(bprm);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b104096fce9e..b0915b734a38 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1677,7 +1677,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1677 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; 1677 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED;
1678 return 1; 1678 return 1;
1679 case Opt_i_version: 1679 case Opt_i_version:
1680 sb->s_flags |= MS_I_VERSION; 1680 sb->s_flags |= SB_I_VERSION;
1681 return 1; 1681 return 1;
1682 case Opt_lazytime: 1682 case Opt_lazytime:
1683 sb->s_flags |= MS_LAZYTIME; 1683 sb->s_flags |= MS_LAZYTIME;
@@ -2060,7 +2060,7 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
2060 SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time); 2060 SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time);
2061 if (nodefs || sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME) 2061 if (nodefs || sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME)
2062 SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time); 2062 SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time);
2063 if (sb->s_flags & MS_I_VERSION) 2063 if (sb->s_flags & SB_I_VERSION)
2064 SEQ_OPTS_PUTS("i_version"); 2064 SEQ_OPTS_PUTS("i_version");
2065 if (nodefs || sbi->s_stripe) 2065 if (nodefs || sbi->s_stripe)
2066 SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe); 2066 SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe);
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index b5ab06fabc60..0438d4cd91ef 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -331,6 +331,13 @@ static void fscache_objlist_config(struct fscache_objlist_data *data)
331 rcu_read_lock(); 331 rcu_read_lock();
332 332
333 confkey = user_key_payload_rcu(key); 333 confkey = user_key_payload_rcu(key);
334 if (!confkey) {
335 /* key was revoked */
336 rcu_read_unlock();
337 key_put(key);
338 goto no_config;
339 }
340
334 buf = confkey->data; 341 buf = confkey->data;
335 342
336 for (len = confkey->datalen - 1; len >= 0; len--) { 343 for (len = confkey->datalen - 1; len >= 0; len--) {
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 65c88379a3a1..94a745acaef8 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1059,7 +1059,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
1059 if (sb->s_flags & MS_MANDLOCK) 1059 if (sb->s_flags & MS_MANDLOCK)
1060 goto err; 1060 goto err;
1061 1061
1062 sb->s_flags &= ~(MS_NOSEC | MS_I_VERSION); 1062 sb->s_flags &= ~(MS_NOSEC | SB_I_VERSION);
1063 1063
1064 if (!parse_fuse_opt(data, &d, is_bdev)) 1064 if (!parse_fuse_opt(data, &d, is_bdev))
1065 goto err; 1065 goto err;
diff --git a/fs/iomap.c b/fs/iomap.c
index be61cf742b5e..d4801f8dd4fd 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -714,23 +714,9 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
714{ 714{
715 struct kiocb *iocb = dio->iocb; 715 struct kiocb *iocb = dio->iocb;
716 struct inode *inode = file_inode(iocb->ki_filp); 716 struct inode *inode = file_inode(iocb->ki_filp);
717 loff_t offset = iocb->ki_pos;
717 ssize_t ret; 718 ssize_t ret;
718 719
719 /*
720 * Try again to invalidate clean pages which might have been cached by
721 * non-direct readahead, or faulted in by get_user_pages() if the source
722 * of the write was an mmap'ed region of the file we're writing. Either
723 * one is a pretty crazy thing to do, so we don't support it 100%. If
724 * this invalidation fails, tough, the write still worked...
725 */
726 if (!dio->error &&
727 (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
728 ret = invalidate_inode_pages2_range(inode->i_mapping,
729 iocb->ki_pos >> PAGE_SHIFT,
730 (iocb->ki_pos + dio->size - 1) >> PAGE_SHIFT);
731 WARN_ON_ONCE(ret);
732 }
733
734 if (dio->end_io) { 720 if (dio->end_io) {
735 ret = dio->end_io(iocb, 721 ret = dio->end_io(iocb,
736 dio->error ? dio->error : dio->size, 722 dio->error ? dio->error : dio->size,
@@ -742,12 +728,33 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
742 if (likely(!ret)) { 728 if (likely(!ret)) {
743 ret = dio->size; 729 ret = dio->size;
744 /* check for short read */ 730 /* check for short read */
745 if (iocb->ki_pos + ret > dio->i_size && 731 if (offset + ret > dio->i_size &&
746 !(dio->flags & IOMAP_DIO_WRITE)) 732 !(dio->flags & IOMAP_DIO_WRITE))
747 ret = dio->i_size - iocb->ki_pos; 733 ret = dio->i_size - offset;
748 iocb->ki_pos += ret; 734 iocb->ki_pos += ret;
749 } 735 }
750 736
737 /*
738 * Try again to invalidate clean pages which might have been cached by
739 * non-direct readahead, or faulted in by get_user_pages() if the source
740 * of the write was an mmap'ed region of the file we're writing. Either
741 * one is a pretty crazy thing to do, so we don't support it 100%. If
742 * this invalidation fails, tough, the write still worked...
743 *
744 * And this page cache invalidation has to be after dio->end_io(), as
745 * some filesystems convert unwritten extents to real allocations in
746 * end_io() when necessary, otherwise a racing buffer read would cache
747 * zeros from unwritten extents.
748 */
749 if (!dio->error &&
750 (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
751 int err;
752 err = invalidate_inode_pages2_range(inode->i_mapping,
753 offset >> PAGE_SHIFT,
754 (offset + dio->size - 1) >> PAGE_SHIFT);
755 WARN_ON_ONCE(err);
756 }
757
751 inode_dio_end(file_inode(iocb->ki_filp)); 758 inode_dio_end(file_inode(iocb->ki_filp));
752 kfree(dio); 759 kfree(dio);
753 760
diff --git a/fs/namespace.c b/fs/namespace.c
index 3b601f115b6c..d18deb4c410b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2825,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2825 SB_MANDLOCK | 2825 SB_MANDLOCK |
2826 SB_DIRSYNC | 2826 SB_DIRSYNC |
2827 SB_SILENT | 2827 SB_SILENT |
2828 SB_POSIXACL); 2828 SB_POSIXACL |
2829 SB_I_VERSION);
2829 2830
2830 if (flags & MS_REMOUNT) 2831 if (flags & MS_REMOUNT)
2831 retval = do_remount(&path, flags, sb_flags, mnt_flags, 2832 retval = do_remount(&path, flags, sb_flags, mnt_flags,
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index def32fa1c225..89263797cf32 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3852,6 +3852,17 @@ xfs_trim_extent(
3852 } 3852 }
3853} 3853}
3854 3854
3855/* trim extent to within eof */
3856void
3857xfs_trim_extent_eof(
3858 struct xfs_bmbt_irec *irec,
3859 struct xfs_inode *ip)
3860
3861{
3862 xfs_trim_extent(irec, 0, XFS_B_TO_FSB(ip->i_mount,
3863 i_size_read(VFS_I(ip))));
3864}
3865
3855/* 3866/*
3856 * Trim the returned map to the required bounds 3867 * Trim the returned map to the required bounds
3857 */ 3868 */
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 851982a5dfbc..502e0d8fb4ff 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -208,6 +208,7 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt,
208 208
209void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, 209void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
210 xfs_filblks_t len); 210 xfs_filblks_t len);
211void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *);
211int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); 212int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
212void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); 213void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
213void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 214void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index f18e5932aec4..a3eeaba156c5 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -446,6 +446,19 @@ xfs_imap_valid(
446{ 446{
447 offset >>= inode->i_blkbits; 447 offset >>= inode->i_blkbits;
448 448
449 /*
450 * We have to make sure the cached mapping is within EOF to protect
451 * against eofblocks trimming on file release leaving us with a stale
452 * mapping. Otherwise, a page for a subsequent file extending buffered
453 * write could get picked up by this writeback cycle and written to the
454 * wrong blocks.
455 *
456 * Note that what we really want here is a generic mapping invalidation
457 * mechanism to protect us from arbitrary extent modifying contexts, not
458 * just eofblocks.
459 */
460 xfs_trim_extent_eof(imap, XFS_I(inode));
461
449 return offset >= imap->br_startoff && 462 return offset >= imap->br_startoff &&
450 offset < imap->br_startoff + imap->br_blockcount; 463 offset < imap->br_startoff + imap->br_blockcount;
451} 464}
@@ -735,6 +748,14 @@ xfs_vm_invalidatepage(
735{ 748{
736 trace_xfs_invalidatepage(page->mapping->host, page, offset, 749 trace_xfs_invalidatepage(page->mapping->host, page, offset,
737 length); 750 length);
751
752 /*
753 * If we are invalidating the entire page, clear the dirty state from it
754 * so that we can check for attempts to release dirty cached pages in
755 * xfs_vm_releasepage().
756 */
757 if (offset == 0 && length >= PAGE_SIZE)
758 cancel_dirty_page(page);
738 block_invalidatepage(page, offset, length); 759 block_invalidatepage(page, offset, length);
739} 760}
740 761
@@ -1190,25 +1211,27 @@ xfs_vm_releasepage(
1190 * mm accommodates an old ext3 case where clean pages might not have had 1211 * mm accommodates an old ext3 case where clean pages might not have had
1191 * the dirty bit cleared. Thus, it can send actual dirty pages to 1212 * the dirty bit cleared. Thus, it can send actual dirty pages to
1192 * ->releasepage() via shrink_active_list(). Conversely, 1213 * ->releasepage() via shrink_active_list(). Conversely,
1193 * block_invalidatepage() can send pages that are still marked dirty 1214 * block_invalidatepage() can send pages that are still marked dirty but
1194 * but otherwise have invalidated buffers. 1215 * otherwise have invalidated buffers.
1195 * 1216 *
1196 * We want to release the latter to avoid unnecessary buildup of the 1217 * We want to release the latter to avoid unnecessary buildup of the
1197 * LRU, skip the former and warn if we've left any lingering 1218 * LRU, so xfs_vm_invalidatepage() clears the page dirty flag on pages
1198 * delalloc/unwritten buffers on clean pages. Skip pages with delalloc 1219 * that are entirely invalidated and need to be released. Hence the
1199 * or unwritten buffers and warn if the page is not dirty. Otherwise 1220 * only time we should get dirty pages here is through
1200 * try to release the buffers. 1221 * shrink_active_list() and so we can simply skip those now.
1222 *
1223 * warn if we've left any lingering delalloc/unwritten buffers on clean
1224 * or invalidated pages we are about to release.
1201 */ 1225 */
1226 if (PageDirty(page))
1227 return 0;
1228
1202 xfs_count_page_state(page, &delalloc, &unwritten); 1229 xfs_count_page_state(page, &delalloc, &unwritten);
1203 1230
1204 if (delalloc) { 1231 if (WARN_ON_ONCE(delalloc))
1205 WARN_ON_ONCE(!PageDirty(page));
1206 return 0; 1232 return 0;
1207 } 1233 if (WARN_ON_ONCE(unwritten))
1208 if (unwritten) {
1209 WARN_ON_ONCE(!PageDirty(page));
1210 return 0; 1234 return 0;
1211 }
1212 1235
1213 return try_to_free_buffers(page); 1236 return try_to_free_buffers(page);
1214} 1237}
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 560e0b40ac1b..43cfc07996a4 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -367,29 +367,6 @@ xfs_getfsmap_datadev_helper(
367 return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr); 367 return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr);
368} 368}
369 369
370/* Transform a rtbitmap "record" into a fsmap */
371STATIC int
372xfs_getfsmap_rtdev_rtbitmap_helper(
373 struct xfs_trans *tp,
374 struct xfs_rtalloc_rec *rec,
375 void *priv)
376{
377 struct xfs_mount *mp = tp->t_mountp;
378 struct xfs_getfsmap_info *info = priv;
379 struct xfs_rmap_irec irec;
380 xfs_daddr_t rec_daddr;
381
382 rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock);
383
384 irec.rm_startblock = rec->ar_startblock;
385 irec.rm_blockcount = rec->ar_blockcount;
386 irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */
387 irec.rm_offset = 0;
388 irec.rm_flags = 0;
389
390 return xfs_getfsmap_helper(tp, info, &irec, rec_daddr);
391}
392
393/* Transform a bnobt irec into a fsmap */ 370/* Transform a bnobt irec into a fsmap */
394STATIC int 371STATIC int
395xfs_getfsmap_datadev_bnobt_helper( 372xfs_getfsmap_datadev_bnobt_helper(
@@ -475,6 +452,30 @@ xfs_getfsmap_logdev(
475 return xfs_getfsmap_helper(tp, info, &rmap, 0); 452 return xfs_getfsmap_helper(tp, info, &rmap, 0);
476} 453}
477 454
455#ifdef CONFIG_XFS_RT
456/* Transform a rtbitmap "record" into a fsmap */
457STATIC int
458xfs_getfsmap_rtdev_rtbitmap_helper(
459 struct xfs_trans *tp,
460 struct xfs_rtalloc_rec *rec,
461 void *priv)
462{
463 struct xfs_mount *mp = tp->t_mountp;
464 struct xfs_getfsmap_info *info = priv;
465 struct xfs_rmap_irec irec;
466 xfs_daddr_t rec_daddr;
467
468 rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock);
469
470 irec.rm_startblock = rec->ar_startblock;
471 irec.rm_blockcount = rec->ar_blockcount;
472 irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */
473 irec.rm_offset = 0;
474 irec.rm_flags = 0;
475
476 return xfs_getfsmap_helper(tp, info, &irec, rec_daddr);
477}
478
478/* Execute a getfsmap query against the realtime device. */ 479/* Execute a getfsmap query against the realtime device. */
479STATIC int 480STATIC int
480__xfs_getfsmap_rtdev( 481__xfs_getfsmap_rtdev(
@@ -521,7 +522,6 @@ __xfs_getfsmap_rtdev(
521 return query_fn(tp, info); 522 return query_fn(tp, info);
522} 523}
523 524
524#ifdef CONFIG_XFS_RT
525/* Actually query the realtime bitmap. */ 525/* Actually query the realtime bitmap. */
526STATIC int 526STATIC int
527xfs_getfsmap_rtdev_rtbitmap_query( 527xfs_getfsmap_rtdev_rtbitmap_query(
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 584cf2d573ba..f663022353c0 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1637,7 +1637,7 @@ xfs_fs_fill_super(
1637 1637
1638 /* version 5 superblocks support inode version counters. */ 1638 /* version 5 superblocks support inode version counters. */
1639 if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) 1639 if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
1640 sb->s_flags |= MS_I_VERSION; 1640 sb->s_flags |= SB_I_VERSION;
1641 1641
1642 if (mp->m_flags & XFS_MOUNT_DAX) { 1642 if (mp->m_flags & XFS_MOUNT_DAX) {
1643 xfs_warn(mp, 1643 xfs_warn(mp,
diff --git a/include/linux/filter.h b/include/linux/filter.h
index d29e58fde364..818a0b26249e 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -728,7 +728,7 @@ void xdp_do_flush_map(void);
728void bpf_warn_invalid_xdp_action(u32 act); 728void bpf_warn_invalid_xdp_action(u32 act);
729void bpf_warn_invalid_xdp_redirect(u32 ifindex); 729void bpf_warn_invalid_xdp_redirect(u32 ifindex);
730 730
731struct sock *do_sk_redirect_map(void); 731struct sock *do_sk_redirect_map(struct sk_buff *skb);
732 732
733#ifdef CONFIG_BPF_JIT 733#ifdef CONFIG_BPF_JIT
734extern int bpf_jit_enable; 734extern int bpf_jit_enable;
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index fc7aae64dcde..331dc377c275 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -231,6 +231,7 @@ struct hid_sensor_common {
231 unsigned usage_id; 231 unsigned usage_id;
232 atomic_t data_ready; 232 atomic_t data_ready;
233 atomic_t user_requested_state; 233 atomic_t user_requested_state;
234 atomic_t runtime_pm_enable;
234 int poll_interval; 235 int poll_interval;
235 int raw_hystersis; 236 int raw_hystersis;
236 int latency_ms; 237 int latency_ms;
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 7b0fa8b5c120..f9bd6e8ab138 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -131,28 +131,39 @@ struct st_sensor_das {
131}; 131};
132 132
133/** 133/**
134 * struct st_sensor_int_drdy - ST sensor device drdy line parameters
135 * @addr: address of INT drdy register.
136 * @mask: mask to enable drdy line.
137 * @addr_od: address to enable/disable Open Drain on the INT line.
138 * @mask_od: mask to enable/disable Open Drain on the INT line.
139 */
140struct st_sensor_int_drdy {
141 u8 addr;
142 u8 mask;
143 u8 addr_od;
144 u8 mask_od;
145};
146
147/**
134 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt 148 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
135 * @addr: address of the register. 149 * struct int1 - data-ready configuration register for INT1 pin.
136 * @mask_int1: mask to enable/disable IRQ on INT1 pin. 150 * struct int2 - data-ready configuration register for INT2 pin.
137 * @mask_int2: mask to enable/disable IRQ on INT2 pin.
138 * @addr_ihl: address to enable/disable active low on the INT lines. 151 * @addr_ihl: address to enable/disable active low on the INT lines.
139 * @mask_ihl: mask to enable/disable active low on the INT lines. 152 * @mask_ihl: mask to enable/disable active low on the INT lines.
140 * @addr_od: address to enable/disable Open Drain on the INT lines. 153 * struct stat_drdy - status register of DRDY (data ready) interrupt.
141 * @mask_od: mask to enable/disable Open Drain on the INT lines.
142 * @addr_stat_drdy: address to read status of DRDY (data ready) interrupt
143 * struct ig1 - represents the Interrupt Generator 1 of sensors. 154 * struct ig1 - represents the Interrupt Generator 1 of sensors.
144 * @en_addr: address of the enable ig1 register. 155 * @en_addr: address of the enable ig1 register.
145 * @en_mask: mask to write the on/off value for enable. 156 * @en_mask: mask to write the on/off value for enable.
146 */ 157 */
147struct st_sensor_data_ready_irq { 158struct st_sensor_data_ready_irq {
148 u8 addr; 159 struct st_sensor_int_drdy int1;
149 u8 mask_int1; 160 struct st_sensor_int_drdy int2;
150 u8 mask_int2;
151 u8 addr_ihl; 161 u8 addr_ihl;
152 u8 mask_ihl; 162 u8 mask_ihl;
153 u8 addr_od; 163 struct {
154 u8 mask_od; 164 u8 addr;
155 u8 addr_stat_drdy; 165 u8 mask;
166 } stat_drdy;
156 struct { 167 struct {
157 u8 en_addr; 168 u8 en_addr;
158 u8 en_mask; 169 u8 en_mask;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index c380daa40c0e..20b61347ea58 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -365,12 +365,9 @@ unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
365#define INDIO_MAX_RAW_ELEMENTS 4 365#define INDIO_MAX_RAW_ELEMENTS 4
366 366
367struct iio_trigger; /* forward declaration */ 367struct iio_trigger; /* forward declaration */
368struct iio_dev;
369 368
370/** 369/**
371 * struct iio_info - constant information about device 370 * struct iio_info - constant information about device
372 * @driver_module: module structure used to ensure correct
373 * ownership of chrdevs etc
374 * @event_attrs: event control attributes 371 * @event_attrs: event control attributes
375 * @attrs: general purpose device attributes 372 * @attrs: general purpose device attributes
376 * @read_raw: function to request a value from the device. 373 * @read_raw: function to request a value from the device.
@@ -425,7 +422,6 @@ struct iio_dev;
425 * were flushed and there was an error. 422 * were flushed and there was an error.
426 **/ 423 **/
427struct iio_info { 424struct iio_info {
428 struct module *driver_module;
429 const struct attribute_group *event_attrs; 425 const struct attribute_group *event_attrs;
430 const struct attribute_group *attrs; 426 const struct attribute_group *attrs;
431 427
@@ -518,6 +514,7 @@ struct iio_buffer_setup_ops {
518/** 514/**
519 * struct iio_dev - industrial I/O device 515 * struct iio_dev - industrial I/O device
520 * @id: [INTERN] used to identify device internally 516 * @id: [INTERN] used to identify device internally
517 * @driver_module: [INTERN] used to make it harder to undercut users
521 * @modes: [DRIVER] operating modes supported by device 518 * @modes: [DRIVER] operating modes supported by device
522 * @currentmode: [DRIVER] current operating mode 519 * @currentmode: [DRIVER] current operating mode
523 * @dev: [DRIVER] device structure, should be assigned a parent 520 * @dev: [DRIVER] device structure, should be assigned a parent
@@ -558,6 +555,7 @@ struct iio_buffer_setup_ops {
558 */ 555 */
559struct iio_dev { 556struct iio_dev {
560 int id; 557 int id;
558 struct module *driver_module;
561 559
562 int modes; 560 int modes;
563 int currentmode; 561 int currentmode;
@@ -604,9 +602,34 @@ struct iio_dev {
604 602
605const struct iio_chan_spec 603const struct iio_chan_spec
606*iio_find_channel_from_si(struct iio_dev *indio_dev, int si); 604*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
607int iio_device_register(struct iio_dev *indio_dev); 605/**
606 * iio_device_register() - register a device with the IIO subsystem
607 * @indio_dev: Device structure filled by the device driver
608 **/
609#define iio_device_register(iio_dev) \
610 __iio_device_register((iio_dev), THIS_MODULE)
611int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod);
608void iio_device_unregister(struct iio_dev *indio_dev); 612void iio_device_unregister(struct iio_dev *indio_dev);
609int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev); 613/**
614 * devm_iio_device_register - Resource-managed iio_device_register()
615 * @dev: Device to allocate iio_dev for
616 * @indio_dev: Device structure filled by the device driver
617 *
618 * Managed iio_device_register. The IIO device registered with this
619 * function is automatically unregistered on driver detach. This function
620 * calls iio_device_register() internally. Refer to that function for more
621 * information.
622 *
623 * If an iio_dev registered with this function needs to be unregistered
624 * separately, devm_iio_device_unregister() must be used.
625 *
626 * RETURNS:
627 * 0 on success, negative error number on failure.
628 */
629#define devm_iio_device_register(dev, indio_dev) \
630 __devm_iio_device_register((dev), (indio_dev), THIS_MODULE);
631int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev,
632 struct module *this_mod);
610void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev); 633void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev);
611int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); 634int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
612int iio_device_claim_direct_mode(struct iio_dev *indio_dev); 635int iio_device_claim_direct_mode(struct iio_dev *indio_dev);
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 7142d8d6e470..7d5e44518379 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -23,7 +23,6 @@ struct iio_trigger;
23 23
24/** 24/**
25 * struct iio_trigger_ops - operations structure for an iio_trigger. 25 * struct iio_trigger_ops - operations structure for an iio_trigger.
26 * @owner: used to monitor usage count of the trigger.
27 * @set_trigger_state: switch on/off the trigger on demand 26 * @set_trigger_state: switch on/off the trigger on demand
28 * @try_reenable: function to reenable the trigger when the 27 * @try_reenable: function to reenable the trigger when the
29 * use count is zero (may be NULL) 28 * use count is zero (may be NULL)
@@ -34,7 +33,6 @@ struct iio_trigger;
34 * instances of a given device. 33 * instances of a given device.
35 **/ 34 **/
36struct iio_trigger_ops { 35struct iio_trigger_ops {
37 struct module *owner;
38 int (*set_trigger_state)(struct iio_trigger *trig, bool state); 36 int (*set_trigger_state)(struct iio_trigger *trig, bool state);
39 int (*try_reenable)(struct iio_trigger *trig); 37 int (*try_reenable)(struct iio_trigger *trig);
40 int (*validate_device)(struct iio_trigger *trig, 38 int (*validate_device)(struct iio_trigger *trig,
@@ -62,6 +60,7 @@ struct iio_trigger_ops {
62 **/ 60 **/
63struct iio_trigger { 61struct iio_trigger {
64 const struct iio_trigger_ops *ops; 62 const struct iio_trigger_ops *ops;
63 struct module *owner;
65 int id; 64 int id;
66 const char *name; 65 const char *name;
67 struct device dev; 66 struct device dev;
@@ -87,14 +86,14 @@ static inline struct iio_trigger *to_iio_trigger(struct device *d)
87 86
88static inline void iio_trigger_put(struct iio_trigger *trig) 87static inline void iio_trigger_put(struct iio_trigger *trig)
89{ 88{
90 module_put(trig->ops->owner); 89 module_put(trig->owner);
91 put_device(&trig->dev); 90 put_device(&trig->dev);
92} 91}
93 92
94static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig) 93static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
95{ 94{
96 get_device(&trig->dev); 95 get_device(&trig->dev);
97 __module_get(trig->ops->owner); 96 __module_get(trig->owner);
98 97
99 return trig; 98 return trig;
100} 99}
@@ -127,10 +126,16 @@ static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig)
127 * iio_trigger_register() - register a trigger with the IIO core 126 * iio_trigger_register() - register a trigger with the IIO core
128 * @trig_info: trigger to be registered 127 * @trig_info: trigger to be registered
129 **/ 128 **/
130int iio_trigger_register(struct iio_trigger *trig_info); 129#define iio_trigger_register(trig_info) \
131 130 __iio_trigger_register((trig_info), THIS_MODULE)
132int devm_iio_trigger_register(struct device *dev, 131int __iio_trigger_register(struct iio_trigger *trig_info,
133 struct iio_trigger *trig_info); 132 struct module *this_mod);
133
134#define devm_iio_trigger_register(dev, trig_info) \
135 __devm_iio_trigger_register((dev), (trig_info), THIS_MODULE)
136int __devm_iio_trigger_register(struct device *dev,
137 struct iio_trigger *trig_info,
138 struct module *this_mod);
134 139
135/** 140/**
136 * iio_trigger_unregister() - unregister a trigger from the core 141 * iio_trigger_unregister() - unregister a trigger from the core
diff --git a/include/linux/input.h b/include/linux/input.h
index fb5e23c7ed98..7c7516eb7d76 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -234,6 +234,10 @@ struct input_dev {
234#error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match" 234#error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match"
235#endif 235#endif
236 236
237#if INPUT_PROP_MAX != INPUT_DEVICE_ID_PROP_MAX
238#error "INPUT_PROP_MAX and INPUT_DEVICE_ID_PROP_MAX do not match"
239#endif
240
237#define INPUT_DEVICE_ID_MATCH_DEVICE \ 241#define INPUT_DEVICE_ID_MATCH_DEVICE \
238 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) 242 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
239#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \ 243#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
@@ -469,6 +473,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
469int input_set_keycode(struct input_dev *dev, 473int input_set_keycode(struct input_dev *dev,
470 const struct input_keymap_entry *ke); 474 const struct input_keymap_entry *ke);
471 475
476bool input_match_device_id(const struct input_dev *dev,
477 const struct input_device_id *id);
478
472void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 479void input_enable_softrepeat(struct input_dev *dev, int delay, int period);
473 480
474extern struct class input_class; 481extern struct class input_class;
diff --git a/include/linux/irq.h b/include/linux/irq.h
index d4728bf6a537..5ad10948ea95 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1009,7 +1009,7 @@ void irq_gc_mask_clr_bit(struct irq_data *d);
1009void irq_gc_unmask_enable_reg(struct irq_data *d); 1009void irq_gc_unmask_enable_reg(struct irq_data *d);
1010void irq_gc_ack_set_bit(struct irq_data *d); 1010void irq_gc_ack_set_bit(struct irq_data *d);
1011void irq_gc_ack_clr_bit(struct irq_data *d); 1011void irq_gc_ack_clr_bit(struct irq_data *d);
1012void irq_gc_mask_disable_reg_and_ack(struct irq_data *d); 1012void irq_gc_mask_disable_and_ack_set(struct irq_data *d);
1013void irq_gc_eoi(struct irq_data *d); 1013void irq_gc_eoi(struct irq_data *d);
1014int irq_gc_set_wake(struct irq_data *d, unsigned int on); 1014int irq_gc_set_wake(struct irq_data *d, unsigned int on);
1015 1015
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index 1ea576c8126f..14b74f22d43c 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -372,6 +372,8 @@
372#define GITS_BASER_ENTRY_SIZE_SHIFT (48) 372#define GITS_BASER_ENTRY_SIZE_SHIFT (48)
373#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0x1f) + 1) 373#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0x1f) + 1)
374#define GITS_BASER_ENTRY_SIZE_MASK GENMASK_ULL(52, 48) 374#define GITS_BASER_ENTRY_SIZE_MASK GENMASK_ULL(52, 48)
375#define GITS_BASER_PHYS_52_to_48(phys) \
376 (((phys) & GENMASK_ULL(47, 16)) | (((phys) >> 48) & 0xf) << 12)
375#define GITS_BASER_SHAREABILITY_SHIFT (10) 377#define GITS_BASER_SHAREABILITY_SHIFT (10)
376#define GITS_BASER_InnerShareable \ 378#define GITS_BASER_InnerShareable \
377 GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable) 379 GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable)
diff --git a/include/linux/key.h b/include/linux/key.h
index e315e16b6ff8..8a15cabe928d 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -138,6 +138,11 @@ struct key_restriction {
138 struct key_type *keytype; 138 struct key_type *keytype;
139}; 139};
140 140
141enum key_state {
142 KEY_IS_UNINSTANTIATED,
143 KEY_IS_POSITIVE, /* Positively instantiated */
144};
145
141/*****************************************************************************/ 146/*****************************************************************************/
142/* 147/*
143 * authentication token / access credential / keyring 148 * authentication token / access credential / keyring
@@ -169,6 +174,7 @@ struct key {
169 * - may not match RCU dereferenced payload 174 * - may not match RCU dereferenced payload
170 * - payload should contain own length 175 * - payload should contain own length
171 */ 176 */
177 short state; /* Key state (+) or rejection error (-) */
172 178
173#ifdef KEY_DEBUGGING 179#ifdef KEY_DEBUGGING
174 unsigned magic; 180 unsigned magic;
@@ -176,18 +182,16 @@ struct key {
176#endif 182#endif
177 183
178 unsigned long flags; /* status flags (change with bitops) */ 184 unsigned long flags; /* status flags (change with bitops) */
179#define KEY_FLAG_INSTANTIATED 0 /* set if key has been instantiated */ 185#define KEY_FLAG_DEAD 0 /* set if key type has been deleted */
180#define KEY_FLAG_DEAD 1 /* set if key type has been deleted */ 186#define KEY_FLAG_REVOKED 1 /* set if key had been revoked */
181#define KEY_FLAG_REVOKED 2 /* set if key had been revoked */ 187#define KEY_FLAG_IN_QUOTA 2 /* set if key consumes quota */
182#define KEY_FLAG_IN_QUOTA 3 /* set if key consumes quota */ 188#define KEY_FLAG_USER_CONSTRUCT 3 /* set if key is being constructed in userspace */
183#define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */ 189#define KEY_FLAG_ROOT_CAN_CLEAR 4 /* set if key can be cleared by root without permission */
184#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */ 190#define KEY_FLAG_INVALIDATED 5 /* set if key has been invalidated */
185#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */ 191#define KEY_FLAG_BUILTIN 6 /* set if key is built in to the kernel */
186#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */ 192#define KEY_FLAG_ROOT_CAN_INVAL 7 /* set if key can be invalidated by root without permission */
187#define KEY_FLAG_BUILTIN 8 /* set if key is built in to the kernel */ 193#define KEY_FLAG_KEEP 8 /* set if key should not be removed */
188#define KEY_FLAG_ROOT_CAN_INVAL 9 /* set if key can be invalidated by root without permission */ 194#define KEY_FLAG_UID_KEYRING 9 /* set if key is a user or user session keyring */
189#define KEY_FLAG_KEEP 10 /* set if key should not be removed */
190#define KEY_FLAG_UID_KEYRING 11 /* set if key is a user or user session keyring */
191 195
192 /* the key type and key description string 196 /* the key type and key description string
193 * - the desc is used to match a key against search criteria 197 * - the desc is used to match a key against search criteria
@@ -213,7 +217,6 @@ struct key {
213 struct list_head name_link; 217 struct list_head name_link;
214 struct assoc_array keys; 218 struct assoc_array keys;
215 }; 219 };
216 int reject_error;
217 }; 220 };
218 221
219 /* This is set on a keyring to restrict the addition of a link to a key 222 /* This is set on a keyring to restrict the addition of a link to a key
@@ -353,17 +356,27 @@ extern void key_set_timeout(struct key *, unsigned);
353#define KEY_NEED_SETATTR 0x20 /* Require permission to change attributes */ 356#define KEY_NEED_SETATTR 0x20 /* Require permission to change attributes */
354#define KEY_NEED_ALL 0x3f /* All the above permissions */ 357#define KEY_NEED_ALL 0x3f /* All the above permissions */
355 358
359static inline short key_read_state(const struct key *key)
360{
361 /* Barrier versus mark_key_instantiated(). */
362 return smp_load_acquire(&key->state);
363}
364
356/** 365/**
357 * key_is_instantiated - Determine if a key has been positively instantiated 366 * key_is_positive - Determine if a key has been positively instantiated
358 * @key: The key to check. 367 * @key: The key to check.
359 * 368 *
360 * Return true if the specified key has been positively instantiated, false 369 * Return true if the specified key has been positively instantiated, false
361 * otherwise. 370 * otherwise.
362 */ 371 */
363static inline bool key_is_instantiated(const struct key *key) 372static inline bool key_is_positive(const struct key *key)
373{
374 return key_read_state(key) == KEY_IS_POSITIVE;
375}
376
377static inline bool key_is_negative(const struct key *key)
364{ 378{
365 return test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && 379 return key_read_state(key) < 0;
366 !test_bit(KEY_FLAG_NEGATIVE, &key->flags);
367} 380}
368 381
369#define dereference_key_rcu(KEY) \ 382#define dereference_key_rcu(KEY) \
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
index 0d3f14fd2621..4773145246ed 100644
--- a/include/linux/mbus.h
+++ b/include/linux/mbus.h
@@ -31,8 +31,8 @@ struct mbus_dram_target_info
31 struct mbus_dram_window { 31 struct mbus_dram_window {
32 u8 cs_index; 32 u8 cs_index;
33 u8 mbus_attr; 33 u8 mbus_attr;
34 u32 base; 34 u64 base;
35 u32 size; 35 u64 size;
36 } cs[4]; 36 } cs[4];
37}; 37};
38 38
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 46f4ecf5479a..1861ea8dba77 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -445,6 +445,9 @@ struct mm_struct {
445 unsigned long flags; /* Must use atomic bitops to access the bits */ 445 unsigned long flags; /* Must use atomic bitops to access the bits */
446 446
447 struct core_state *core_state; /* coredumping support */ 447 struct core_state *core_state; /* coredumping support */
448#ifdef CONFIG_MEMBARRIER
449 atomic_t membarrier_state;
450#endif
448#ifdef CONFIG_AIO 451#ifdef CONFIG_AIO
449 spinlock_t ioctx_lock; 452 spinlock_t ioctx_lock;
450 struct kioctx_table __rcu *ioctx_table; 453 struct kioctx_table __rcu *ioctx_table;
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 694cebb50f72..2657f9f51536 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -293,6 +293,7 @@ struct pcmcia_device_id {
293#define INPUT_DEVICE_ID_SND_MAX 0x07 293#define INPUT_DEVICE_ID_SND_MAX 0x07
294#define INPUT_DEVICE_ID_FF_MAX 0x7f 294#define INPUT_DEVICE_ID_FF_MAX 0x7f
295#define INPUT_DEVICE_ID_SW_MAX 0x0f 295#define INPUT_DEVICE_ID_SW_MAX 0x0f
296#define INPUT_DEVICE_ID_PROP_MAX 0x1f
296 297
297#define INPUT_DEVICE_ID_MATCH_BUS 1 298#define INPUT_DEVICE_ID_MATCH_BUS 1
298#define INPUT_DEVICE_ID_MATCH_VENDOR 2 299#define INPUT_DEVICE_ID_MATCH_VENDOR 2
@@ -308,6 +309,7 @@ struct pcmcia_device_id {
308#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x0400 309#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x0400
309#define INPUT_DEVICE_ID_MATCH_FFBIT 0x0800 310#define INPUT_DEVICE_ID_MATCH_FFBIT 0x0800
310#define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 311#define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000
312#define INPUT_DEVICE_ID_MATCH_PROPBIT 0x2000
311 313
312struct input_device_id { 314struct input_device_id {
313 315
@@ -327,6 +329,7 @@ struct input_device_id {
327 kernel_ulong_t sndbit[INPUT_DEVICE_ID_SND_MAX / BITS_PER_LONG + 1]; 329 kernel_ulong_t sndbit[INPUT_DEVICE_ID_SND_MAX / BITS_PER_LONG + 1];
328 kernel_ulong_t ffbit[INPUT_DEVICE_ID_FF_MAX / BITS_PER_LONG + 1]; 330 kernel_ulong_t ffbit[INPUT_DEVICE_ID_FF_MAX / BITS_PER_LONG + 1];
329 kernel_ulong_t swbit[INPUT_DEVICE_ID_SW_MAX / BITS_PER_LONG + 1]; 331 kernel_ulong_t swbit[INPUT_DEVICE_ID_SW_MAX / BITS_PER_LONG + 1];
332 kernel_ulong_t propbit[INPUT_DEVICE_ID_PROP_MAX / BITS_PER_LONG + 1];
330 333
331 kernel_ulong_t driver_info; 334 kernel_ulong_t driver_info;
332}; 335};
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f535779d9dc1..2eaac7d75af4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3694,6 +3694,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
3694 unsigned char name_assign_type, 3694 unsigned char name_assign_type,
3695 void (*setup)(struct net_device *), 3695 void (*setup)(struct net_device *),
3696 unsigned int txqs, unsigned int rxqs); 3696 unsigned int txqs, unsigned int rxqs);
3697int dev_get_valid_name(struct net *net, struct net_device *dev,
3698 const char *name);
3699
3697#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ 3700#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
3698 alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1) 3701 alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)
3699 3702
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index b1fd8bf85fdc..2bea1d5e9930 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -276,7 +276,7 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
276#define list_entry_rcu(ptr, type, member) \ 276#define list_entry_rcu(ptr, type, member) \
277 container_of(lockless_dereference(ptr), type, member) 277 container_of(lockless_dereference(ptr), type, member)
278 278
279/** 279/*
280 * Where are list_empty_rcu() and list_first_entry_rcu()? 280 * Where are list_empty_rcu() and list_first_entry_rcu()?
281 * 281 *
282 * Implementing those functions following their counterparts list_empty() and 282 * Implementing those functions following their counterparts list_empty() and
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index de50d8a4cf41..1a9f70d44af9 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -523,7 +523,7 @@ static inline void rcu_preempt_sleep_check(void) { }
523 * Return the value of the specified RCU-protected pointer, but omit 523 * Return the value of the specified RCU-protected pointer, but omit
524 * both the smp_read_barrier_depends() and the READ_ONCE(). This 524 * both the smp_read_barrier_depends() and the READ_ONCE(). This
525 * is useful in cases where update-side locks prevent the value of the 525 * is useful in cases where update-side locks prevent the value of the
526 * pointer from changing. Please note that this primitive does -not- 526 * pointer from changing. Please note that this primitive does *not*
527 * prevent the compiler from repeating this reference or combining it 527 * prevent the compiler from repeating this reference or combining it
528 * with other references, so it should not be used without protection 528 * with other references, so it should not be used without protection
529 * of appropriate locks. 529 * of appropriate locks.
@@ -568,7 +568,7 @@ static inline void rcu_preempt_sleep_check(void) { }
568 * is handed off from RCU to some other synchronization mechanism, for 568 * is handed off from RCU to some other synchronization mechanism, for
569 * example, reference counting or locking. In C11, it would map to 569 * example, reference counting or locking. In C11, it would map to
570 * kill_dependency(). It could be used as follows: 570 * kill_dependency(). It could be used as follows:
571 * 571 * ``
572 * rcu_read_lock(); 572 * rcu_read_lock();
573 * p = rcu_dereference(gp); 573 * p = rcu_dereference(gp);
574 * long_lived = is_long_lived(p); 574 * long_lived = is_long_lived(p);
@@ -579,6 +579,7 @@ static inline void rcu_preempt_sleep_check(void) { }
579 * p = rcu_pointer_handoff(p); 579 * p = rcu_pointer_handoff(p);
580 * } 580 * }
581 * rcu_read_unlock(); 581 * rcu_read_unlock();
582 *``
582 */ 583 */
583#define rcu_pointer_handoff(p) (p) 584#define rcu_pointer_handoff(p) (p)
584 585
@@ -778,18 +779,21 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
778 779
779/** 780/**
780 * RCU_INIT_POINTER() - initialize an RCU protected pointer 781 * RCU_INIT_POINTER() - initialize an RCU protected pointer
782 * @p: The pointer to be initialized.
783 * @v: The value to initialized the pointer to.
781 * 784 *
782 * Initialize an RCU-protected pointer in special cases where readers 785 * Initialize an RCU-protected pointer in special cases where readers
783 * do not need ordering constraints on the CPU or the compiler. These 786 * do not need ordering constraints on the CPU or the compiler. These
784 * special cases are: 787 * special cases are:
785 * 788 *
786 * 1. This use of RCU_INIT_POINTER() is NULLing out the pointer -or- 789 * 1. This use of RCU_INIT_POINTER() is NULLing out the pointer *or*
787 * 2. The caller has taken whatever steps are required to prevent 790 * 2. The caller has taken whatever steps are required to prevent
788 * RCU readers from concurrently accessing this pointer -or- 791 * RCU readers from concurrently accessing this pointer *or*
789 * 3. The referenced data structure has already been exposed to 792 * 3. The referenced data structure has already been exposed to
790 * readers either at compile time or via rcu_assign_pointer() -and- 793 * readers either at compile time or via rcu_assign_pointer() *and*
791 * a. You have not made -any- reader-visible changes to 794 *
792 * this structure since then -or- 795 * a. You have not made *any* reader-visible changes to
796 * this structure since then *or*
793 * b. It is OK for readers accessing this structure from its 797 * b. It is OK for readers accessing this structure from its
794 * new location to see the old state of the structure. (For 798 * new location to see the old state of the structure. (For
795 * example, the changes were to statistical counters or to 799 * example, the changes were to statistical counters or to
@@ -805,7 +809,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
805 * by a single external-to-structure RCU-protected pointer, then you may 809 * by a single external-to-structure RCU-protected pointer, then you may
806 * use RCU_INIT_POINTER() to initialize the internal RCU-protected 810 * use RCU_INIT_POINTER() to initialize the internal RCU-protected
807 * pointers, but you must use rcu_assign_pointer() to initialize the 811 * pointers, but you must use rcu_assign_pointer() to initialize the
808 * external-to-structure pointer -after- you have completely initialized 812 * external-to-structure pointer *after* you have completely initialized
809 * the reader-accessible portions of the linked structure. 813 * the reader-accessible portions of the linked structure.
810 * 814 *
811 * Note that unlike rcu_assign_pointer(), RCU_INIT_POINTER() provides no 815 * Note that unlike rcu_assign_pointer(), RCU_INIT_POINTER() provides no
@@ -819,6 +823,8 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
819 823
820/** 824/**
821 * RCU_POINTER_INITIALIZER() - statically initialize an RCU protected pointer 825 * RCU_POINTER_INITIALIZER() - statically initialize an RCU protected pointer
826 * @p: The pointer to be initialized.
827 * @v: The value to initialized the pointer to.
822 * 828 *
823 * GCC-style initialization for an RCU-protected pointer in a structure field. 829 * GCC-style initialization for an RCU-protected pointer in a structure field.
824 */ 830 */
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index ae53e413fb13..ab9bf7b73954 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -211,4 +211,20 @@ static inline void memalloc_noreclaim_restore(unsigned int flags)
211 current->flags = (current->flags & ~PF_MEMALLOC) | flags; 211 current->flags = (current->flags & ~PF_MEMALLOC) | flags;
212} 212}
213 213
214#ifdef CONFIG_MEMBARRIER
215enum {
216 MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY = (1U << 0),
217 MEMBARRIER_STATE_SWITCH_MM = (1U << 1),
218};
219
220static inline void membarrier_execve(struct task_struct *t)
221{
222 atomic_set(&t->mm->membarrier_state, 0);
223}
224#else
225static inline void membarrier_execve(struct task_struct *t)
226{
227}
228#endif
229
214#endif /* _LINUX_SCHED_MM_H */ 230#endif /* _LINUX_SCHED_MM_H */
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 39af9bc0f653..62be8966e837 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -78,6 +78,7 @@ void synchronize_srcu(struct srcu_struct *sp);
78 78
79/** 79/**
80 * srcu_read_lock_held - might we be in SRCU read-side critical section? 80 * srcu_read_lock_held - might we be in SRCU read-side critical section?
81 * @sp: The srcu_struct structure to check
81 * 82 *
82 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an SRCU 83 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an SRCU
83 * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC, 84 * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC,
diff --git a/drivers/staging/typec/pd.h b/include/linux/usb/pd.h
index 30b32ad72acd..e00051ced806 100644
--- a/drivers/staging/typec/pd.h
+++ b/include/linux/usb/pd.h
@@ -104,6 +104,11 @@ static inline unsigned int pd_header_msgid_le(__le16 header)
104 104
105#define PD_MAX_PAYLOAD 7 105#define PD_MAX_PAYLOAD 7
106 106
107/**
108 * struct pd_message - PD message as seen on wire
109 * @header: PD message header
110 * @payload: PD message payload
111 */
107struct pd_message { 112struct pd_message {
108 __le16 header; 113 __le16 header;
109 __le32 payload[PD_MAX_PAYLOAD]; 114 __le32 payload[PD_MAX_PAYLOAD];
diff --git a/drivers/staging/typec/pd_bdo.h b/include/linux/usb/pd_bdo.h
index 90b94d9fea5d..90b94d9fea5d 100644
--- a/drivers/staging/typec/pd_bdo.h
+++ b/include/linux/usb/pd_bdo.h
diff --git a/drivers/staging/typec/pd_vdo.h b/include/linux/usb/pd_vdo.h
index d92259f8de0a..d92259f8de0a 100644
--- a/drivers/staging/typec/pd_vdo.h
+++ b/include/linux/usb/pd_vdo.h
diff --git a/drivers/staging/typec/tcpm.h b/include/linux/usb/tcpm.h
index 7e9a6b7b5cd6..073197f0d2bb 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -54,6 +54,27 @@ enum tcpm_transmit_type {
54 TCPC_TX_BIST_MODE_2 = 7 54 TCPC_TX_BIST_MODE_2 = 7
55}; 55};
56 56
57/**
58 * struct tcpc_config - Port configuration
59 * @src_pdo: PDO parameters sent to port partner as response to
60 * PD_CTRL_GET_SOURCE_CAP message
61 * @nr_src_pdo: Number of entries in @src_pdo
62 * @snk_pdo: PDO parameters sent to partner as response to
63 * PD_CTRL_GET_SINK_CAP message
64 * @nr_snk_pdo: Number of entries in @snk_pdo
65 * @max_snk_mv: Maximum acceptable sink voltage in mV
66 * @max_snk_ma: Maximum sink current in mA
67 * @max_snk_mw: Maximum required sink power in mW
68 * @operating_snk_mw:
69 * Required operating sink power in mW
70 * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or
71 * TYPEC_PORT_DRP)
72 * @default_role:
73 * Default port role (TYPEC_SINK or TYPEC_SOURCE).
74 * Set to TYPEC_NO_PREFERRED_ROLE if no default role.
75 * @try_role_hw:True if try.{Src,Snk} is implemented in hardware
76 * @alt_modes: List of supported alternate modes
77 */
57struct tcpc_config { 78struct tcpc_config {
58 const u32 *src_pdo; 79 const u32 *src_pdo;
59 unsigned int nr_src_pdo; 80 unsigned int nr_src_pdo;
@@ -79,7 +100,6 @@ struct tcpc_config {
79enum tcpc_usb_switch { 100enum tcpc_usb_switch {
80 TCPC_USB_SWITCH_CONNECT, 101 TCPC_USB_SWITCH_CONNECT,
81 TCPC_USB_SWITCH_DISCONNECT, 102 TCPC_USB_SWITCH_DISCONNECT,
82 TCPC_USB_SWITCH_RESTORE, /* TODO FIXME */
83}; 103};
84 104
85/* Mux state attributes */ 105/* Mux state attributes */
@@ -104,17 +124,40 @@ struct tcpc_mux_dev {
104 void *priv_data; 124 void *priv_data;
105}; 125};
106 126
127/**
128 * struct tcpc_dev - Port configuration and callback functions
129 * @config: Pointer to port configuration
130 * @get_vbus: Called to read current VBUS state
131 * @get_current_limit:
132 * Optional; called by the tcpm core when configured as a snk
133 * and cc=Rp-def. This allows the tcpm to provide a fallback
134 * current-limit detection method for the cc=Rp-def case.
135 * For example, some tcpcs may include BC1.2 charger detection
136 * and use that in this case.
137 * @set_cc: Called to set value of CC pins
138 * @get_cc: Called to read current CC pin values
139 * @set_polarity:
140 * Called to set polarity
141 * @set_vconn: Called to enable or disable VCONN
142 * @set_vbus: Called to enable or disable VBUS
143 * @set_current_limit:
144 * Optional; called to set current limit as negotiated
145 * with partner.
146 * @set_pd_rx: Called to enable or disable reception of PD messages
147 * @set_roles: Called to set power and data roles
148 * @start_drp_toggling:
149 * Optional; if supported by hardware, called to start DRP
150 * toggling. DRP toggling is stopped automatically if
151 * a connection is established.
152 * @try_role: Optional; called to set a preferred role
153 * @pd_transmit:Called to transmit PD message
154 * @mux: Pointer to multiplexer data
155 */
107struct tcpc_dev { 156struct tcpc_dev {
108 const struct tcpc_config *config; 157 const struct tcpc_config *config;
109 158
110 int (*init)(struct tcpc_dev *dev); 159 int (*init)(struct tcpc_dev *dev);
111 int (*get_vbus)(struct tcpc_dev *dev); 160 int (*get_vbus)(struct tcpc_dev *dev);
112 /*
113 * This optional callback gets called by the tcpm core when configured
114 * as a snk and cc=Rp-def. This allows the tcpm to provide a fallback
115 * current-limit detection method for the cc=Rp-def case. E.g. some
116 * tcpcs may include BC1.2 charger detection and use that in this case.
117 */
118 int (*get_current_limit)(struct tcpc_dev *dev); 161 int (*get_current_limit)(struct tcpc_dev *dev);
119 int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc); 162 int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
120 int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, 163 int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index aa95053dfc78..425752f768d2 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -96,7 +96,7 @@ struct inet_request_sock {
96 kmemcheck_bitfield_end(flags); 96 kmemcheck_bitfield_end(flags);
97 u32 ir_mark; 97 u32 ir_mark;
98 union { 98 union {
99 struct ip_options_rcu *opt; 99 struct ip_options_rcu __rcu *ireq_opt;
100#if IS_ENABLED(CONFIG_IPV6) 100#if IS_ENABLED(CONFIG_IPV6)
101 struct { 101 struct {
102 struct ipv6_txoptions *ipv6_opt; 102 struct ipv6_txoptions *ipv6_opt;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 89974c5286d8..b1ef98ebce53 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -840,6 +840,11 @@ struct tcp_skb_cb {
840 struct inet6_skb_parm h6; 840 struct inet6_skb_parm h6;
841#endif 841#endif
842 } header; /* For incoming skbs */ 842 } header; /* For incoming skbs */
843 struct {
844 __u32 key;
845 __u32 flags;
846 struct bpf_map *map;
847 } bpf;
843 }; 848 };
844}; 849};
845 850
diff --git a/include/sound/control.h b/include/sound/control.h
index bd7246de58e7..a1f1152bc687 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -248,6 +248,9 @@ int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl,
248 void *private_data); 248 void *private_data);
249void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only); 249void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only);
250#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true) 250#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true)
251int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
252 int (*func)(struct snd_kcontrol *, void *),
253 void *arg);
251 254
252/* 255/*
253 * Helper functions for jack-detection controls 256 * Helper functions for jack-detection controls
diff --git a/include/uapi/linux/membarrier.h b/include/uapi/linux/membarrier.h
index 6d47b3249d8a..4e01ad7ffe98 100644
--- a/include/uapi/linux/membarrier.h
+++ b/include/uapi/linux/membarrier.h
@@ -52,21 +52,30 @@
52 * (non-running threads are de facto in such a 52 * (non-running threads are de facto in such a
53 * state). This only covers threads from the 53 * state). This only covers threads from the
54 * same processes as the caller thread. This 54 * same processes as the caller thread. This
55 * command returns 0. The "expedited" commands 55 * command returns 0 on success. The
56 * complete faster than the non-expedited ones, 56 * "expedited" commands complete faster than
57 * they never block, but have the downside of 57 * the non-expedited ones, they never block,
58 * causing extra overhead. 58 * but have the downside of causing extra
59 * overhead. A process needs to register its
60 * intent to use the private expedited command
61 * prior to using it, otherwise this command
62 * returns -EPERM.
63 * @MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED:
64 * Register the process intent to use
65 * MEMBARRIER_CMD_PRIVATE_EXPEDITED. Always
66 * returns 0.
59 * 67 *
60 * Command to be passed to the membarrier system call. The commands need to 68 * Command to be passed to the membarrier system call. The commands need to
61 * be a single bit each, except for MEMBARRIER_CMD_QUERY which is assigned to 69 * be a single bit each, except for MEMBARRIER_CMD_QUERY which is assigned to
62 * the value 0. 70 * the value 0.
63 */ 71 */
64enum membarrier_cmd { 72enum membarrier_cmd {
65 MEMBARRIER_CMD_QUERY = 0, 73 MEMBARRIER_CMD_QUERY = 0,
66 MEMBARRIER_CMD_SHARED = (1 << 0), 74 MEMBARRIER_CMD_SHARED = (1 << 0),
67 /* reserved for MEMBARRIER_CMD_SHARED_EXPEDITED (1 << 1) */ 75 /* reserved for MEMBARRIER_CMD_SHARED_EXPEDITED (1 << 1) */
68 /* reserved for MEMBARRIER_CMD_PRIVATE (1 << 2) */ 76 /* reserved for MEMBARRIER_CMD_PRIVATE (1 << 2) */
69 MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3), 77 MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3),
78 MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = (1 << 4),
70}; 79};
71 80
72#endif /* _UAPI_LINUX_MEMBARRIER_H */ 81#endif /* _UAPI_LINUX_MEMBARRIER_H */
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 98c0f00c3f5e..e2636737b69b 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -98,7 +98,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
98 array_size += (u64) attr->max_entries * elem_size * num_possible_cpus(); 98 array_size += (u64) attr->max_entries * elem_size * num_possible_cpus();
99 99
100 if (array_size >= U32_MAX - PAGE_SIZE || 100 if (array_size >= U32_MAX - PAGE_SIZE ||
101 elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) { 101 bpf_array_alloc_percpu(array)) {
102 bpf_map_area_free(array); 102 bpf_map_area_free(array);
103 return ERR_PTR(-ENOMEM); 103 return ERR_PTR(-ENOMEM);
104 } 104 }
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index e093d9a2c4dd..e745d6a88224 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -69,7 +69,7 @@ static LIST_HEAD(dev_map_list);
69 69
70static u64 dev_map_bitmap_size(const union bpf_attr *attr) 70static u64 dev_map_bitmap_size(const union bpf_attr *attr)
71{ 71{
72 return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long); 72 return BITS_TO_LONGS((u64) attr->max_entries) * sizeof(unsigned long);
73} 73}
74 74
75static struct bpf_map *dev_map_alloc(union bpf_attr *attr) 75static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
@@ -78,6 +78,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
78 int err = -EINVAL; 78 int err = -EINVAL;
79 u64 cost; 79 u64 cost;
80 80
81 if (!capable(CAP_NET_ADMIN))
82 return ERR_PTR(-EPERM);
83
81 /* check sanity of attributes */ 84 /* check sanity of attributes */
82 if (attr->max_entries == 0 || attr->key_size != 4 || 85 if (attr->max_entries == 0 || attr->key_size != 4 ||
83 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE) 86 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
@@ -111,8 +114,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
111 err = -ENOMEM; 114 err = -ENOMEM;
112 115
113 /* A per cpu bitfield with a bit per possible net device */ 116 /* A per cpu bitfield with a bit per possible net device */
114 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr), 117 dtab->flush_needed = __alloc_percpu_gfp(dev_map_bitmap_size(attr),
115 __alignof__(unsigned long)); 118 __alignof__(unsigned long),
119 GFP_KERNEL | __GFP_NOWARN);
116 if (!dtab->flush_needed) 120 if (!dtab->flush_needed)
117 goto free_dtab; 121 goto free_dtab;
118 122
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 431126f31ea3..6533f08d1238 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -317,10 +317,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
317 */ 317 */
318 goto free_htab; 318 goto free_htab;
319 319
320 if (percpu && round_up(htab->map.value_size, 8) > PCPU_MIN_UNIT_SIZE)
321 /* make sure the size for pcpu_alloc() is reasonable */
322 goto free_htab;
323
324 htab->elem_size = sizeof(struct htab_elem) + 320 htab->elem_size = sizeof(struct htab_elem) +
325 round_up(htab->map.key_size, 8); 321 round_up(htab->map.key_size, 8);
326 if (percpu) 322 if (percpu)
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 6424ce0e4969..2b6eb35ae5d3 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -39,6 +39,7 @@
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40#include <linux/list.h> 40#include <linux/list.h>
41#include <net/strparser.h> 41#include <net/strparser.h>
42#include <net/tcp.h>
42 43
43struct bpf_stab { 44struct bpf_stab {
44 struct bpf_map map; 45 struct bpf_map map;
@@ -101,9 +102,16 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb)
101 return SK_DROP; 102 return SK_DROP;
102 103
103 skb_orphan(skb); 104 skb_orphan(skb);
105 /* We need to ensure that BPF metadata for maps is also cleared
106 * when we orphan the skb so that we don't have the possibility
107 * to reference a stale map.
108 */
109 TCP_SKB_CB(skb)->bpf.map = NULL;
104 skb->sk = psock->sock; 110 skb->sk = psock->sock;
105 bpf_compute_data_end(skb); 111 bpf_compute_data_end(skb);
112 preempt_disable();
106 rc = (*prog->bpf_func)(skb, prog->insnsi); 113 rc = (*prog->bpf_func)(skb, prog->insnsi);
114 preempt_enable();
107 skb->sk = NULL; 115 skb->sk = NULL;
108 116
109 return rc; 117 return rc;
@@ -114,17 +122,10 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb)
114 struct sock *sk; 122 struct sock *sk;
115 int rc; 123 int rc;
116 124
117 /* Because we use per cpu values to feed input from sock redirect
118 * in BPF program to do_sk_redirect_map() call we need to ensure we
119 * are not preempted. RCU read lock is not sufficient in this case
120 * with CONFIG_PREEMPT_RCU enabled so we must be explicit here.
121 */
122 preempt_disable();
123 rc = smap_verdict_func(psock, skb); 125 rc = smap_verdict_func(psock, skb);
124 switch (rc) { 126 switch (rc) {
125 case SK_REDIRECT: 127 case SK_REDIRECT:
126 sk = do_sk_redirect_map(); 128 sk = do_sk_redirect_map(skb);
127 preempt_enable();
128 if (likely(sk)) { 129 if (likely(sk)) {
129 struct smap_psock *peer = smap_psock_sk(sk); 130 struct smap_psock *peer = smap_psock_sk(sk);
130 131
@@ -141,8 +142,6 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb)
141 /* Fall through and free skb otherwise */ 142 /* Fall through and free skb otherwise */
142 case SK_DROP: 143 case SK_DROP:
143 default: 144 default:
144 if (rc != SK_REDIRECT)
145 preempt_enable();
146 kfree_skb(skb); 145 kfree_skb(skb);
147 } 146 }
148} 147}
@@ -487,6 +486,9 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
487 int err = -EINVAL; 486 int err = -EINVAL;
488 u64 cost; 487 u64 cost;
489 488
489 if (!capable(CAP_NET_ADMIN))
490 return ERR_PTR(-EPERM);
491
490 /* check sanity of attributes */ 492 /* check sanity of attributes */
491 if (attr->max_entries == 0 || attr->key_size != 4 || 493 if (attr->max_entries == 0 || attr->key_size != 4 ||
492 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE) 494 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
@@ -840,6 +842,12 @@ static int sock_map_update_elem(struct bpf_map *map,
840 return -EINVAL; 842 return -EINVAL;
841 } 843 }
842 844
845 if (skops.sk->sk_type != SOCK_STREAM ||
846 skops.sk->sk_protocol != IPPROTO_TCP) {
847 fput(socket->file);
848 return -EOPNOTSUPP;
849 }
850
843 err = sock_map_ctx_update_elem(&skops, map, key, flags); 851 err = sock_map_ctx_update_elem(&skops, map, key, flags);
844 fput(socket->file); 852 fput(socket->file);
845 return err; 853 return err;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 8b8d6ba39e23..c48ca2a34b5e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1116,7 +1116,12 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
1116 /* ctx accesses must be at a fixed offset, so that we can 1116 /* ctx accesses must be at a fixed offset, so that we can
1117 * determine what type of data were returned. 1117 * determine what type of data were returned.
1118 */ 1118 */
1119 if (!tnum_is_const(reg->var_off)) { 1119 if (reg->off) {
1120 verbose("dereference of modified ctx ptr R%d off=%d+%d, ctx+const is allowed, ctx+const+const is not\n",
1121 regno, reg->off, off - reg->off);
1122 return -EACCES;
1123 }
1124 if (!tnum_is_const(reg->var_off) || reg->var_off.value) {
1120 char tn_buf[48]; 1125 char tn_buf[48];
1121 1126
1122 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off); 1127 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
@@ -1124,7 +1129,6 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
1124 tn_buf, off, size); 1129 tn_buf, off, size);
1125 return -EACCES; 1130 return -EACCES;
1126 } 1131 }
1127 off += reg->var_off.value;
1128 err = check_ctx_access(env, insn_idx, off, size, t, &reg_type); 1132 err = check_ctx_access(env, insn_idx, off, size, t, &reg_type);
1129 if (!err && t == BPF_READ && value_regno >= 0) { 1133 if (!err && t == BPF_READ && value_regno >= 0) {
1130 /* ctx access returns either a scalar, or a 1134 /* ctx access returns either a scalar, or a
@@ -2426,12 +2430,15 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
2426} 2430}
2427 2431
2428static void find_good_pkt_pointers(struct bpf_verifier_state *state, 2432static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2429 struct bpf_reg_state *dst_reg) 2433 struct bpf_reg_state *dst_reg,
2434 bool range_right_open)
2430{ 2435{
2431 struct bpf_reg_state *regs = state->regs, *reg; 2436 struct bpf_reg_state *regs = state->regs, *reg;
2437 u16 new_range;
2432 int i; 2438 int i;
2433 2439
2434 if (dst_reg->off < 0) 2440 if (dst_reg->off < 0 ||
2441 (dst_reg->off == 0 && range_right_open))
2435 /* This doesn't give us any range */ 2442 /* This doesn't give us any range */
2436 return; 2443 return;
2437 2444
@@ -2442,9 +2449,13 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2442 */ 2449 */
2443 return; 2450 return;
2444 2451
2445 /* LLVM can generate four kind of checks: 2452 new_range = dst_reg->off;
2453 if (range_right_open)
2454 new_range--;
2455
2456 /* Examples for register markings:
2446 * 2457 *
2447 * Type 1/2: 2458 * pkt_data in dst register:
2448 * 2459 *
2449 * r2 = r3; 2460 * r2 = r3;
2450 * r2 += 8; 2461 * r2 += 8;
@@ -2461,7 +2472,7 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2461 * r2=pkt(id=n,off=8,r=0) 2472 * r2=pkt(id=n,off=8,r=0)
2462 * r3=pkt(id=n,off=0,r=0) 2473 * r3=pkt(id=n,off=0,r=0)
2463 * 2474 *
2464 * Type 3/4: 2475 * pkt_data in src register:
2465 * 2476 *
2466 * r2 = r3; 2477 * r2 = r3;
2467 * r2 += 8; 2478 * r2 += 8;
@@ -2479,7 +2490,9 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2479 * r3=pkt(id=n,off=0,r=0) 2490 * r3=pkt(id=n,off=0,r=0)
2480 * 2491 *
2481 * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8) 2492 * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)
2482 * so that range of bytes [r3, r3 + 8) is safe to access. 2493 * or r3=pkt(id=n,off=0,r=8-1), so that range of bytes [r3, r3 + 8)
2494 * and [r3, r3 + 8-1) respectively is safe to access depending on
2495 * the check.
2483 */ 2496 */
2484 2497
2485 /* If our ids match, then we must have the same max_value. And we 2498 /* If our ids match, then we must have the same max_value. And we
@@ -2490,14 +2503,14 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2490 for (i = 0; i < MAX_BPF_REG; i++) 2503 for (i = 0; i < MAX_BPF_REG; i++)
2491 if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id) 2504 if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id)
2492 /* keep the maximum range already checked */ 2505 /* keep the maximum range already checked */
2493 regs[i].range = max_t(u16, regs[i].range, dst_reg->off); 2506 regs[i].range = max(regs[i].range, new_range);
2494 2507
2495 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) { 2508 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {
2496 if (state->stack_slot_type[i] != STACK_SPILL) 2509 if (state->stack_slot_type[i] != STACK_SPILL)
2497 continue; 2510 continue;
2498 reg = &state->spilled_regs[i / BPF_REG_SIZE]; 2511 reg = &state->spilled_regs[i / BPF_REG_SIZE];
2499 if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id) 2512 if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id)
2500 reg->range = max_t(u16, reg->range, dst_reg->off); 2513 reg->range = max(reg->range, new_range);
2501 } 2514 }
2502} 2515}
2503 2516
@@ -2861,19 +2874,43 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
2861 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT && 2874 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&
2862 dst_reg->type == PTR_TO_PACKET && 2875 dst_reg->type == PTR_TO_PACKET &&
2863 regs[insn->src_reg].type == PTR_TO_PACKET_END) { 2876 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2864 find_good_pkt_pointers(this_branch, dst_reg); 2877 /* pkt_data' > pkt_end */
2878 find_good_pkt_pointers(this_branch, dst_reg, false);
2879 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&
2880 dst_reg->type == PTR_TO_PACKET_END &&
2881 regs[insn->src_reg].type == PTR_TO_PACKET) {
2882 /* pkt_end > pkt_data' */
2883 find_good_pkt_pointers(other_branch, &regs[insn->src_reg], true);
2865 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT && 2884 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&
2866 dst_reg->type == PTR_TO_PACKET && 2885 dst_reg->type == PTR_TO_PACKET &&
2867 regs[insn->src_reg].type == PTR_TO_PACKET_END) { 2886 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2868 find_good_pkt_pointers(other_branch, dst_reg); 2887 /* pkt_data' < pkt_end */
2888 find_good_pkt_pointers(other_branch, dst_reg, true);
2889 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&
2890 dst_reg->type == PTR_TO_PACKET_END &&
2891 regs[insn->src_reg].type == PTR_TO_PACKET) {
2892 /* pkt_end < pkt_data' */
2893 find_good_pkt_pointers(this_branch, &regs[insn->src_reg], false);
2894 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&
2895 dst_reg->type == PTR_TO_PACKET &&
2896 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2897 /* pkt_data' >= pkt_end */
2898 find_good_pkt_pointers(this_branch, dst_reg, true);
2869 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE && 2899 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&
2870 dst_reg->type == PTR_TO_PACKET_END && 2900 dst_reg->type == PTR_TO_PACKET_END &&
2871 regs[insn->src_reg].type == PTR_TO_PACKET) { 2901 regs[insn->src_reg].type == PTR_TO_PACKET) {
2872 find_good_pkt_pointers(other_branch, &regs[insn->src_reg]); 2902 /* pkt_end >= pkt_data' */
2903 find_good_pkt_pointers(other_branch, &regs[insn->src_reg], false);
2904 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&
2905 dst_reg->type == PTR_TO_PACKET &&
2906 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2907 /* pkt_data' <= pkt_end */
2908 find_good_pkt_pointers(other_branch, dst_reg, false);
2873 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE && 2909 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&
2874 dst_reg->type == PTR_TO_PACKET_END && 2910 dst_reg->type == PTR_TO_PACKET_END &&
2875 regs[insn->src_reg].type == PTR_TO_PACKET) { 2911 regs[insn->src_reg].type == PTR_TO_PACKET) {
2876 find_good_pkt_pointers(this_branch, &regs[insn->src_reg]); 2912 /* pkt_end <= pkt_data' */
2913 find_good_pkt_pointers(this_branch, &regs[insn->src_reg], true);
2877 } else if (is_pointer_value(env, insn->dst_reg)) { 2914 } else if (is_pointer_value(env, insn->dst_reg)) {
2878 verbose("R%d pointer comparison prohibited\n", insn->dst_reg); 2915 verbose("R%d pointer comparison prohibited\n", insn->dst_reg);
2879 return -EACCES; 2916 return -EACCES;
diff --git a/kernel/cpu.c b/kernel/cpu.c
index d851df22f5c5..04892a82f6ac 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -632,6 +632,11 @@ cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state, bool bringup,
632 __cpuhp_kick_ap(st); 632 __cpuhp_kick_ap(st);
633 } 633 }
634 634
635 /*
636 * Clean up the leftovers so the next hotplug operation wont use stale
637 * data.
638 */
639 st->node = st->last = NULL;
635 return ret; 640 return ret;
636} 641}
637 642
diff --git a/kernel/exit.c b/kernel/exit.c
index cf28528842bc..f6cad39f35df 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1611,7 +1611,7 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
1611 return err; 1611 return err;
1612 1612
1613 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop))) 1613 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
1614 goto Efault; 1614 return -EFAULT;
1615 1615
1616 user_access_begin(); 1616 user_access_begin();
1617 unsafe_put_user(signo, &infop->si_signo, Efault); 1617 unsafe_put_user(signo, &infop->si_signo, Efault);
@@ -1739,7 +1739,7 @@ COMPAT_SYSCALL_DEFINE5(waitid,
1739 return err; 1739 return err;
1740 1740
1741 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop))) 1741 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
1742 goto Efault; 1742 return -EFAULT;
1743 1743
1744 user_access_begin(); 1744 user_access_begin();
1745 unsafe_put_user(signo, &infop->si_signo, Efault); 1745 unsafe_put_user(signo, &infop->si_signo, Efault);
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 5270a54b9fa4..c26c5bb6b491 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -135,17 +135,26 @@ void irq_gc_ack_clr_bit(struct irq_data *d)
135} 135}
136 136
137/** 137/**
138 * irq_gc_mask_disable_reg_and_ack - Mask and ack pending interrupt 138 * irq_gc_mask_disable_and_ack_set - Mask and ack pending interrupt
139 * @d: irq_data 139 * @d: irq_data
140 *
141 * This generic implementation of the irq_mask_ack method is for chips
142 * with separate enable/disable registers instead of a single mask
143 * register and where a pending interrupt is acknowledged by setting a
144 * bit.
145 *
146 * Note: This is the only permutation currently used. Similar generic
147 * functions should be added here if other permutations are required.
140 */ 148 */
141void irq_gc_mask_disable_reg_and_ack(struct irq_data *d) 149void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
142{ 150{
143 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 151 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
144 struct irq_chip_type *ct = irq_data_get_chip_type(d); 152 struct irq_chip_type *ct = irq_data_get_chip_type(d);
145 u32 mask = d->mask; 153 u32 mask = d->mask;
146 154
147 irq_gc_lock(gc); 155 irq_gc_lock(gc);
148 irq_reg_writel(gc, mask, ct->regs.mask); 156 irq_reg_writel(gc, mask, ct->regs.disable);
157 *ct->mask_cache &= ~mask;
149 irq_reg_writel(gc, mask, ct->regs.ack); 158 irq_reg_writel(gc, mask, ct->regs.ack);
150 irq_gc_unlock(gc); 159 irq_gc_unlock(gc);
151} 160}
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 729a8706751d..6d5880089ff6 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -854,7 +854,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp,
854/** 854/**
855 * call_srcu() - Queue a callback for invocation after an SRCU grace period 855 * call_srcu() - Queue a callback for invocation after an SRCU grace period
856 * @sp: srcu_struct in queue the callback 856 * @sp: srcu_struct in queue the callback
857 * @head: structure to be used for queueing the SRCU callback. 857 * @rhp: structure to be used for queueing the SRCU callback.
858 * @func: function to be invoked after the SRCU grace period 858 * @func: function to be invoked after the SRCU grace period
859 * 859 *
860 * The callback function will be invoked some time after a full SRCU 860 * The callback function will be invoked some time after a full SRCU
diff --git a/kernel/rcu/sync.c b/kernel/rcu/sync.c
index 50d1861f7759..3f943efcf61c 100644
--- a/kernel/rcu/sync.c
+++ b/kernel/rcu/sync.c
@@ -85,6 +85,9 @@ void rcu_sync_init(struct rcu_sync *rsp, enum rcu_sync_type type)
85} 85}
86 86
87/** 87/**
88 * rcu_sync_enter_start - Force readers onto slow path for multiple updates
89 * @rsp: Pointer to rcu_sync structure to use for synchronization
90 *
88 * Must be called after rcu_sync_init() and before first use. 91 * Must be called after rcu_sync_init() and before first use.
89 * 92 *
90 * Ensures rcu_sync_is_idle() returns false and rcu_sync_{enter,exit}() 93 * Ensures rcu_sync_is_idle() returns false and rcu_sync_{enter,exit}()
@@ -142,7 +145,7 @@ void rcu_sync_enter(struct rcu_sync *rsp)
142 145
143/** 146/**
144 * rcu_sync_func() - Callback function managing reader access to fastpath 147 * rcu_sync_func() - Callback function managing reader access to fastpath
145 * @rsp: Pointer to rcu_sync structure to use for synchronization 148 * @rhp: Pointer to rcu_head in rcu_sync structure to use for synchronization
146 * 149 *
147 * This function is passed to one of the call_rcu() functions by 150 * This function is passed to one of the call_rcu() functions by
148 * rcu_sync_exit(), so that it is invoked after a grace period following the 151 * rcu_sync_exit(), so that it is invoked after a grace period following the
@@ -158,9 +161,9 @@ void rcu_sync_enter(struct rcu_sync *rsp)
158 * rcu_sync_exit(). Otherwise, set all state back to idle so that readers 161 * rcu_sync_exit(). Otherwise, set all state back to idle so that readers
159 * can again use their fastpaths. 162 * can again use their fastpaths.
160 */ 163 */
161static void rcu_sync_func(struct rcu_head *rcu) 164static void rcu_sync_func(struct rcu_head *rhp)
162{ 165{
163 struct rcu_sync *rsp = container_of(rcu, struct rcu_sync, cb_head); 166 struct rcu_sync *rsp = container_of(rhp, struct rcu_sync, cb_head);
164 unsigned long flags; 167 unsigned long flags;
165 168
166 BUG_ON(rsp->gp_state != GP_PASSED); 169 BUG_ON(rsp->gp_state != GP_PASSED);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index b0ad62b0e7b8..3e3650e94ae6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3097,9 +3097,10 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func,
3097 * read-side critical sections have completed. call_rcu_sched() assumes 3097 * read-side critical sections have completed. call_rcu_sched() assumes
3098 * that the read-side critical sections end on enabling of preemption 3098 * that the read-side critical sections end on enabling of preemption
3099 * or on voluntary preemption. 3099 * or on voluntary preemption.
3100 * RCU read-side critical sections are delimited by : 3100 * RCU read-side critical sections are delimited by:
3101 * - rcu_read_lock_sched() and rcu_read_unlock_sched(), OR 3101 *
3102 * - anything that disables preemption. 3102 * - rcu_read_lock_sched() and rcu_read_unlock_sched(), OR
3103 * - anything that disables preemption.
3103 * 3104 *
3104 * These may be nested. 3105 * These may be nested.
3105 * 3106 *
@@ -3124,11 +3125,12 @@ EXPORT_SYMBOL_GPL(call_rcu_sched);
3124 * handler. This means that read-side critical sections in process 3125 * handler. This means that read-side critical sections in process
3125 * context must not be interrupted by softirqs. This interface is to be 3126 * context must not be interrupted by softirqs. This interface is to be
3126 * used when most of the read-side critical sections are in softirq context. 3127 * used when most of the read-side critical sections are in softirq context.
3127 * RCU read-side critical sections are delimited by : 3128 * RCU read-side critical sections are delimited by:
3128 * - rcu_read_lock() and rcu_read_unlock(), if in interrupt context. 3129 *
3129 * OR 3130 * - rcu_read_lock() and rcu_read_unlock(), if in interrupt context, OR
3130 * - rcu_read_lock_bh() and rcu_read_unlock_bh(), if in process context. 3131 * - rcu_read_lock_bh() and rcu_read_unlock_bh(), if in process context.
3131 * These may be nested. 3132 *
3133 * These may be nested.
3132 * 3134 *
3133 * See the description of call_rcu() for more detailed information on 3135 * See the description of call_rcu() for more detailed information on
3134 * memory ordering guarantees. 3136 * memory ordering guarantees.
diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c
index a92fddc22747..dd7908743dab 100644
--- a/kernel/sched/membarrier.c
+++ b/kernel/sched/membarrier.c
@@ -18,6 +18,7 @@
18#include <linux/membarrier.h> 18#include <linux/membarrier.h>
19#include <linux/tick.h> 19#include <linux/tick.h>
20#include <linux/cpumask.h> 20#include <linux/cpumask.h>
21#include <linux/atomic.h>
21 22
22#include "sched.h" /* for cpu_rq(). */ 23#include "sched.h" /* for cpu_rq(). */
23 24
@@ -26,21 +27,26 @@
26 * except MEMBARRIER_CMD_QUERY. 27 * except MEMBARRIER_CMD_QUERY.
27 */ 28 */
28#define MEMBARRIER_CMD_BITMASK \ 29#define MEMBARRIER_CMD_BITMASK \
29 (MEMBARRIER_CMD_SHARED | MEMBARRIER_CMD_PRIVATE_EXPEDITED) 30 (MEMBARRIER_CMD_SHARED | MEMBARRIER_CMD_PRIVATE_EXPEDITED \
31 | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED)
30 32
31static void ipi_mb(void *info) 33static void ipi_mb(void *info)
32{ 34{
33 smp_mb(); /* IPIs should be serializing but paranoid. */ 35 smp_mb(); /* IPIs should be serializing but paranoid. */
34} 36}
35 37
36static void membarrier_private_expedited(void) 38static int membarrier_private_expedited(void)
37{ 39{
38 int cpu; 40 int cpu;
39 bool fallback = false; 41 bool fallback = false;
40 cpumask_var_t tmpmask; 42 cpumask_var_t tmpmask;
41 43
44 if (!(atomic_read(&current->mm->membarrier_state)
45 & MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY))
46 return -EPERM;
47
42 if (num_online_cpus() == 1) 48 if (num_online_cpus() == 1)
43 return; 49 return 0;
44 50
45 /* 51 /*
46 * Matches memory barriers around rq->curr modification in 52 * Matches memory barriers around rq->curr modification in
@@ -94,6 +100,24 @@ static void membarrier_private_expedited(void)
94 * rq->curr modification in scheduler. 100 * rq->curr modification in scheduler.
95 */ 101 */
96 smp_mb(); /* exit from system call is not a mb */ 102 smp_mb(); /* exit from system call is not a mb */
103 return 0;
104}
105
106static void membarrier_register_private_expedited(void)
107{
108 struct task_struct *p = current;
109 struct mm_struct *mm = p->mm;
110
111 /*
112 * We need to consider threads belonging to different thread
113 * groups, which use the same mm. (CLONE_VM but not
114 * CLONE_THREAD).
115 */
116 if (atomic_read(&mm->membarrier_state)
117 & MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY)
118 return;
119 atomic_or(MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY,
120 &mm->membarrier_state);
97} 121}
98 122
99/** 123/**
@@ -144,7 +168,9 @@ SYSCALL_DEFINE2(membarrier, int, cmd, int, flags)
144 synchronize_sched(); 168 synchronize_sched();
145 return 0; 169 return 0;
146 case MEMBARRIER_CMD_PRIVATE_EXPEDITED: 170 case MEMBARRIER_CMD_PRIVATE_EXPEDITED:
147 membarrier_private_expedited(); 171 return membarrier_private_expedited();
172 case MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED:
173 membarrier_register_private_expedited();
148 return 0; 174 return 0;
149 default: 175 default:
150 return -EINVAL; 176 return -EINVAL;
diff --git a/lib/digsig.c b/lib/digsig.c
index 03d7c63837ae..6ba6fcd92dd1 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
87 down_read(&key->sem); 87 down_read(&key->sem);
88 ukp = user_key_payload_locked(key); 88 ukp = user_key_payload_locked(key);
89 89
90 if (!ukp) {
91 /* key was revoked before we acquired its semaphore */
92 err = -EKEYREVOKED;
93 goto err1;
94 }
95
90 if (ukp->datalen < sizeof(*pkh)) 96 if (ukp->datalen < sizeof(*pkh))
91 goto err1; 97 goto err1;
92 98
diff --git a/lib/ts_fsm.c b/lib/ts_fsm.c
index 5696a35184e4..69557c74ef9f 100644
--- a/lib/ts_fsm.c
+++ b/lib/ts_fsm.c
@@ -11,7 +11,7 @@
11 * ========================================================================== 11 * ==========================================================================
12 * 12 *
13 * A finite state machine consists of n states (struct ts_fsm_token) 13 * A finite state machine consists of n states (struct ts_fsm_token)
14 * representing the pattern as a finite automation. The data is read 14 * representing the pattern as a finite automaton. The data is read
15 * sequentially on an octet basis. Every state token specifies the number 15 * sequentially on an octet basis. Every state token specifies the number
16 * of recurrences and the type of value accepted which can be either a 16 * of recurrences and the type of value accepted which can be either a
17 * specific character or ctype based set of characters. The available 17 * specific character or ctype based set of characters. The available
diff --git a/lib/ts_kmp.c b/lib/ts_kmp.c
index 632f783e65f1..ffbe66cbb0ed 100644
--- a/lib/ts_kmp.c
+++ b/lib/ts_kmp.c
@@ -27,7 +27,7 @@
27 * 27 *
28 * [1] Cormen, Leiserson, Rivest, Stein 28 * [1] Cormen, Leiserson, Rivest, Stein
29 * Introdcution to Algorithms, 2nd Edition, MIT Press 29 * Introdcution to Algorithms, 2nd Edition, MIT Press
30 * [2] See finite automation theory 30 * [2] See finite automaton theory
31 */ 31 */
32 32
33#include <linux/module.h> 33#include <linux/module.h>
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d5f3a62887cf..661f046ad318 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5828,21 +5828,6 @@ void mem_cgroup_sk_alloc(struct sock *sk)
5828 if (!mem_cgroup_sockets_enabled) 5828 if (!mem_cgroup_sockets_enabled)
5829 return; 5829 return;
5830 5830
5831 /*
5832 * Socket cloning can throw us here with sk_memcg already
5833 * filled. It won't however, necessarily happen from
5834 * process context. So the test for root memcg given
5835 * the current task's memcg won't help us in this case.
5836 *
5837 * Respecting the original socket's memcg is a better
5838 * decision in this case.
5839 */
5840 if (sk->sk_memcg) {
5841 BUG_ON(mem_cgroup_is_root(sk->sk_memcg));
5842 css_get(&sk->sk_memcg->css);
5843 return;
5844 }
5845
5846 rcu_read_lock(); 5831 rcu_read_lock();
5847 memcg = mem_cgroup_from_task(current); 5832 memcg = mem_cgroup_from_task(current);
5848 if (memcg == root_mem_cgroup) 5833 if (memcg == root_mem_cgroup)
diff --git a/mm/percpu.c b/mm/percpu.c
index aa121cef76de..a0e0c82c1e4c 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1329,7 +1329,9 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
1329 * @gfp: allocation flags 1329 * @gfp: allocation flags
1330 * 1330 *
1331 * Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't 1331 * Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't
1332 * contain %GFP_KERNEL, the allocation is atomic. 1332 * contain %GFP_KERNEL, the allocation is atomic. If @gfp has __GFP_NOWARN
1333 * then no warning will be triggered on invalid or failed allocation
1334 * requests.
1333 * 1335 *
1334 * RETURNS: 1336 * RETURNS:
1335 * Percpu pointer to the allocated area on success, NULL on failure. 1337 * Percpu pointer to the allocated area on success, NULL on failure.
@@ -1337,10 +1339,11 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
1337static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, 1339static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
1338 gfp_t gfp) 1340 gfp_t gfp)
1339{ 1341{
1342 bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
1343 bool do_warn = !(gfp & __GFP_NOWARN);
1340 static int warn_limit = 10; 1344 static int warn_limit = 10;
1341 struct pcpu_chunk *chunk; 1345 struct pcpu_chunk *chunk;
1342 const char *err; 1346 const char *err;
1343 bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
1344 int slot, off, cpu, ret; 1347 int slot, off, cpu, ret;
1345 unsigned long flags; 1348 unsigned long flags;
1346 void __percpu *ptr; 1349 void __percpu *ptr;
@@ -1361,7 +1364,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
1361 1364
1362 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE || 1365 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||
1363 !is_power_of_2(align))) { 1366 !is_power_of_2(align))) {
1364 WARN(true, "illegal size (%zu) or align (%zu) for percpu allocation\n", 1367 WARN(do_warn, "illegal size (%zu) or align (%zu) for percpu allocation\n",
1365 size, align); 1368 size, align);
1366 return NULL; 1369 return NULL;
1367 } 1370 }
@@ -1482,7 +1485,7 @@ fail_unlock:
1482fail: 1485fail:
1483 trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align); 1486 trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
1484 1487
1485 if (!is_atomic && warn_limit) { 1488 if (!is_atomic && do_warn && warn_limit) {
1486 pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n", 1489 pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
1487 size, align, is_atomic, err); 1490 size, align, is_atomic, err);
1488 dump_stack(); 1491 dump_stack();
@@ -1507,7 +1510,9 @@ fail:
1507 * 1510 *
1508 * Allocate zero-filled percpu area of @size bytes aligned at @align. If 1511 * Allocate zero-filled percpu area of @size bytes aligned at @align. If
1509 * @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can 1512 * @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can
1510 * be called from any context but is a lot more likely to fail. 1513 * be called from any context but is a lot more likely to fail. If @gfp
1514 * has __GFP_NOWARN then no warning will be triggered on invalid or failed
1515 * allocation requests.
1511 * 1516 *
1512 * RETURNS: 1517 * RETURNS:
1513 * Percpu pointer to the allocated area on success, NULL on failure. 1518 * Percpu pointer to the allocated area on success, NULL on failure.
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 3bc890716c89..de2152730809 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -573,7 +573,7 @@ static int br_process_vlan_info(struct net_bridge *br,
573 } 573 }
574 *vinfo_last = NULL; 574 *vinfo_last = NULL;
575 575
576 return 0; 576 return err;
577 } 577 }
578 578
579 return br_vlan_info(br, p, cmd, vinfo_curr); 579 return br_vlan_info(br, p, cmd, vinfo_curr);
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 88edac0f3e36..ecd5c703d11e 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -78,7 +78,7 @@ MODULE_PARM_DESC(stats_timer, "enable timer for statistics (default:on)");
78static struct kmem_cache *rcv_cache __read_mostly; 78static struct kmem_cache *rcv_cache __read_mostly;
79 79
80/* table of registered CAN protocols */ 80/* table of registered CAN protocols */
81static const struct can_proto *proto_tab[CAN_NPROTO] __read_mostly; 81static const struct can_proto __rcu *proto_tab[CAN_NPROTO] __read_mostly;
82static DEFINE_MUTEX(proto_tab_lock); 82static DEFINE_MUTEX(proto_tab_lock);
83 83
84static atomic_t skbcounter = ATOMIC_INIT(0); 84static atomic_t skbcounter = ATOMIC_INIT(0);
@@ -788,7 +788,7 @@ int can_proto_register(const struct can_proto *cp)
788 788
789 mutex_lock(&proto_tab_lock); 789 mutex_lock(&proto_tab_lock);
790 790
791 if (proto_tab[proto]) { 791 if (rcu_access_pointer(proto_tab[proto])) {
792 pr_err("can: protocol %d already registered\n", proto); 792 pr_err("can: protocol %d already registered\n", proto);
793 err = -EBUSY; 793 err = -EBUSY;
794 } else 794 } else
@@ -812,7 +812,7 @@ void can_proto_unregister(const struct can_proto *cp)
812 int proto = cp->protocol; 812 int proto = cp->protocol;
813 813
814 mutex_lock(&proto_tab_lock); 814 mutex_lock(&proto_tab_lock);
815 BUG_ON(proto_tab[proto] != cp); 815 BUG_ON(rcu_access_pointer(proto_tab[proto]) != cp);
816 RCU_INIT_POINTER(proto_tab[proto], NULL); 816 RCU_INIT_POINTER(proto_tab[proto], NULL);
817 mutex_unlock(&proto_tab_lock); 817 mutex_unlock(&proto_tab_lock);
818 818
@@ -875,9 +875,14 @@ static int can_pernet_init(struct net *net)
875 spin_lock_init(&net->can.can_rcvlists_lock); 875 spin_lock_init(&net->can.can_rcvlists_lock);
876 net->can.can_rx_alldev_list = 876 net->can.can_rx_alldev_list =
877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL); 877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
878 878 if (!net->can.can_rx_alldev_list)
879 goto out;
879 net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL); 880 net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL);
881 if (!net->can.can_stats)
882 goto out_free_alldev_list;
880 net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL); 883 net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL);
884 if (!net->can.can_pstats)
885 goto out_free_can_stats;
881 886
882 if (IS_ENABLED(CONFIG_PROC_FS)) { 887 if (IS_ENABLED(CONFIG_PROC_FS)) {
883 /* the statistics are updated every second (timer triggered) */ 888 /* the statistics are updated every second (timer triggered) */
@@ -892,6 +897,13 @@ static int can_pernet_init(struct net *net)
892 } 897 }
893 898
894 return 0; 899 return 0;
900
901 out_free_can_stats:
902 kfree(net->can.can_stats);
903 out_free_alldev_list:
904 kfree(net->can.can_rx_alldev_list);
905 out:
906 return -ENOMEM;
895} 907}
896 908
897static void can_pernet_exit(struct net *net) 909static void can_pernet_exit(struct net *net)
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 47a8748d953a..13690334efa3 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1493,13 +1493,14 @@ static int bcm_init(struct sock *sk)
1493static int bcm_release(struct socket *sock) 1493static int bcm_release(struct socket *sock)
1494{ 1494{
1495 struct sock *sk = sock->sk; 1495 struct sock *sk = sock->sk;
1496 struct net *net = sock_net(sk); 1496 struct net *net;
1497 struct bcm_sock *bo; 1497 struct bcm_sock *bo;
1498 struct bcm_op *op, *next; 1498 struct bcm_op *op, *next;
1499 1499
1500 if (sk == NULL) 1500 if (!sk)
1501 return 0; 1501 return 0;
1502 1502
1503 net = sock_net(sk);
1503 bo = bcm_sk(sk); 1504 bo = bcm_sk(sk);
1504 1505
1505 /* remove bcm_ops, timer, rx_unregister(), etc. */ 1506 /* remove bcm_ops, timer, rx_unregister(), etc. */
diff --git a/net/core/dev.c b/net/core/dev.c
index 588b473194a8..11596a302a26 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1147,9 +1147,8 @@ static int dev_alloc_name_ns(struct net *net,
1147 return ret; 1147 return ret;
1148} 1148}
1149 1149
1150static int dev_get_valid_name(struct net *net, 1150int dev_get_valid_name(struct net *net, struct net_device *dev,
1151 struct net_device *dev, 1151 const char *name)
1152 const char *name)
1153{ 1152{
1154 BUG_ON(!net); 1153 BUG_ON(!net);
1155 1154
@@ -1165,6 +1164,7 @@ static int dev_get_valid_name(struct net *net,
1165 1164
1166 return 0; 1165 return 0;
1167} 1166}
1167EXPORT_SYMBOL(dev_get_valid_name);
1168 1168
1169/** 1169/**
1170 * dev_change_name - change name of a device 1170 * dev_change_name - change name of a device
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 709a4e6fb447..f9c7a88cd981 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -303,7 +303,18 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
303 case SIOCSIFTXQLEN: 303 case SIOCSIFTXQLEN:
304 if (ifr->ifr_qlen < 0) 304 if (ifr->ifr_qlen < 0)
305 return -EINVAL; 305 return -EINVAL;
306 dev->tx_queue_len = ifr->ifr_qlen; 306 if (dev->tx_queue_len ^ ifr->ifr_qlen) {
307 unsigned int orig_len = dev->tx_queue_len;
308
309 dev->tx_queue_len = ifr->ifr_qlen;
310 err = call_netdevice_notifiers(
311 NETDEV_CHANGE_TX_QUEUE_LEN, dev);
312 err = notifier_to_errno(err);
313 if (err) {
314 dev->tx_queue_len = orig_len;
315 return err;
316 }
317 }
307 return 0; 318 return 0;
308 319
309 case SIOCSIFNAME: 320 case SIOCSIFNAME:
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 3228411ada0f..9a9a3d77e327 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -436,7 +436,7 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
436EXPORT_SYMBOL(ethtool_convert_link_mode_to_legacy_u32); 436EXPORT_SYMBOL(ethtool_convert_link_mode_to_legacy_u32);
437 437
438/* return false if legacy contained non-0 deprecated fields 438/* return false if legacy contained non-0 deprecated fields
439 * transceiver/maxtxpkt/maxrxpkt. rest of ksettings always updated 439 * maxtxpkt/maxrxpkt. rest of ksettings always updated
440 */ 440 */
441static bool 441static bool
442convert_legacy_settings_to_link_ksettings( 442convert_legacy_settings_to_link_ksettings(
@@ -451,8 +451,7 @@ convert_legacy_settings_to_link_ksettings(
451 * deprecated legacy fields, and they should not use 451 * deprecated legacy fields, and they should not use
452 * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS 452 * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS
453 */ 453 */
454 if (legacy_settings->transceiver || 454 if (legacy_settings->maxtxpkt ||
455 legacy_settings->maxtxpkt ||
456 legacy_settings->maxrxpkt) 455 legacy_settings->maxrxpkt)
457 retval = false; 456 retval = false;
458 457
diff --git a/net/core/filter.c b/net/core/filter.c
index 74b8c91fb5f4..aa0265997f93 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1839,31 +1839,31 @@ static const struct bpf_func_proto bpf_redirect_proto = {
1839 .arg2_type = ARG_ANYTHING, 1839 .arg2_type = ARG_ANYTHING,
1840}; 1840};
1841 1841
1842BPF_CALL_3(bpf_sk_redirect_map, struct bpf_map *, map, u32, key, u64, flags) 1842BPF_CALL_4(bpf_sk_redirect_map, struct sk_buff *, skb,
1843 struct bpf_map *, map, u32, key, u64, flags)
1843{ 1844{
1844 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 1845 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
1845 1846
1846 if (unlikely(flags)) 1847 if (unlikely(flags))
1847 return SK_ABORTED; 1848 return SK_ABORTED;
1848 1849
1849 ri->ifindex = key; 1850 tcb->bpf.key = key;
1850 ri->flags = flags; 1851 tcb->bpf.flags = flags;
1851 ri->map = map; 1852 tcb->bpf.map = map;
1852 1853
1853 return SK_REDIRECT; 1854 return SK_REDIRECT;
1854} 1855}
1855 1856
1856struct sock *do_sk_redirect_map(void) 1857struct sock *do_sk_redirect_map(struct sk_buff *skb)
1857{ 1858{
1858 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 1859 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
1859 struct sock *sk = NULL; 1860 struct sock *sk = NULL;
1860 1861
1861 if (ri->map) { 1862 if (tcb->bpf.map) {
1862 sk = __sock_map_lookup_elem(ri->map, ri->ifindex); 1863 sk = __sock_map_lookup_elem(tcb->bpf.map, tcb->bpf.key);
1863 1864
1864 ri->ifindex = 0; 1865 tcb->bpf.key = 0;
1865 ri->map = NULL; 1866 tcb->bpf.map = NULL;
1866 /* we do not clear flags for future lookup */
1867 } 1867 }
1868 1868
1869 return sk; 1869 return sk;
@@ -1873,9 +1873,10 @@ static const struct bpf_func_proto bpf_sk_redirect_map_proto = {
1873 .func = bpf_sk_redirect_map, 1873 .func = bpf_sk_redirect_map,
1874 .gpl_only = false, 1874 .gpl_only = false,
1875 .ret_type = RET_INTEGER, 1875 .ret_type = RET_INTEGER,
1876 .arg1_type = ARG_CONST_MAP_PTR, 1876 .arg1_type = ARG_PTR_TO_CTX,
1877 .arg2_type = ARG_ANYTHING, 1877 .arg2_type = ARG_CONST_MAP_PTR,
1878 .arg3_type = ARG_ANYTHING, 1878 .arg3_type = ARG_ANYTHING,
1879 .arg4_type = ARG_ANYTHING,
1879}; 1880};
1880 1881
1881BPF_CALL_1(bpf_get_cgroup_classid, const struct sk_buff *, skb) 1882BPF_CALL_1(bpf_get_cgroup_classid, const struct sk_buff *, skb)
@@ -3683,7 +3684,6 @@ static bool sk_skb_is_valid_access(int off, int size,
3683{ 3684{
3684 if (type == BPF_WRITE) { 3685 if (type == BPF_WRITE) {
3685 switch (off) { 3686 switch (off) {
3686 case bpf_ctx_range(struct __sk_buff, mark):
3687 case bpf_ctx_range(struct __sk_buff, tc_index): 3687 case bpf_ctx_range(struct __sk_buff, tc_index):
3688 case bpf_ctx_range(struct __sk_buff, priority): 3688 case bpf_ctx_range(struct __sk_buff, priority):
3689 break; 3689 break;
@@ -3693,6 +3693,7 @@ static bool sk_skb_is_valid_access(int off, int size,
3693 } 3693 }
3694 3694
3695 switch (off) { 3695 switch (off) {
3696 case bpf_ctx_range(struct __sk_buff, mark):
3696 case bpf_ctx_range(struct __sk_buff, tc_classid): 3697 case bpf_ctx_range(struct __sk_buff, tc_classid):
3697 return false; 3698 return false;
3698 case bpf_ctx_range(struct __sk_buff, data): 3699 case bpf_ctx_range(struct __sk_buff, data):
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d4bcdcc68e92..5ace48926b19 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1483,7 +1483,10 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1483 [IFLA_LINKINFO] = { .type = NLA_NESTED }, 1483 [IFLA_LINKINFO] = { .type = NLA_NESTED },
1484 [IFLA_NET_NS_PID] = { .type = NLA_U32 }, 1484 [IFLA_NET_NS_PID] = { .type = NLA_U32 },
1485 [IFLA_NET_NS_FD] = { .type = NLA_U32 }, 1485 [IFLA_NET_NS_FD] = { .type = NLA_U32 },
1486 [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 }, 1486 /* IFLA_IFALIAS is a string, but policy is set to NLA_BINARY to
1487 * allow 0-length string (needed to remove an alias).
1488 */
1489 [IFLA_IFALIAS] = { .type = NLA_BINARY, .len = IFALIASZ - 1 },
1487 [IFLA_VFINFO_LIST] = {. type = NLA_NESTED }, 1490 [IFLA_VFINFO_LIST] = {. type = NLA_NESTED },
1488 [IFLA_VF_PORTS] = { .type = NLA_NESTED }, 1491 [IFLA_VF_PORTS] = { .type = NLA_NESTED },
1489 [IFLA_PORT_SELF] = { .type = NLA_NESTED }, 1492 [IFLA_PORT_SELF] = { .type = NLA_NESTED },
@@ -2093,7 +2096,7 @@ static int do_setlink(const struct sk_buff *skb,
2093 dev->tx_queue_len = orig_len; 2096 dev->tx_queue_len = orig_len;
2094 goto errout; 2097 goto errout;
2095 } 2098 }
2096 status |= DO_SETLINK_NOTIFY; 2099 status |= DO_SETLINK_MODIFIED;
2097 } 2100 }
2098 } 2101 }
2099 2102
@@ -2248,7 +2251,7 @@ static int do_setlink(const struct sk_buff *skb,
2248 2251
2249errout: 2252errout:
2250 if (status & DO_SETLINK_MODIFIED) { 2253 if (status & DO_SETLINK_MODIFIED) {
2251 if (status & DO_SETLINK_NOTIFY) 2254 if ((status & DO_SETLINK_NOTIFY) == DO_SETLINK_NOTIFY)
2252 netdev_state_change(dev); 2255 netdev_state_change(dev);
2253 2256
2254 if (err < 0) 2257 if (err < 0)
@@ -4279,13 +4282,17 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
4279 4282
4280 switch (event) { 4283 switch (event) {
4281 case NETDEV_REBOOT: 4284 case NETDEV_REBOOT:
4285 case NETDEV_CHANGEMTU:
4282 case NETDEV_CHANGEADDR: 4286 case NETDEV_CHANGEADDR:
4283 case NETDEV_CHANGENAME: 4287 case NETDEV_CHANGENAME:
4284 case NETDEV_FEAT_CHANGE: 4288 case NETDEV_FEAT_CHANGE:
4285 case NETDEV_BONDING_FAILOVER: 4289 case NETDEV_BONDING_FAILOVER:
4290 case NETDEV_POST_TYPE_CHANGE:
4286 case NETDEV_NOTIFY_PEERS: 4291 case NETDEV_NOTIFY_PEERS:
4292 case NETDEV_CHANGEUPPER:
4287 case NETDEV_RESEND_IGMP: 4293 case NETDEV_RESEND_IGMP:
4288 case NETDEV_CHANGEINFODATA: 4294 case NETDEV_CHANGEINFODATA:
4295 case NETDEV_CHANGE_TX_QUEUE_LEN:
4289 rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event), 4296 rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event),
4290 GFP_KERNEL); 4297 GFP_KERNEL);
4291 break; 4298 break;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 16982de649b9..24656076906d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1124,9 +1124,13 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
1124 1124
1125 err = __zerocopy_sg_from_iter(sk, skb, &msg->msg_iter, len); 1125 err = __zerocopy_sg_from_iter(sk, skb, &msg->msg_iter, len);
1126 if (err == -EFAULT || (err == -EMSGSIZE && skb->len == orig_len)) { 1126 if (err == -EFAULT || (err == -EMSGSIZE && skb->len == orig_len)) {
1127 struct sock *save_sk = skb->sk;
1128
1127 /* Streams do not free skb on error. Reset to prev state. */ 1129 /* Streams do not free skb on error. Reset to prev state. */
1128 msg->msg_iter = orig_iter; 1130 msg->msg_iter = orig_iter;
1131 skb->sk = sk;
1129 ___pskb_trim(skb, orig_len); 1132 ___pskb_trim(skb, orig_len);
1133 skb->sk = save_sk;
1130 return err; 1134 return err;
1131 } 1135 }
1132 1136
@@ -1896,7 +1900,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
1896 } 1900 }
1897 1901
1898 /* If we need update frag list, we are in troubles. 1902 /* If we need update frag list, we are in troubles.
1899 * Certainly, it possible to add an offset to skb data, 1903 * Certainly, it is possible to add an offset to skb data,
1900 * but taking into account that pulling is expected to 1904 * but taking into account that pulling is expected to
1901 * be very rare operation, it is worth to fight against 1905 * be very rare operation, it is worth to fight against
1902 * further bloating skb head and crucify ourselves here instead. 1906 * further bloating skb head and crucify ourselves here instead.
diff --git a/net/core/sock.c b/net/core/sock.c
index 23953b741a41..415f441c63b9 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1677,12 +1677,17 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
1677 newsk->sk_dst_pending_confirm = 0; 1677 newsk->sk_dst_pending_confirm = 0;
1678 newsk->sk_wmem_queued = 0; 1678 newsk->sk_wmem_queued = 0;
1679 newsk->sk_forward_alloc = 0; 1679 newsk->sk_forward_alloc = 0;
1680
1681 /* sk->sk_memcg will be populated at accept() time */
1682 newsk->sk_memcg = NULL;
1683
1680 atomic_set(&newsk->sk_drops, 0); 1684 atomic_set(&newsk->sk_drops, 0);
1681 newsk->sk_send_head = NULL; 1685 newsk->sk_send_head = NULL;
1682 newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK; 1686 newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;
1683 atomic_set(&newsk->sk_zckey, 0); 1687 atomic_set(&newsk->sk_zckey, 0);
1684 1688
1685 sock_reset_flag(newsk, SOCK_DONE); 1689 sock_reset_flag(newsk, SOCK_DONE);
1690 cgroup_sk_alloc(&newsk->sk_cgrp_data);
1686 1691
1687 rcu_read_lock(); 1692 rcu_read_lock();
1688 filter = rcu_dereference(sk->sk_filter); 1693 filter = rcu_dereference(sk->sk_filter);
@@ -1714,9 +1719,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
1714 newsk->sk_incoming_cpu = raw_smp_processor_id(); 1719 newsk->sk_incoming_cpu = raw_smp_processor_id();
1715 atomic64_set(&newsk->sk_cookie, 0); 1720 atomic64_set(&newsk->sk_cookie, 0);
1716 1721
1717 mem_cgroup_sk_alloc(newsk);
1718 cgroup_sk_alloc(&newsk->sk_cgrp_data);
1719
1720 /* 1722 /*
1721 * Before updating sk_refcnt, we must commit prior changes to memory 1723 * Before updating sk_refcnt, we must commit prior changes to memory
1722 * (Documentation/RCU/rculist_nulls.txt for details) 1724 * (Documentation/RCU/rculist_nulls.txt for details)
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index eed1ebf7f29d..b1e0dbea1e8c 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -36,9 +36,14 @@ int reuseport_alloc(struct sock *sk)
36 * soft irq of receive path or setsockopt from process context 36 * soft irq of receive path or setsockopt from process context
37 */ 37 */
38 spin_lock_bh(&reuseport_lock); 38 spin_lock_bh(&reuseport_lock);
39 WARN_ONCE(rcu_dereference_protected(sk->sk_reuseport_cb, 39
40 lockdep_is_held(&reuseport_lock)), 40 /* Allocation attempts can occur concurrently via the setsockopt path
41 "multiple allocations for the same socket"); 41 * and the bind/hash path. Nothing to do when we lose the race.
42 */
43 if (rcu_dereference_protected(sk->sk_reuseport_cb,
44 lockdep_is_held(&reuseport_lock)))
45 goto out;
46
42 reuse = __reuseport_alloc(INIT_SOCKS); 47 reuse = __reuseport_alloc(INIT_SOCKS);
43 if (!reuse) { 48 if (!reuse) {
44 spin_unlock_bh(&reuseport_lock); 49 spin_unlock_bh(&reuseport_lock);
@@ -49,6 +54,7 @@ int reuseport_alloc(struct sock *sk)
49 reuse->num_socks = 1; 54 reuse->num_socks = 1;
50 rcu_assign_pointer(sk->sk_reuseport_cb, reuse); 55 rcu_assign_pointer(sk->sk_reuseport_cb, reuse);
51 56
57out:
52 spin_unlock_bh(&reuseport_lock); 58 spin_unlock_bh(&reuseport_lock);
53 59
54 return 0; 60 return 0;
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 001c08696334..0490916864f9 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -414,8 +414,7 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk,
414 sk_daddr_set(newsk, ireq->ir_rmt_addr); 414 sk_daddr_set(newsk, ireq->ir_rmt_addr);
415 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); 415 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
416 newinet->inet_saddr = ireq->ir_loc_addr; 416 newinet->inet_saddr = ireq->ir_loc_addr;
417 newinet->inet_opt = ireq->opt; 417 RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt));
418 ireq->opt = NULL;
419 newinet->mc_index = inet_iif(skb); 418 newinet->mc_index = inet_iif(skb);
420 newinet->mc_ttl = ip_hdr(skb)->ttl; 419 newinet->mc_ttl = ip_hdr(skb)->ttl;
421 newinet->inet_id = jiffies; 420 newinet->inet_id = jiffies;
@@ -430,7 +429,10 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk,
430 if (__inet_inherit_port(sk, newsk) < 0) 429 if (__inet_inherit_port(sk, newsk) < 0)
431 goto put_and_exit; 430 goto put_and_exit;
432 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash)); 431 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
433 432 if (*own_req)
433 ireq->ireq_opt = NULL;
434 else
435 newinet->inet_opt = NULL;
434 return newsk; 436 return newsk;
435 437
436exit_overflow: 438exit_overflow:
@@ -441,6 +443,7 @@ exit:
441 __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS); 443 __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);
442 return NULL; 444 return NULL;
443put_and_exit: 445put_and_exit:
446 newinet->inet_opt = NULL;
444 inet_csk_prepare_forced_close(newsk); 447 inet_csk_prepare_forced_close(newsk);
445 dccp_done(newsk); 448 dccp_done(newsk);
446 goto exit; 449 goto exit;
@@ -492,7 +495,7 @@ static int dccp_v4_send_response(const struct sock *sk, struct request_sock *req
492 ireq->ir_rmt_addr); 495 ireq->ir_rmt_addr);
493 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, 496 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
494 ireq->ir_rmt_addr, 497 ireq->ir_rmt_addr,
495 ireq->opt); 498 rcu_dereference(ireq->ireq_opt));
496 err = net_xmit_eval(err); 499 err = net_xmit_eval(err);
497 } 500 }
498 501
@@ -548,7 +551,7 @@ out:
548static void dccp_v4_reqsk_destructor(struct request_sock *req) 551static void dccp_v4_reqsk_destructor(struct request_sock *req)
549{ 552{
550 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg); 553 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
551 kfree(inet_rsk(req)->opt); 554 kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
552} 555}
553 556
554void dccp_syn_ack_timeout(const struct request_sock *req) 557void dccp_syn_ack_timeout(const struct request_sock *req)
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 8737412c7b27..e1d4d898a007 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -224,7 +224,7 @@ static int dns_resolver_match_preparse(struct key_match_data *match_data)
224static void dns_resolver_describe(const struct key *key, struct seq_file *m) 224static void dns_resolver_describe(const struct key *key, struct seq_file *m)
225{ 225{
226 seq_puts(m, key->description); 226 seq_puts(m, key->description);
227 if (key_is_instantiated(key)) { 227 if (key_is_positive(key)) {
228 int err = PTR_ERR(key->payload.data[dns_key_error]); 228 int err = PTR_ERR(key->payload.data[dns_key_error]);
229 229
230 if (err) 230 if (err)
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 91a2557942fa..f48fe6fc7e8c 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -70,11 +70,9 @@ config IP_MULTIPLE_TABLES
70 address into account. Furthermore, the TOS (Type-Of-Service) field 70 address into account. Furthermore, the TOS (Type-Of-Service) field
71 of the packet can be used for routing decisions as well. 71 of the packet can be used for routing decisions as well.
72 72
73 If you are interested in this, please see the preliminary 73 If you need more information, see the Linux Advanced
74 documentation at <http://www.compendium.com.ar/policy-routing.txt> 74 Routing and Traffic Control documentation at
75 and <ftp://post.tepkom.ru/pub/vol2/Linux/docs/advanced-routing.tex>. 75 <http://lartc.org/howto/lartc.rpdb.html>
76 You will need supporting software from
77 <ftp://ftp.tux.org/pub/net/ip-routing/>.
78 76
79 If unsure, say N. 77 If unsure, say N.
80 78
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 2ae8f54cb321..82178cc69c96 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1951,7 +1951,7 @@ int cipso_v4_req_setattr(struct request_sock *req,
1951 buf = NULL; 1951 buf = NULL;
1952 1952
1953 req_inet = inet_rsk(req); 1953 req_inet = inet_rsk(req);
1954 opt = xchg(&req_inet->opt, opt); 1954 opt = xchg((__force struct ip_options_rcu **)&req_inet->ireq_opt, opt);
1955 if (opt) 1955 if (opt)
1956 kfree_rcu(opt, rcu); 1956 kfree_rcu(opt, rcu);
1957 1957
@@ -1973,11 +1973,13 @@ req_setattr_failure:
1973 * values on failure. 1973 * values on failure.
1974 * 1974 *
1975 */ 1975 */
1976static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr) 1976static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr)
1977{ 1977{
1978 struct ip_options_rcu *opt = rcu_dereference_protected(*opt_ptr, 1);
1978 int hdr_delta = 0; 1979 int hdr_delta = 0;
1979 struct ip_options_rcu *opt = *opt_ptr;
1980 1980
1981 if (!opt || opt->opt.cipso == 0)
1982 return 0;
1981 if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) { 1983 if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) {
1982 u8 cipso_len; 1984 u8 cipso_len;
1983 u8 cipso_off; 1985 u8 cipso_off;
@@ -2039,14 +2041,10 @@ static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr)
2039 */ 2041 */
2040void cipso_v4_sock_delattr(struct sock *sk) 2042void cipso_v4_sock_delattr(struct sock *sk)
2041{ 2043{
2042 int hdr_delta;
2043 struct ip_options_rcu *opt;
2044 struct inet_sock *sk_inet; 2044 struct inet_sock *sk_inet;
2045 int hdr_delta;
2045 2046
2046 sk_inet = inet_sk(sk); 2047 sk_inet = inet_sk(sk);
2047 opt = rcu_dereference_protected(sk_inet->inet_opt, 1);
2048 if (!opt || opt->opt.cipso == 0)
2049 return;
2050 2048
2051 hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt); 2049 hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);
2052 if (sk_inet->is_icsk && hdr_delta > 0) { 2050 if (sk_inet->is_icsk && hdr_delta > 0) {
@@ -2066,15 +2064,7 @@ void cipso_v4_sock_delattr(struct sock *sk)
2066 */ 2064 */
2067void cipso_v4_req_delattr(struct request_sock *req) 2065void cipso_v4_req_delattr(struct request_sock *req)
2068{ 2066{
2069 struct ip_options_rcu *opt; 2067 cipso_v4_delopt(&inet_rsk(req)->ireq_opt);
2070 struct inet_request_sock *req_inet;
2071
2072 req_inet = inet_rsk(req);
2073 opt = req_inet->opt;
2074 if (!opt || opt->opt.cipso == 0)
2075 return;
2076
2077 cipso_v4_delopt(&req_inet->opt);
2078} 2068}
2079 2069
2080/** 2070/**
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index c039c937ba90..5ec9136a7c36 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -475,6 +475,7 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
475 } 475 }
476 spin_unlock_bh(&queue->fastopenq.lock); 476 spin_unlock_bh(&queue->fastopenq.lock);
477 } 477 }
478 mem_cgroup_sk_alloc(newsk);
478out: 479out:
479 release_sock(sk); 480 release_sock(sk);
480 if (req) 481 if (req)
@@ -539,9 +540,10 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk,
539{ 540{
540 const struct inet_request_sock *ireq = inet_rsk(req); 541 const struct inet_request_sock *ireq = inet_rsk(req);
541 struct net *net = read_pnet(&ireq->ireq_net); 542 struct net *net = read_pnet(&ireq->ireq_net);
542 struct ip_options_rcu *opt = ireq->opt; 543 struct ip_options_rcu *opt;
543 struct rtable *rt; 544 struct rtable *rt;
544 545
546 opt = rcu_dereference(ireq->ireq_opt);
545 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark, 547 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
546 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, 548 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
547 sk->sk_protocol, inet_sk_flowi_flags(sk), 549 sk->sk_protocol, inet_sk_flowi_flags(sk),
@@ -575,10 +577,9 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
575 struct flowi4 *fl4; 577 struct flowi4 *fl4;
576 struct rtable *rt; 578 struct rtable *rt;
577 579
580 opt = rcu_dereference(ireq->ireq_opt);
578 fl4 = &newinet->cork.fl.u.ip4; 581 fl4 = &newinet->cork.fl.u.ip4;
579 582
580 rcu_read_lock();
581 opt = rcu_dereference(newinet->inet_opt);
582 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark, 583 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
583 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, 584 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
584 sk->sk_protocol, inet_sk_flowi_flags(sk), 585 sk->sk_protocol, inet_sk_flowi_flags(sk),
@@ -591,13 +592,11 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
591 goto no_route; 592 goto no_route;
592 if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway) 593 if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)
593 goto route_err; 594 goto route_err;
594 rcu_read_unlock();
595 return &rt->dst; 595 return &rt->dst;
596 596
597route_err: 597route_err:
598 ip_rt_put(rt); 598 ip_rt_put(rt);
599no_route: 599no_route:
600 rcu_read_unlock();
601 __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES); 600 __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
602 return NULL; 601 return NULL;
603} 602}
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 597bb4cfe805..e7d15fb0d94d 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -456,10 +456,7 @@ static int inet_reuseport_add_sock(struct sock *sk,
456 return reuseport_add_sock(sk, sk2); 456 return reuseport_add_sock(sk, sk2);
457 } 457 }
458 458
459 /* Initial allocation may have already happened via setsockopt */ 459 return reuseport_alloc(sk);
460 if (!rcu_access_pointer(sk->sk_reuseport_cb))
461 return reuseport_alloc(sk);
462 return 0;
463} 460}
464 461
465int __inet_hash(struct sock *sk, struct sock *osk) 462int __inet_hash(struct sock *sk, struct sock *osk)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index b1bb1b3a1082..77cf32a80952 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -355,7 +355,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
355 /* We throwed the options of the initial SYN away, so we hope 355 /* We throwed the options of the initial SYN away, so we hope
356 * the ACK carries the same options again (see RFC1122 4.2.3.8) 356 * the ACK carries the same options again (see RFC1122 4.2.3.8)
357 */ 357 */
358 ireq->opt = tcp_v4_save_options(sock_net(sk), skb); 358 RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(sock_net(sk), skb));
359 359
360 if (security_inet_conn_request(sk, skb, req)) { 360 if (security_inet_conn_request(sk, skb, req)) {
361 reqsk_free(req); 361 reqsk_free(req);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index c5d7656beeee..7eec3383702b 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6196,7 +6196,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
6196 struct inet_request_sock *ireq = inet_rsk(req); 6196 struct inet_request_sock *ireq = inet_rsk(req);
6197 6197
6198 kmemcheck_annotate_bitfield(ireq, flags); 6198 kmemcheck_annotate_bitfield(ireq, flags);
6199 ireq->opt = NULL; 6199 ireq->ireq_opt = NULL;
6200#if IS_ENABLED(CONFIG_IPV6) 6200#if IS_ENABLED(CONFIG_IPV6)
6201 ireq->pktopts = NULL; 6201 ireq->pktopts = NULL;
6202#endif 6202#endif
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 85164d4d3e53..4c43365c374c 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -877,7 +877,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst,
877 877
878 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, 878 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
879 ireq->ir_rmt_addr, 879 ireq->ir_rmt_addr,
880 ireq->opt); 880 rcu_dereference(ireq->ireq_opt));
881 err = net_xmit_eval(err); 881 err = net_xmit_eval(err);
882 } 882 }
883 883
@@ -889,7 +889,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst,
889 */ 889 */
890static void tcp_v4_reqsk_destructor(struct request_sock *req) 890static void tcp_v4_reqsk_destructor(struct request_sock *req)
891{ 891{
892 kfree(inet_rsk(req)->opt); 892 kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
893} 893}
894 894
895#ifdef CONFIG_TCP_MD5SIG 895#ifdef CONFIG_TCP_MD5SIG
@@ -1265,10 +1265,11 @@ static void tcp_v4_init_req(struct request_sock *req,
1265 struct sk_buff *skb) 1265 struct sk_buff *skb)
1266{ 1266{
1267 struct inet_request_sock *ireq = inet_rsk(req); 1267 struct inet_request_sock *ireq = inet_rsk(req);
1268 struct net *net = sock_net(sk_listener);
1268 1269
1269 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr); 1270 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
1270 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr); 1271 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
1271 ireq->opt = tcp_v4_save_options(sock_net(sk_listener), skb); 1272 RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(net, skb));
1272} 1273}
1273 1274
1274static struct dst_entry *tcp_v4_route_req(const struct sock *sk, 1275static struct dst_entry *tcp_v4_route_req(const struct sock *sk,
@@ -1355,10 +1356,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
1355 sk_daddr_set(newsk, ireq->ir_rmt_addr); 1356 sk_daddr_set(newsk, ireq->ir_rmt_addr);
1356 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); 1357 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
1357 newsk->sk_bound_dev_if = ireq->ir_iif; 1358 newsk->sk_bound_dev_if = ireq->ir_iif;
1358 newinet->inet_saddr = ireq->ir_loc_addr; 1359 newinet->inet_saddr = ireq->ir_loc_addr;
1359 inet_opt = ireq->opt; 1360 inet_opt = rcu_dereference(ireq->ireq_opt);
1360 rcu_assign_pointer(newinet->inet_opt, inet_opt); 1361 RCU_INIT_POINTER(newinet->inet_opt, inet_opt);
1361 ireq->opt = NULL;
1362 newinet->mc_index = inet_iif(skb); 1362 newinet->mc_index = inet_iif(skb);
1363 newinet->mc_ttl = ip_hdr(skb)->ttl; 1363 newinet->mc_ttl = ip_hdr(skb)->ttl;
1364 newinet->rcv_tos = ip_hdr(skb)->tos; 1364 newinet->rcv_tos = ip_hdr(skb)->tos;
@@ -1403,9 +1403,12 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
1403 if (__inet_inherit_port(sk, newsk) < 0) 1403 if (__inet_inherit_port(sk, newsk) < 0)
1404 goto put_and_exit; 1404 goto put_and_exit;
1405 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash)); 1405 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
1406 if (*own_req) 1406 if (likely(*own_req)) {
1407 tcp_move_syn(newtp, req); 1407 tcp_move_syn(newtp, req);
1408 1408 ireq->ireq_opt = NULL;
1409 } else {
1410 newinet->inet_opt = NULL;
1411 }
1409 return newsk; 1412 return newsk;
1410 1413
1411exit_overflow: 1414exit_overflow:
@@ -1416,6 +1419,7 @@ exit:
1416 tcp_listendrop(sk); 1419 tcp_listendrop(sk);
1417 return NULL; 1420 return NULL;
1418put_and_exit: 1421put_and_exit:
1422 newinet->inet_opt = NULL;
1419 inet_csk_prepare_forced_close(newsk); 1423 inet_csk_prepare_forced_close(newsk);
1420 tcp_done(newsk); 1424 tcp_done(newsk);
1421 goto exit; 1425 goto exit;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e45177ceb0ee..ebfbccae62fd 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -231,10 +231,7 @@ static int udp_reuseport_add_sock(struct sock *sk, struct udp_hslot *hslot)
231 } 231 }
232 } 232 }
233 233
234 /* Initial allocation may have already happened via setsockopt */ 234 return reuseport_alloc(sk);
235 if (!rcu_access_pointer(sk->sk_reuseport_cb))
236 return reuseport_alloc(sk);
237 return 0;
238} 235}
239 236
240/** 237/**
@@ -1061,7 +1058,7 @@ back_from_confirm:
1061 /* ... which is an evident application bug. --ANK */ 1058 /* ... which is an evident application bug. --ANK */
1062 release_sock(sk); 1059 release_sock(sk);
1063 1060
1064 net_dbg_ratelimited("cork app bug 2\n"); 1061 net_dbg_ratelimited("socket already corked\n");
1065 err = -EINVAL; 1062 err = -EINVAL;
1066 goto out; 1063 goto out;
1067 } 1064 }
@@ -1144,7 +1141,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset,
1144 if (unlikely(!up->pending)) { 1141 if (unlikely(!up->pending)) {
1145 release_sock(sk); 1142 release_sock(sk);
1146 1143
1147 net_dbg_ratelimited("udp cork app bug 3\n"); 1144 net_dbg_ratelimited("cork failed\n");
1148 return -EINVAL; 1145 return -EINVAL;
1149 } 1146 }
1150 1147
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 8081bafe441b..15535ee327c5 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -315,6 +315,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space,
315 } 315 }
316 opt_space->dst1opt = fopt->dst1opt; 316 opt_space->dst1opt = fopt->dst1opt;
317 opt_space->opt_flen = fopt->opt_flen; 317 opt_space->opt_flen = fopt->opt_flen;
318 opt_space->tot_len = fopt->tot_len;
318 return opt_space; 319 return opt_space;
319} 320}
320EXPORT_SYMBOL_GPL(fl6_merge_options); 321EXPORT_SYMBOL_GPL(fl6_merge_options);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 43ca864327c7..5110a418cc4d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1161,11 +1161,11 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
1161 if (WARN_ON(v6_cork->opt)) 1161 if (WARN_ON(v6_cork->opt))
1162 return -EINVAL; 1162 return -EINVAL;
1163 1163
1164 v6_cork->opt = kzalloc(opt->tot_len, sk->sk_allocation); 1164 v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
1165 if (unlikely(!v6_cork->opt)) 1165 if (unlikely(!v6_cork->opt))
1166 return -ENOBUFS; 1166 return -ENOBUFS;
1167 1167
1168 v6_cork->opt->tot_len = opt->tot_len; 1168 v6_cork->opt->tot_len = sizeof(*opt);
1169 v6_cork->opt->opt_flen = opt->opt_flen; 1169 v6_cork->opt->opt_flen = opt->opt_flen;
1170 v6_cork->opt->opt_nflen = opt->opt_nflen; 1170 v6_cork->opt->opt_nflen = opt->opt_nflen;
1171 1171
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index bc6e8bfc5be4..f50452b919d5 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -988,6 +988,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
988 session->name, cmd, arg); 988 session->name, cmd, arg);
989 989
990 sk = ps->sock; 990 sk = ps->sock;
991 if (!sk)
992 return -EBADR;
993
991 sock_hold(sk); 994 sock_hold(sk);
992 995
993 switch (cmd) { 996 switch (cmd) {
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index a98fc2b5e0dc..ae995c8480db 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -4,7 +4,7 @@
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net> 5 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2015 Intel Deutschland GmbH 7 * Copyright 2015-2017 Intel Deutschland GmbH
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -620,9 +620,6 @@ int ieee80211_key_link(struct ieee80211_key *key,
620 620
621 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; 621 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
622 idx = key->conf.keyidx; 622 idx = key->conf.keyidx;
623 key->local = sdata->local;
624 key->sdata = sdata;
625 key->sta = sta;
626 623
627 mutex_lock(&sdata->local->key_mtx); 624 mutex_lock(&sdata->local->key_mtx);
628 625
@@ -633,6 +630,21 @@ int ieee80211_key_link(struct ieee80211_key *key,
633 else 630 else
634 old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]); 631 old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
635 632
633 /*
634 * Silently accept key re-installation without really installing the
635 * new version of the key to avoid nonce reuse or replay issues.
636 */
637 if (old_key && key->conf.keylen == old_key->conf.keylen &&
638 !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
639 ieee80211_key_free_unused(key);
640 ret = 0;
641 goto out;
642 }
643
644 key->local = sdata->local;
645 key->sdata = sdata;
646 key->sta = sta;
647
636 increment_tailroom_need_count(sdata); 648 increment_tailroom_need_count(sdata);
637 649
638 ieee80211_key_replace(sdata, sta, pairwise, old_key, key); 650 ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -648,6 +660,7 @@ int ieee80211_key_link(struct ieee80211_key *key,
648 ret = 0; 660 ret = 0;
649 } 661 }
650 662
663 out:
651 mutex_unlock(&sdata->local->key_mtx); 664 mutex_unlock(&sdata->local->key_mtx);
652 665
653 return ret; 666 return ret;
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index af3d636534ef..d30f7bd741d0 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -286,6 +286,7 @@ struct ncsi_dev_priv {
286 struct work_struct work; /* For channel management */ 286 struct work_struct work; /* For channel management */
287 struct packet_type ptype; /* NCSI packet Rx handler */ 287 struct packet_type ptype; /* NCSI packet Rx handler */
288 struct list_head node; /* Form NCSI device list */ 288 struct list_head node; /* Form NCSI device list */
289#define NCSI_MAX_VLAN_VIDS 15
289 struct list_head vlan_vids; /* List of active VLAN IDs */ 290 struct list_head vlan_vids; /* List of active VLAN IDs */
290}; 291};
291 292
diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index 6898e7229285..f135938bf781 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -187,7 +187,7 @@ static struct ncsi_aen_handler {
187} ncsi_aen_handlers[] = { 187} ncsi_aen_handlers[] = {
188 { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc }, 188 { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },
189 { NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr }, 189 { NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr },
190 { NCSI_PKT_AEN_HNCDSC, 4, ncsi_aen_handler_hncdsc } 190 { NCSI_PKT_AEN_HNCDSC, 8, ncsi_aen_handler_hncdsc }
191}; 191};
192 192
193int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb) 193int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 3fd3c39e6278..28c42b22b748 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -189,6 +189,7 @@ static void ncsi_channel_monitor(unsigned long data)
189 struct ncsi_channel *nc = (struct ncsi_channel *)data; 189 struct ncsi_channel *nc = (struct ncsi_channel *)data;
190 struct ncsi_package *np = nc->package; 190 struct ncsi_package *np = nc->package;
191 struct ncsi_dev_priv *ndp = np->ndp; 191 struct ncsi_dev_priv *ndp = np->ndp;
192 struct ncsi_channel_mode *ncm;
192 struct ncsi_cmd_arg nca; 193 struct ncsi_cmd_arg nca;
193 bool enabled, chained; 194 bool enabled, chained;
194 unsigned int monitor_state; 195 unsigned int monitor_state;
@@ -202,11 +203,15 @@ static void ncsi_channel_monitor(unsigned long data)
202 monitor_state = nc->monitor.state; 203 monitor_state = nc->monitor.state;
203 spin_unlock_irqrestore(&nc->lock, flags); 204 spin_unlock_irqrestore(&nc->lock, flags);
204 205
205 if (!enabled || chained) 206 if (!enabled || chained) {
207 ncsi_stop_channel_monitor(nc);
206 return; 208 return;
209 }
207 if (state != NCSI_CHANNEL_INACTIVE && 210 if (state != NCSI_CHANNEL_INACTIVE &&
208 state != NCSI_CHANNEL_ACTIVE) 211 state != NCSI_CHANNEL_ACTIVE) {
212 ncsi_stop_channel_monitor(nc);
209 return; 213 return;
214 }
210 215
211 switch (monitor_state) { 216 switch (monitor_state) {
212 case NCSI_CHANNEL_MONITOR_START: 217 case NCSI_CHANNEL_MONITOR_START:
@@ -217,28 +222,28 @@ static void ncsi_channel_monitor(unsigned long data)
217 nca.type = NCSI_PKT_CMD_GLS; 222 nca.type = NCSI_PKT_CMD_GLS;
218 nca.req_flags = 0; 223 nca.req_flags = 0;
219 ret = ncsi_xmit_cmd(&nca); 224 ret = ncsi_xmit_cmd(&nca);
220 if (ret) { 225 if (ret)
221 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n", 226 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n",
222 ret); 227 ret);
223 return;
224 }
225
226 break; 228 break;
227 case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX: 229 case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:
228 break; 230 break;
229 default: 231 default:
230 if (!(ndp->flags & NCSI_DEV_HWA) && 232 if (!(ndp->flags & NCSI_DEV_HWA)) {
231 state == NCSI_CHANNEL_ACTIVE) {
232 ncsi_report_link(ndp, true); 233 ncsi_report_link(ndp, true);
233 ndp->flags |= NCSI_DEV_RESHUFFLE; 234 ndp->flags |= NCSI_DEV_RESHUFFLE;
234 } 235 }
235 236
237 ncsi_stop_channel_monitor(nc);
238
239 ncm = &nc->modes[NCSI_MODE_LINK];
236 spin_lock_irqsave(&nc->lock, flags); 240 spin_lock_irqsave(&nc->lock, flags);
237 nc->state = NCSI_CHANNEL_INVISIBLE; 241 nc->state = NCSI_CHANNEL_INVISIBLE;
242 ncm->data[2] &= ~0x1;
238 spin_unlock_irqrestore(&nc->lock, flags); 243 spin_unlock_irqrestore(&nc->lock, flags);
239 244
240 spin_lock_irqsave(&ndp->lock, flags); 245 spin_lock_irqsave(&ndp->lock, flags);
241 nc->state = NCSI_CHANNEL_INACTIVE; 246 nc->state = NCSI_CHANNEL_ACTIVE;
242 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 247 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
243 spin_unlock_irqrestore(&ndp->lock, flags); 248 spin_unlock_irqrestore(&ndp->lock, flags);
244 ncsi_process_next_channel(ndp); 249 ncsi_process_next_channel(ndp);
@@ -732,6 +737,10 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
732 if (index < 0) { 737 if (index < 0) {
733 netdev_err(ndp->ndev.dev, 738 netdev_err(ndp->ndev.dev,
734 "Failed to add new VLAN tag, error %d\n", index); 739 "Failed to add new VLAN tag, error %d\n", index);
740 if (index == -ENOSPC)
741 netdev_err(ndp->ndev.dev,
742 "Channel %u already has all VLAN filters set\n",
743 nc->id);
735 return -1; 744 return -1;
736 } 745 }
737 746
@@ -998,12 +1007,15 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
998 struct ncsi_package *np; 1007 struct ncsi_package *np;
999 struct ncsi_channel *nc; 1008 struct ncsi_channel *nc;
1000 unsigned int cap; 1009 unsigned int cap;
1010 bool has_channel = false;
1001 1011
1002 /* The hardware arbitration is disabled if any one channel 1012 /* The hardware arbitration is disabled if any one channel
1003 * doesn't support explicitly. 1013 * doesn't support explicitly.
1004 */ 1014 */
1005 NCSI_FOR_EACH_PACKAGE(ndp, np) { 1015 NCSI_FOR_EACH_PACKAGE(ndp, np) {
1006 NCSI_FOR_EACH_CHANNEL(np, nc) { 1016 NCSI_FOR_EACH_CHANNEL(np, nc) {
1017 has_channel = true;
1018
1007 cap = nc->caps[NCSI_CAP_GENERIC].cap; 1019 cap = nc->caps[NCSI_CAP_GENERIC].cap;
1008 if (!(cap & NCSI_CAP_GENERIC_HWA) || 1020 if (!(cap & NCSI_CAP_GENERIC_HWA) ||
1009 (cap & NCSI_CAP_GENERIC_HWA_MASK) != 1021 (cap & NCSI_CAP_GENERIC_HWA_MASK) !=
@@ -1014,8 +1026,13 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
1014 } 1026 }
1015 } 1027 }
1016 1028
1017 ndp->flags |= NCSI_DEV_HWA; 1029 if (has_channel) {
1018 return true; 1030 ndp->flags |= NCSI_DEV_HWA;
1031 return true;
1032 }
1033
1034 ndp->flags &= ~NCSI_DEV_HWA;
1035 return false;
1019} 1036}
1020 1037
1021static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp) 1038static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp)
@@ -1403,7 +1420,6 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
1403 1420
1404int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) 1421int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1405{ 1422{
1406 struct ncsi_channel_filter *ncf;
1407 struct ncsi_dev_priv *ndp; 1423 struct ncsi_dev_priv *ndp;
1408 unsigned int n_vids = 0; 1424 unsigned int n_vids = 0;
1409 struct vlan_vid *vlan; 1425 struct vlan_vid *vlan;
@@ -1420,7 +1436,6 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1420 } 1436 }
1421 1437
1422 ndp = TO_NCSI_DEV_PRIV(nd); 1438 ndp = TO_NCSI_DEV_PRIV(nd);
1423 ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN];
1424 1439
1425 /* Add the VLAN id to our internal list */ 1440 /* Add the VLAN id to our internal list */
1426 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { 1441 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {
@@ -1431,12 +1446,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1431 return 0; 1446 return 0;
1432 } 1447 }
1433 } 1448 }
1434 1449 if (n_vids >= NCSI_MAX_VLAN_VIDS) {
1435 if (n_vids >= ncf->total) { 1450 netdev_warn(dev,
1436 netdev_info(dev, 1451 "tried to add vlan id %u but NCSI max already registered (%u)\n",
1437 "NCSI Channel supports up to %u VLAN tags but %u are already set\n", 1452 vid, NCSI_MAX_VLAN_VIDS);
1438 ncf->total, n_vids); 1453 return -ENOSPC;
1439 return -EINVAL;
1440 } 1454 }
1441 1455
1442 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL); 1456 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index 265b9a892d41..927dad4759d1 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -959,7 +959,7 @@ static struct ncsi_rsp_handler {
959 { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf }, 959 { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf },
960 { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf }, 960 { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf },
961 { NCSI_PKT_RSP_SNFC, 4, ncsi_rsp_handler_snfc }, 961 { NCSI_PKT_RSP_SNFC, 4, ncsi_rsp_handler_snfc },
962 { NCSI_PKT_RSP_GVI, 36, ncsi_rsp_handler_gvi }, 962 { NCSI_PKT_RSP_GVI, 40, ncsi_rsp_handler_gvi },
963 { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc }, 963 { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc },
964 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp }, 964 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp },
965 { NCSI_PKT_RSP_GCPS, 172, ncsi_rsp_handler_gcps }, 965 { NCSI_PKT_RSP_GCPS, 172, ncsi_rsp_handler_gcps },
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f34750691c5c..b93148e8e9fb 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2307,6 +2307,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2307 size_t tlvlen = 0; 2307 size_t tlvlen = 0;
2308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk); 2308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
2309 unsigned int flags = 0; 2309 unsigned int flags = 0;
2310 bool nlk_has_extack = nlk->flags & NETLINK_F_EXT_ACK;
2310 2311
2311 /* Error messages get the original request appened, unless the user 2312 /* Error messages get the original request appened, unless the user
2312 * requests to cap the error message, and get extra error data if 2313 * requests to cap the error message, and get extra error data if
@@ -2317,7 +2318,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2317 payload += nlmsg_len(nlh); 2318 payload += nlmsg_len(nlh);
2318 else 2319 else
2319 flags |= NLM_F_CAPPED; 2320 flags |= NLM_F_CAPPED;
2320 if (nlk->flags & NETLINK_F_EXT_ACK && extack) { 2321 if (nlk_has_extack && extack) {
2321 if (extack->_msg) 2322 if (extack->_msg)
2322 tlvlen += nla_total_size(strlen(extack->_msg) + 1); 2323 tlvlen += nla_total_size(strlen(extack->_msg) + 1);
2323 if (extack->bad_attr) 2324 if (extack->bad_attr)
@@ -2326,8 +2327,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2326 } else { 2327 } else {
2327 flags |= NLM_F_CAPPED; 2328 flags |= NLM_F_CAPPED;
2328 2329
2329 if (nlk->flags & NETLINK_F_EXT_ACK && 2330 if (nlk_has_extack && extack && extack->cookie_len)
2330 extack && extack->cookie_len)
2331 tlvlen += nla_total_size(extack->cookie_len); 2331 tlvlen += nla_total_size(extack->cookie_len);
2332 } 2332 }
2333 2333
@@ -2355,7 +2355,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2355 errmsg->error = err; 2355 errmsg->error = err;
2356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh)); 2356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
2357 2357
2358 if (nlk->flags & NETLINK_F_EXT_ACK && extack) { 2358 if (nlk_has_extack && extack) {
2359 if (err) { 2359 if (err) {
2360 if (extack->_msg) 2360 if (extack->_msg)
2361 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG, 2361 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index bec01a3daf5b..2986941164b1 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1769,7 +1769,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
1769 1769
1770out: 1770out:
1771 if (err && rollover) { 1771 if (err && rollover) {
1772 kfree(rollover); 1772 kfree_rcu(rollover, rcu);
1773 po->rollover = NULL; 1773 po->rollover = NULL;
1774 } 1774 }
1775 mutex_unlock(&fanout_mutex); 1775 mutex_unlock(&fanout_mutex);
@@ -1796,8 +1796,10 @@ static struct packet_fanout *fanout_release(struct sock *sk)
1796 else 1796 else
1797 f = NULL; 1797 f = NULL;
1798 1798
1799 if (po->rollover) 1799 if (po->rollover) {
1800 kfree_rcu(po->rollover, rcu); 1800 kfree_rcu(po->rollover, rcu);
1801 po->rollover = NULL;
1802 }
1801 } 1803 }
1802 mutex_unlock(&fanout_mutex); 1804 mutex_unlock(&fanout_mutex);
1803 1805
@@ -3851,6 +3853,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
3851 void *data = &val; 3853 void *data = &val;
3852 union tpacket_stats_u st; 3854 union tpacket_stats_u st;
3853 struct tpacket_rollover_stats rstats; 3855 struct tpacket_rollover_stats rstats;
3856 struct packet_rollover *rollover;
3854 3857
3855 if (level != SOL_PACKET) 3858 if (level != SOL_PACKET)
3856 return -ENOPROTOOPT; 3859 return -ENOPROTOOPT;
@@ -3929,13 +3932,18 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
3929 0); 3932 0);
3930 break; 3933 break;
3931 case PACKET_ROLLOVER_STATS: 3934 case PACKET_ROLLOVER_STATS:
3932 if (!po->rollover) 3935 rcu_read_lock();
3936 rollover = rcu_dereference(po->rollover);
3937 if (rollover) {
3938 rstats.tp_all = atomic_long_read(&rollover->num);
3939 rstats.tp_huge = atomic_long_read(&rollover->num_huge);
3940 rstats.tp_failed = atomic_long_read(&rollover->num_failed);
3941 data = &rstats;
3942 lv = sizeof(rstats);
3943 }
3944 rcu_read_unlock();
3945 if (!rollover)
3933 return -EINVAL; 3946 return -EINVAL;
3934 rstats.tp_all = atomic_long_read(&po->rollover->num);
3935 rstats.tp_huge = atomic_long_read(&po->rollover->num_huge);
3936 rstats.tp_failed = atomic_long_read(&po->rollover->num_failed);
3937 data = &rstats;
3938 lv = sizeof(rstats);
3939 break; 3947 break;
3940 case PACKET_TX_HAS_OFF: 3948 case PACKET_TX_HAS_OFF:
3941 val = po->tp_tx_has_off; 3949 val = po->tp_tx_has_off;
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index fb17552fd292..4b0a8288c98a 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -308,10 +308,11 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
308 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len, 308 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len,
309 gfp); 309 gfp);
310 /* The socket has been unlocked. */ 310 /* The socket has been unlocked. */
311 if (!IS_ERR(call)) 311 if (!IS_ERR(call)) {
312 call->notify_rx = notify_rx; 312 call->notify_rx = notify_rx;
313 mutex_unlock(&call->user_mutex);
314 }
313 315
314 mutex_unlock(&call->user_mutex);
315 _leave(" = %p", call); 316 _leave(" = %p", call);
316 return call; 317 return call;
317} 318}
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index d230cb4c8094..b480d7c792ba 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -234,6 +234,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)
234 tc_cls_common_offload_init(&cls_flower.common, tp); 234 tc_cls_common_offload_init(&cls_flower.common, tp);
235 cls_flower.command = TC_CLSFLOWER_DESTROY; 235 cls_flower.command = TC_CLSFLOWER_DESTROY;
236 cls_flower.cookie = (unsigned long) f; 236 cls_flower.cookie = (unsigned long) f;
237 cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
237 238
238 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, &cls_flower); 239 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, &cls_flower);
239} 240}
@@ -289,6 +290,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
289 cls_flower.command = TC_CLSFLOWER_STATS; 290 cls_flower.command = TC_CLSFLOWER_STATS;
290 cls_flower.cookie = (unsigned long) f; 291 cls_flower.cookie = (unsigned long) f;
291 cls_flower.exts = &f->exts; 292 cls_flower.exts = &f->exts;
293 cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
292 294
293 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, 295 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,
294 &cls_flower); 296 &cls_flower);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 92a07141fd07..34f10e75f3b9 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -421,7 +421,7 @@ void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t,
421{ 421{
422 struct dst_entry *dst; 422 struct dst_entry *dst;
423 423
424 if (!t) 424 if (sock_owned_by_user(sk) || !t)
425 return; 425 return;
426 dst = sctp_transport_dst_check(t); 426 dst = sctp_transport_dst_check(t);
427 if (dst) 427 if (dst)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d4730ada7f32..17841ab30798 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4906,6 +4906,10 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
4906 struct socket *sock; 4906 struct socket *sock;
4907 int err = 0; 4907 int err = 0;
4908 4908
4909 /* Do not peel off from one netns to another one. */
4910 if (!net_eq(current->nsproxy->net_ns, sock_net(sk)))
4911 return -EINVAL;
4912
4909 if (!asoc) 4913 if (!asoc)
4910 return -EINVAL; 4914 return -EINVAL;
4911 4915
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index 14ed5a344cdf..e21991fe883a 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -310,11 +310,15 @@ static void hvs_close_connection(struct vmbus_channel *chan)
310 struct sock *sk = get_per_channel_state(chan); 310 struct sock *sk = get_per_channel_state(chan);
311 struct vsock_sock *vsk = vsock_sk(sk); 311 struct vsock_sock *vsk = vsock_sk(sk);
312 312
313 lock_sock(sk);
314
313 sk->sk_state = SS_UNCONNECTED; 315 sk->sk_state = SS_UNCONNECTED;
314 sock_set_flag(sk, SOCK_DONE); 316 sock_set_flag(sk, SOCK_DONE);
315 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN; 317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN;
316 318
317 sk->sk_state_change(sk); 319 sk->sk_state_change(sk);
320
321 release_sock(sk);
318} 322}
319 323
320static void hvs_open_connection(struct vmbus_channel *chan) 324static void hvs_open_connection(struct vmbus_channel *chan)
@@ -344,6 +348,8 @@ static void hvs_open_connection(struct vmbus_channel *chan)
344 if (!sk) 348 if (!sk)
345 return; 349 return;
346 350
351 lock_sock(sk);
352
347 if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) || 353 if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) ||
348 (!conn_from_host && sk->sk_state != SS_CONNECTING)) 354 (!conn_from_host && sk->sk_state != SS_CONNECTING))
349 goto out; 355 goto out;
@@ -395,9 +401,7 @@ static void hvs_open_connection(struct vmbus_channel *chan)
395 401
396 vsock_insert_connected(vnew); 402 vsock_insert_connected(vnew);
397 403
398 lock_sock(sk);
399 vsock_enqueue_accept(sk, new); 404 vsock_enqueue_accept(sk, new);
400 release_sock(sk);
401 } else { 405 } else {
402 sk->sk_state = SS_CONNECTED; 406 sk->sk_state = SS_CONNECTED;
403 sk->sk_socket->state = SS_CONNECTED; 407 sk->sk_socket->state = SS_CONNECTED;
@@ -410,6 +414,8 @@ static void hvs_open_connection(struct vmbus_channel *chan)
410out: 414out:
411 /* Release refcnt obtained when we called vsock_find_bound_socket() */ 415 /* Release refcnt obtained when we called vsock_find_bound_socket() */
412 sock_put(sk); 416 sock_put(sk);
417
418 release_sock(sk);
413} 419}
414 420
415static u32 hvs_get_local_cid(void) 421static u32 hvs_get_local_cid(void)
@@ -476,13 +482,21 @@ out:
476 482
477static void hvs_release(struct vsock_sock *vsk) 483static void hvs_release(struct vsock_sock *vsk)
478{ 484{
485 struct sock *sk = sk_vsock(vsk);
479 struct hvsock *hvs = vsk->trans; 486 struct hvsock *hvs = vsk->trans;
480 struct vmbus_channel *chan = hvs->chan; 487 struct vmbus_channel *chan;
481 488
489 lock_sock(sk);
490
491 sk->sk_state = SS_DISCONNECTING;
492 vsock_remove_sock(vsk);
493
494 release_sock(sk);
495
496 chan = hvs->chan;
482 if (chan) 497 if (chan)
483 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN); 498 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN);
484 499
485 vsock_remove_sock(vsk);
486} 500}
487 501
488static void hvs_destruct(struct vsock_sock *vsk) 502static void hvs_destruct(struct vsock_sock *vsk)
diff --git a/samples/sockmap/sockmap_kern.c b/samples/sockmap/sockmap_kern.c
index f9b38ef82dc2..52b0053274f4 100644
--- a/samples/sockmap/sockmap_kern.c
+++ b/samples/sockmap/sockmap_kern.c
@@ -62,7 +62,7 @@ int bpf_prog2(struct __sk_buff *skb)
62 ret = 1; 62 ret = 1;
63 63
64 bpf_printk("sockmap: %d -> %d @ %d\n", lport, bpf_ntohl(rport), ret); 64 bpf_printk("sockmap: %d -> %d @ %d\n", lport, bpf_ntohl(rport), ret);
65 return bpf_sk_redirect_map(&sock_map, ret, 0); 65 return bpf_sk_redirect_map(skb, &sock_map, ret, 0);
66} 66}
67 67
68SEC("sockops") 68SEC("sockops")
diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c
index bc7fcf010a5b..446beb7ac48d 100644
--- a/samples/trace_events/trace-events-sample.c
+++ b/samples/trace_events/trace-events-sample.c
@@ -78,29 +78,37 @@ static int simple_thread_fn(void *arg)
78} 78}
79 79
80static DEFINE_MUTEX(thread_mutex); 80static DEFINE_MUTEX(thread_mutex);
81static bool simple_thread_cnt;
81 82
82int foo_bar_reg(void) 83int foo_bar_reg(void)
83{ 84{
85 mutex_lock(&thread_mutex);
86 if (simple_thread_cnt++)
87 goto out;
88
84 pr_info("Starting thread for foo_bar_fn\n"); 89 pr_info("Starting thread for foo_bar_fn\n");
85 /* 90 /*
86 * We shouldn't be able to start a trace when the module is 91 * We shouldn't be able to start a trace when the module is
87 * unloading (there's other locks to prevent that). But 92 * unloading (there's other locks to prevent that). But
88 * for consistency sake, we still take the thread_mutex. 93 * for consistency sake, we still take the thread_mutex.
89 */ 94 */
90 mutex_lock(&thread_mutex);
91 simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn"); 95 simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn");
96 out:
92 mutex_unlock(&thread_mutex); 97 mutex_unlock(&thread_mutex);
93 return 0; 98 return 0;
94} 99}
95 100
96void foo_bar_unreg(void) 101void foo_bar_unreg(void)
97{ 102{
98 pr_info("Killing thread for foo_bar_fn\n");
99 /* protect against module unloading */
100 mutex_lock(&thread_mutex); 103 mutex_lock(&thread_mutex);
104 if (--simple_thread_cnt)
105 goto out;
106
107 pr_info("Killing thread for foo_bar_fn\n");
101 if (simple_tsk_fn) 108 if (simple_tsk_fn)
102 kthread_stop(simple_tsk_fn); 109 kthread_stop(simple_tsk_fn);
103 simple_tsk_fn = NULL; 110 simple_tsk_fn = NULL;
111 out:
104 mutex_unlock(&thread_mutex); 112 mutex_unlock(&thread_mutex);
105} 113}
106 114
diff --git a/security/commoncap.c b/security/commoncap.c
index c25e0d27537f..fc46f5b85251 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -585,13 +585,14 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
585 struct vfs_ns_cap_data data, *nscaps = &data; 585 struct vfs_ns_cap_data data, *nscaps = &data;
586 struct vfs_cap_data *caps = (struct vfs_cap_data *) &data; 586 struct vfs_cap_data *caps = (struct vfs_cap_data *) &data;
587 kuid_t rootkuid; 587 kuid_t rootkuid;
588 struct user_namespace *fs_ns = inode->i_sb->s_user_ns; 588 struct user_namespace *fs_ns;
589 589
590 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); 590 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
591 591
592 if (!inode) 592 if (!inode)
593 return -ENODATA; 593 return -ENODATA;
594 594
595 fs_ns = inode->i_sb->s_user_ns;
595 size = __vfs_getxattr((struct dentry *)dentry, inode, 596 size = __vfs_getxattr((struct dentry *)dentry, inode,
596 XATTR_NAME_CAPS, &data, XATTR_CAPS_SZ); 597 XATTR_NAME_CAPS, &data, XATTR_CAPS_SZ);
597 if (size == -ENODATA || size == -EOPNOTSUPP) 598 if (size == -ENODATA || size == -EOPNOTSUPP)
diff --git a/security/keys/Kconfig b/security/keys/Kconfig
index 91eafada3164..6462e6654ccf 100644
--- a/security/keys/Kconfig
+++ b/security/keys/Kconfig
@@ -45,6 +45,7 @@ config BIG_KEYS
45 bool "Large payload keys" 45 bool "Large payload keys"
46 depends on KEYS 46 depends on KEYS
47 depends on TMPFS 47 depends on TMPFS
48 select CRYPTO
48 select CRYPTO_AES 49 select CRYPTO_AES
49 select CRYPTO_GCM 50 select CRYPTO_GCM
50 help 51 help
diff --git a/security/keys/big_key.c b/security/keys/big_key.c
index e607830b6154..929e14978c42 100644
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -247,7 +247,7 @@ void big_key_revoke(struct key *key)
247 247
248 /* clear the quota */ 248 /* clear the quota */
249 key_payload_reserve(key, 0); 249 key_payload_reserve(key, 0);
250 if (key_is_instantiated(key) && 250 if (key_is_positive(key) &&
251 (size_t)key->payload.data[big_key_len] > BIG_KEY_FILE_THRESHOLD) 251 (size_t)key->payload.data[big_key_len] > BIG_KEY_FILE_THRESHOLD)
252 vfs_truncate(path, 0); 252 vfs_truncate(path, 0);
253} 253}
@@ -279,7 +279,7 @@ void big_key_describe(const struct key *key, struct seq_file *m)
279 279
280 seq_puts(m, key->description); 280 seq_puts(m, key->description);
281 281
282 if (key_is_instantiated(key)) 282 if (key_is_positive(key))
283 seq_printf(m, ": %zu [%s]", 283 seq_printf(m, ": %zu [%s]",
284 datalen, 284 datalen,
285 datalen > BIG_KEY_FILE_THRESHOLD ? "file" : "buff"); 285 datalen > BIG_KEY_FILE_THRESHOLD ? "file" : "buff");
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index 69855ba0d3b3..d92cbf9687c3 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -309,6 +309,13 @@ static struct key *request_user_key(const char *master_desc, const u8 **master_k
309 309
310 down_read(&ukey->sem); 310 down_read(&ukey->sem);
311 upayload = user_key_payload_locked(ukey); 311 upayload = user_key_payload_locked(ukey);
312 if (!upayload) {
313 /* key was revoked before we acquired its semaphore */
314 up_read(&ukey->sem);
315 key_put(ukey);
316 ukey = ERR_PTR(-EKEYREVOKED);
317 goto error;
318 }
312 *master_key = upayload->data; 319 *master_key = upayload->data;
313 *master_keylen = upayload->datalen; 320 *master_keylen = upayload->datalen;
314error: 321error:
@@ -847,7 +854,7 @@ static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)
847 size_t datalen = prep->datalen; 854 size_t datalen = prep->datalen;
848 int ret = 0; 855 int ret = 0;
849 856
850 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) 857 if (key_is_negative(key))
851 return -ENOKEY; 858 return -ENOKEY;
852 if (datalen <= 0 || datalen > 32767 || !prep->data) 859 if (datalen <= 0 || datalen > 32767 || !prep->data)
853 return -EINVAL; 860 return -EINVAL;
diff --git a/security/keys/gc.c b/security/keys/gc.c
index 87cb260e4890..f01d48cb3de1 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -129,15 +129,15 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
129 while (!list_empty(keys)) { 129 while (!list_empty(keys)) {
130 struct key *key = 130 struct key *key =
131 list_entry(keys->next, struct key, graveyard_link); 131 list_entry(keys->next, struct key, graveyard_link);
132 short state = key->state;
133
132 list_del(&key->graveyard_link); 134 list_del(&key->graveyard_link);
133 135
134 kdebug("- %u", key->serial); 136 kdebug("- %u", key->serial);
135 key_check(key); 137 key_check(key);
136 138
137 /* Throw away the key data if the key is instantiated */ 139 /* Throw away the key data if the key is instantiated */
138 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && 140 if (state == KEY_IS_POSITIVE && key->type->destroy)
139 !test_bit(KEY_FLAG_NEGATIVE, &key->flags) &&
140 key->type->destroy)
141 key->type->destroy(key); 141 key->type->destroy(key);
142 142
143 security_key_free(key); 143 security_key_free(key);
@@ -151,7 +151,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
151 } 151 }
152 152
153 atomic_dec(&key->user->nkeys); 153 atomic_dec(&key->user->nkeys);
154 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) 154 if (state != KEY_IS_UNINSTANTIATED)
155 atomic_dec(&key->user->nikeys); 155 atomic_dec(&key->user->nikeys);
156 156
157 key_user_put(key->user); 157 key_user_put(key->user);
diff --git a/security/keys/key.c b/security/keys/key.c
index eb914a838840..83bf4b4afd49 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -402,6 +402,18 @@ int key_payload_reserve(struct key *key, size_t datalen)
402EXPORT_SYMBOL(key_payload_reserve); 402EXPORT_SYMBOL(key_payload_reserve);
403 403
404/* 404/*
405 * Change the key state to being instantiated.
406 */
407static void mark_key_instantiated(struct key *key, int reject_error)
408{
409 /* Commit the payload before setting the state; barrier versus
410 * key_read_state().
411 */
412 smp_store_release(&key->state,
413 (reject_error < 0) ? reject_error : KEY_IS_POSITIVE);
414}
415
416/*
405 * Instantiate a key and link it into the target keyring atomically. Must be 417 * Instantiate a key and link it into the target keyring atomically. Must be
406 * called with the target keyring's semaphore writelocked. The target key's 418 * called with the target keyring's semaphore writelocked. The target key's
407 * semaphore need not be locked as instantiation is serialised by 419 * semaphore need not be locked as instantiation is serialised by
@@ -424,14 +436,14 @@ static int __key_instantiate_and_link(struct key *key,
424 mutex_lock(&key_construction_mutex); 436 mutex_lock(&key_construction_mutex);
425 437
426 /* can't instantiate twice */ 438 /* can't instantiate twice */
427 if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { 439 if (key->state == KEY_IS_UNINSTANTIATED) {
428 /* instantiate the key */ 440 /* instantiate the key */
429 ret = key->type->instantiate(key, prep); 441 ret = key->type->instantiate(key, prep);
430 442
431 if (ret == 0) { 443 if (ret == 0) {
432 /* mark the key as being instantiated */ 444 /* mark the key as being instantiated */
433 atomic_inc(&key->user->nikeys); 445 atomic_inc(&key->user->nikeys);
434 set_bit(KEY_FLAG_INSTANTIATED, &key->flags); 446 mark_key_instantiated(key, 0);
435 447
436 if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) 448 if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags))
437 awaken = 1; 449 awaken = 1;
@@ -577,13 +589,10 @@ int key_reject_and_link(struct key *key,
577 mutex_lock(&key_construction_mutex); 589 mutex_lock(&key_construction_mutex);
578 590
579 /* can't instantiate twice */ 591 /* can't instantiate twice */
580 if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { 592 if (key->state == KEY_IS_UNINSTANTIATED) {
581 /* mark the key as being negatively instantiated */ 593 /* mark the key as being negatively instantiated */
582 atomic_inc(&key->user->nikeys); 594 atomic_inc(&key->user->nikeys);
583 key->reject_error = -error; 595 mark_key_instantiated(key, -error);
584 smp_wmb();
585 set_bit(KEY_FLAG_NEGATIVE, &key->flags);
586 set_bit(KEY_FLAG_INSTANTIATED, &key->flags);
587 now = current_kernel_time(); 596 now = current_kernel_time();
588 key->expiry = now.tv_sec + timeout; 597 key->expiry = now.tv_sec + timeout;
589 key_schedule_gc(key->expiry + key_gc_delay); 598 key_schedule_gc(key->expiry + key_gc_delay);
@@ -752,8 +761,8 @@ static inline key_ref_t __key_update(key_ref_t key_ref,
752 761
753 ret = key->type->update(key, prep); 762 ret = key->type->update(key, prep);
754 if (ret == 0) 763 if (ret == 0)
755 /* updating a negative key instantiates it */ 764 /* Updating a negative key positively instantiates it */
756 clear_bit(KEY_FLAG_NEGATIVE, &key->flags); 765 mark_key_instantiated(key, 0);
757 766
758 up_write(&key->sem); 767 up_write(&key->sem);
759 768
@@ -936,6 +945,16 @@ error:
936 */ 945 */
937 __key_link_end(keyring, &index_key, edit); 946 __key_link_end(keyring, &index_key, edit);
938 947
948 key = key_ref_to_ptr(key_ref);
949 if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) {
950 ret = wait_for_key_construction(key, true);
951 if (ret < 0) {
952 key_ref_put(key_ref);
953 key_ref = ERR_PTR(ret);
954 goto error_free_prep;
955 }
956 }
957
939 key_ref = __key_update(key_ref, &prep); 958 key_ref = __key_update(key_ref, &prep);
940 goto error_free_prep; 959 goto error_free_prep;
941} 960}
@@ -986,8 +1005,8 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen)
986 1005
987 ret = key->type->update(key, &prep); 1006 ret = key->type->update(key, &prep);
988 if (ret == 0) 1007 if (ret == 0)
989 /* updating a negative key instantiates it */ 1008 /* Updating a negative key positively instantiates it */
990 clear_bit(KEY_FLAG_NEGATIVE, &key->flags); 1009 mark_key_instantiated(key, 0);
991 1010
992 up_write(&key->sem); 1011 up_write(&key->sem);
993 1012
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 365ff85d7e27..76d22f726ae4 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -766,10 +766,9 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
766 766
767 key = key_ref_to_ptr(key_ref); 767 key = key_ref_to_ptr(key_ref);
768 768
769 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { 769 ret = key_read_state(key);
770 ret = -ENOKEY; 770 if (ret < 0)
771 goto error2; 771 goto error2; /* Negatively instantiated */
772 }
773 772
774 /* see if we can read it directly */ 773 /* see if we can read it directly */
775 ret = key_permission(key_ref, KEY_NEED_READ); 774 ret = key_permission(key_ref, KEY_NEED_READ);
@@ -901,7 +900,7 @@ long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group)
901 atomic_dec(&key->user->nkeys); 900 atomic_dec(&key->user->nkeys);
902 atomic_inc(&newowner->nkeys); 901 atomic_inc(&newowner->nkeys);
903 902
904 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { 903 if (key->state != KEY_IS_UNINSTANTIATED) {
905 atomic_dec(&key->user->nikeys); 904 atomic_dec(&key->user->nikeys);
906 atomic_inc(&newowner->nikeys); 905 atomic_inc(&newowner->nikeys);
907 } 906 }
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 4fa82a8a9c0e..a7e51f793867 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -414,7 +414,7 @@ static void keyring_describe(const struct key *keyring, struct seq_file *m)
414 else 414 else
415 seq_puts(m, "[anon]"); 415 seq_puts(m, "[anon]");
416 416
417 if (key_is_instantiated(keyring)) { 417 if (key_is_positive(keyring)) {
418 if (keyring->keys.nr_leaves_on_tree != 0) 418 if (keyring->keys.nr_leaves_on_tree != 0)
419 seq_printf(m, ": %lu", keyring->keys.nr_leaves_on_tree); 419 seq_printf(m, ": %lu", keyring->keys.nr_leaves_on_tree);
420 else 420 else
@@ -553,7 +553,8 @@ static int keyring_search_iterator(const void *object, void *iterator_data)
553{ 553{
554 struct keyring_search_context *ctx = iterator_data; 554 struct keyring_search_context *ctx = iterator_data;
555 const struct key *key = keyring_ptr_to_key(object); 555 const struct key *key = keyring_ptr_to_key(object);
556 unsigned long kflags = key->flags; 556 unsigned long kflags = READ_ONCE(key->flags);
557 short state = READ_ONCE(key->state);
557 558
558 kenter("{%d}", key->serial); 559 kenter("{%d}", key->serial);
559 560
@@ -565,6 +566,8 @@ static int keyring_search_iterator(const void *object, void *iterator_data)
565 566
566 /* skip invalidated, revoked and expired keys */ 567 /* skip invalidated, revoked and expired keys */
567 if (ctx->flags & KEYRING_SEARCH_DO_STATE_CHECK) { 568 if (ctx->flags & KEYRING_SEARCH_DO_STATE_CHECK) {
569 time_t expiry = READ_ONCE(key->expiry);
570
568 if (kflags & ((1 << KEY_FLAG_INVALIDATED) | 571 if (kflags & ((1 << KEY_FLAG_INVALIDATED) |
569 (1 << KEY_FLAG_REVOKED))) { 572 (1 << KEY_FLAG_REVOKED))) {
570 ctx->result = ERR_PTR(-EKEYREVOKED); 573 ctx->result = ERR_PTR(-EKEYREVOKED);
@@ -572,7 +575,7 @@ static int keyring_search_iterator(const void *object, void *iterator_data)
572 goto skipped; 575 goto skipped;
573 } 576 }
574 577
575 if (key->expiry && ctx->now.tv_sec >= key->expiry) { 578 if (expiry && ctx->now.tv_sec >= expiry) {
576 if (!(ctx->flags & KEYRING_SEARCH_SKIP_EXPIRED)) 579 if (!(ctx->flags & KEYRING_SEARCH_SKIP_EXPIRED))
577 ctx->result = ERR_PTR(-EKEYEXPIRED); 580 ctx->result = ERR_PTR(-EKEYEXPIRED);
578 kleave(" = %d [expire]", ctx->skipped_ret); 581 kleave(" = %d [expire]", ctx->skipped_ret);
@@ -597,9 +600,8 @@ static int keyring_search_iterator(const void *object, void *iterator_data)
597 600
598 if (ctx->flags & KEYRING_SEARCH_DO_STATE_CHECK) { 601 if (ctx->flags & KEYRING_SEARCH_DO_STATE_CHECK) {
599 /* we set a different error code if we pass a negative key */ 602 /* we set a different error code if we pass a negative key */
600 if (kflags & (1 << KEY_FLAG_NEGATIVE)) { 603 if (state < 0) {
601 smp_rmb(); 604 ctx->result = ERR_PTR(state);
602 ctx->result = ERR_PTR(key->reject_error);
603 kleave(" = %d [neg]", ctx->skipped_ret); 605 kleave(" = %d [neg]", ctx->skipped_ret);
604 goto skipped; 606 goto skipped;
605 } 607 }
diff --git a/security/keys/permission.c b/security/keys/permission.c
index 732cc0beffdf..a72b4dd70c8a 100644
--- a/security/keys/permission.c
+++ b/security/keys/permission.c
@@ -88,7 +88,8 @@ EXPORT_SYMBOL(key_task_permission);
88 */ 88 */
89int key_validate(const struct key *key) 89int key_validate(const struct key *key)
90{ 90{
91 unsigned long flags = key->flags; 91 unsigned long flags = READ_ONCE(key->flags);
92 time_t expiry = READ_ONCE(key->expiry);
92 93
93 if (flags & (1 << KEY_FLAG_INVALIDATED)) 94 if (flags & (1 << KEY_FLAG_INVALIDATED))
94 return -ENOKEY; 95 return -ENOKEY;
@@ -99,9 +100,9 @@ int key_validate(const struct key *key)
99 return -EKEYREVOKED; 100 return -EKEYREVOKED;
100 101
101 /* check it hasn't expired */ 102 /* check it hasn't expired */
102 if (key->expiry) { 103 if (expiry) {
103 struct timespec now = current_kernel_time(); 104 struct timespec now = current_kernel_time();
104 if (now.tv_sec >= key->expiry) 105 if (now.tv_sec >= expiry)
105 return -EKEYEXPIRED; 106 return -EKEYEXPIRED;
106 } 107 }
107 108
diff --git a/security/keys/proc.c b/security/keys/proc.c
index de834309d100..6d1fcbba1e09 100644
--- a/security/keys/proc.c
+++ b/security/keys/proc.c
@@ -179,9 +179,12 @@ static int proc_keys_show(struct seq_file *m, void *v)
179 struct rb_node *_p = v; 179 struct rb_node *_p = v;
180 struct key *key = rb_entry(_p, struct key, serial_node); 180 struct key *key = rb_entry(_p, struct key, serial_node);
181 struct timespec now; 181 struct timespec now;
182 time_t expiry;
182 unsigned long timo; 183 unsigned long timo;
184 unsigned long flags;
183 key_ref_t key_ref, skey_ref; 185 key_ref_t key_ref, skey_ref;
184 char xbuf[16]; 186 char xbuf[16];
187 short state;
185 int rc; 188 int rc;
186 189
187 struct keyring_search_context ctx = { 190 struct keyring_search_context ctx = {
@@ -217,12 +220,13 @@ static int proc_keys_show(struct seq_file *m, void *v)
217 rcu_read_lock(); 220 rcu_read_lock();
218 221
219 /* come up with a suitable timeout value */ 222 /* come up with a suitable timeout value */
220 if (key->expiry == 0) { 223 expiry = READ_ONCE(key->expiry);
224 if (expiry == 0) {
221 memcpy(xbuf, "perm", 5); 225 memcpy(xbuf, "perm", 5);
222 } else if (now.tv_sec >= key->expiry) { 226 } else if (now.tv_sec >= expiry) {
223 memcpy(xbuf, "expd", 5); 227 memcpy(xbuf, "expd", 5);
224 } else { 228 } else {
225 timo = key->expiry - now.tv_sec; 229 timo = expiry - now.tv_sec;
226 230
227 if (timo < 60) 231 if (timo < 60)
228 sprintf(xbuf, "%lus", timo); 232 sprintf(xbuf, "%lus", timo);
@@ -236,18 +240,21 @@ static int proc_keys_show(struct seq_file *m, void *v)
236 sprintf(xbuf, "%luw", timo / (60*60*24*7)); 240 sprintf(xbuf, "%luw", timo / (60*60*24*7));
237 } 241 }
238 242
239#define showflag(KEY, LETTER, FLAG) \ 243 state = key_read_state(key);
240 (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-')
241 244
245#define showflag(FLAGS, LETTER, FLAG) \
246 ((FLAGS & (1 << FLAG)) ? LETTER : '-')
247
248 flags = READ_ONCE(key->flags);
242 seq_printf(m, "%08x %c%c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ", 249 seq_printf(m, "%08x %c%c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ",
243 key->serial, 250 key->serial,
244 showflag(key, 'I', KEY_FLAG_INSTANTIATED), 251 state != KEY_IS_UNINSTANTIATED ? 'I' : '-',
245 showflag(key, 'R', KEY_FLAG_REVOKED), 252 showflag(flags, 'R', KEY_FLAG_REVOKED),
246 showflag(key, 'D', KEY_FLAG_DEAD), 253 showflag(flags, 'D', KEY_FLAG_DEAD),
247 showflag(key, 'Q', KEY_FLAG_IN_QUOTA), 254 showflag(flags, 'Q', KEY_FLAG_IN_QUOTA),
248 showflag(key, 'U', KEY_FLAG_USER_CONSTRUCT), 255 showflag(flags, 'U', KEY_FLAG_USER_CONSTRUCT),
249 showflag(key, 'N', KEY_FLAG_NEGATIVE), 256 state < 0 ? 'N' : '-',
250 showflag(key, 'i', KEY_FLAG_INVALIDATED), 257 showflag(flags, 'i', KEY_FLAG_INVALIDATED),
251 refcount_read(&key->usage), 258 refcount_read(&key->usage),
252 xbuf, 259 xbuf,
253 key->perm, 260 key->perm,
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 293d3598153b..740affd65ee9 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -730,7 +730,7 @@ try_again:
730 730
731 ret = -EIO; 731 ret = -EIO;
732 if (!(lflags & KEY_LOOKUP_PARTIAL) && 732 if (!(lflags & KEY_LOOKUP_PARTIAL) &&
733 !test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) 733 key_read_state(key) == KEY_IS_UNINSTANTIATED)
734 goto invalid_key; 734 goto invalid_key;
735 735
736 /* check the permissions */ 736 /* check the permissions */
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 63e63a42db3c..e8036cd0ad54 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -595,10 +595,9 @@ int wait_for_key_construction(struct key *key, bool intr)
595 intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); 595 intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
596 if (ret) 596 if (ret)
597 return -ERESTARTSYS; 597 return -ERESTARTSYS;
598 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { 598 ret = key_read_state(key);
599 smp_rmb(); 599 if (ret < 0)
600 return key->reject_error; 600 return ret;
601 }
602 return key_validate(key); 601 return key_validate(key);
603} 602}
604EXPORT_SYMBOL(wait_for_key_construction); 603EXPORT_SYMBOL(wait_for_key_construction);
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index 6ebf1af8fce9..424e1d90412e 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -73,7 +73,7 @@ static void request_key_auth_describe(const struct key *key,
73 73
74 seq_puts(m, "key:"); 74 seq_puts(m, "key:");
75 seq_puts(m, key->description); 75 seq_puts(m, key->description);
76 if (key_is_instantiated(key)) 76 if (key_is_positive(key))
77 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); 77 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len);
78} 78}
79 79
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index ddfaebf60fc8..bd85315cbfeb 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -1066,7 +1066,7 @@ static int trusted_update(struct key *key, struct key_preparsed_payload *prep)
1066 char *datablob; 1066 char *datablob;
1067 int ret = 0; 1067 int ret = 0;
1068 1068
1069 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) 1069 if (key_is_negative(key))
1070 return -ENOKEY; 1070 return -ENOKEY;
1071 p = key->payload.data[0]; 1071 p = key->payload.data[0];
1072 if (!p->migratable) 1072 if (!p->migratable)
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c
index 3d8c68eba516..9f558bedba23 100644
--- a/security/keys/user_defined.c
+++ b/security/keys/user_defined.c
@@ -114,7 +114,7 @@ int user_update(struct key *key, struct key_preparsed_payload *prep)
114 114
115 /* attach the new data, displacing the old */ 115 /* attach the new data, displacing the old */
116 key->expiry = prep->expiry; 116 key->expiry = prep->expiry;
117 if (!test_bit(KEY_FLAG_NEGATIVE, &key->flags)) 117 if (key_is_positive(key))
118 zap = dereference_key_locked(key); 118 zap = dereference_key_locked(key);
119 rcu_assign_keypointer(key, prep->payload.data[0]); 119 rcu_assign_keypointer(key, prep->payload.data[0]);
120 prep->payload.data[0] = NULL; 120 prep->payload.data[0] = NULL;
@@ -162,7 +162,7 @@ EXPORT_SYMBOL_GPL(user_destroy);
162void user_describe(const struct key *key, struct seq_file *m) 162void user_describe(const struct key *key, struct seq_file *m)
163{ 163{
164 seq_puts(m, key->description); 164 seq_puts(m, key->description);
165 if (key_is_instantiated(key)) 165 if (key_is_positive(key))
166 seq_printf(m, ": %u", key->datalen); 166 seq_printf(m, ": %u", key->datalen);
167} 167}
168 168
diff --git a/sound/core/seq/seq_lock.c b/sound/core/seq/seq_lock.c
index 0ff7926a5a69..cda64b489e42 100644
--- a/sound/core/seq/seq_lock.c
+++ b/sound/core/seq/seq_lock.c
@@ -23,8 +23,6 @@
23#include <sound/core.h> 23#include <sound/core.h>
24#include "seq_lock.h" 24#include "seq_lock.h"
25 25
26#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)
27
28/* wait until all locks are released */ 26/* wait until all locks are released */
29void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line) 27void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
30{ 28{
@@ -41,5 +39,3 @@ void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
41 } 39 }
42} 40}
43EXPORT_SYMBOL(snd_use_lock_sync_helper); 41EXPORT_SYMBOL(snd_use_lock_sync_helper);
44
45#endif
diff --git a/sound/core/seq/seq_lock.h b/sound/core/seq/seq_lock.h
index 54044bc2c9ef..ac38031c370e 100644
--- a/sound/core/seq/seq_lock.h
+++ b/sound/core/seq/seq_lock.h
@@ -3,8 +3,6 @@
3 3
4#include <linux/sched.h> 4#include <linux/sched.h>
5 5
6#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)
7
8typedef atomic_t snd_use_lock_t; 6typedef atomic_t snd_use_lock_t;
9 7
10/* initialize lock */ 8/* initialize lock */
@@ -20,14 +18,4 @@ typedef atomic_t snd_use_lock_t;
20void snd_use_lock_sync_helper(snd_use_lock_t *lock, const char *file, int line); 18void snd_use_lock_sync_helper(snd_use_lock_t *lock, const char *file, int line);
21#define snd_use_lock_sync(lockp) snd_use_lock_sync_helper(lockp, __BASE_FILE__, __LINE__) 19#define snd_use_lock_sync(lockp) snd_use_lock_sync_helper(lockp, __BASE_FILE__, __LINE__)
22 20
23#else /* SMP || CONFIG_SND_DEBUG */
24
25typedef spinlock_t snd_use_lock_t; /* dummy */
26#define snd_use_lock_init(lockp) /**/
27#define snd_use_lock_use(lockp) /**/
28#define snd_use_lock_free(lockp) /**/
29#define snd_use_lock_sync(lockp) /**/
30
31#endif /* SMP || CONFIG_SND_DEBUG */
32
33#endif /* __SND_SEQ_LOCK_H */ 21#endif /* __SND_SEQ_LOCK_H */
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 6c58e6f73a01..e43af18d4383 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -484,3 +484,34 @@ void snd_ctl_sync_vmaster(struct snd_kcontrol *kcontrol, bool hook_only)
484 master->hook(master->hook_private_data, master->val); 484 master->hook(master->hook_private_data, master->val);
485} 485}
486EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster); 486EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster);
487
488/**
489 * snd_ctl_apply_vmaster_slaves - Apply function to each vmaster slave
490 * @kctl: vmaster kctl element
491 * @func: function to apply
492 * @arg: optional function argument
493 *
494 * Apply the function @func to each slave kctl of the given vmaster kctl.
495 * Returns 0 if successful, or a negative error code.
496 */
497int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
498 int (*func)(struct snd_kcontrol *, void *),
499 void *arg)
500{
501 struct link_master *master;
502 struct link_slave *slave;
503 int err;
504
505 master = snd_kcontrol_chip(kctl);
506 err = master_init(master);
507 if (err < 0)
508 return err;
509 list_for_each_entry(slave, &master->slaves, list) {
510 err = func(&slave->slave, arg);
511 if (err < 0)
512 return err;
513 }
514
515 return 0;
516}
517EXPORT_SYMBOL_GPL(snd_ctl_apply_vmaster_slaves);
diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c
index 978dc1801b3a..f6d2985b2520 100644
--- a/sound/hda/hdac_controller.c
+++ b/sound/hda/hdac_controller.c
@@ -284,6 +284,11 @@ int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus)
284 dev_dbg(bus->dev, "HDA capability ID: 0x%x\n", 284 dev_dbg(bus->dev, "HDA capability ID: 0x%x\n",
285 (cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF); 285 (cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF);
286 286
287 if (cur_cap == -1) {
288 dev_dbg(bus->dev, "Invalid capability reg read\n");
289 break;
290 }
291
287 switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) { 292 switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) {
288 case AZX_ML_CAP_ID: 293 case AZX_ML_CAP_ID:
289 dev_dbg(bus->dev, "Found ML capability\n"); 294 dev_dbg(bus->dev, "Found ML capability\n");
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 3db26c451837..a0989d231fd0 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1803,36 +1803,6 @@ static int check_slave_present(struct hda_codec *codec,
1803 return 1; 1803 return 1;
1804} 1804}
1805 1805
1806/* guess the value corresponding to 0dB */
1807static int get_kctl_0dB_offset(struct hda_codec *codec,
1808 struct snd_kcontrol *kctl, int *step_to_check)
1809{
1810 int _tlv[4];
1811 const int *tlv = NULL;
1812 int val = -1;
1813
1814 if ((kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) &&
1815 kctl->tlv.c == snd_hda_mixer_amp_tlv) {
1816 get_ctl_amp_tlv(kctl, _tlv);
1817 tlv = _tlv;
1818 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
1819 tlv = kctl->tlv.p;
1820 if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) {
1821 int step = tlv[3];
1822 step &= ~TLV_DB_SCALE_MUTE;
1823 if (!step)
1824 return -1;
1825 if (*step_to_check && *step_to_check != step) {
1826 codec_err(codec, "Mismatching dB step for vmaster slave (%d!=%d)\n",
1827- *step_to_check, step);
1828 return -1;
1829 }
1830 *step_to_check = step;
1831 val = -tlv[2] / step;
1832 }
1833 return val;
1834}
1835
1836/* call kctl->put with the given value(s) */ 1806/* call kctl->put with the given value(s) */
1837static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) 1807static int put_kctl_with_value(struct snd_kcontrol *kctl, int val)
1838{ 1808{
@@ -1847,19 +1817,58 @@ static int put_kctl_with_value(struct snd_kcontrol *kctl, int val)
1847 return 0; 1817 return 0;
1848} 1818}
1849 1819
1850/* initialize the slave volume with 0dB */ 1820struct slave_init_arg {
1851static int init_slave_0dB(struct hda_codec *codec, 1821 struct hda_codec *codec;
1852 void *data, struct snd_kcontrol *slave) 1822 int step;
1823};
1824
1825/* initialize the slave volume with 0dB via snd_ctl_apply_vmaster_slaves() */
1826static int init_slave_0dB(struct snd_kcontrol *kctl, void *_arg)
1853{ 1827{
1854 int offset = get_kctl_0dB_offset(codec, slave, data); 1828 struct slave_init_arg *arg = _arg;
1855 if (offset > 0) 1829 int _tlv[4];
1856 put_kctl_with_value(slave, offset); 1830 const int *tlv = NULL;
1831 int step;
1832 int val;
1833
1834 if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
1835 if (kctl->tlv.c != snd_hda_mixer_amp_tlv) {
1836 codec_err(arg->codec,
1837 "Unexpected TLV callback for slave %s:%d\n",
1838 kctl->id.name, kctl->id.index);
1839 return 0; /* ignore */
1840 }
1841 get_ctl_amp_tlv(kctl, _tlv);
1842 tlv = _tlv;
1843 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
1844 tlv = kctl->tlv.p;
1845
1846 if (!tlv || tlv[0] != SNDRV_CTL_TLVT_DB_SCALE)
1847 return 0;
1848
1849 step = tlv[3];
1850 step &= ~TLV_DB_SCALE_MUTE;
1851 if (!step)
1852 return 0;
1853 if (arg->step && arg->step != step) {
1854 codec_err(arg->codec,
1855 "Mismatching dB step for vmaster slave (%d!=%d)\n",
1856 arg->step, step);
1857 return 0;
1858 }
1859
1860 arg->step = step;
1861 val = -tlv[2] / step;
1862 if (val > 0) {
1863 put_kctl_with_value(kctl, val);
1864 return val;
1865 }
1866
1857 return 0; 1867 return 0;
1858} 1868}
1859 1869
1860/* unmute the slave */ 1870/* unmute the slave via snd_ctl_apply_vmaster_slaves() */
1861static int init_slave_unmute(struct hda_codec *codec, 1871static int init_slave_unmute(struct snd_kcontrol *slave, void *_arg)
1862 void *data, struct snd_kcontrol *slave)
1863{ 1872{
1864 return put_kctl_with_value(slave, 1); 1873 return put_kctl_with_value(slave, 1);
1865} 1874}
@@ -1919,9 +1928,13 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1919 /* init with master mute & zero volume */ 1928 /* init with master mute & zero volume */
1920 put_kctl_with_value(kctl, 0); 1929 put_kctl_with_value(kctl, 0);
1921 if (init_slave_vol) { 1930 if (init_slave_vol) {
1922 int step = 0; 1931 struct slave_init_arg arg = {
1923 map_slaves(codec, slaves, suffix, 1932 .codec = codec,
1924 tlv ? init_slave_0dB : init_slave_unmute, &step); 1933 .step = 0,
1934 };
1935 snd_ctl_apply_vmaster_slaves(kctl,
1936 tlv ? init_slave_0dB : init_slave_unmute,
1937 &arg);
1925 } 1938 }
1926 1939
1927 if (ctl_ret) 1940 if (ctl_ret)
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 9ddaae3784f5..4f5f18f22974 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1354,6 +1354,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1354 case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */ 1354 case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */
1355 case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */ 1355 case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */
1356 case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */ 1356 case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */
1357 case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */
1357 if (fp->altsetting == 2) 1358 if (fp->altsetting == 2)
1358 return SNDRV_PCM_FMTBIT_DSD_U32_BE; 1359 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1359 break; 1360 break;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index f90860d1f897..24b35a1fd4d6 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -569,9 +569,10 @@ union bpf_attr {
569 * @flags: reserved for future use 569 * @flags: reserved for future use
570 * Return: 0 on success or negative error code 570 * Return: 0 on success or negative error code
571 * 571 *
572 * int bpf_sk_redirect_map(map, key, flags) 572 * int bpf_sk_redirect_map(skb, map, key, flags)
573 * Redirect skb to a sock in map using key as a lookup key for the 573 * Redirect skb to a sock in map using key as a lookup key for the
574 * sock in map. 574 * sock in map.
575 * @skb: pointer to skb
575 * @map: pointer to sockmap 576 * @map: pointer to sockmap
576 * @key: key to lookup sock in map 577 * @key: key to lookup sock in map
577 * @flags: reserved for future use 578 * @flags: reserved for future use
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a0c518ecf085..c0e26ad1fa7e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -267,12 +267,13 @@ static int decode_instructions(struct objtool_file *file)
267 &insn->immediate, 267 &insn->immediate,
268 &insn->stack_op); 268 &insn->stack_op);
269 if (ret) 269 if (ret)
270 return ret; 270 goto err;
271 271
272 if (!insn->type || insn->type > INSN_LAST) { 272 if (!insn->type || insn->type > INSN_LAST) {
273 WARN_FUNC("invalid instruction type %d", 273 WARN_FUNC("invalid instruction type %d",
274 insn->sec, insn->offset, insn->type); 274 insn->sec, insn->offset, insn->type);
275 return -1; 275 ret = -1;
276 goto err;
276 } 277 }
277 278
278 hash_add(file->insn_hash, &insn->hash, insn->offset); 279 hash_add(file->insn_hash, &insn->hash, insn->offset);
@@ -296,6 +297,10 @@ static int decode_instructions(struct objtool_file *file)
296 } 297 }
297 298
298 return 0; 299 return 0;
300
301err:
302 free(insn);
303 return ret;
299} 304}
300 305
301/* 306/*
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index e397453e5a46..63526f4416ea 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into perf.data
8SYNOPSIS 8SYNOPSIS
9-------- 9--------
10[verse] 10[verse]
11'perf record' [-e <EVENT> | --event=EVENT] [-l] [-a] <command> 11'perf record' [-e <EVENT> | --event=EVENT] [-a] <command>
12'perf record' [-e <EVENT> | --event=EVENT] [-l] [-a] -- <command> [<options>] 12'perf record' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
13 13
14DESCRIPTION 14DESCRIPTION
15----------- 15-----------
diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 462fc755092e..7a84d73324e3 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -10,6 +10,9 @@
10 10
11. $(dirname $0)/lib/probe.sh 11. $(dirname $0)/lib/probe.sh
12 12
13ld=$(realpath /lib64/ld*.so.* | uniq)
14libc=$(echo $ld | sed 's/ld/libc/g')
15
13trace_libc_inet_pton_backtrace() { 16trace_libc_inet_pton_backtrace() {
14 idx=0 17 idx=0
15 expected[0]="PING.*bytes" 18 expected[0]="PING.*bytes"
@@ -18,8 +21,8 @@ trace_libc_inet_pton_backtrace() {
18 expected[3]=".*packets transmitted.*" 21 expected[3]=".*packets transmitted.*"
19 expected[4]="rtt min.*" 22 expected[4]="rtt min.*"
20 expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" 23 expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)"
21 expected[6]=".*inet_pton[[:space:]]\(/usr/lib.*/libc-[0-9]+\.[0-9]+\.so\)$" 24 expected[6]=".*inet_pton[[:space:]]\($libc\)$"
22 expected[7]="getaddrinfo[[:space:]]\(/usr/lib.*/libc-[0-9]+\.[0-9]+\.so\)$" 25 expected[7]="getaddrinfo[[:space:]]\($libc\)$"
23 expected[8]=".*\(.*/bin/ping.*\)$" 26 expected[8]=".*\(.*/bin/ping.*\)$"
24 27
25 perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do 28 perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do
@@ -35,7 +38,7 @@ trace_libc_inet_pton_backtrace() {
35} 38}
36 39
37skip_if_no_perf_probe && \ 40skip_if_no_perf_probe && \
38perf probe -q /lib64/libc-*.so inet_pton && \ 41perf probe -q $libc inet_pton && \
39trace_libc_inet_pton_backtrace 42trace_libc_inet_pton_backtrace
40err=$? 43err=$?
41rm -f ${file} 44rm -f ${file}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index ddb2c6fbdf91..db79017a6e56 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -532,7 +532,7 @@ void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
532 532
533void perf_hpp__column_unregister(struct perf_hpp_fmt *format) 533void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
534{ 534{
535 list_del(&format->list); 535 list_del_init(&format->list);
536} 536}
537 537
538void perf_hpp__cancel_cumulate(void) 538void perf_hpp__cancel_cumulate(void)
@@ -606,6 +606,13 @@ next:
606 606
607static void fmt_free(struct perf_hpp_fmt *fmt) 607static void fmt_free(struct perf_hpp_fmt *fmt)
608{ 608{
609 /*
610 * At this point fmt should be completely
611 * unhooked, if not it's a bug.
612 */
613 BUG_ON(!list_empty(&fmt->list));
614 BUG_ON(!list_empty(&fmt->sort_list));
615
609 if (fmt->free) 616 if (fmt->free)
610 fmt->free(fmt); 617 fmt->free(fmt);
611} 618}
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index c42edeac451f..dcfdafdc2f1c 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -8,6 +8,9 @@
8 8
9%{ 9%{
10#include <errno.h> 10#include <errno.h>
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <unistd.h>
11#include "../perf.h" 14#include "../perf.h"
12#include "parse-events.h" 15#include "parse-events.h"
13#include "parse-events-bison.h" 16#include "parse-events-bison.h"
@@ -53,9 +56,8 @@ static int str(yyscan_t scanner, int token)
53 return token; 56 return token;
54} 57}
55 58
56static bool isbpf(yyscan_t scanner) 59static bool isbpf_suffix(char *text)
57{ 60{
58 char *text = parse_events_get_text(scanner);
59 int len = strlen(text); 61 int len = strlen(text);
60 62
61 if (len < 2) 63 if (len < 2)
@@ -68,6 +70,17 @@ static bool isbpf(yyscan_t scanner)
68 return false; 70 return false;
69} 71}
70 72
73static bool isbpf(yyscan_t scanner)
74{
75 char *text = parse_events_get_text(scanner);
76 struct stat st;
77
78 if (!isbpf_suffix(text))
79 return false;
80
81 return stat(text, &st) == 0;
82}
83
71/* 84/*
72 * This function is called when the parser gets two kind of input: 85 * This function is called when the parser gets two kind of input:
73 * 86 *
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index a7ebd9fe8e40..76ab0709a20c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -374,6 +374,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
374 tool->mmap2 = process_event_stub; 374 tool->mmap2 = process_event_stub;
375 if (tool->comm == NULL) 375 if (tool->comm == NULL)
376 tool->comm = process_event_stub; 376 tool->comm = process_event_stub;
377 if (tool->namespaces == NULL)
378 tool->namespaces = process_event_stub;
377 if (tool->fork == NULL) 379 if (tool->fork == NULL)
378 tool->fork = process_event_stub; 380 tool->fork = process_event_stub;
379 if (tool->exit == NULL) 381 if (tool->exit == NULL)
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
index 4ba726c90870..54af60462130 100644
--- a/tools/perf/util/xyarray.h
+++ b/tools/perf/util/xyarray.h
@@ -23,12 +23,12 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
23 23
24static inline int xyarray__max_y(struct xyarray *xy) 24static inline int xyarray__max_y(struct xyarray *xy)
25{ 25{
26 return xy->max_x; 26 return xy->max_y;
27} 27}
28 28
29static inline int xyarray__max_x(struct xyarray *xy) 29static inline int xyarray__max_x(struct xyarray *xy)
30{ 30{
31 return xy->max_y; 31 return xy->max_x;
32} 32}
33 33
34#endif /* _PERF_XYARRAY_H_ */ 34#endif /* _PERF_XYARRAY_H_ */
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 0dafba2c1e7d..bd9c6b31a504 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -92,7 +92,6 @@ unsigned int do_ring_perf_limit_reasons;
92unsigned int crystal_hz; 92unsigned int crystal_hz;
93unsigned long long tsc_hz; 93unsigned long long tsc_hz;
94int base_cpu; 94int base_cpu;
95int do_migrate;
96double discover_bclk(unsigned int family, unsigned int model); 95double discover_bclk(unsigned int family, unsigned int model);
97unsigned int has_hwp; /* IA32_PM_ENABLE, IA32_HWP_CAPABILITIES */ 96unsigned int has_hwp; /* IA32_PM_ENABLE, IA32_HWP_CAPABILITIES */
98 /* IA32_HWP_REQUEST, IA32_HWP_STATUS */ 97 /* IA32_HWP_REQUEST, IA32_HWP_STATUS */
@@ -303,9 +302,6 @@ int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg
303 302
304int cpu_migrate(int cpu) 303int cpu_migrate(int cpu)
305{ 304{
306 if (!do_migrate)
307 return 0;
308
309 CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set); 305 CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set);
310 CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set); 306 CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set);
311 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) 307 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1)
@@ -5007,7 +5003,6 @@ void cmdline(int argc, char **argv)
5007 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help 5003 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help
5008 {"Joules", no_argument, 0, 'J'}, 5004 {"Joules", no_argument, 0, 'J'},
5009 {"list", no_argument, 0, 'l'}, 5005 {"list", no_argument, 0, 'l'},
5010 {"migrate", no_argument, 0, 'm'},
5011 {"out", required_argument, 0, 'o'}, 5006 {"out", required_argument, 0, 'o'},
5012 {"quiet", no_argument, 0, 'q'}, 5007 {"quiet", no_argument, 0, 'q'},
5013 {"show", required_argument, 0, 's'}, 5008 {"show", required_argument, 0, 's'},
@@ -5019,7 +5014,7 @@ void cmdline(int argc, char **argv)
5019 5014
5020 progname = argv[0]; 5015 progname = argv[0];
5021 5016
5022 while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:Jmo:qST:v", 5017 while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:v",
5023 long_options, &option_index)) != -1) { 5018 long_options, &option_index)) != -1) {
5024 switch (opt) { 5019 switch (opt) {
5025 case 'a': 5020 case 'a':
@@ -5062,9 +5057,6 @@ void cmdline(int argc, char **argv)
5062 list_header_only++; 5057 list_header_only++;
5063 quiet++; 5058 quiet++;
5064 break; 5059 break;
5065 case 'm':
5066 do_migrate = 1;
5067 break;
5068 case 'o': 5060 case 'o':
5069 outf = fopen_or_die(optarg, "w"); 5061 outf = fopen_or_die(optarg, "w");
5070 break; 5062 break;
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index 36fb9161b34a..b2e02bdcd098 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -65,7 +65,7 @@ static int (*bpf_xdp_adjust_head)(void *ctx, int offset) =
65static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval, 65static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval,
66 int optlen) = 66 int optlen) =
67 (void *) BPF_FUNC_setsockopt; 67 (void *) BPF_FUNC_setsockopt;
68static int (*bpf_sk_redirect_map)(void *map, int key, int flags) = 68static int (*bpf_sk_redirect_map)(void *ctx, void *map, int key, int flags) =
69 (void *) BPF_FUNC_sk_redirect_map; 69 (void *) BPF_FUNC_sk_redirect_map;
70static int (*bpf_sock_map_update)(void *map, void *key, void *value, 70static int (*bpf_sock_map_update)(void *map, void *key, void *value,
71 unsigned long long flags) = 71 unsigned long long flags) =
diff --git a/tools/testing/selftests/bpf/sockmap_verdict_prog.c b/tools/testing/selftests/bpf/sockmap_verdict_prog.c
index 9b99bd10807d..2cd2d552938b 100644
--- a/tools/testing/selftests/bpf/sockmap_verdict_prog.c
+++ b/tools/testing/selftests/bpf/sockmap_verdict_prog.c
@@ -61,8 +61,8 @@ int bpf_prog2(struct __sk_buff *skb)
61 bpf_printk("verdict: data[0] = redir(%u:%u)\n", map, sk); 61 bpf_printk("verdict: data[0] = redir(%u:%u)\n", map, sk);
62 62
63 if (!map) 63 if (!map)
64 return bpf_sk_redirect_map(&sock_map_rx, sk, 0); 64 return bpf_sk_redirect_map(skb, &sock_map_rx, sk, 0);
65 return bpf_sk_redirect_map(&sock_map_tx, sk, 0); 65 return bpf_sk_redirect_map(skb, &sock_map_tx, sk, 0);
66} 66}
67 67
68char _license[] SEC("license") = "GPL"; 68char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index fe3a443a1102..50ce52d2013d 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -466,7 +466,7 @@ static void test_sockmap(int tasks, void *data)
466 int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc; 466 int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc;
467 struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break; 467 struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break;
468 int ports[] = {50200, 50201, 50202, 50204}; 468 int ports[] = {50200, 50201, 50202, 50204};
469 int err, i, fd, sfd[6] = {0xdeadbeef}; 469 int err, i, fd, udp, sfd[6] = {0xdeadbeef};
470 u8 buf[20] = {0x0, 0x5, 0x3, 0x2, 0x1, 0x0}; 470 u8 buf[20] = {0x0, 0x5, 0x3, 0x2, 0x1, 0x0};
471 int parse_prog, verdict_prog; 471 int parse_prog, verdict_prog;
472 struct sockaddr_in addr; 472 struct sockaddr_in addr;
@@ -548,6 +548,16 @@ static void test_sockmap(int tasks, void *data)
548 goto out_sockmap; 548 goto out_sockmap;
549 } 549 }
550 550
551 /* Test update with unsupported UDP socket */
552 udp = socket(AF_INET, SOCK_DGRAM, 0);
553 i = 0;
554 err = bpf_map_update_elem(fd, &i, &udp, BPF_ANY);
555 if (!err) {
556 printf("Failed socket SOCK_DGRAM allowed '%i:%i'\n",
557 i, udp);
558 goto out_sockmap;
559 }
560
551 /* Test update without programs */ 561 /* Test update without programs */
552 for (i = 0; i < 6; i++) { 562 for (i = 0; i < 6; i++) {
553 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY); 563 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY);
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 26f3250bdcd2..64ae21f64489 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1130,15 +1130,27 @@ static struct bpf_test tests[] = {
1130 .errstr = "invalid bpf_context access", 1130 .errstr = "invalid bpf_context access",
1131 }, 1131 },
1132 { 1132 {
1133 "check skb->mark is writeable by SK_SKB", 1133 "invalid access of skb->mark for SK_SKB",
1134 .insns = {
1135 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
1136 offsetof(struct __sk_buff, mark)),
1137 BPF_EXIT_INSN(),
1138 },
1139 .result = REJECT,
1140 .prog_type = BPF_PROG_TYPE_SK_SKB,
1141 .errstr = "invalid bpf_context access",
1142 },
1143 {
1144 "check skb->mark is not writeable by SK_SKB",
1134 .insns = { 1145 .insns = {
1135 BPF_MOV64_IMM(BPF_REG_0, 0), 1146 BPF_MOV64_IMM(BPF_REG_0, 0),
1136 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0, 1147 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0,
1137 offsetof(struct __sk_buff, mark)), 1148 offsetof(struct __sk_buff, mark)),
1138 BPF_EXIT_INSN(), 1149 BPF_EXIT_INSN(),
1139 }, 1150 },
1140 .result = ACCEPT, 1151 .result = REJECT,
1141 .prog_type = BPF_PROG_TYPE_SK_SKB, 1152 .prog_type = BPF_PROG_TYPE_SK_SKB,
1153 .errstr = "invalid bpf_context access",
1142 }, 1154 },
1143 { 1155 {
1144 "check skb->tc_index is writeable by SK_SKB", 1156 "check skb->tc_index is writeable by SK_SKB",
@@ -6645,6 +6657,500 @@ static struct bpf_test tests[] = {
6645 .errstr = "BPF_END uses reserved fields", 6657 .errstr = "BPF_END uses reserved fields",
6646 .result = REJECT, 6658 .result = REJECT,
6647 }, 6659 },
6660 {
6661 "arithmetic ops make PTR_TO_CTX unusable",
6662 .insns = {
6663 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1,
6664 offsetof(struct __sk_buff, data) -
6665 offsetof(struct __sk_buff, mark)),
6666 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
6667 offsetof(struct __sk_buff, mark)),
6668 BPF_EXIT_INSN(),
6669 },
6670 .errstr = "dereference of modified ctx ptr R1 off=68+8, ctx+const is allowed, ctx+const+const is not",
6671 .result = REJECT,
6672 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
6673 },
6674 {
6675 "XDP pkt read, pkt_end mangling, bad access 1",
6676 .insns = {
6677 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6678 offsetof(struct xdp_md, data)),
6679 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6680 offsetof(struct xdp_md, data_end)),
6681 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6682 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6683 BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 8),
6684 BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6685 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6686 BPF_MOV64_IMM(BPF_REG_0, 0),
6687 BPF_EXIT_INSN(),
6688 },
6689 .errstr = "R1 offset is outside of the packet",
6690 .result = REJECT,
6691 .prog_type = BPF_PROG_TYPE_XDP,
6692 },
6693 {
6694 "XDP pkt read, pkt_end mangling, bad access 2",
6695 .insns = {
6696 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6697 offsetof(struct xdp_md, data)),
6698 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6699 offsetof(struct xdp_md, data_end)),
6700 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6701 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6702 BPF_ALU64_IMM(BPF_SUB, BPF_REG_3, 8),
6703 BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6704 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6705 BPF_MOV64_IMM(BPF_REG_0, 0),
6706 BPF_EXIT_INSN(),
6707 },
6708 .errstr = "R1 offset is outside of the packet",
6709 .result = REJECT,
6710 .prog_type = BPF_PROG_TYPE_XDP,
6711 },
6712 {
6713 "XDP pkt read, pkt_data' > pkt_end, good access",
6714 .insns = {
6715 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6716 offsetof(struct xdp_md, data)),
6717 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6718 offsetof(struct xdp_md, data_end)),
6719 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6720 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6721 BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6722 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6723 BPF_MOV64_IMM(BPF_REG_0, 0),
6724 BPF_EXIT_INSN(),
6725 },
6726 .result = ACCEPT,
6727 .prog_type = BPF_PROG_TYPE_XDP,
6728 },
6729 {
6730 "XDP pkt read, pkt_data' > pkt_end, bad access 1",
6731 .insns = {
6732 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6733 offsetof(struct xdp_md, data)),
6734 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6735 offsetof(struct xdp_md, data_end)),
6736 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6737 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6738 BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6739 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
6740 BPF_MOV64_IMM(BPF_REG_0, 0),
6741 BPF_EXIT_INSN(),
6742 },
6743 .errstr = "R1 offset is outside of the packet",
6744 .result = REJECT,
6745 .prog_type = BPF_PROG_TYPE_XDP,
6746 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6747 },
6748 {
6749 "XDP pkt read, pkt_data' > pkt_end, bad access 2",
6750 .insns = {
6751 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6752 offsetof(struct xdp_md, data)),
6753 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6754 offsetof(struct xdp_md, data_end)),
6755 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6756 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6757 BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 0),
6758 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6759 BPF_MOV64_IMM(BPF_REG_0, 0),
6760 BPF_EXIT_INSN(),
6761 },
6762 .errstr = "R1 offset is outside of the packet",
6763 .result = REJECT,
6764 .prog_type = BPF_PROG_TYPE_XDP,
6765 },
6766 {
6767 "XDP pkt read, pkt_end > pkt_data', good access",
6768 .insns = {
6769 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6770 offsetof(struct xdp_md, data)),
6771 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6772 offsetof(struct xdp_md, data_end)),
6773 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6774 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6775 BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6776 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6777 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6778 BPF_MOV64_IMM(BPF_REG_0, 0),
6779 BPF_EXIT_INSN(),
6780 },
6781 .result = ACCEPT,
6782 .prog_type = BPF_PROG_TYPE_XDP,
6783 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6784 },
6785 {
6786 "XDP pkt read, pkt_end > pkt_data', bad access 1",
6787 .insns = {
6788 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6789 offsetof(struct xdp_md, data)),
6790 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6791 offsetof(struct xdp_md, data_end)),
6792 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6793 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6794 BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6795 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6796 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6797 BPF_MOV64_IMM(BPF_REG_0, 0),
6798 BPF_EXIT_INSN(),
6799 },
6800 .errstr = "R1 offset is outside of the packet",
6801 .result = REJECT,
6802 .prog_type = BPF_PROG_TYPE_XDP,
6803 },
6804 {
6805 "XDP pkt read, pkt_end > pkt_data', bad access 2",
6806 .insns = {
6807 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6808 offsetof(struct xdp_md, data)),
6809 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6810 offsetof(struct xdp_md, data_end)),
6811 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6812 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6813 BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6814 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6815 BPF_MOV64_IMM(BPF_REG_0, 0),
6816 BPF_EXIT_INSN(),
6817 },
6818 .errstr = "R1 offset is outside of the packet",
6819 .result = REJECT,
6820 .prog_type = BPF_PROG_TYPE_XDP,
6821 },
6822 {
6823 "XDP pkt read, pkt_data' < pkt_end, good access",
6824 .insns = {
6825 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6826 offsetof(struct xdp_md, data)),
6827 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6828 offsetof(struct xdp_md, data_end)),
6829 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6830 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6831 BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6832 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6833 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6834 BPF_MOV64_IMM(BPF_REG_0, 0),
6835 BPF_EXIT_INSN(),
6836 },
6837 .result = ACCEPT,
6838 .prog_type = BPF_PROG_TYPE_XDP,
6839 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6840 },
6841 {
6842 "XDP pkt read, pkt_data' < pkt_end, bad access 1",
6843 .insns = {
6844 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6845 offsetof(struct xdp_md, data)),
6846 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6847 offsetof(struct xdp_md, data_end)),
6848 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6849 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6850 BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6851 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6852 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6853 BPF_MOV64_IMM(BPF_REG_0, 0),
6854 BPF_EXIT_INSN(),
6855 },
6856 .errstr = "R1 offset is outside of the packet",
6857 .result = REJECT,
6858 .prog_type = BPF_PROG_TYPE_XDP,
6859 },
6860 {
6861 "XDP pkt read, pkt_data' < pkt_end, bad access 2",
6862 .insns = {
6863 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6864 offsetof(struct xdp_md, data)),
6865 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6866 offsetof(struct xdp_md, data_end)),
6867 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6868 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6869 BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6870 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6871 BPF_MOV64_IMM(BPF_REG_0, 0),
6872 BPF_EXIT_INSN(),
6873 },
6874 .errstr = "R1 offset is outside of the packet",
6875 .result = REJECT,
6876 .prog_type = BPF_PROG_TYPE_XDP,
6877 },
6878 {
6879 "XDP pkt read, pkt_end < pkt_data', good access",
6880 .insns = {
6881 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6882 offsetof(struct xdp_md, data)),
6883 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6884 offsetof(struct xdp_md, data_end)),
6885 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6886 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6887 BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 1),
6888 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6889 BPF_MOV64_IMM(BPF_REG_0, 0),
6890 BPF_EXIT_INSN(),
6891 },
6892 .result = ACCEPT,
6893 .prog_type = BPF_PROG_TYPE_XDP,
6894 },
6895 {
6896 "XDP pkt read, pkt_end < pkt_data', bad access 1",
6897 .insns = {
6898 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6899 offsetof(struct xdp_md, data)),
6900 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6901 offsetof(struct xdp_md, data_end)),
6902 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6903 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6904 BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 1),
6905 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
6906 BPF_MOV64_IMM(BPF_REG_0, 0),
6907 BPF_EXIT_INSN(),
6908 },
6909 .errstr = "R1 offset is outside of the packet",
6910 .result = REJECT,
6911 .prog_type = BPF_PROG_TYPE_XDP,
6912 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6913 },
6914 {
6915 "XDP pkt read, pkt_end < pkt_data', bad access 2",
6916 .insns = {
6917 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6918 offsetof(struct xdp_md, data)),
6919 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6920 offsetof(struct xdp_md, data_end)),
6921 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6922 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6923 BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 0),
6924 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6925 BPF_MOV64_IMM(BPF_REG_0, 0),
6926 BPF_EXIT_INSN(),
6927 },
6928 .errstr = "R1 offset is outside of the packet",
6929 .result = REJECT,
6930 .prog_type = BPF_PROG_TYPE_XDP,
6931 },
6932 {
6933 "XDP pkt read, pkt_data' >= pkt_end, good access",
6934 .insns = {
6935 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6936 offsetof(struct xdp_md, data)),
6937 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6938 offsetof(struct xdp_md, data_end)),
6939 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6940 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6941 BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 1),
6942 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6943 BPF_MOV64_IMM(BPF_REG_0, 0),
6944 BPF_EXIT_INSN(),
6945 },
6946 .result = ACCEPT,
6947 .prog_type = BPF_PROG_TYPE_XDP,
6948 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6949 },
6950 {
6951 "XDP pkt read, pkt_data' >= pkt_end, bad access 1",
6952 .insns = {
6953 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6954 offsetof(struct xdp_md, data)),
6955 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6956 offsetof(struct xdp_md, data_end)),
6957 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6958 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6959 BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 1),
6960 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6961 BPF_MOV64_IMM(BPF_REG_0, 0),
6962 BPF_EXIT_INSN(),
6963 },
6964 .errstr = "R1 offset is outside of the packet",
6965 .result = REJECT,
6966 .prog_type = BPF_PROG_TYPE_XDP,
6967 },
6968 {
6969 "XDP pkt read, pkt_data' >= pkt_end, bad access 2",
6970 .insns = {
6971 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6972 offsetof(struct xdp_md, data)),
6973 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6974 offsetof(struct xdp_md, data_end)),
6975 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6976 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6977 BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 0),
6978 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6979 BPF_MOV64_IMM(BPF_REG_0, 0),
6980 BPF_EXIT_INSN(),
6981 },
6982 .errstr = "R1 offset is outside of the packet",
6983 .result = REJECT,
6984 .prog_type = BPF_PROG_TYPE_XDP,
6985 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6986 },
6987 {
6988 "XDP pkt read, pkt_end >= pkt_data', good access",
6989 .insns = {
6990 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6991 offsetof(struct xdp_md, data)),
6992 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6993 offsetof(struct xdp_md, data_end)),
6994 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6995 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6996 BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
6997 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6998 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6999 BPF_MOV64_IMM(BPF_REG_0, 0),
7000 BPF_EXIT_INSN(),
7001 },
7002 .result = ACCEPT,
7003 .prog_type = BPF_PROG_TYPE_XDP,
7004 },
7005 {
7006 "XDP pkt read, pkt_end >= pkt_data', bad access 1",
7007 .insns = {
7008 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7009 offsetof(struct xdp_md, data)),
7010 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7011 offsetof(struct xdp_md, data_end)),
7012 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7013 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7014 BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
7015 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7016 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
7017 BPF_MOV64_IMM(BPF_REG_0, 0),
7018 BPF_EXIT_INSN(),
7019 },
7020 .errstr = "R1 offset is outside of the packet",
7021 .result = REJECT,
7022 .prog_type = BPF_PROG_TYPE_XDP,
7023 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7024 },
7025 {
7026 "XDP pkt read, pkt_end >= pkt_data', bad access 2",
7027 .insns = {
7028 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7029 offsetof(struct xdp_md, data)),
7030 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7031 offsetof(struct xdp_md, data_end)),
7032 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7033 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7034 BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
7035 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7036 BPF_MOV64_IMM(BPF_REG_0, 0),
7037 BPF_EXIT_INSN(),
7038 },
7039 .errstr = "R1 offset is outside of the packet",
7040 .result = REJECT,
7041 .prog_type = BPF_PROG_TYPE_XDP,
7042 },
7043 {
7044 "XDP pkt read, pkt_data' <= pkt_end, good access",
7045 .insns = {
7046 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7047 offsetof(struct xdp_md, data)),
7048 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7049 offsetof(struct xdp_md, data_end)),
7050 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7051 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7052 BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7053 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7054 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7055 BPF_MOV64_IMM(BPF_REG_0, 0),
7056 BPF_EXIT_INSN(),
7057 },
7058 .result = ACCEPT,
7059 .prog_type = BPF_PROG_TYPE_XDP,
7060 },
7061 {
7062 "XDP pkt read, pkt_data' <= pkt_end, bad access 1",
7063 .insns = {
7064 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7065 offsetof(struct xdp_md, data)),
7066 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7067 offsetof(struct xdp_md, data_end)),
7068 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7069 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7070 BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7071 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7072 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
7073 BPF_MOV64_IMM(BPF_REG_0, 0),
7074 BPF_EXIT_INSN(),
7075 },
7076 .errstr = "R1 offset is outside of the packet",
7077 .result = REJECT,
7078 .prog_type = BPF_PROG_TYPE_XDP,
7079 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7080 },
7081 {
7082 "XDP pkt read, pkt_data' <= pkt_end, bad access 2",
7083 .insns = {
7084 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7085 offsetof(struct xdp_md, data)),
7086 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7087 offsetof(struct xdp_md, data_end)),
7088 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7089 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7090 BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7091 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7092 BPF_MOV64_IMM(BPF_REG_0, 0),
7093 BPF_EXIT_INSN(),
7094 },
7095 .errstr = "R1 offset is outside of the packet",
7096 .result = REJECT,
7097 .prog_type = BPF_PROG_TYPE_XDP,
7098 },
7099 {
7100 "XDP pkt read, pkt_end <= pkt_data', good access",
7101 .insns = {
7102 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7103 offsetof(struct xdp_md, data)),
7104 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7105 offsetof(struct xdp_md, data_end)),
7106 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7107 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7108 BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 1),
7109 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
7110 BPF_MOV64_IMM(BPF_REG_0, 0),
7111 BPF_EXIT_INSN(),
7112 },
7113 .result = ACCEPT,
7114 .prog_type = BPF_PROG_TYPE_XDP,
7115 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7116 },
7117 {
7118 "XDP pkt read, pkt_end <= pkt_data', bad access 1",
7119 .insns = {
7120 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7121 offsetof(struct xdp_md, data)),
7122 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7123 offsetof(struct xdp_md, data_end)),
7124 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7125 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7126 BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 1),
7127 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7128 BPF_MOV64_IMM(BPF_REG_0, 0),
7129 BPF_EXIT_INSN(),
7130 },
7131 .errstr = "R1 offset is outside of the packet",
7132 .result = REJECT,
7133 .prog_type = BPF_PROG_TYPE_XDP,
7134 },
7135 {
7136 "XDP pkt read, pkt_end <= pkt_data', bad access 2",
7137 .insns = {
7138 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7139 offsetof(struct xdp_md, data)),
7140 BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7141 offsetof(struct xdp_md, data_end)),
7142 BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7143 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7144 BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 0),
7145 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
7146 BPF_MOV64_IMM(BPF_REG_0, 0),
7147 BPF_EXIT_INSN(),
7148 },
7149 .errstr = "R1 offset is outside of the packet",
7150 .result = REJECT,
7151 .prog_type = BPF_PROG_TYPE_XDP,
7152 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7153 },
6648}; 7154};
6649 7155
6650static int probe_filter_length(const struct bpf_insn *fp) 7156static int probe_filter_length(const struct bpf_insn *fp)