aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2018-05-30 16:53:59 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2018-05-30 16:53:59 +1000
commitb15d407f8a8ebad36eb43bf53eb0a0bee9ed7c13 (patch)
tree18f72b02c3468a204ceef96f9afbfe3f23e7b218
parent7376eb5c3c1f5fb3ea1274b114552859bee81011 (diff)
parent7a5abc3d9699c88781ae12cf957a8c49f9bbb494 (diff)
Merge remote-tracking branch 'staging/staging-next'
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio9
-rw-r--r--Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/adc/mcp320x.txt2
-rw-r--r--Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt6
-rw-r--r--Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.txt7
-rw-r--r--Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt26
-rw-r--r--Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt41
-rw-r--r--Documentation/devicetree/bindings/iio/afe/voltage-divider.txt53
-rw-r--r--Documentation/devicetree/bindings/iio/dac/ltc2632.txt14
-rw-r--r--Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt24
-rw-r--r--Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt12
-rw-r--r--Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt9
-rw-r--r--MAINTAINERS23
-rw-r--r--drivers/iio/Kconfig2
-rw-r--r--drivers/iio/Makefile2
-rw-r--r--drivers/iio/accel/Kconfig24
-rw-r--r--drivers/iio/accel/Makefile2
-rw-r--r--drivers/iio/accel/adis16201.c321
-rw-r--r--drivers/iio/accel/adis16209.c (renamed from drivers/staging/iio/accel/adis16209.c)52
-rw-r--r--drivers/iio/accel/bmc150-accel-core.c23
-rw-r--r--drivers/iio/accel/mma8452.c24
-rw-r--r--drivers/iio/accel/sca3000.c13
-rw-r--r--drivers/iio/accel/st_accel_i2c.c1
-rw-r--r--drivers/iio/adc/ad7791.c87
-rw-r--r--drivers/iio/adc/imx7d_adc.c2
-rw-r--r--drivers/iio/adc/meson_saradc.c83
-rw-r--r--drivers/iio/adc/stm32-adc-core.c66
-rw-r--r--drivers/iio/adc/stm32-adc.c47
-rw-r--r--drivers/iio/adc/stm32-dfsdm-adc.c17
-rw-r--r--drivers/iio/adc/stm32-dfsdm-core.c26
-rw-r--r--drivers/iio/adc/stx104.c11
-rw-r--r--drivers/iio/adc/ti-ads8688.c48
-rw-r--r--drivers/iio/afe/Kconfig19
-rw-r--r--drivers/iio/afe/Makefile6
-rw-r--r--drivers/iio/afe/iio-rescale.c359
-rw-r--r--drivers/iio/amplifiers/ad8366.c6
-rw-r--r--drivers/iio/chemical/atlas-ph-sensor.c14
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c9
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c9
-rw-r--r--drivers/iio/dac/Kconfig33
-rw-r--r--drivers/iio/dac/Makefile3
-rw-r--r--drivers/iio/dac/ad5686-spi.c119
-rw-r--r--drivers/iio/dac/ad5686.c428
-rw-r--r--drivers/iio/dac/ad5686.h145
-rw-r--r--drivers/iio/dac/ad5696-i2c.c102
-rw-r--r--drivers/iio/dac/ltc2632.c89
-rw-r--r--drivers/iio/dac/ti-dac5571.c439
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c284
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c86
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h22
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c47
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c12
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c52
-rw-r--r--drivers/iio/imu/st_lsm6dsx/Kconfig3
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h2
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c10
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c7
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c5
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c5
-rw-r--r--drivers/iio/light/Kconfig8
-rw-r--r--drivers/iio/light/Makefile1
-rw-r--r--drivers/iio/light/cros_ec_light_prox.c3
-rw-r--r--drivers/iio/light/tsl2583.c2
-rw-r--r--drivers/iio/light/tsl2772.c1800
-rw-r--r--drivers/iio/magnetometer/mag3110.c158
-rw-r--r--drivers/iio/potentiometer/mcp4018.c41
-rw-r--r--drivers/iio/potentiometer/mcp4531.c145
-rw-r--r--drivers/iio/potentiostat/lmp91000.c2
-rw-r--r--drivers/iio/pressure/cros_ec_baro.c3
-rw-r--r--drivers/iio/resolver/Kconfig17
-rw-r--r--drivers/iio/resolver/Makefile5
-rw-r--r--drivers/iio/resolver/ad2s1200.c (renamed from drivers/staging/iio/resolver/ad2s1200.c)167
-rw-r--r--drivers/staging/android/Kconfig11
-rw-r--r--drivers/staging/android/Makefile1
-rw-r--r--drivers/staging/android/TODO9
-rw-r--r--drivers/staging/android/ashmem.h6
-rw-r--r--drivers/staging/android/ion/Kconfig2
-rw-r--r--drivers/staging/android/ion/ion.c22
-rw-r--r--drivers/staging/android/ion/ion.h2
-rw-r--r--drivers/staging/android/ion/ion_page_pool.c5
-rw-r--r--drivers/staging/android/uapi/ashmem.h6
-rw-r--r--drivers/staging/android/uapi/ion.h2
-rw-r--r--drivers/staging/android/uapi/vsoc_shm.h295
-rw-r--r--drivers/staging/android/vsoc.c1152
-rw-r--r--drivers/staging/board/armadillo800eva.c10
-rw-r--r--drivers/staging/board/board.c5
-rw-r--r--drivers/staging/comedi/comedi_compat32.c12
-rw-r--r--drivers/staging/comedi/comedidev.h2
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c6
-rw-r--r--drivers/staging/emxx_udc/Kconfig2
-rw-r--r--drivers/staging/emxx_udc/TODO2
-rw-r--r--drivers/staging/fbtft/TODO4
-rw-r--r--drivers/staging/fbtft/fbtft-bus.c13
-rw-r--r--drivers/staging/fsl-dpaa2/Kconfig8
-rw-r--r--drivers/staging/fsl-dpaa2/Makefile5
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c111
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h49
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c23
-rw-r--r--drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h13
-rw-r--r--drivers/staging/fsl-dpaa2/ethsw/dpsw.c42
-rw-r--r--drivers/staging/fsl-dpaa2/ethsw/dpsw.h6
-rw-r--r--drivers/staging/fsl-dpaa2/ethsw/ethsw.c39
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/Makefile7
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h137
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/dprtc.c701
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/dprtc.h164
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/rtc.c229
-rw-r--r--drivers/staging/fsl-dpaa2/rtc/rtc.h14
-rw-r--r--drivers/staging/fsl-mc/bus/dpio/dpio-driver.c28
-rw-r--r--drivers/staging/fsl-mc/bus/dpio/qbman-portal.h4
-rw-r--r--drivers/staging/fsl-mc/include/dpaa2-io.h2
-rw-r--r--drivers/staging/gdm724x/gdm_endian.c14
-rw-r--r--drivers/staging/gdm724x/gdm_endian.h14
-rw-r--r--drivers/staging/gdm724x/gdm_lte.c16
-rw-r--r--drivers/staging/gdm724x/gdm_lte.h14
-rw-r--r--drivers/staging/gdm724x/gdm_mux.c14
-rw-r--r--drivers/staging/gdm724x/gdm_mux.h14
-rw-r--r--drivers/staging/gdm724x/gdm_tty.c14
-rw-r--r--drivers/staging/gdm724x/gdm_tty.h14
-rw-r--r--drivers/staging/gdm724x/gdm_usb.c14
-rw-r--r--drivers/staging/gdm724x/gdm_usb.h14
-rw-r--r--drivers/staging/gdm724x/hci.h14
-rw-r--r--drivers/staging/gdm724x/hci_packet.h14
-rw-r--r--drivers/staging/gdm724x/netlink_k.c14
-rw-r--r--drivers/staging/gdm724x/netlink_k.h14
-rw-r--r--drivers/staging/goldfish/Kconfig9
-rw-r--r--drivers/staging/goldfish/Makefile1
-rw-r--r--drivers/staging/goldfish/goldfish_nand.c441
-rw-r--r--drivers/staging/goldfish/goldfish_nand_reg.h76
-rw-r--r--drivers/staging/greybus/TODO5
-rw-r--r--drivers/staging/greybus/arche-platform.c9
-rw-r--r--drivers/staging/greybus/audio_codec.h5
-rw-r--r--drivers/staging/greybus/audio_topology.c2
-rw-r--r--drivers/staging/greybus/svc.c3
-rw-r--r--drivers/staging/iio/Kconfig1
-rw-r--r--drivers/staging/iio/Makefile1
-rw-r--r--drivers/staging/iio/TODO9
-rw-r--r--drivers/staging/iio/accel/Kconfig24
-rw-r--r--drivers/staging/iio/accel/Makefile2
-rw-r--r--drivers/staging/iio/accel/adis16201.c385
-rw-r--r--drivers/staging/iio/adc/ad7606_par.c6
-rw-r--r--drivers/staging/iio/adc/ad7780.c2
-rw-r--r--drivers/staging/iio/cdc/ad7746.c44
-rw-r--r--drivers/staging/iio/light/Kconfig14
-rw-r--r--drivers/staging/iio/light/Makefile5
-rw-r--r--drivers/staging/iio/light/tsl2x7x.c1889
-rw-r--r--drivers/staging/iio/light/tsl2x7x.h99
-rw-r--r--drivers/staging/iio/meter/Kconfig42
-rw-r--r--drivers/staging/iio/meter/Makefile8
-rw-r--r--drivers/staging/iio/meter/ade7753.c630
-rw-r--r--drivers/staging/iio/meter/ade7754.c664
-rw-r--r--drivers/staging/iio/meter/ade7758.h183
-rw-r--r--drivers/staging/iio/meter/ade7758_core.c955
-rw-r--r--drivers/staging/iio/meter/ade7758_ring.c177
-rw-r--r--drivers/staging/iio/meter/ade7758_trigger.c108
-rw-r--r--drivers/staging/iio/meter/ade7759.c558
-rw-r--r--drivers/staging/iio/meter/ade7854-i2c.c238
-rw-r--r--drivers/staging/iio/meter/ade7854-spi.c268
-rw-r--r--drivers/staging/iio/meter/ade7854.c40
-rw-r--r--drivers/staging/iio/meter/ade7854.h16
-rw-r--r--drivers/staging/iio/resolver/Kconfig12
-rw-r--r--drivers/staging/iio/resolver/Makefile1
-rw-r--r--drivers/staging/ks7010/eap_packet.h76
-rw-r--r--drivers/staging/ks7010/ks7010_sdio.c632
-rw-r--r--drivers/staging/ks7010/ks7010_sdio.h164
-rw-r--r--drivers/staging/ks7010/ks_hostif.c1043
-rw-r--r--drivers/staging/ks7010/ks_hostif.h465
-rw-r--r--drivers/staging/ks7010/ks_wlan.h278
-rw-r--r--drivers/staging/ks7010/ks_wlan_ioctl.h7
-rw-r--r--drivers/staging/ks7010/ks_wlan_net.c1118
-rw-r--r--drivers/staging/ks7010/michael_mic.c28
-rw-r--r--drivers/staging/ks7010/michael_mic.h11
-rw-r--r--drivers/staging/lustre/README.txt2
-rw-r--r--drivers/staging/lustre/TODO2
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/curproc.h85
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs.h103
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h217
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h3
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h40
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h9
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h3
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h82
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_string.h2
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_time.h79
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h133
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h78
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h103
-rw-r--r--drivers/staging/lustre/include/linux/lnet/lib-lnet.h8
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h3
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lnet/lnetctl.h11
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h2
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h6
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lustre/lustre_ioctl.h2
-rw-r--r--drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h6
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c40
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h24
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c77
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c9
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c19
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h3
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c98
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c1
-rw-r--r--drivers/staging/lustre/lnet/libcfs/Makefile19
-rw-r--r--drivers/staging/lustre/lnet/libcfs/debug.c9
-rw-r--r--drivers/staging/lustre/lnet/libcfs/fail.c4
-rw-r--r--drivers/staging/lustre/lnet/libcfs/hash.c5
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c942
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_lock.c3
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_mem.c6
-rw-r--r--drivers/staging/lustre/lnet/libcfs/libcfs_string.c6
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c (renamed from drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c)0
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux-crypto.c (renamed from drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c)10
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux-crypto.h (renamed from drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h)0
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux-debug.c (renamed from drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c)5
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux-tracefile.c (renamed from drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c)5
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c1079
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-module.c197
-rw-r--r--drivers/staging/lustre/lnet/libcfs/module.c296
-rw-r--r--drivers/staging/lustre/lnet/libcfs/tracefile.c27
-rw-r--r--drivers/staging/lustre/lnet/libcfs/tracefile.h11
-rw-r--r--drivers/staging/lustre/lnet/lnet/api-ni.c6
-rw-r--r--drivers/staging/lustre/lnet/lnet/config.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-eq.c2
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-move.c16
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-socket.c1
-rw-r--r--drivers/staging/lustre/lnet/lnet/module.c42
-rw-r--r--drivers/staging/lustre/lnet/lnet/net_fault.c40
-rw-r--r--drivers/staging/lustre/lnet/lnet/nidstrings.c3
-rw-r--r--drivers/staging/lustre/lnet/lnet/peer.c2
-rw-r--r--drivers/staging/lustre/lnet/lnet/router.c17
-rw-r--r--drivers/staging/lustre/lnet/lnet/router_proc.c16
-rw-r--r--drivers/staging/lustre/lnet/selftest/conctl.c28
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.c15
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.c15
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.h4
-rw-r--r--drivers/staging/lustre/lnet/selftest/framework.c4
-rw-r--r--drivers/staging/lustre/lnet/selftest/module.c6
-rw-r--r--drivers/staging/lustre/lnet/selftest/selftest.h1
-rw-r--r--drivers/staging/lustre/lnet/selftest/timer.c4
-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.c7
-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.c7
-rw-r--r--drivers/staging/lustre/lustre/fld/lproc_fld.c1
-rw-r--r--drivers/staging/lustre/lustre/include/cl_object.h10
-rw-r--r--drivers/staging/lustre/lustre/include/lprocfs_status.h2
-rw-r--r--drivers/staging/lustre/lustre/include/lu_object.h42
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_compat.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_disk.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_dlm.h18
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_export.h9
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_fld.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_handles.h2
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_import.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_intent.h2
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_lib.h22
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_mds.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_net.h11
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_patchless_compat.h1
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_sec.h2
-rw-r--r--drivers/staging/lustre/lustre/include/obd.h28
-rw-r--r--drivers/staging/lustre/lustre/include/obd_class.h15
-rw-r--r--drivers/staging/lustre/lustre/include/obd_support.h28
-rw-r--r--drivers/staging/lustre/lustre/ldlm/l_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_extent.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_flock.c11
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lib.c1
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lock.c25
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c16
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_request.c67
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_resource.c31
-rw-r--r--drivers/staging/lustre/lustre/llite/dir.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c24
-rw-r--r--drivers/staging/lustre/lustre/llite/glimpse.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/lcommon_cl.c9
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_internal.h4
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c11
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_mmap.c14
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_nfs.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/lproc_llite.c12
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c11
-rw-r--r--drivers/staging/lustre/lustre/llite/range_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/range_lock.h2
-rw-r--r--drivers/staging/lustre/lustre/llite/statahead.c10
-rw-r--r--drivers/staging/lustre/lustre/llite/super25.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_dev.c167
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_internal.h8
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_object.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr.c227
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr_cache.c83
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_intent.c12
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_internal.h2
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_obd.c31
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_cl_internal.h20
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_ea.c1
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_internal.h13
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_merge.c4
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_obd.c25
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_object.c8
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_offset.c2
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_pool.c161
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_request.c6
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_internal.h8
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_lib.c17
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_locks.c68
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_reint.c2
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_request.c12
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_internal.h1
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_request.c7
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_io.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_object.c2
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_page.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/class_obd.c15
-rw-r--r--drivers/staging/lustre/lustre/obdclass/genops.c36
-rw-r--r--drivers/staging/lustre/lustre/obdclass/kernelcomm.c2
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-module.c4
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog.c3
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_status.c12
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lu_object.c266
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lu_ref.c2
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lustre_handles.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_config.c163
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_mount.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/uuid.c2
-rw-r--r--drivers/staging/lustre/lustre/obdecho/echo_client.c9
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_cache.c4
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_cl_internal.h12
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_internal.h7
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_io.c2
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_lock.c1
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_object.c11
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_page.c4
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_quota.c136
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_request.c50
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/client.c20
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/connection.c164
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/errno.c4
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/import.c11
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/llog_client.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/llog_net.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/niobuf.c7
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs.c3
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c3
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pack_generic.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pinger.c23
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c4
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c14
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/service.c21
-rw-r--r--drivers/staging/most/cdev/cdev.c16
-rw-r--r--drivers/staging/most/core.c68
-rw-r--r--drivers/staging/most/core.h4
-rw-r--r--drivers/staging/most/dim2/Kconfig2
-rw-r--r--drivers/staging/most/dim2/dim2.c397
-rw-r--r--drivers/staging/most/dim2/dim2.h21
-rw-r--r--drivers/staging/most/dim2/hal.c9
-rw-r--r--drivers/staging/most/dim2/reg.h84
-rw-r--r--drivers/staging/most/i2c/i2c.c140
-rw-r--r--drivers/staging/most/sound/sound.c123
-rw-r--r--drivers/staging/most/usb/usb.c55
-rw-r--r--drivers/staging/most/video/video.c32
-rw-r--r--drivers/staging/mt7621-dts/gbpc1.dts3
-rw-r--r--drivers/staging/mt7621-dts/mt7621.dtsi20
-rw-r--r--drivers/staging/mt7621-eth/ethtool.c54
-rw-r--r--drivers/staging/mt7621-eth/gsw_mt7620.h4
-rw-r--r--drivers/staging/mt7621-eth/gsw_mt7621.c10
-rw-r--r--drivers/staging/mt7621-eth/mdio.c6
-rw-r--r--drivers/staging/mt7621-eth/mtk_eth_soc.c44
-rw-r--r--drivers/staging/mt7621-eth/mtk_eth_soc.h33
-rw-r--r--drivers/staging/mt7621-eth/soc_mt7621.c7
-rw-r--r--drivers/staging/mt7621-gpio/TODO2
-rw-r--r--drivers/staging/mt7621-gpio/gpio-mt7621.c144
-rw-r--r--drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt58
-rw-r--r--drivers/staging/mt7621-mmc/board.h82
-rw-r--r--drivers/staging/mt7621-mmc/dbg.c397
-rw-r--r--drivers/staging/mt7621-mmc/dbg.h97
-rw-r--r--drivers/staging/mt7621-mmc/mt6575_sd.h1087
-rw-r--r--drivers/staging/mt7621-mmc/sd.c4458
-rw-r--r--drivers/staging/mt7621-pci/pci-mt7621.c478
-rw-r--r--drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c1
-rw-r--r--drivers/staging/mt7621-spi/spi-mt7621.c4
-rw-r--r--drivers/staging/nvec/nvec.c81
-rw-r--r--drivers/staging/nvec/nvec.h2
-rw-r--r--drivers/staging/olpc_dcon/TODO4
-rw-r--r--drivers/staging/pi433/Documentation/devicetree/pi433.txt6
-rw-r--r--drivers/staging/pi433/Documentation/pi433.txt10
-rw-r--r--drivers/staging/pi433/Kconfig2
-rw-r--r--drivers/staging/pi433/pi433_if.c39
-rw-r--r--drivers/staging/pi433/rf69.c182
-rw-r--r--drivers/staging/pi433/rf69.h28
-rw-r--r--drivers/staging/rtl8188eu/TODO5
-rw-r--r--drivers/staging/rtl8188eu/os_dep/recv_linux.c4
-rw-r--r--drivers/staging/rtl8192e/dot11d.c2
-rw-r--r--drivers/staging/rtl8192e/rtllib_tx.c14
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c170
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c2
-rw-r--r--drivers/staging/rtl8192u/r8192U_dm.c4
-rw-r--r--drivers/staging/rtl8723bs/Makefile2
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ap.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_btcoex.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_cmd.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_debug.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_eeprom.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_efuse.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ieee80211.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_io.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ioctl_set.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme_ext.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_odm.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_pwrctrl.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_recv.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_rf.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_security.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_sta_mgt.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_wlan_util.c10
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_xmit.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c12
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/Mp_Precomp.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_btcoex.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com_phycfg.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_intf.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_phy.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_pwr_seq.c (renamed from drivers/staging/rtl8723bs/hal/Hal8723BPwrSeq.c)12
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_sdio.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_AntDiv.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_AntDiv.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_CfoTracking.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_CfoTracking.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DIG.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DIG.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_HWConfig.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_HWConfig.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_PathDiv.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_PathDiv.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RTL8723B.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RTL8723B.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_debug.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_debug.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_interface.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_precomp.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_reg.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_types.h10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_dm.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c40
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_halinit.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_ops.c10
-rw-r--r--drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h10
-rw-r--r--drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h10
-rw-r--r--drivers/staging/rtl8723bs/include/HalVerDef.h10
-rw-r--r--drivers/staging/rtl8723bs/include/autoconf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/basic_types.h10
-rw-r--r--drivers/staging/rtl8723bs/include/cmd_osdep.h10
-rw-r--r--drivers/staging/rtl8723bs/include/drv_conf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/drv_types.h10
-rw-r--r--drivers/staging/rtl8723bs/include/drv_types_sdio.h10
-rw-r--r--drivers/staging/rtl8723bs/include/ethernet.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_btcoex.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_h2c.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_phycfg.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_reg.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_data.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_intf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_pg.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy_cfg.h (renamed from drivers/staging/rtl8723bs/include/Hal8723BPhyCfg.h)10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy_reg.h10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy_reg_8723b.h (renamed from drivers/staging/rtl8723bs/include/Hal8723BPhyReg.h)10
-rw-r--r--drivers/staging/rtl8723bs/include/hal_pwr_seq.h (renamed from drivers/staging/rtl8723bs/include/Hal8723BPwrSeq.h)0
-rw-r--r--drivers/staging/rtl8723bs/include/hal_sdio.h10
-rw-r--r--drivers/staging/rtl8723bs/include/ieee80211.h10
-rw-r--r--drivers/staging/rtl8723bs/include/ioctl_cfg80211.h10
-rw-r--r--drivers/staging/rtl8723bs/include/mlme_osdep.h10
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_intf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service.h10
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service_linux.h10
-rw-r--r--drivers/staging/rtl8723bs/include/recv_osdep.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8192c_recv.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8192c_rf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_cmd.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_dm.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_hal.h283
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_recv.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_rf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_spec.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_xmit.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ap.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_beamforming.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_br_ext.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_btcoex.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_byteorder.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_cmd.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_debug.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_eeprom.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_efuse.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_event.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ht.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_io.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ioctl.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ioctl_set.h10
-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_mp.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_odm.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_pwrctrl.h35
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_qos.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_recv.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_rf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_security.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_version.h1
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_xmit.h10
-rw-r--r--drivers/staging/rtl8723bs/include/sdio_hal.h10
-rw-r--r--drivers/staging/rtl8723bs/include/sdio_ops.h10
-rw-r--r--drivers/staging/rtl8723bs/include/sdio_ops_linux.h10
-rw-r--r--drivers/staging/rtl8723bs/include/sdio_osintf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/sta_info.h10
-rw-r--r--drivers/staging/rtl8723bs/include/wifi.h22
-rw-r--r--drivers/staging/rtl8723bs/include/wlan_bssdef.h10
-rw-r--r--drivers/staging/rtl8723bs/include/xmit_osdep.h10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c12
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_linux.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/mlme_linux.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/os_intfs.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/osdep_service.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/recv_linux.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/rtw_proc.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/rtw_proc.h10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/sdio_intf.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c10
-rw-r--r--drivers/staging/rtl8723bs/os_dep/xmit_linux.c10
-rw-r--r--drivers/staging/rtlwifi/base.c13
-rw-r--r--drivers/staging/rtlwifi/base.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbt_precomp.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/rtl_btc.c13
-rw-r--r--drivers/staging/rtlwifi/btcoexist/rtl_btc.h13
-rw-r--r--drivers/staging/rtlwifi/cam.c13
-rw-r--r--drivers/staging/rtlwifi/cam.h13
-rw-r--r--drivers/staging/rtlwifi/core.c13
-rw-r--r--drivers/staging/rtlwifi/core.h13
-rw-r--r--drivers/staging/rtlwifi/debug.c13
-rw-r--r--drivers/staging/rtlwifi/debug.h13
-rw-r--r--drivers/staging/rtlwifi/efuse.c13
-rw-r--r--drivers/staging/rtlwifi/efuse.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_2_platform.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_api.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_api.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_bit2.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_fw_info.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_reg2.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_type.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/halmac_usb_reg.h13
-rw-r--r--drivers/staging/rtlwifi/halmac/rtl_halmac.c13
-rw-r--r--drivers/staging/rtlwifi/halmac/rtl_halmac.h13
-rw-r--r--drivers/staging/rtlwifi/pci.c13
-rw-r--r--drivers/staging/rtlwifi/pci.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/halphyrf_ce.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/halphyrf_ce.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/mp_precomp.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_acs.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_acs.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_adaptivity.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_adaptivity.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_antdiv.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_antdiv.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_beamforming.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_ccx.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_ccx.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_cfotracking.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_cfotracking.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_debug.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_debug.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dfs.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dig.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dig.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_features.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_hwconfig.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_hwconfig.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_interface.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_interface.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_iqk.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_kfree.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_kfree.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_pre_define.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_precomp.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_psd.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_psd.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_rainfo.c17
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_rainfo.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_reg.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_regdefine11n.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/phydm_types.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c47
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl_phydm.c13
-rw-r--r--drivers/staging/rtlwifi/phydm/rtl_phydm.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h13
-rw-r--r--drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h13
-rw-r--r--drivers/staging/rtlwifi/ps.c13
-rw-r--r--drivers/staging/rtlwifi/ps.h13
-rw-r--r--drivers/staging/rtlwifi/pwrseqcmd.h13
-rw-r--r--drivers/staging/rtlwifi/rc.c13
-rw-r--r--drivers/staging/rtlwifi/rc.h13
-rw-r--r--drivers/staging/rtlwifi/regd.c13
-rw-r--r--drivers/staging/rtlwifi/regd.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/def.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/fw.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/fw.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/hw.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/hw.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/led.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/led.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/phy.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/phy.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/reg.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/sw.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/sw.h13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/trx.c13
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/trx.h13
-rw-r--r--drivers/staging/rtlwifi/stats.c13
-rw-r--r--drivers/staging/rtlwifi/stats.h13
-rw-r--r--drivers/staging/rtlwifi/wifi.h13
-rw-r--r--drivers/staging/sm750fb/TODO5
-rw-r--r--drivers/staging/speakup/buffers.c4
-rw-r--r--drivers/staging/speakup/main.c6
-rw-r--r--drivers/staging/speakup/speakup.h3
-rw-r--r--drivers/staging/speakup/speakup_dummy.c1
-rw-r--r--drivers/staging/speakup/speakup_soft.c3
-rw-r--r--drivers/staging/speakup/spk_types.h2
-rw-r--r--drivers/staging/speakup/varhandlers.c1
-rw-r--r--drivers/staging/unisys/visornic/visornic_main.c2
-rw-r--r--drivers/staging/vboxvideo/vbox_main.c3
-rw-r--r--drivers/staging/vboxvideo/vbox_mode.c2
-rw-r--r--drivers/staging/vc04_services/Kconfig1
-rw-r--r--drivers/staging/vc04_services/Makefile2
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c64
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835.c43
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835.h12
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/TODO11
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c402
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-common.h9
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h2
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h13
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c345
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h15
-rw-r--r--drivers/staging/vc04_services/interface/vchi/TODO9
-rw-r--r--drivers/staging/vc04_services/interface/vchi/vchi_common.h2
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c6
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c83
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c55
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h1
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c1
-rw-r--r--drivers/staging/vt6655/card.c5
-rw-r--r--drivers/staging/vt6655/device_main.c150
-rw-r--r--drivers/staging/wilc1000/TODO12
-rw-r--r--drivers/staging/wilc1000/coreconfigurator.c140
-rw-r--r--drivers/staging/wilc1000/coreconfigurator.h37
-rw-r--r--drivers/staging/wilc1000/host_interface.c549
-rw-r--r--drivers/staging/wilc1000/host_interface.h6
-rw-r--r--drivers/staging/wilc1000/linux_mon.c90
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c378
-rw-r--r--drivers/staging/wilc1000/wilc_debugfs.c2
-rw-r--r--drivers/staging/wilc1000/wilc_sdio.c109
-rw-r--r--drivers/staging/wilc1000/wilc_spi.c99
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.c1049
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.h18
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_netdevice.h83
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.c26
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.h37
-rw-r--r--drivers/staging/wilc1000/wilc_wlan_cfg.c1
-rw-r--r--drivers/staging/wilc1000/wilc_wlan_if.h16
-rw-r--r--drivers/staging/wlan-ng/hfa384x.h2
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c7
-rw-r--r--drivers/staging/wlan-ng/p80211conv.c8
-rw-r--r--drivers/staging/wlan-ng/p80211conv.h26
-rw-r--r--drivers/staging/wlan-ng/p80211hdr.h2
-rw-r--r--drivers/staging/wlan-ng/p80211ioctl.h2
-rw-r--r--drivers/staging/wlan-ng/p80211metadef.h2
-rw-r--r--drivers/staging/wlan-ng/p80211metastruct.h90
-rw-r--r--drivers/staging/wlan-ng/p80211mgmt.h2
-rw-r--r--drivers/staging/wlan-ng/p80211msg.h2
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.c8
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.h8
-rw-r--r--drivers/staging/wlan-ng/p80211req.h2
-rw-r--r--drivers/staging/wlan-ng/p80211types.h2
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.h2
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c52
-rw-r--r--include/linux/iio/adc/ad_sigma_delta.h24
-rw-r--r--include/linux/iio/adc/stm32-dfsdm-adc.h2
-rw-r--r--include/linux/iio/common/cros_ec_sensors_core.h (renamed from drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h)3
-rw-r--r--include/linux/iio/iio.h24
-rw-r--r--include/linux/kernel.h16
-rw-r--r--include/linux/platform_data/tsl2772.h101
-rw-r--r--tools/iio/iio_generic_buffer.c13
826 files changed, 19290 insertions, 24222 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 6a5f34b4d5b9..731146c3b138 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -190,6 +190,13 @@ Description:
but should match other such assignments on device).
Units after application of scale and offset are m/s^2.
+What: /sys/bus/iio/devices/iio:deviceX/in_angl_raw
+KernelVersion: 4.17
+Contact: linux-iio@vger.kernel.org
+Description:
+ Angle of rotation. Units after application of scale and offset
+ are radians.
+
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
@@ -297,6 +304,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_pressure_offset
What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset
What: /sys/bus/iio/devices/iio:deviceX/in_magn_offset
What: /sys/bus/iio/devices/iio:deviceX/in_rot_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_angl_offset
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
@@ -350,6 +358,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale
What: /sys/bus/iio/devices/iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_scale
What: /sys/bus/iio/devices/iio:deviceX/in_illuminance_scale
What: /sys/bus/iio/devices/iio:deviceX/in_countY_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_angl_scale
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
index 1e6ee3deb4fa..d1acd5ea2737 100644
--- a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
@@ -7,6 +7,7 @@ Required properties:
- "amlogic,meson-gxbb-saradc" for GXBB
- "amlogic,meson-gxl-saradc" for GXL
- "amlogic,meson-gxm-saradc" for GXM
+ - "amlogic,meson-axg-saradc" for AXG
along with the generic "amlogic,meson-saradc"
- reg: the physical base address and length of the registers
- interrupts: the interrupt indicating end of sampling
diff --git a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
index 7d64753df949..56373d643f76 100644
--- a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
@@ -49,7 +49,7 @@ Required properties:
Examples:
spi_controller {
mcp3x0x@0 {
- compatible = "mcp3002";
+ compatible = "microchip,mcp3002";
reg = <0>;
spi-max-frequency = <1000000>;
vref-supply = <&vref_reg>;
diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
index e8bb8243e92c..f1ead43a1a95 100644
--- a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
@@ -24,8 +24,11 @@ Required properties:
- compatible: Should be one of:
"st,stm32f4-adc-core"
"st,stm32h7-adc-core"
+ "st,stm32mp1-adc-core"
- reg: Offset and length of the ADC block register set.
-- interrupts: Must contain the interrupt for ADC block.
+- interrupts: One or more interrupts for ADC block. Some parts like stm32f4
+ and stm32h7 share a common ADC interrupt line. stm32mp1 has two separate
+ interrupt lines, one for each ADC within ADC block.
- clocks: Core can use up to two clocks, depending on part used:
- "adc" clock: for the analog circuitry, common to all ADCs.
It's required on stm32f4.
@@ -53,6 +56,7 @@ Required properties:
- compatible: Should be one of:
"st,stm32f4-adc"
"st,stm32h7-adc"
+ "st,stm32mp1-adc"
- reg: Offset of ADC instance in ADC block (e.g. may be 0x0, 0x100, 0x200).
- clocks: Input clock private to this ADC instance. It's required only on
stm32f4, that has per instance clock input for registers access.
diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.txt b/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.txt
index ed7520d1d051..75ba25d062e1 100644
--- a/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.txt
@@ -8,14 +8,16 @@ It is mainly targeted for:
- PDM microphones (audio digital microphone)
It features up to 8 serial digital interfaces (SPI or Manchester) and
-up to 4 filters on stm32h7.
+up to 4 filters on stm32h7 or 6 filters on stm32mp1.
Each child node match with a filter instance.
Contents of a STM32 DFSDM root node:
------------------------------------
Required properties:
-- compatible: Should be "st,stm32h7-dfsdm".
+- compatible: Should be one of:
+ "st,stm32h7-dfsdm"
+ "st,stm32mp1-dfsdm"
- reg: Offset and length of the DFSDM block register set.
- clocks: IP and serial interfaces clocking. Should be set according
to rcc clock ID and "clock-names".
@@ -45,6 +47,7 @@ Required properties:
"st,stm32-dfsdm-adc" for sigma delta ADCs
"st,stm32-dfsdm-dmic" for audio digital microphone.
- reg: Specifies the DFSDM filter instance used.
+ Valid values are from 0 to 3 on stm32h7, 0 to 5 on stm32mp1.
- interrupts: IRQ lines connected to each DFSDM filter instance.
- st,adc-channels: List of single-ended channels muxed for this ADC.
valid values:
diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt
new file mode 100644
index 000000000000..821b61b8c542
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt
@@ -0,0 +1,26 @@
+Current Sense Amplifier
+=======================
+
+When an io-channel measures the output voltage from a current sense
+amplifier, the interesting measurement is almost always the current
+through the sense resistor, not the voltage output. This binding
+describes such a current sense circuit.
+
+Required properties:
+- compatible : "current-sense-amplifier"
+- io-channels : Channel node of a voltage io-channel.
+- sense-resistor-micro-ohms : The sense resistance in microohms.
+
+Optional properties:
+- sense-gain-mult: Amplifier gain multiplier. The default is <1>.
+- sense-gain-div: Amplifier gain divider. The default is <1>.
+
+Example:
+
+sysi {
+ compatible = "current-sense-amplifier";
+ io-channels = <&tiadc 0>;
+
+ sense-resistor-micro-ohms = <20000>;
+ sense-gain-mul = <50>;
+};
diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt b/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt
new file mode 100644
index 000000000000..0f67108a07b6
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt
@@ -0,0 +1,41 @@
+Current Sense Shunt
+===================
+
+When an io-channel measures the voltage over a current sense shunt,
+the interesting measurement is almost always the current through the
+shunt, not the voltage over it. This binding describes such a current
+sense circuit.
+
+Required properties:
+- compatible : "current-sense-shunt"
+- io-channels : Channel node of a voltage io-channel.
+- shunt-resistor-micro-ohms : The shunt resistance in microohms.
+
+Example:
+The system current is measured by measuring the voltage over a
+3.3 ohms shunt resistor.
+
+sysi {
+ compatible = "current-sense-shunt";
+ io-channels = <&tiadc 0>;
+
+ /* Divide the voltage by 3300000/1000000 (or 3.3) for the current. */
+ shunt-resistor-micro-ohms = <3300000>;
+};
+
+&i2c {
+ tiadc: adc@48 {
+ compatible = "ti,ads1015";
+ reg = <0x48>;
+ #io-channel-cells = <1>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ channel@0 { /* IN0,IN1 differential */
+ reg = <0>;
+ ti,gain = <1>;
+ ti,datarate = <4>;
+ };
+ };
+};
diff --git a/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt b/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt
new file mode 100644
index 000000000000..b452a8406107
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt
@@ -0,0 +1,53 @@
+Voltage divider
+===============
+
+When an io-channel measures the midpoint of a voltage divider, the
+interesting voltage is often the voltage over the full resistance
+of the divider. This binding describes the voltage divider in such
+a curcuit.
+
+ Vin ----.
+ |
+ .-----.
+ | R |
+ '-----'
+ |
+ +---- Vout
+ |
+ .-----.
+ | Rout|
+ '-----'
+ |
+ GND
+
+Required properties:
+- compatible : "voltage-divider"
+- io-channels : Channel node of a voltage io-channel measuring Vout.
+- output-ohms : Resistance Rout over which the output voltage is measured.
+ See full-ohms.
+- full-ohms : Resistance R + Rout for the full divider. The io-channel
+ is scaled by the Rout / (R + Rout) quotient.
+
+Example:
+The system voltage is circa 12V, but divided down with a 22/222
+voltage divider (R = 200 Ohms, Rout = 22 Ohms) and fed to an ADC.
+
+sysv {
+ compatible = "voltage-divider";
+ io-channels = <&maxadc 1>;
+
+ /* Scale the system voltage by 22/222 to fit the ADC range. */
+ output-ohms = <22>;
+ full-ohms = <222>; /* 200 + 22 */
+};
+
+&spi {
+ maxadc: adc@0 {
+ compatible = "maxim,max1027";
+ reg = <0>;
+ #io-channel-cells = <1>;
+ interrupt-parent = <&gpio5>;
+ interrupts = <15 IRQ_TYPE_EDGE_RISING>;
+ spi-max-frequency = <1000000>;
+ };
+};
diff --git a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt
index eb911e5a8ab4..e0d5fea33031 100644
--- a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt
+++ b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt
@@ -12,12 +12,26 @@ Required properties:
Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
apply. In particular, "reg" and "spi-max-frequency" properties must be given.
+Optional properties:
+ - vref-supply: Phandle to the external reference voltage supply. This should
+ only be set if there is an external reference voltage connected to the VREF
+ pin. If the property is not set the internal reference is used.
+
Example:
+ vref: regulator-vref {
+ compatible = "regulator-fixed";
+ regulator-name = "vref-ltc2632";
+ regulator-min-microvolt = <1250000>;
+ regulator-max-microvolt = <1250000>;
+ regulator-always-on;
+ };
+
spi_master {
dac: ltc2632@0 {
compatible = "lltc,ltc2632-l12";
reg = <0>; /* CS0 */
spi-max-frequency = <1000000>;
+ vref-supply = <&vref>; /* optional */
};
};
diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt
new file mode 100644
index 000000000000..03af6b9a4d07
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt
@@ -0,0 +1,24 @@
+* Texas Instruments DAC5571 Family
+
+Required properties:
+ - compatible: Should contain
+ "ti,dac5571"
+ "ti,dac6571"
+ "ti,dac7571"
+ "ti,dac5574"
+ "ti,dac6574"
+ "ti,dac7574"
+ "ti,dac5573"
+ "ti,dac6573"
+ "ti,dac7573"
+ - reg: Should contain the DAC I2C address
+
+Optional properties:
+ - vref-supply: The regulator supply for DAC reference voltage
+
+Example:
+dac@0 {
+ compatible = "ti,dac5571";
+ reg = <0x4C>;
+ vref-supply = <&vdd_supply>;
+};
diff --git a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
index 2b4514592f83..5f4777e8cc9e 100644
--- a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
+++ b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
@@ -8,10 +8,16 @@ Required properties:
"invensense,mpu6500"
"invensense,mpu9150"
"invensense,mpu9250"
+ "invensense,mpu9255"
"invensense,icm20608"
- reg : the I2C address of the sensor
- interrupt-parent : should be the phandle for the interrupt controller
- - interrupts : interrupt mapping for GPIO IRQ
+ - interrupts: interrupt mapping for IRQ. It should be configured with flags
+ IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or
+ IRQ_TYPE_EDGE_FALLING.
+
+ Refer to interrupt-controller/interrupts.txt for generic interrupt client node
+ bindings.
Optional properties:
- mount-matrix: an optional 3x3 mounting rotation matrix
@@ -24,7 +30,7 @@ Example:
compatible = "invensense,mpu6050";
reg = <0x68>;
interrupt-parent = <&gpio1>;
- interrupts = <18 1>;
+ interrupts = <18 IRQ_TYPE_EDGE_RISING>;
mount-matrix = "-0.984807753012208", /* x0 */
"0", /* y0 */
"-0.173648177666930", /* z0 */
@@ -41,7 +47,7 @@ Example:
compatible = "invensense,mpu9250";
reg = <0x68>;
interrupt-parent = <&gpio3>;
- interrupts = <21 1>;
+ interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
i2c-gate {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
index 1ff1af799c76..ef8a8566c63f 100644
--- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -6,6 +6,7 @@ Required properties:
"st,lsm6ds3h"
"st,lsm6dsl"
"st,lsm6dsm"
+ "st,ism330dlc"
- reg: i2c address of the sensor / spi cs line
Optional properties:
diff --git a/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt b/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt
index b9b621e94cd7..e6d0c2eb345c 100644
--- a/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt
+++ b/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt
@@ -1,10 +1,13 @@
-* Texas Instruments LMP91000 potentiostat
+* Texas Instruments LMP91000 series of potentiostats
-http://www.ti.com/lit/ds/symlink/lmp91000.pdf
+LMP91000: http://www.ti.com/lit/ds/symlink/lmp91000.pdf
+LMP91002: http://www.ti.com/lit/ds/symlink/lmp91002.pdf
Required properties:
- - compatible: should be "ti,lmp91000"
+ - compatible: should be one of the following:
+ "ti,lmp91000"
+ "ti,lmp91002"
- reg: the I2C address of the device
- io-channels: the phandle of the iio provider
diff --git a/MAINTAINERS b/MAINTAINERS
index 8b0a37b93d1a..c641a8692865 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -796,6 +796,14 @@ M: Michael Hanselmann <linux-kernel@hansmi.ch>
S: Supported
F: drivers/macintosh/ams/
+ANALOG DEVICES INC AD5686 DRIVER
+M: Stefan Popa <stefan.popa@analog.com>
+L: linux-pm@vger.kernel.org
+W: http://ez.analog.com/community/linux-device-drivers
+S: Supported
+F: drivers/iio/dac/ad5686*
+F: drivers/iio/dac/ad5696*
+
ANALOG DEVICES INC AD9389B DRIVER
M: Hans Verkuil <hans.verkuil@cisco.com>
L: linux-media@vger.kernel.org
@@ -4425,6 +4433,12 @@ L: linux-kernel@vger.kernel.org
S: Maintained
F: drivers/staging/fsl-dpaa2/ethsw
+DPAA2 PTP CLOCK DRIVER
+M: Yangbo Lu <yangbo.lu@nxp.com>
+L: linux-kernel@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/rtc
+
DPT_I2O SCSI RAID DRIVER
M: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
L: linux-scsi@vger.kernel.org
@@ -6960,6 +6974,15 @@ F: drivers/staging/iio/
F: include/linux/iio/
F: tools/iio/
+IIO UNIT CONVERTER
+M: Peter Rosin <peda@axentia.se>
+L: linux-iio@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt
+F: Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt
+F: Documentation/devicetree/bindings/iio/afe/voltage-divider.txt
+F: drivers/iio/afe/iio-rescale.c
+
IKANOS/ADI EAGLE ADSL USB DRIVER
M: Matthieu Castet <castet.matthieu@free.fr>
M: Stanislaw Gruszka <stf_xl@wp.pl>
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index b3c8c6ef0dff..d08aeb41cd07 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -70,6 +70,7 @@ config IIO_TRIGGERED_EVENT
source "drivers/iio/accel/Kconfig"
source "drivers/iio/adc/Kconfig"
+source "drivers/iio/afe/Kconfig"
source "drivers/iio/amplifiers/Kconfig"
source "drivers/iio/chemical/Kconfig"
source "drivers/iio/common/Kconfig"
@@ -92,6 +93,7 @@ source "drivers/iio/potentiometer/Kconfig"
source "drivers/iio/potentiostat/Kconfig"
source "drivers/iio/pressure/Kconfig"
source "drivers/iio/proximity/Kconfig"
+source "drivers/iio/resolver/Kconfig"
source "drivers/iio/temperature/Kconfig"
endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index b16b2e9ddc40..cb5993251381 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_IIO_TRIGGERED_EVENT) += industrialio-triggered-event.o
obj-y += accel/
obj-y += adc/
+obj-y += afe/
obj-y += amplifiers/
obj-y += buffer/
obj-y += chemical/
@@ -35,5 +36,6 @@ obj-y += potentiometer/
obj-y += potentiostat/
obj-y += pressure/
obj-y += proximity/
+obj-y += resolver/
obj-y += temperature/
obj-y += trigger/
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index c6d9517d7611..62ae7e5abcfa 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -5,6 +5,30 @@
menu "Accelerometers"
+config ADIS16201
+ tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer"
+ depends on SPI
+ select IIO_ADIS_LIB
+ select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+ help
+ Say Y here to build support for Analog Devices adis16201 dual-axis
+ digital inclinometer and accelerometer.
+
+ To compile this driver as a module, say M here: the module will
+ be called adis16201.
+
+config ADIS16209
+ tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer"
+ depends on SPI
+ select IIO_ADIS_LIB
+ select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+ help
+ Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer
+ and accelerometer.
+
+ To compile this driver as a module, say M here: the module will be
+ called adis16209.
+
config ADXL345
tristate
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 368aedb6377a..636d4d1b2990 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -4,6 +4,8 @@
#
# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_ADIS16201) += adis16201.o
+obj-$(CONFIG_ADIS16209) += adis16209.o
obj-$(CONFIG_ADXL345) += adxl345_core.o
obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o
obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o
diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
new file mode 100644
index 000000000000..4c1d482ea73a
--- /dev/null
+++ b/drivers/iio/accel/adis16201.c
@@ -0,0 +1,321 @@
+/*
+ * ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer
+ *
+ * Copyright 2010 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/sysfs.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/imu/adis.h>
+
+#define ADIS16201_STARTUP_DELAY_MS 220
+#define ADIS16201_FLASH_CNT 0x00
+
+/* Data Output Register Information */
+#define ADIS16201_SUPPLY_OUT_REG 0x02
+#define ADIS16201_XACCL_OUT_REG 0x04
+#define ADIS16201_YACCL_OUT_REG 0x06
+#define ADIS16201_AUX_ADC_REG 0x08
+#define ADIS16201_TEMP_OUT_REG 0x0A
+#define ADIS16201_XINCL_OUT_REG 0x0C
+#define ADIS16201_YINCL_OUT_REG 0x0E
+
+/* Calibration Register Definition */
+#define ADIS16201_XACCL_OFFS_REG 0x10
+#define ADIS16201_YACCL_OFFS_REG 0x12
+#define ADIS16201_XACCL_SCALE_REG 0x14
+#define ADIS16201_YACCL_SCALE_REG 0x16
+#define ADIS16201_XINCL_OFFS_REG 0x18
+#define ADIS16201_YINCL_OFFS_REG 0x1A
+#define ADIS16201_XINCL_SCALE_REG 0x1C
+#define ADIS16201_YINCL_SCALE_REG 0x1E
+
+/* Alarm Register Definition */
+#define ADIS16201_ALM_MAG1_REG 0x20
+#define ADIS16201_ALM_MAG2_REG 0x22
+#define ADIS16201_ALM_SMPL1_REG 0x24
+#define ADIS16201_ALM_SMPL2_REG 0x26
+#define ADIS16201_ALM_CTRL_REG 0x28
+
+#define ADIS16201_AUX_DAC_REG 0x30
+#define ADIS16201_GPIO_CTRL_REG 0x32
+#define ADIS16201_SMPL_PRD_REG 0x36
+/* Operation, filter configuration */
+#define ADIS16201_AVG_CNT_REG 0x38
+#define ADIS16201_SLP_CNT_REG 0x3A
+
+/* Miscellaneous Control Register Definition */
+#define ADIS16201_MSC_CTRL_REG 0x34
+#define ADIS16201_MSC_CTRL_SELF_TEST_EN BIT(8)
+/* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2)
+/* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16201_MSC_CTRL_ACTIVE_DATA_RDY_HIGH BIT(1)
+/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
+#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1 BIT(0)
+
+/* Diagnostics System Status Register Definition */
+#define ADIS16201_DIAG_STAT_REG 0x3C
+#define ADIS16201_DIAG_STAT_ALARM2 BIT(9)
+#define ADIS16201_DIAG_STAT_ALARM1 BIT(8)
+#define ADIS16201_DIAG_STAT_SPI_FAIL_BIT 3
+#define ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT 2
+/* Power supply above 3.625 V */
+#define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1
+/* Power supply below 3.15 V */
+#define ADIS16201_DIAG_STAT_POWER_LOW_BIT 0
+
+/* System Command Register Definition */
+#define ADIS16201_GLOB_CMD_REG 0x3E
+#define ADIS16201_GLOB_CMD_SW_RESET BIT(7)
+#define ADIS16201_GLOB_CMD_FACTORY_RESET BIT(1)
+
+#define ADIS16201_ERROR_ACTIVE BIT(14)
+
+enum adis16201_scan {
+ ADIS16201_SCAN_ACC_X,
+ ADIS16201_SCAN_ACC_Y,
+ ADIS16201_SCAN_INCLI_X,
+ ADIS16201_SCAN_INCLI_Y,
+ ADIS16201_SCAN_SUPPLY,
+ ADIS16201_SCAN_AUX_ADC,
+ ADIS16201_SCAN_TEMP,
+};
+
+static const u8 adis16201_addresses[] = {
+ [ADIS16201_SCAN_ACC_X] = ADIS16201_XACCL_OFFS_REG,
+ [ADIS16201_SCAN_ACC_Y] = ADIS16201_YACCL_OFFS_REG,
+ [ADIS16201_SCAN_INCLI_X] = ADIS16201_XINCL_OFFS_REG,
+ [ADIS16201_SCAN_INCLI_Y] = ADIS16201_YINCL_OFFS_REG,
+};
+
+static int adis16201_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2,
+ long mask)
+{
+ struct adis *st = iio_priv(indio_dev);
+ int ret;
+ int bits;
+ u8 addr;
+ s16 val16;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ return adis_single_conversion(indio_dev, chan,
+ ADIS16201_ERROR_ACTIVE, val);
+ case IIO_CHAN_INFO_SCALE:
+ switch (chan->type) {
+ case IIO_VOLTAGE:
+ if (chan->channel == 0) {
+ /* Voltage base units are mV hence 1.22 mV */
+ *val = 1;
+ *val2 = 220000;
+ } else {
+ /* Voltage base units are mV hence 0.61 mV */
+ *val = 0;
+ *val2 = 610000;
+ }
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_TEMP:
+ *val = -470;
+ *val2 = 0;
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_ACCEL:
+ /*
+ * IIO base unit for sensitivity of accelerometer
+ * is milli g.
+ * 1 LSB represents 0.244 mg.
+ */
+ *val = 0;
+ *val2 = IIO_G_TO_M_S_2(462400);
+ return IIO_VAL_INT_PLUS_NANO;
+ case IIO_INCLI:
+ *val = 0;
+ *val2 = 100000;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+ break;
+ case IIO_CHAN_INFO_OFFSET:
+ /*
+ * The raw ADC value is 1278 when the temperature
+ * is 25 degrees and the scale factor per milli
+ * degree celcius is -470.
+ */
+ *val = 25000 / -470 - 1278;
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ switch (chan->type) {
+ case IIO_ACCEL:
+ bits = 12;
+ break;
+ case IIO_INCLI:
+ bits = 9;
+ break;
+ default:
+ return -EINVAL;
+ }
+ addr = adis16201_addresses[chan->scan_index];
+ ret = adis_read_reg_16(st, addr, &val16);
+ if (ret)
+ return ret;
+
+ *val = sign_extend32(val16, bits - 1);
+ return IIO_VAL_INT;
+ }
+
+ return -EINVAL;
+}
+
+static int adis16201_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
+{
+ struct adis *st = iio_priv(indio_dev);
+ int m;
+
+ if (mask != IIO_CHAN_INFO_CALIBBIAS)
+ return -EINVAL;
+
+ switch (chan->type) {
+ case IIO_ACCEL:
+ m = GENMASK(11, 0);
+ break;
+ case IIO_INCLI:
+ m = GENMASK(8, 0);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return adis_write_reg_16(st, adis16201_addresses[chan->scan_index],
+ val & m);
+}
+
+static const struct iio_chan_spec adis16201_channels[] = {
+ ADIS_SUPPLY_CHAN(ADIS16201_SUPPLY_OUT_REG, ADIS16201_SCAN_SUPPLY, 0,
+ 12),
+ ADIS_TEMP_CHAN(ADIS16201_TEMP_OUT_REG, ADIS16201_SCAN_TEMP, 0, 12),
+ ADIS_ACCEL_CHAN(X, ADIS16201_XACCL_OUT_REG, ADIS16201_SCAN_ACC_X,
+ BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+ ADIS_ACCEL_CHAN(Y, ADIS16201_YACCL_OUT_REG, ADIS16201_SCAN_ACC_Y,
+ BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+ ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC_REG, ADIS16201_SCAN_AUX_ADC, 0, 12),
+ ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT_REG, ADIS16201_SCAN_INCLI_X,
+ BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+ ADIS_INCLI_CHAN(X, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
+ BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+ IIO_CHAN_SOFT_TIMESTAMP(7)
+};
+
+static const struct iio_info adis16201_info = {
+ .read_raw = adis16201_read_raw,
+ .write_raw = adis16201_write_raw,
+ .update_scan_mode = adis_update_scan_mode,
+};
+
+static const char * const adis16201_status_error_msgs[] = {
+ [ADIS16201_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure",
+ [ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed",
+ [ADIS16201_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V",
+ [ADIS16201_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V",
+};
+
+static const struct adis_data adis16201_data = {
+ .read_delay = 20,
+ .msc_ctrl_reg = ADIS16201_MSC_CTRL_REG,
+ .glob_cmd_reg = ADIS16201_GLOB_CMD_REG,
+ .diag_stat_reg = ADIS16201_DIAG_STAT_REG,
+
+ .self_test_mask = ADIS16201_MSC_CTRL_SELF_TEST_EN,
+ .self_test_no_autoclear = true,
+ .startup_delay = ADIS16201_STARTUP_DELAY_MS,
+
+ .status_error_msgs = adis16201_status_error_msgs,
+ .status_error_mask = BIT(ADIS16201_DIAG_STAT_SPI_FAIL_BIT) |
+ BIT(ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT) |
+ BIT(ADIS16201_DIAG_STAT_POWER_HIGH_BIT) |
+ BIT(ADIS16201_DIAG_STAT_POWER_LOW_BIT),
+};
+
+static int adis16201_probe(struct spi_device *spi)
+{
+ struct iio_dev *indio_dev;
+ struct adis *st;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ st = iio_priv(indio_dev);
+ spi_set_drvdata(spi, indio_dev);
+
+ indio_dev->name = spi->dev.driver->name;
+ indio_dev->dev.parent = &spi->dev;
+ indio_dev->info = &adis16201_info;
+
+ indio_dev->channels = adis16201_channels;
+ indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = adis_init(st, indio_dev, spi, &adis16201_data);
+ if (ret)
+ return ret;
+
+ ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
+ if (ret)
+ return ret;
+
+ ret = adis_initial_startup(st);
+ if (ret)
+ goto error_cleanup_buffer_trigger;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0)
+ goto error_cleanup_buffer_trigger;
+
+ return 0;
+
+error_cleanup_buffer_trigger:
+ adis_cleanup_buffer_and_trigger(st, indio_dev);
+ return ret;
+}
+
+static int adis16201_remove(struct spi_device *spi)
+{
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
+ struct adis *st = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+ adis_cleanup_buffer_and_trigger(st, indio_dev);
+
+ return 0;
+}
+
+static struct spi_driver adis16201_driver = {
+ .driver = {
+ .name = "adis16201",
+ },
+ .probe = adis16201_probe,
+ .remove = adis16201_remove,
+};
+module_spi_driver(adis16201_driver);
+
+MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
+MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("spi:adis16201");
diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c
index 72a18cfe81ee..f2dc3a5f0463 100644
--- a/drivers/staging/iio/accel/adis16209.c
+++ b/drivers/iio/accel/adis16209.c
@@ -6,7 +6,6 @@
* Licensed under the GPL-2 or later.
*/
-#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -16,8 +15,6 @@
#include <linux/sysfs.h>
#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
#include <linux/iio/imu/adis.h>
#define ADIS16209_STARTUP_DELAY_MS 220
@@ -71,13 +68,13 @@
#define ADIS16209_STAT_REG 0x3C
#define ADIS16209_STAT_ALARM2 BIT(9)
#define ADIS16209_STAT_ALARM1 BIT(8)
-#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5
-#define ADIS16209_STAT_SPI_FAIL_BIT 3
-#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2
+#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5
+#define ADIS16209_STAT_SPI_FAIL_BIT 3
+#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2
/* Power supply above 3.625 V */
-#define ADIS16209_STAT_POWER_HIGH_BIT 1
+#define ADIS16209_STAT_POWER_HIGH_BIT 1
/* Power supply below 3.15 V */
-#define ADIS16209_STAT_POWER_LOW_BIT 0
+#define ADIS16209_STAT_POWER_LOW_BIT 0
#define ADIS16209_CMD_REG 0x3E
#define ADIS16209_CMD_SW_RESET BIT(7)
@@ -115,25 +112,22 @@ static int adis16209_write_raw(struct iio_dev *indio_dev,
long mask)
{
struct adis *st = iio_priv(indio_dev);
- int bits;
- s16 val16;
- u8 addr;
+ int m;
- switch (mask) {
- case IIO_CHAN_INFO_CALIBBIAS:
- switch (chan->type) {
- case IIO_ACCEL:
- case IIO_INCLI:
- bits = 14;
- break;
- default:
- return -EINVAL;
- }
- val16 = val & ((1 << bits) - 1);
- addr = adis16209_addresses[chan->scan_index][0];
- return adis_write_reg_16(st, addr, val16);
+ if (mask != IIO_CHAN_INFO_CALIBBIAS)
+ return -EINVAL;
+
+ switch (chan->type) {
+ case IIO_ACCEL:
+ case IIO_INCLI:
+ m = GENMASK(13, 0);
+ break;
+ default:
+ return -EINVAL;
}
- return -EINVAL;
+
+ return adis_write_reg_16(st, adis16209_addresses[chan->scan_index][0],
+ val & m);
}
static int adis16209_read_raw(struct iio_dev *indio_dev,
@@ -195,7 +189,7 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_OFFSET:
/*
* The raw ADC value is 0x4FE when the temperature
- * is 25 degrees and the scale factor per milli
+ * is 45 degrees and the scale factor per milli
* degree celcius is -470.
*/
*val = 25000 / -470 - 0x4FE;
@@ -270,13 +264,14 @@ static const struct adis_data adis16209_data = {
static int adis16209_probe(struct spi_device *spi)
{
- int ret;
- struct adis *st;
struct iio_dev *indio_dev;
+ struct adis *st;
+ int ret;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
+
st = iio_priv(indio_dev);
spi_set_drvdata(spi, indio_dev);
@@ -290,6 +285,7 @@ static int adis16209_probe(struct spi_device *spi)
ret = adis_init(st, indio_dev, spi, &adis16209_data);
if (ret)
return ret;
+
ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
if (ret)
return ret;
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 208f2d9f0e8a..383c802eb5b8 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -837,29 +837,12 @@ static int bmc150_accel_fifo_transfer(struct bmc150_accel_data *data,
int sample_length = 3 * 2;
int ret;
int total_length = samples * sample_length;
- int i;
- size_t step = regmap_get_raw_read_max(data->regmap);
-
- if (!step || step > total_length)
- step = total_length;
- else if (step < total_length)
- step = sample_length;
-
- /*
- * Seems we have a bus with size limitation so we have to execute
- * multiple reads
- */
- for (i = 0; i < total_length; i += step) {
- ret = regmap_raw_read(data->regmap, BMC150_ACCEL_REG_FIFO_DATA,
- &buffer[i], step);
- if (ret)
- break;
- }
+ ret = regmap_raw_read(data->regmap, BMC150_ACCEL_REG_FIFO_DATA,
+ buffer, total_length);
if (ret)
dev_err(dev,
- "Error transferring data from fifo in single steps of %zu\n",
- step);
+ "Error transferring data from fifo: %d\n", ret);
return ret;
}
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 7a2da7f9d4dc..7e3d82cff3d5 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -106,6 +106,7 @@ struct mma8452_data {
u8 ctrl_reg1;
u8 data_cfg;
const struct mma_chip_info *chip_info;
+ int sleep_val;
};
/**
@@ -193,7 +194,11 @@ static int mma8452_drdy(struct mma8452_data *data)
if ((ret & MMA8452_STATUS_DRDY) == MMA8452_STATUS_DRDY)
return 0;
- msleep(20);
+ if (data->sleep_val <= 20)
+ usleep_range(data->sleep_val * 250,
+ data->sleep_val * 500);
+ else
+ msleep(20);
}
dev_err(&data->client->dev, "data not ready\n");
@@ -544,6 +549,18 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}
+static int mma8452_calculate_sleep(struct mma8452_data *data)
+{
+ int ret, i = mma8452_get_odr_index(data);
+
+ if (mma8452_samp_freq[i][0] > 0)
+ ret = 1000 / mma8452_samp_freq[i][0];
+ else
+ ret = 1000;
+
+ return ret == 0 ? 1 : ret;
+}
+
static int mma8452_standby(struct mma8452_data *data)
{
return i2c_smbus_write_byte_data(data->client, MMA8452_CTRL_REG1,
@@ -700,6 +717,8 @@ static int mma8452_write_raw(struct iio_dev *indio_dev,
data->ctrl_reg1 &= ~MMA8452_CTRL_DR_MASK;
data->ctrl_reg1 |= i << MMA8452_CTRL_DR_SHIFT;
+ data->sleep_val = mma8452_calculate_sleep(data);
+
ret = mma8452_change_config(data, MMA8452_CTRL_REG1,
data->ctrl_reg1);
break;
@@ -1593,6 +1612,9 @@ static int mma8452_probe(struct i2c_client *client,
data->ctrl_reg1 = MMA8452_CTRL_ACTIVE |
(MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT);
+
+ data->sleep_val = mma8452_calculate_sleep(data);
+
ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1,
data->ctrl_reg1);
if (ret < 0)
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index f33dadf7b262..4dceb75e3586 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1277,7 +1277,7 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
{
struct iio_buffer *buffer;
- buffer = iio_kfifo_allocate();
+ buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
if (!buffer)
return -ENOMEM;
@@ -1287,11 +1287,6 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
return 0;
}
-static void sca3000_unconfigure_ring(struct iio_dev *indio_dev)
-{
- iio_kfifo_free(indio_dev->buffer);
-}
-
static inline
int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
{
@@ -1486,7 +1481,9 @@ static int sca3000_probe(struct spi_device *spi)
}
indio_dev->modes = INDIO_DIRECT_MODE;
- sca3000_configure_ring(indio_dev);
+ ret = sca3000_configure_ring(indio_dev);
+ if (ret)
+ return ret;
if (spi->irq) {
ret = request_threaded_irq(spi->irq,
@@ -1546,8 +1543,6 @@ static int sca3000_remove(struct spi_device *spi)
if (spi->irq)
free_irq(spi->irq, indio_dev);
- sca3000_unconfigure_ring(indio_dev);
-
return 0;
}
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index 6bdec8c451e0..056dddb27236 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -107,6 +107,7 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match);
#ifdef CONFIG_ACPI
static const struct acpi_device_id st_accel_acpi_match[] = {
+ {"SMO8840", LNG2DM},
{"SMO8A90", LNG2DM},
{ },
};
diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index 70fbf92f9827..a9ff0695ddf7 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -153,6 +153,17 @@ struct ad7791_state {
const struct ad7791_chip_info *info;
};
+static const int ad7791_sample_freq_avail[8][2] = {
+ [AD7791_FILTER_RATE_120] = { 120, 0 },
+ [AD7791_FILTER_RATE_100] = { 100, 0 },
+ [AD7791_FILTER_RATE_33_3] = { 33, 300000 },
+ [AD7791_FILTER_RATE_20] = { 20, 0 },
+ [AD7791_FILTER_RATE_16_6] = { 16, 600000 },
+ [AD7791_FILTER_RATE_16_7] = { 16, 700000 },
+ [AD7791_FILTER_RATE_13_3] = { 13, 300000 },
+ [AD7791_FILTER_RATE_9_5] = { 9, 500000 },
+};
+
static struct ad7791_state *ad_sigma_delta_to_ad7791(struct ad_sigma_delta *sd)
{
return container_of(sd, struct ad7791_state, sd);
@@ -202,6 +213,7 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
{
struct ad7791_state *st = iio_priv(indio_dev);
bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR);
+ unsigned int rate;
switch (info) {
case IIO_CHAN_INFO_RAW:
@@ -239,63 +251,56 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ rate = st->filter & AD7791_FILTER_RATE_MASK;
+ *val = ad7791_sample_freq_avail[rate][0];
+ *val2 = ad7791_sample_freq_avail[rate][1];
+ return IIO_VAL_INT_PLUS_MICRO;
}
return -EINVAL;
}
-static const char * const ad7791_sample_freq_avail[] = {
- [AD7791_FILTER_RATE_120] = "120",
- [AD7791_FILTER_RATE_100] = "100",
- [AD7791_FILTER_RATE_33_3] = "33.3",
- [AD7791_FILTER_RATE_20] = "20",
- [AD7791_FILTER_RATE_16_6] = "16.6",
- [AD7791_FILTER_RATE_16_7] = "16.7",
- [AD7791_FILTER_RATE_13_3] = "13.3",
- [AD7791_FILTER_RATE_9_5] = "9.5",
-};
-
-static ssize_t ad7791_read_frequency(struct device *dev,
- struct device_attribute *attr, char *buf)
+static int ad7791_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int val, int val2, long mask)
{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7791_state *st = iio_priv(indio_dev);
- unsigned int rate = st->filter & AD7791_FILTER_RATE_MASK;
-
- return sprintf(buf, "%s\n", ad7791_sample_freq_avail[rate]);
-}
-
-static ssize_t ad7791_write_frequency(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ad7791_state *st = iio_priv(indio_dev);
- int i, ret;
-
- i = sysfs_match_string(ad7791_sample_freq_avail, buf);
- if (i < 0)
- return i;
+ int ret, i;
ret = iio_device_claim_direct_mode(indio_dev);
if (ret)
return ret;
- st->filter &= ~AD7791_FILTER_RATE_MASK;
- st->filter |= i;
- ad_sd_write_reg(&st->sd, AD7791_REG_FILTER, sizeof(st->filter),
- st->filter);
- iio_device_release_direct_mode(indio_dev);
- return len;
-}
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ for (i = 0; i < ARRAY_SIZE(ad7791_sample_freq_avail); i++) {
+ if (ad7791_sample_freq_avail[i][0] == val &&
+ ad7791_sample_freq_avail[i][1] == val2)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(ad7791_sample_freq_avail)) {
+ ret = -EINVAL;
+ break;
+ }
+
+ st->filter &= ~AD7791_FILTER_RATE_MASK;
+ st->filter |= i;
+ ad_sd_write_reg(&st->sd, AD7791_REG_FILTER,
+ sizeof(st->filter),
+ st->filter);
+ break;
+ default:
+ ret = -EINVAL;
+ }
-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
- ad7791_read_frequency,
- ad7791_write_frequency);
+ iio_device_release_direct_mode(indio_dev);
+ return ret;
+}
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("120 100 33.3 20 16.7 16.6 13.3 9.5");
static struct attribute *ad7791_attributes[] = {
- &iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr,
NULL
};
@@ -306,12 +311,14 @@ static const struct attribute_group ad7791_attribute_group = {
static const struct iio_info ad7791_info = {
.read_raw = &ad7791_read_raw,
+ .write_raw = &ad7791_write_raw,
.attrs = &ad7791_attribute_group,
.validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_info ad7791_no_filter_info = {
.read_raw = &ad7791_read_raw,
+ .write_raw = &ad7791_write_raw,
.validate_trigger = ad_sd_validate_trigger,
};
diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index cfab31162845..ad6764fb2a23 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -604,5 +604,5 @@ static struct platform_driver imx7d_adc_driver = {
module_platform_driver(imx7d_adc_driver);
MODULE_AUTHOR("Haibo Chen <haibo.chen@freescale.com>");
-MODULE_DESCRIPTION("Freeacale IMX7D ADC driver");
+MODULE_DESCRIPTION("Freescale IMX7D ADC driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index ede955d9b2a4..2948909f3ee3 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -219,15 +219,19 @@ enum meson_sar_adc_chan7_mux_sel {
CHAN7_MUX_CH7_INPUT = 0x7,
};
-struct meson_sar_adc_data {
+struct meson_sar_adc_param {
bool has_bl30_integration;
unsigned long clock_rate;
u32 bandgap_reg;
unsigned int resolution;
- const char *name;
const struct regmap_config *regmap_config;
};
+struct meson_sar_adc_data {
+ const struct meson_sar_adc_param *param;
+ const char *name;
+};
+
struct meson_sar_adc_priv {
struct regmap *regmap;
struct regulator *vref;
@@ -276,7 +280,7 @@ static int meson_sar_adc_calib_val(struct iio_dev *indio_dev, int val)
/* use val_calib = scale * val_raw + offset calibration function */
tmp = div_s64((s64)val * priv->calibscale, MILLION) + priv->calibbias;
- return clamp(tmp, 0, (1 << priv->data->resolution) - 1);
+ return clamp(tmp, 0, (1 << priv->data->param->resolution) - 1);
}
static int meson_sar_adc_wait_busy_clear(struct iio_dev *indio_dev)
@@ -328,7 +332,7 @@ static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev,
}
fifo_val = FIELD_GET(MESON_SAR_ADC_FIFO_RD_SAMPLE_VALUE_MASK, regval);
- fifo_val &= GENMASK(priv->data->resolution - 1, 0);
+ fifo_val &= GENMASK(priv->data->param->resolution - 1, 0);
*val = meson_sar_adc_calib_val(indio_dev, fifo_val);
return 0;
@@ -447,7 +451,7 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
mutex_lock(&indio_dev->mlock);
- if (priv->data->has_bl30_integration) {
+ if (priv->data->param->has_bl30_integration) {
/* prevent BL30 from using the SAR ADC while we are using it */
regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY,
MESON_SAR_ADC_DELAY_KERNEL_BUSY,
@@ -475,7 +479,7 @@ static void meson_sar_adc_unlock(struct iio_dev *indio_dev)
{
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
- if (priv->data->has_bl30_integration)
+ if (priv->data->param->has_bl30_integration)
/* allow BL30 to use the SAR ADC again */
regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY,
MESON_SAR_ADC_DELAY_KERNEL_BUSY, 0);
@@ -559,7 +563,7 @@ static int meson_sar_adc_iio_info_read_raw(struct iio_dev *indio_dev,
}
*val = ret / 1000;
- *val2 = priv->data->resolution;
+ *val2 = priv->data->param->resolution;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_CALIBBIAS:
@@ -632,7 +636,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
*/
meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_CH7_INPUT);
- if (priv->data->has_bl30_integration) {
+ if (priv->data->param->has_bl30_integration) {
/*
* leave sampling delay and the input clocks as configured by
* BL30 to make sure BL30 gets the values it expects when
@@ -712,7 +716,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
return ret;
}
- ret = clk_set_rate(priv->adc_clk, priv->data->clock_rate);
+ ret = clk_set_rate(priv->adc_clk, priv->data->param->clock_rate);
if (ret) {
dev_err(indio_dev->dev.parent,
"failed to set adc clock rate\n");
@@ -725,14 +729,15 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
static void meson_sar_adc_set_bandgap(struct iio_dev *indio_dev, bool on_off)
{
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
+ const struct meson_sar_adc_param *param = priv->data->param;
u32 enable_mask;
- if (priv->data->bandgap_reg == MESON_SAR_ADC_REG11)
+ if (param->bandgap_reg == MESON_SAR_ADC_REG11)
enable_mask = MESON_SAR_ADC_REG11_BANDGAP_EN;
else
enable_mask = MESON_SAR_ADC_DELTA_10_TS_VBG_EN;
- regmap_update_bits(priv->regmap, priv->data->bandgap_reg, enable_mask,
+ regmap_update_bits(priv->regmap, param->bandgap_reg, enable_mask,
on_off ? enable_mask : 0);
}
@@ -844,8 +849,8 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev)
int ret, nominal0, nominal1, value0, value1;
/* use points 25% and 75% for calibration */
- nominal0 = (1 << priv->data->resolution) / 4;
- nominal1 = (1 << priv->data->resolution) * 3 / 4;
+ nominal0 = (1 << priv->data->param->resolution) / 4;
+ nominal1 = (1 << priv->data->param->resolution) * 3 / 4;
meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_DIV4);
usleep_range(10, 20);
@@ -883,51 +888,60 @@ static const struct iio_info meson_sar_adc_iio_info = {
.read_raw = meson_sar_adc_iio_info_read_raw,
};
-static const struct meson_sar_adc_data meson_sar_adc_meson8_data = {
- .has_bl30_integration = false,
- .clock_rate = 1150000,
- .bandgap_reg = MESON_SAR_ADC_DELTA_10,
- .regmap_config = &meson_sar_adc_regmap_config_meson8,
- .resolution = 10,
- .name = "meson-meson8-saradc",
-};
-
-static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = {
+static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {
.has_bl30_integration = false,
.clock_rate = 1150000,
.bandgap_reg = MESON_SAR_ADC_DELTA_10,
.regmap_config = &meson_sar_adc_regmap_config_meson8,
.resolution = 10,
- .name = "meson-meson8b-saradc",
};
-static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = {
+static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
.has_bl30_integration = true,
.clock_rate = 1200000,
.bandgap_reg = MESON_SAR_ADC_REG11,
.regmap_config = &meson_sar_adc_regmap_config_gxbb,
.resolution = 10,
- .name = "meson-gxbb-saradc",
};
-static const struct meson_sar_adc_data meson_sar_adc_gxl_data = {
+static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
.has_bl30_integration = true,
.clock_rate = 1200000,
.bandgap_reg = MESON_SAR_ADC_REG11,
.regmap_config = &meson_sar_adc_regmap_config_gxbb,
.resolution = 12,
+};
+
+static const struct meson_sar_adc_data meson_sar_adc_meson8_data = {
+ .param = &meson_sar_adc_meson8_param,
+ .name = "meson-meson8-saradc",
+};
+
+static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = {
+ .param = &meson_sar_adc_meson8_param,
+ .name = "meson-meson8b-saradc",
+};
+
+static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = {
+ .param = &meson_sar_adc_gxbb_param,
+ .name = "meson-gxbb-saradc",
+};
+
+static const struct meson_sar_adc_data meson_sar_adc_gxl_data = {
+ .param = &meson_sar_adc_gxl_param,
.name = "meson-gxl-saradc",
};
static const struct meson_sar_adc_data meson_sar_adc_gxm_data = {
- .has_bl30_integration = true,
- .clock_rate = 1200000,
- .bandgap_reg = MESON_SAR_ADC_REG11,
- .regmap_config = &meson_sar_adc_regmap_config_gxbb,
- .resolution = 12,
+ .param = &meson_sar_adc_gxl_param,
.name = "meson-gxm-saradc",
};
+static const struct meson_sar_adc_data meson_sar_adc_axg_data = {
+ .param = &meson_sar_adc_gxl_param,
+ .name = "meson-axg-saradc",
+};
+
static const struct of_device_id meson_sar_adc_of_match[] = {
{
.compatible = "amlogic,meson8-saradc",
@@ -946,6 +960,9 @@ static const struct of_device_id meson_sar_adc_of_match[] = {
}, {
.compatible = "amlogic,meson-gxm-saradc",
.data = &meson_sar_adc_gxm_data,
+ }, {
+ .compatible = "amlogic,meson-axg-saradc",
+ .data = &meson_sar_adc_axg_data,
},
{},
};
@@ -1001,7 +1018,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
return ret;
priv->regmap = devm_regmap_init_mmio(&pdev->dev, base,
- priv->data->regmap_config);
+ priv->data->param->regmap_config);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index 40be7d9fadbf..ca432e7b6ff1 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -34,9 +34,6 @@
#define STM32F4_ADC_ADCPRE_SHIFT 16
#define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16)
-/* STM32 F4 maximum analog clock rate (from datasheet) */
-#define STM32F4_ADC_MAX_CLK_RATE 36000000
-
/* STM32H7 - common registers for all ADC instances */
#define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00)
#define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08)
@@ -51,9 +48,6 @@
#define STM32H7_CKMODE_SHIFT 16
#define STM32H7_CKMODE_MASK GENMASK(17, 16)
-/* STM32 H7 maximum analog clock rate (from datasheet) */
-#define STM32H7_ADC_MAX_CLK_RATE 36000000
-
/**
* stm32_adc_common_regs - stm32 common registers, compatible dependent data
* @csr: common status register offset
@@ -74,15 +68,17 @@ struct stm32_adc_priv;
* stm32_adc_priv_cfg - stm32 core compatible configuration data
* @regs: common registers for all instances
* @clk_sel: clock selection routine
+ * @max_clk_rate_hz: maximum analog clock rate (Hz, from datasheet)
*/
struct stm32_adc_priv_cfg {
const struct stm32_adc_common_regs *regs;
int (*clk_sel)(struct platform_device *, struct stm32_adc_priv *);
+ u32 max_clk_rate_hz;
};
/**
* struct stm32_adc_priv - stm32 ADC core private data
- * @irq: irq for ADC block
+ * @irq: irq(s) for ADC block
* @domain: irq domain reference
* @aclk: clock reference for the analog circuitry
* @bclk: bus clock common for all ADCs, depends on part used
@@ -91,7 +87,7 @@ struct stm32_adc_priv_cfg {
* @common: common data for all ADC instances
*/
struct stm32_adc_priv {
- int irq;
+ int irq[STM32_ADC_MAX_ADCS];
struct irq_domain *domain;
struct clk *aclk;
struct clk *bclk;
@@ -133,7 +129,7 @@ static int stm32f4_adc_clk_sel(struct platform_device *pdev,
}
for (i = 0; i < ARRAY_SIZE(stm32f4_pclk_div); i++) {
- if ((rate / stm32f4_pclk_div[i]) <= STM32F4_ADC_MAX_CLK_RATE)
+ if ((rate / stm32f4_pclk_div[i]) <= priv->cfg->max_clk_rate_hz)
break;
}
if (i >= ARRAY_SIZE(stm32f4_pclk_div)) {
@@ -222,7 +218,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
if (ckmode)
continue;
- if ((rate / div) <= STM32H7_ADC_MAX_CLK_RATE)
+ if ((rate / div) <= priv->cfg->max_clk_rate_hz)
goto out;
}
}
@@ -242,7 +238,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
if (!ckmode)
continue;
- if ((rate / div) <= STM32H7_ADC_MAX_CLK_RATE)
+ if ((rate / div) <= priv->cfg->max_clk_rate_hz)
goto out;
}
@@ -328,11 +324,24 @@ static int stm32_adc_irq_probe(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{
struct device_node *np = pdev->dev.of_node;
+ unsigned int i;
+
+ for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
+ priv->irq[i] = platform_get_irq(pdev, i);
+ if (priv->irq[i] < 0) {
+ /*
+ * At least one interrupt must be provided, make others
+ * optional:
+ * - stm32f4/h7 shares a common interrupt.
+ * - stm32mp1, has one line per ADC (either for ADC1,
+ * ADC2 or both).
+ */
+ if (i && priv->irq[i] == -ENXIO)
+ continue;
+ dev_err(&pdev->dev, "failed to get irq\n");
- priv->irq = platform_get_irq(pdev, 0);
- if (priv->irq < 0) {
- dev_err(&pdev->dev, "failed to get irq\n");
- return priv->irq;
+ return priv->irq[i];
+ }
}
priv->domain = irq_domain_add_simple(np, STM32_ADC_MAX_ADCS, 0,
@@ -343,8 +352,12 @@ static int stm32_adc_irq_probe(struct platform_device *pdev,
return -ENOMEM;
}
- irq_set_chained_handler(priv->irq, stm32_adc_irq_handler);
- irq_set_handler_data(priv->irq, priv);
+ for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
+ if (priv->irq[i] < 0)
+ continue;
+ irq_set_chained_handler(priv->irq[i], stm32_adc_irq_handler);
+ irq_set_handler_data(priv->irq[i], priv);
+ }
return 0;
}
@@ -353,11 +366,17 @@ static void stm32_adc_irq_remove(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{
int hwirq;
+ unsigned int i;
for (hwirq = 0; hwirq < STM32_ADC_MAX_ADCS; hwirq++)
irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq));
irq_domain_remove(priv->domain);
- irq_set_chained_handler(priv->irq, NULL);
+
+ for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
+ if (priv->irq[i] < 0)
+ continue;
+ irq_set_chained_handler(priv->irq[i], NULL);
+ }
}
static int stm32_adc_probe(struct platform_device *pdev)
@@ -497,11 +516,19 @@ static int stm32_adc_remove(struct platform_device *pdev)
static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = {
.regs = &stm32f4_adc_common_regs,
.clk_sel = stm32f4_adc_clk_sel,
+ .max_clk_rate_hz = 36000000,
};
static const struct stm32_adc_priv_cfg stm32h7_adc_priv_cfg = {
.regs = &stm32h7_adc_common_regs,
.clk_sel = stm32h7_adc_clk_sel,
+ .max_clk_rate_hz = 36000000,
+};
+
+static const struct stm32_adc_priv_cfg stm32mp1_adc_priv_cfg = {
+ .regs = &stm32h7_adc_common_regs,
+ .clk_sel = stm32h7_adc_clk_sel,
+ .max_clk_rate_hz = 40000000,
};
static const struct of_device_id stm32_adc_of_match[] = {
@@ -512,6 +539,9 @@ static const struct of_device_id stm32_adc_of_match[] = {
.compatible = "st,stm32h7-adc-core",
.data = (void *)&stm32h7_adc_priv_cfg
}, {
+ .compatible = "st,stm32mp1-adc-core",
+ .data = (void *)&stm32mp1_adc_priv_cfg
+ }, {
},
};
MODULE_DEVICE_TABLE(of, stm32_adc_of_match);
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 9a2583caedaa..378411853d75 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -84,6 +84,7 @@
#define STM32H7_ADC_CALFACT2 0xC8
/* STM32H7_ADC_ISR - bit fields */
+#define STM32MP1_VREGREADY BIT(12)
#define STM32H7_EOC BIT(2)
#define STM32H7_ADRDY BIT(0)
@@ -249,6 +250,7 @@ struct stm32_adc;
* @adc_info: per instance input channels definitions
* @trigs: external trigger sources
* @clk_required: clock is required
+ * @has_vregready: vregready status flag presence
* @selfcalib: optional routine for self-calibration
* @prepare: optional prepare routine (power-up, enable)
* @start_conv: routine to start conversions
@@ -261,6 +263,7 @@ struct stm32_adc_cfg {
const struct stm32_adc_info *adc_info;
struct stm32_adc_trig_info *trigs;
bool clk_required;
+ bool has_vregready;
int (*selfcalib)(struct stm32_adc *);
int (*prepare)(struct stm32_adc *);
void (*start_conv)(struct stm32_adc *, bool dma);
@@ -695,8 +698,12 @@ static void stm32h7_adc_stop_conv(struct stm32_adc *adc)
stm32_adc_clr_bits(adc, STM32H7_ADC_CFGR, STM32H7_DMNGT_MASK);
}
-static void stm32h7_adc_exit_pwr_down(struct stm32_adc *adc)
+static int stm32h7_adc_exit_pwr_down(struct stm32_adc *adc)
{
+ struct iio_dev *indio_dev = iio_priv_to_dev(adc);
+ int ret;
+ u32 val;
+
/* Exit deep power down, then enable ADC voltage regulator */
stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_DEEPPWD);
stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADVREGEN);
@@ -705,7 +712,20 @@ static void stm32h7_adc_exit_pwr_down(struct stm32_adc *adc)
stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_BOOST);
/* Wait for startup time */
- usleep_range(10, 20);
+ if (!adc->cfg->has_vregready) {
+ usleep_range(10, 20);
+ return 0;
+ }
+
+ ret = stm32_adc_readl_poll_timeout(STM32H7_ADC_ISR, val,
+ val & STM32MP1_VREGREADY, 100,
+ STM32_ADC_TIMEOUT_US);
+ if (ret) {
+ stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_DEEPPWD);
+ dev_err(&indio_dev->dev, "Failed to exit power down\n");
+ }
+
+ return ret;
}
static void stm32h7_adc_enter_pwr_down(struct stm32_adc *adc)
@@ -888,7 +908,9 @@ static int stm32h7_adc_selfcalib(struct stm32_adc *adc)
int ret;
u32 val;
- stm32h7_adc_exit_pwr_down(adc);
+ ret = stm32h7_adc_exit_pwr_down(adc);
+ if (ret)
+ return ret;
/*
* Select calibration mode:
@@ -952,7 +974,10 @@ static int stm32h7_adc_prepare(struct stm32_adc *adc)
{
int ret;
- stm32h7_adc_exit_pwr_down(adc);
+ ret = stm32h7_adc_exit_pwr_down(adc);
+ if (ret)
+ return ret;
+
stm32_adc_writel(adc, STM32H7_ADC_DIFSEL, adc->difsel);
ret = stm32h7_adc_enable(adc);
@@ -1944,9 +1969,23 @@ static const struct stm32_adc_cfg stm32h7_adc_cfg = {
.smp_cycles = stm32h7_adc_smp_cycles,
};
+static const struct stm32_adc_cfg stm32mp1_adc_cfg = {
+ .regs = &stm32h7_adc_regspec,
+ .adc_info = &stm32h7_adc_info,
+ .trigs = stm32h7_adc_trigs,
+ .has_vregready = true,
+ .selfcalib = stm32h7_adc_selfcalib,
+ .start_conv = stm32h7_adc_start_conv,
+ .stop_conv = stm32h7_adc_stop_conv,
+ .prepare = stm32h7_adc_prepare,
+ .unprepare = stm32h7_adc_unprepare,
+ .smp_cycles = stm32h7_adc_smp_cycles,
+};
+
static const struct of_device_id stm32_adc_of_match[] = {
{ .compatible = "st,stm32f4-adc", .data = (void *)&stm32f4_adc_cfg },
{ .compatible = "st,stm32h7-adc", .data = (void *)&stm32h7_adc_cfg },
+ { .compatible = "st,stm32mp1-adc", .data = (void *)&stm32mp1_adc_cfg },
{},
};
MODULE_DEVICE_TABLE(of, stm32_adc_of_match);
diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index b28a716a23b2..fcd4a1c00ca0 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -8,11 +8,11 @@
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
-#include <linux/interrupt.h>
+#include <linux/iio/adc/stm32-dfsdm-adc.h>
#include <linux/iio/buffer.h>
#include <linux/iio/hw-consumer.h>
-#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
+#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
@@ -254,7 +254,8 @@ static int stm32_dfsdm_start_filter(struct stm32_dfsdm *dfsdm,
DFSDM_CR1_RSWSTART(1));
}
-static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm, unsigned int fl_id)
+static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm,
+ unsigned int fl_id)
{
/* Disable conversion */
regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id),
@@ -338,7 +339,7 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
"st,adc-channel-types", chan_idx,
&of_str);
if (!ret) {
- val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type);
+ val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type);
if (val < 0)
return val;
} else {
@@ -350,7 +351,7 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
"st,adc-channel-clk-src", chan_idx,
&of_str);
if (!ret) {
- val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src);
+ val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src);
if (val < 0)
return val;
} else {
@@ -1104,7 +1105,6 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
char *name;
int ret, irq, val;
-
dev_data = of_device_get_match_data(dev);
iio = devm_iio_device_alloc(dev, sizeof(*adc));
if (!iio) {
@@ -1122,8 +1122,8 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, adc);
ret = of_property_read_u32(dev->of_node, "reg", &adc->fl_id);
- if (ret != 0) {
- dev_err(dev, "Missing reg property\n");
+ if (ret != 0 || adc->fl_id >= adc->dfsdm->num_fls) {
+ dev_err(dev, "Missing or bad reg property\n");
return -EINVAL;
}
@@ -1172,7 +1172,6 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
if (ret < 0)
goto err_cleanup;
- dev_err(dev, "of_platform_populate\n");
if (dev_data->type == DFSDM_AUDIO) {
ret = of_platform_populate(np, NULL, NULL, dev);
if (ret < 0) {
diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
index e50efdcc41ff..bf089f5d6225 100644
--- a/drivers/iio/adc/stm32-dfsdm-core.c
+++ b/drivers/iio/adc/stm32-dfsdm-core.c
@@ -25,6 +25,8 @@ struct stm32_dfsdm_dev_data {
#define STM32H7_DFSDM_NUM_FILTERS 4
#define STM32H7_DFSDM_NUM_CHANNELS 8
+#define STM32MP1_DFSDM_NUM_FILTERS 6
+#define STM32MP1_DFSDM_NUM_CHANNELS 8
static bool stm32_dfsdm_volatile_reg(struct device *dev, unsigned int reg)
{
@@ -61,6 +63,21 @@ static const struct stm32_dfsdm_dev_data stm32h7_dfsdm_data = {
.regmap_cfg = &stm32h7_dfsdm_regmap_cfg,
};
+static const struct regmap_config stm32mp1_dfsdm_regmap_cfg = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = sizeof(u32),
+ .max_register = 0x7fc,
+ .volatile_reg = stm32_dfsdm_volatile_reg,
+ .fast_io = true,
+};
+
+static const struct stm32_dfsdm_dev_data stm32mp1_dfsdm_data = {
+ .num_filters = STM32MP1_DFSDM_NUM_FILTERS,
+ .num_channels = STM32MP1_DFSDM_NUM_CHANNELS,
+ .regmap_cfg = &stm32mp1_dfsdm_regmap_cfg,
+};
+
struct dfsdm_priv {
struct platform_device *pdev; /* platform device */
@@ -227,6 +244,11 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
}
priv->spi_clk_out_div = div_u64_rem(clk_freq, spi_freq, &rem) - 1;
+ if (!priv->spi_clk_out_div) {
+ /* spi_clk_out_div == 0 means ckout is OFF */
+ dev_err(&pdev->dev, "spi-max-frequency not achievable\n");
+ return -EINVAL;
+ }
priv->dfsdm.spi_master_freq = spi_freq;
if (rem) {
@@ -243,6 +265,10 @@ static const struct of_device_id stm32_dfsdm_of_match[] = {
.compatible = "st,stm32h7-dfsdm",
.data = &stm32h7_dfsdm_data,
},
+ {
+ .compatible = "st,stm32mp1-dfsdm",
+ .data = &stm32mp1_dfsdm_data,
+ },
{}
};
MODULE_DEVICE_TABLE(of, stm32_dfsdm_of_match);
diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index 17b021f33180..0662ca199eb0 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -233,6 +233,16 @@ static int stx104_gpio_get(struct gpio_chip *chip, unsigned int offset)
return !!(inb(stx104gpio->base) & BIT(offset));
}
+static int stx104_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask,
+ unsigned long *bits)
+{
+ struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip);
+
+ *bits = inb(stx104gpio->base);
+
+ return 0;
+}
+
static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
@@ -342,6 +352,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
stx104gpio->chip.direction_input = stx104_gpio_direction_input;
stx104gpio->chip.direction_output = stx104_gpio_direction_output;
stx104gpio->chip.get = stx104_gpio_get;
+ stx104gpio->chip.get_multiple = stx104_gpio_get_multiple;
stx104gpio->chip.set = stx104_gpio_set;
stx104gpio->chip.set_multiple = stx104_gpio_set_multiple;
stx104gpio->base = base[id] + 3;
diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
index 079f133144b0..184d686ebd99 100644
--- a/drivers/iio/adc/ti-ads8688.c
+++ b/drivers/iio/adc/ti-ads8688.c
@@ -17,6 +17,9 @@
#include <linux/of.h>
#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include <linux/iio/sysfs.h>
#define ADS8688_CMD_REG(x) (x << 8)
@@ -155,6 +158,13 @@ static const struct attribute_group ads8688_attribute_group = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \
| BIT(IIO_CHAN_INFO_SCALE) \
| BIT(IIO_CHAN_INFO_OFFSET), \
+ .scan_index = index, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 16, \
+ .storagebits = 16, \
+ .endianness = IIO_BE, \
+ }, \
}
static const struct iio_chan_spec ads8684_channels[] = {
@@ -371,6 +381,28 @@ static const struct iio_info ads8688_info = {
.attrs = &ads8688_attribute_group,
};
+static irqreturn_t ads8688_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ u16 buffer[8];
+ int i, j = 0;
+
+ for (i = 0; i < indio_dev->masklength; i++) {
+ if (!test_bit(i, indio_dev->active_scan_mask))
+ continue;
+ buffer[j] = ads8688_read(indio_dev, i);
+ j++;
+ }
+
+ iio_push_to_buffers_with_timestamp(indio_dev, buffer,
+ pf->timestamp);
+
+ iio_trigger_notify_done(indio_dev->trig);
+
+ return IRQ_HANDLED;
+}
+
static const struct ads8688_chip_info ads8688_chip_info_tbl[] = {
[ID_ADS8684] = {
.channels = ads8684_channels,
@@ -402,7 +434,7 @@ static int ads8688_probe(struct spi_device *spi)
ret = regulator_get_voltage(st->reg);
if (ret < 0)
- goto error_out;
+ goto err_regulator_disable;
st->vref_mv = ret / 1000;
} else {
@@ -430,13 +462,22 @@ static int ads8688_probe(struct spi_device *spi)
mutex_init(&st->lock);
+ ret = iio_triggered_buffer_setup(indio_dev, NULL, ads8688_trigger_handler, NULL);
+ if (ret < 0) {
+ dev_err(&spi->dev, "iio triggered buffer setup failed\n");
+ goto err_regulator_disable;
+ }
+
ret = iio_device_register(indio_dev);
if (ret)
- goto error_out;
+ goto err_buffer_cleanup;
return 0;
-error_out:
+err_buffer_cleanup:
+ iio_triggered_buffer_cleanup(indio_dev);
+
+err_regulator_disable:
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
@@ -449,6 +490,7 @@ static int ads8688_remove(struct spi_device *spi)
struct ads8688_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
+ iio_triggered_buffer_cleanup(indio_dev);
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
diff --git a/drivers/iio/afe/Kconfig b/drivers/iio/afe/Kconfig
new file mode 100644
index 000000000000..c91eef04825a
--- /dev/null
+++ b/drivers/iio/afe/Kconfig
@@ -0,0 +1,19 @@
+#
+# Analog Front End drivers
+#
+# When adding new entries keep the list in alphabetical order
+
+menu "Analog Front Ends"
+
+config IIO_RESCALE
+ tristate "IIO rescale"
+ depends on OF || COMPILE_TEST
+ help
+ Say yes here to build support for the IIO rescaling
+ that handles voltage dividers, current sense shunts and
+ current sense amplifiers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called iio-rescale.
+
+endmenu
diff --git a/drivers/iio/afe/Makefile b/drivers/iio/afe/Makefile
new file mode 100644
index 000000000000..5fabb7bcac47
--- /dev/null
+++ b/drivers/iio/afe/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for industrial I/O Analog Front Ends (AFE)
+#
+
+# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_IIO_RESCALE) += iio-rescale.o
diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
new file mode 100644
index 000000000000..e9ceee66d1e7
--- /dev/null
+++ b/drivers/iio/afe/iio-rescale.c
@@ -0,0 +1,359 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IIO rescale driver
+ *
+ * Copyright (C) 2018 Axentia Technologies AB
+ *
+ * Author: Peter Rosin <peda@axentia.se>
+ */
+
+#include <linux/err.h>
+#include <linux/gcd.h>
+#include <linux/iio/consumer.h>
+#include <linux/iio/iio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+struct rescale;
+
+struct rescale_cfg {
+ enum iio_chan_type type;
+ int (*props)(struct device *dev, struct rescale *rescale);
+};
+
+struct rescale {
+ const struct rescale_cfg *cfg;
+ struct iio_channel *source;
+ struct iio_chan_spec chan;
+ struct iio_chan_spec_ext_info *ext_info;
+ s32 numerator;
+ s32 denominator;
+};
+
+static int rescale_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct rescale *rescale = iio_priv(indio_dev);
+ unsigned long long tmp;
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ return iio_read_channel_raw(rescale->source, val);
+
+ case IIO_CHAN_INFO_SCALE:
+ ret = iio_read_channel_scale(rescale->source, val, val2);
+ switch (ret) {
+ case IIO_VAL_FRACTIONAL:
+ *val *= rescale->numerator;
+ *val2 *= rescale->denominator;
+ return ret;
+ case IIO_VAL_INT:
+ *val *= rescale->numerator;
+ if (rescale->denominator == 1)
+ return ret;
+ *val2 = rescale->denominator;
+ return IIO_VAL_FRACTIONAL;
+ case IIO_VAL_FRACTIONAL_LOG2:
+ tmp = *val * 1000000000LL;
+ do_div(tmp, rescale->denominator);
+ tmp *= rescale->numerator;
+ do_div(tmp, 1000000000LL);
+ *val = tmp;
+ return ret;
+ default:
+ return -EOPNOTSUPP;
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int rescale_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ struct rescale *rescale = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ *type = IIO_VAL_INT;
+ return iio_read_avail_channel_raw(rescale->source,
+ vals, length);
+ default:
+ return -EINVAL;
+ }
+}
+
+static const struct iio_info rescale_info = {
+ .read_raw = rescale_read_raw,
+ .read_avail = rescale_read_avail,
+};
+
+static ssize_t rescale_read_ext_info(struct iio_dev *indio_dev,
+ uintptr_t private,
+ struct iio_chan_spec const *chan,
+ char *buf)
+{
+ struct rescale *rescale = iio_priv(indio_dev);
+
+ return iio_read_channel_ext_info(rescale->source,
+ rescale->ext_info[private].name,
+ buf);
+}
+
+static ssize_t rescale_write_ext_info(struct iio_dev *indio_dev,
+ uintptr_t private,
+ struct iio_chan_spec const *chan,
+ const char *buf, size_t len)
+{
+ struct rescale *rescale = iio_priv(indio_dev);
+
+ return iio_write_channel_ext_info(rescale->source,
+ rescale->ext_info[private].name,
+ buf, len);
+}
+
+static int rescale_configure_channel(struct device *dev,
+ struct rescale *rescale)
+{
+ struct iio_chan_spec *chan = &rescale->chan;
+ struct iio_chan_spec const *schan = rescale->source->channel;
+
+ chan->indexed = 1;
+ chan->output = schan->output;
+ chan->ext_info = rescale->ext_info;
+ chan->type = rescale->cfg->type;
+
+ if (!iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) ||
+ !iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) {
+ dev_err(dev, "source channel does not support raw/scale\n");
+ return -EINVAL;
+ }
+
+ chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE);
+
+ if (iio_channel_has_available(schan, IIO_CHAN_INFO_RAW))
+ chan->info_mask_separate_available |= BIT(IIO_CHAN_INFO_RAW);
+
+ return 0;
+}
+
+static int rescale_current_sense_amplifier_props(struct device *dev,
+ struct rescale *rescale)
+{
+ u32 sense;
+ u32 gain_mult = 1;
+ u32 gain_div = 1;
+ u32 factor;
+ int ret;
+
+ ret = device_property_read_u32(dev, "sense-resistor-micro-ohms",
+ &sense);
+ if (ret) {
+ dev_err(dev, "failed to read the sense resistance: %d\n", ret);
+ return ret;
+ }
+
+ device_property_read_u32(dev, "sense-gain-mult", &gain_mult);
+ device_property_read_u32(dev, "sense-gain-div", &gain_div);
+
+ /*
+ * Calculate the scaling factor, 1 / (gain * sense), or
+ * gain_div / (gain_mult * sense), while trying to keep the
+ * numerator/denominator from overflowing.
+ */
+ factor = gcd(sense, 1000000);
+ rescale->numerator = 1000000 / factor;
+ rescale->denominator = sense / factor;
+
+ factor = gcd(rescale->numerator, gain_mult);
+ rescale->numerator /= factor;
+ rescale->denominator *= gain_mult / factor;
+
+ factor = gcd(rescale->denominator, gain_div);
+ rescale->numerator *= gain_div / factor;
+ rescale->denominator /= factor;
+
+ return 0;
+}
+
+static int rescale_current_sense_shunt_props(struct device *dev,
+ struct rescale *rescale)
+{
+ u32 shunt;
+ u32 factor;
+ int ret;
+
+ ret = device_property_read_u32(dev, "shunt-resistor-micro-ohms",
+ &shunt);
+ if (ret) {
+ dev_err(dev, "failed to read the shunt resistance: %d\n", ret);
+ return ret;
+ }
+
+ factor = gcd(shunt, 1000000);
+ rescale->numerator = 1000000 / factor;
+ rescale->denominator = shunt / factor;
+
+ return 0;
+}
+
+static int rescale_voltage_divider_props(struct device *dev,
+ struct rescale *rescale)
+{
+ int ret;
+ u32 factor;
+
+ ret = device_property_read_u32(dev, "output-ohms",
+ &rescale->denominator);
+ if (ret) {
+ dev_err(dev, "failed to read output-ohms: %d\n", ret);
+ return ret;
+ }
+
+ ret = device_property_read_u32(dev, "full-ohms",
+ &rescale->numerator);
+ if (ret) {
+ dev_err(dev, "failed to read full-ohms: %d\n", ret);
+ return ret;
+ }
+
+ factor = gcd(rescale->numerator, rescale->denominator);
+ rescale->numerator /= factor;
+ rescale->denominator /= factor;
+
+ return 0;
+}
+
+enum rescale_variant {
+ CURRENT_SENSE_AMPLIFIER,
+ CURRENT_SENSE_SHUNT,
+ VOLTAGE_DIVIDER,
+};
+
+static const struct rescale_cfg rescale_cfg[] = {
+ [CURRENT_SENSE_AMPLIFIER] = {
+ .type = IIO_CURRENT,
+ .props = rescale_current_sense_amplifier_props,
+ },
+ [CURRENT_SENSE_SHUNT] = {
+ .type = IIO_CURRENT,
+ .props = rescale_current_sense_shunt_props,
+ },
+ [VOLTAGE_DIVIDER] = {
+ .type = IIO_VOLTAGE,
+ .props = rescale_voltage_divider_props,
+ },
+};
+
+static const struct of_device_id rescale_match[] = {
+ { .compatible = "current-sense-amplifier",
+ .data = &rescale_cfg[CURRENT_SENSE_AMPLIFIER], },
+ { .compatible = "current-sense-shunt",
+ .data = &rescale_cfg[CURRENT_SENSE_SHUNT], },
+ { .compatible = "voltage-divider",
+ .data = &rescale_cfg[VOLTAGE_DIVIDER], },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, rescale_match);
+
+static int rescale_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct iio_dev *indio_dev;
+ struct iio_channel *source;
+ struct rescale *rescale;
+ int sizeof_ext_info;
+ int sizeof_priv;
+ int i;
+ int ret;
+
+ source = devm_iio_channel_get(dev, NULL);
+ if (IS_ERR(source)) {
+ if (PTR_ERR(source) != -EPROBE_DEFER)
+ dev_err(dev, "failed to get source channel\n");
+ return PTR_ERR(source);
+ }
+
+ sizeof_ext_info = iio_get_channel_ext_info_count(source);
+ if (sizeof_ext_info) {
+ sizeof_ext_info += 1; /* one extra entry for the sentinel */
+ sizeof_ext_info *= sizeof(*rescale->ext_info);
+ }
+
+ sizeof_priv = sizeof(*rescale) + sizeof_ext_info;
+
+ indio_dev = devm_iio_device_alloc(dev, sizeof_priv);
+ if (!indio_dev)
+ return -ENOMEM;
+
+ rescale = iio_priv(indio_dev);
+
+ rescale->cfg = of_device_get_match_data(dev);
+ rescale->numerator = 1;
+ rescale->denominator = 1;
+
+ ret = rescale->cfg->props(dev, rescale);
+ if (ret)
+ return ret;
+
+ if (!rescale->numerator || !rescale->denominator) {
+ dev_err(dev, "invalid scaling factor.\n");
+ return -EINVAL;
+ }
+
+ platform_set_drvdata(pdev, indio_dev);
+
+ rescale->source = source;
+
+ indio_dev->name = dev_name(dev);
+ indio_dev->dev.parent = dev;
+ indio_dev->info = &rescale_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = &rescale->chan;
+ indio_dev->num_channels = 1;
+ if (sizeof_ext_info) {
+ rescale->ext_info = devm_kmemdup(dev,
+ source->channel->ext_info,
+ sizeof_ext_info, GFP_KERNEL);
+ if (!rescale->ext_info)
+ return -ENOMEM;
+
+ for (i = 0; rescale->ext_info[i].name; ++i) {
+ struct iio_chan_spec_ext_info *ext_info =
+ &rescale->ext_info[i];
+
+ if (source->channel->ext_info[i].read)
+ ext_info->read = rescale_read_ext_info;
+ if (source->channel->ext_info[i].write)
+ ext_info->write = rescale_write_ext_info;
+ ext_info->private = i;
+ }
+ }
+
+ ret = rescale_configure_channel(dev, rescale);
+ if (ret)
+ return ret;
+
+ return devm_iio_device_register(dev, indio_dev);
+}
+
+static struct platform_driver rescale_driver = {
+ .probe = rescale_probe,
+ .driver = {
+ .name = "iio-rescale",
+ .of_match_table = rescale_match,
+ },
+};
+module_platform_driver(rescale_driver);
+
+MODULE_DESCRIPTION("IIO rescale driver");
+MODULE_AUTHOR("Peter Rosin <peda@axentia.se>");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 43667866321e..0138337aedd1 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -161,12 +161,14 @@ static int ad8366_probe(struct spi_device *spi)
indio_dev->channels = ad8366_channels;
indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
+ ret = ad8366_write(indio_dev, 0 , 0);
+ if (ret < 0)
+ goto error_disable_reg;
+
ret = iio_device_register(indio_dev);
if (ret)
goto error_disable_reg;
- ad8366_write(indio_dev, 0, 0);
-
return 0;
error_disable_reg:
diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c
index abfc4bbc4cfc..a406ad31b096 100644
--- a/drivers/iio/chemical/atlas-ph-sensor.c
+++ b/drivers/iio/chemical/atlas-ph-sensor.c
@@ -61,9 +61,9 @@
#define ATLAS_REG_ORP_CALIB_STATUS 0x0d
#define ATLAS_REG_ORP_DATA 0x0e
-#define ATLAS_PH_INT_TIME_IN_US 450000
-#define ATLAS_EC_INT_TIME_IN_US 650000
-#define ATLAS_ORP_INT_TIME_IN_US 450000
+#define ATLAS_PH_INT_TIME_IN_MS 450
+#define ATLAS_EC_INT_TIME_IN_MS 650
+#define ATLAS_ORP_INT_TIME_IN_MS 450
enum {
ATLAS_PH_SM,
@@ -270,21 +270,21 @@ static struct atlas_device atlas_devices[] = {
.num_channels = 3,
.data_reg = ATLAS_REG_PH_DATA,
.calibration = &atlas_check_ph_calibration,
- .delay = ATLAS_PH_INT_TIME_IN_US,
+ .delay = ATLAS_PH_INT_TIME_IN_MS,
},
[ATLAS_EC_SM] = {
.channels = atlas_ec_channels,
.num_channels = 5,
.data_reg = ATLAS_REG_EC_DATA,
.calibration = &atlas_check_ec_calibration,
- .delay = ATLAS_EC_INT_TIME_IN_US,
+ .delay = ATLAS_EC_INT_TIME_IN_MS,
},
[ATLAS_ORP_SM] = {
.channels = atlas_orp_channels,
.num_channels = 2,
.data_reg = ATLAS_REG_ORP_DATA,
.calibration = &atlas_check_orp_calibration,
- .delay = ATLAS_ORP_INT_TIME_IN_US,
+ .delay = ATLAS_ORP_INT_TIME_IN_MS,
},
};
@@ -393,7 +393,7 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val)
}
if (suspended)
- usleep_range(data->chip->delay, data->chip->delay + 100000);
+ msleep(data->chip->delay);
ret = regmap_bulk_read(data->regmap, reg, (u8 *) val, sizeof(*val));
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 705cb3e72663..89cb0066a6e0 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -19,6 +19,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger_consumer.h>
@@ -31,8 +32,6 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
-#include "cros_ec_sensors_core.h"
-
#define CROS_EC_SENSORS_MAX_CHANNELS 4
/* State data for ec_sensors iio driver. */
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index a620eb5ce202..414cc43c287e 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger_consumer.h>
@@ -27,8 +28,6 @@
#include <linux/sysfs.h>
#include <linux/platform_device.h>
-#include "cros_ec_sensors_core.h"
-
static char *cros_ec_loc[] = {
[MOTIONSENSE_LOC_BASE] = "base",
[MOTIONSENSE_LOC_LID] = "lid",
@@ -448,8 +447,7 @@ EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);
static int __maybe_unused cros_ec_sensors_prepare(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
if (st->curr_sampl_freq == 0)
@@ -471,8 +469,7 @@ static int __maybe_unused cros_ec_sensors_prepare(struct device *dev)
static void __maybe_unused cros_ec_sensors_complete(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
if (st->curr_sampl_freq == 0)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 4905a997a7ec..1e10c0af2f2c 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -304,8 +304,7 @@ EXPORT_SYMBOL(hid_sensor_setup_trigger);
static int __maybe_unused hid_sensor_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
return _hid_sensor_power_state(attrb, false);
@@ -313,8 +312,7 @@ static int __maybe_unused hid_sensor_suspend(struct device *dev)
static int __maybe_unused hid_sensor_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
schedule_work(&attrb->work);
return 0;
@@ -322,8 +320,7 @@ static int __maybe_unused hid_sensor_resume(struct device *dev)
static int __maybe_unused hid_sensor_runtime_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
return _hid_sensor_power_state(attrb, true);
}
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index 76db0768e454..06e90debb9f5 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -131,16 +131,31 @@ config LTC2632
module will be called ltc2632.
config AD5686
- tristate "Analog Devices AD5686R/AD5685R/AD5684R DAC SPI driver"
+ tristate
+
+config AD5686_SPI
+ tristate "Analog Devices AD5686 and similar multi-channel DACs (SPI)"
depends on SPI
+ select AD5686
help
- Say yes here to build support for Analog Devices AD5686R, AD5685R,
- AD5684R, AD5791 Voltage Output Digital to
- Analog Converter.
+ Say yes here to build support for Analog Devices AD5672R, AD5676,
+ AD5676R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, AD5686R.
+ Voltage Output Digital to Analog Converter.
To compile this driver as a module, choose M here: the
module will be called ad5686.
+config AD5696_I2C
+ tristate "Analog Devices AD5696 and similar multi-channel DACs (I2C)"
+ depends on I2C
+ select AD5686
+ help
+ Say yes here to build support for Analog Devices AD5671R, AD5675R,
+ AD5694, AD5694R, AD5695R, AD5696, AD5696R Voltage Output Digital to
+ Analog Converter.
+ To compile this driver as a module, choose M here: the module will be
+ called ad5696.
+
config AD5755
tristate "Analog Devices AD5755/AD5755-1/AD5757/AD5735/AD5737 DAC driver"
depends on SPI_MASTER
@@ -321,6 +336,16 @@ config TI_DAC082S085
If compiled as a module, it will be called ti-dac082s085.
+config TI_DAC5571
+ tristate "Texas Instruments 8/10/12/16-bit 1/2/4-channel DAC driver"
+ depends on I2C
+ help
+ Driver for the Texas Instruments
+ DAC5571, DAC6571, DAC7571, DAC5574, DAC6574, DAC7574, DAC5573,
+ DAC6573, DAC7573, DAC8571, DAC8574.
+
+ If compiled as a module, it will be called ti-dac5571.
+
config VF610_DAC
tristate "Vybrid vf610 DAC driver"
depends on OF
diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
index 81e710ed7491..57aa230d34ab 100644
--- a/drivers/iio/dac/Makefile
+++ b/drivers/iio/dac/Makefile
@@ -20,6 +20,8 @@ obj-$(CONFIG_AD5761) += ad5761.o
obj-$(CONFIG_AD5764) += ad5764.o
obj-$(CONFIG_AD5791) += ad5791.o
obj-$(CONFIG_AD5686) += ad5686.o
+obj-$(CONFIG_AD5686_SPI) += ad5686-spi.o
+obj-$(CONFIG_AD5696_I2C) += ad5696-i2c.o
obj-$(CONFIG_AD7303) += ad7303.o
obj-$(CONFIG_AD8801) += ad8801.o
obj-$(CONFIG_CIO_DAC) += cio-dac.o
@@ -35,4 +37,5 @@ obj-$(CONFIG_MCP4922) += mcp4922.o
obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o
obj-$(CONFIG_STM32_DAC) += stm32-dac.o
obj-$(CONFIG_TI_DAC082S085) += ti-dac082s085.o
+obj-$(CONFIG_TI_DAC5571) += ti-dac5571.o
obj-$(CONFIG_VF610_DAC) += vf610_dac.o
diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c
new file mode 100644
index 000000000000..1df9143f55e9
--- /dev/null
+++ b/drivers/iio/dac/ad5686-spi.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AD5672R, AD5676, AD5676R, AD5681R, AD5682R, AD5683, AD5683R,
+ * AD5684, AD5684R, AD5685R, AD5686, AD5686R
+ * Digital to analog converters driver
+ *
+ * Copyright 2018 Analog Devices Inc.
+ */
+
+#include "ad5686.h"
+
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+
+static int ad5686_spi_write(struct ad5686_state *st,
+ u8 cmd, u8 addr, u16 val)
+{
+ struct spi_device *spi = to_spi_device(st->dev);
+ u8 tx_len, *buf;
+
+ switch (st->chip_info->regmap_type) {
+ case AD5683_REGMAP:
+ st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
+ AD5683_DATA(val));
+ buf = &st->data[0].d8[1];
+ tx_len = 3;
+ break;
+ case AD5686_REGMAP:
+ st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
+ AD5686_ADDR(addr) |
+ val);
+ buf = &st->data[0].d8[1];
+ tx_len = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return spi_write(spi, buf, tx_len);
+}
+
+static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
+{
+ struct spi_transfer t[] = {
+ {
+ .tx_buf = &st->data[0].d8[1],
+ .len = 3,
+ .cs_change = 1,
+ }, {
+ .tx_buf = &st->data[1].d8[1],
+ .rx_buf = &st->data[2].d8[1],
+ .len = 3,
+ },
+ };
+ struct spi_device *spi = to_spi_device(st->dev);
+ u8 cmd = 0;
+ int ret;
+
+ if (st->chip_info->regmap_type == AD5686_REGMAP)
+ cmd = AD5686_CMD_READBACK_ENABLE;
+ else if (st->chip_info->regmap_type == AD5683_REGMAP)
+ cmd = AD5686_CMD_READBACK_ENABLE_V2;
+
+ st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
+ AD5686_ADDR(addr));
+ st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));
+
+ ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t));
+ if (ret < 0)
+ return ret;
+
+ return be32_to_cpu(st->data[2].d32);
+}
+
+static int ad5686_spi_probe(struct spi_device *spi)
+{
+ const struct spi_device_id *id = spi_get_device_id(spi);
+
+ return ad5686_probe(&spi->dev, id->driver_data, id->name,
+ ad5686_spi_write, ad5686_spi_read);
+}
+
+static int ad5686_spi_remove(struct spi_device *spi)
+{
+ return ad5686_remove(&spi->dev);
+}
+
+static const struct spi_device_id ad5686_spi_id[] = {
+ {"ad5672r", ID_AD5672R},
+ {"ad5676", ID_AD5676},
+ {"ad5676r", ID_AD5676R},
+ {"ad5681r", ID_AD5681R},
+ {"ad5682r", ID_AD5682R},
+ {"ad5683", ID_AD5683},
+ {"ad5683r", ID_AD5683R},
+ {"ad5684", ID_AD5684},
+ {"ad5684r", ID_AD5684R},
+ {"ad5685", ID_AD5685R}, /* Does not exist */
+ {"ad5685r", ID_AD5685R},
+ {"ad5686", ID_AD5686},
+ {"ad5686r", ID_AD5686R},
+ {}
+};
+MODULE_DEVICE_TABLE(spi, ad5686_spi_id);
+
+static struct spi_driver ad5686_spi_driver = {
+ .driver = {
+ .name = "ad5686",
+ },
+ .probe = ad5686_spi_probe,
+ .remove = ad5686_spi_remove,
+ .id_table = ad5686_spi_id,
+};
+
+module_spi_driver(ad5686_spi_driver);
+
+MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");
+MODULE_DESCRIPTION("Analog Devices AD5686 and similar multi-channel DACs");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 20254df7f9c7..e136f0fd38f0 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* AD5686R, AD5685R, AD5684R Digital to analog converters driver
*
* Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
*/
#include <linux/interrupt.h>
@@ -11,7 +10,6 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/regulator/consumer.h>
@@ -19,116 +17,7 @@
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
-#define AD5686_DAC_CHANNELS 4
-
-#define AD5686_ADDR(x) ((x) << 16)
-#define AD5686_CMD(x) ((x) << 20)
-
-#define AD5686_ADDR_DAC(chan) (0x1 << (chan))
-#define AD5686_ADDR_ALL_DAC 0xF
-
-#define AD5686_CMD_NOOP 0x0
-#define AD5686_CMD_WRITE_INPUT_N 0x1
-#define AD5686_CMD_UPDATE_DAC_N 0x2
-#define AD5686_CMD_WRITE_INPUT_N_UPDATE_N 0x3
-#define AD5686_CMD_POWERDOWN_DAC 0x4
-#define AD5686_CMD_LDAC_MASK 0x5
-#define AD5686_CMD_RESET 0x6
-#define AD5686_CMD_INTERNAL_REFER_SETUP 0x7
-#define AD5686_CMD_DAISY_CHAIN_ENABLE 0x8
-#define AD5686_CMD_READBACK_ENABLE 0x9
-
-#define AD5686_LDAC_PWRDN_NONE 0x0
-#define AD5686_LDAC_PWRDN_1K 0x1
-#define AD5686_LDAC_PWRDN_100K 0x2
-#define AD5686_LDAC_PWRDN_3STATE 0x3
-
-/**
- * struct ad5686_chip_info - chip specific information
- * @int_vref_mv: AD5620/40/60: the internal reference voltage
- * @channel: channel specification
-*/
-
-struct ad5686_chip_info {
- u16 int_vref_mv;
- struct iio_chan_spec channel[AD5686_DAC_CHANNELS];
-};
-
-/**
- * struct ad5446_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @reg: supply regulator
- * @vref_mv: actual reference voltage used
- * @pwr_down_mask: power down mask
- * @pwr_down_mode: current power down mode
- * @data: spi transfer buffers
- */
-
-struct ad5686_state {
- struct spi_device *spi;
- const struct ad5686_chip_info *chip_info;
- struct regulator *reg;
- unsigned short vref_mv;
- unsigned pwr_down_mask;
- unsigned pwr_down_mode;
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
-
- union {
- __be32 d32;
- u8 d8[4];
- } data[3] ____cacheline_aligned;
-};
-
-/**
- * ad5686_supported_device_ids:
- */
-
-enum ad5686_supported_device_ids {
- ID_AD5684,
- ID_AD5685,
- ID_AD5686,
-};
-static int ad5686_spi_write(struct ad5686_state *st,
- u8 cmd, u8 addr, u16 val, u8 shift)
-{
- val <<= shift;
-
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
- AD5686_ADDR(addr) |
- val);
-
- return spi_write(st->spi, &st->data[0].d8[1], 3);
-}
-
-static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
-{
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .tx_buf = &st->data[1].d8[1],
- .rx_buf = &st->data[2].d8[1],
- .len = 3,
- },
- };
- int ret;
-
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) |
- AD5686_ADDR(addr));
- st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));
-
- ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t));
- if (ret < 0)
- return ret;
-
- return be32_to_cpu(st->data[2].d32);
-}
+#include "ad5686.h"
static const char * const ad5686_powerdown_modes[] = {
"1kohm_to_gnd",
@@ -137,7 +26,7 @@ static const char * const ad5686_powerdown_modes[] = {
};
static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
+ const struct iio_chan_spec *chan)
{
struct ad5686_state *st = iio_priv(indio_dev);
@@ -145,7 +34,8 @@ static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev,
}
static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, unsigned int mode)
+ const struct iio_chan_spec *chan,
+ unsigned int mode)
{
struct ad5686_state *st = iio_priv(indio_dev);
@@ -163,21 +53,25 @@ static const struct iio_enum ad5686_powerdown_mode_enum = {
};
static ssize_t ad5686_read_dac_powerdown(struct iio_dev *indio_dev,
- uintptr_t private, const struct iio_chan_spec *chan, char *buf)
+ uintptr_t private, const struct iio_chan_spec *chan, char *buf)
{
struct ad5686_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n", !!(st->pwr_down_mask &
- (0x3 << (chan->channel * 2))));
+ (0x3 << (chan->channel * 2))));
}
static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
- uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
- size_t len)
+ uintptr_t private,
+ const struct iio_chan_spec *chan,
+ const char *buf,
+ size_t len)
{
bool readin;
int ret;
struct ad5686_state *st = iio_priv(indio_dev);
+ unsigned int val, ref_bit_msk;
+ u8 shift;
ret = strtobool(buf, &readin);
if (ret)
@@ -188,8 +82,28 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
else
st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));
- ret = ad5686_spi_write(st, AD5686_CMD_POWERDOWN_DAC, 0,
- st->pwr_down_mask & st->pwr_down_mode, 0);
+ switch (st->chip_info->regmap_type) {
+ case AD5683_REGMAP:
+ shift = 13;
+ ref_bit_msk = AD5683_REF_BIT_MSK;
+ break;
+ case AD5686_REGMAP:
+ shift = 0;
+ ref_bit_msk = 0;
+ break;
+ case AD5693_REGMAP:
+ shift = 13;
+ ref_bit_msk = AD5693_REF_BIT_MSK;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ val = ((st->pwr_down_mask & st->pwr_down_mode) << shift);
+ if (!st->use_internal_vref)
+ val |= ref_bit_msk;
+
+ ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, 0, val);
return ret ? ret : len;
}
@@ -206,7 +120,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
- ret = ad5686_spi_read(st, chan->address);
+ ret = st->read(st, chan->address);
mutex_unlock(&indio_dev->mlock);
if (ret < 0)
return ret;
@@ -221,10 +135,10 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
}
static int ad5686_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
{
struct ad5686_state *st = iio_priv(indio_dev);
int ret;
@@ -235,11 +149,10 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
return -EINVAL;
mutex_lock(&indio_dev->mlock);
- ret = ad5686_spi_write(st,
- AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address,
- val,
- chan->scan_type.shift);
+ ret = st->write(st,
+ AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
+ chan->address,
+ val << chan->scan_type.shift);
mutex_unlock(&indio_dev->mlock);
break;
default:
@@ -266,14 +179,14 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
{ },
};
-#define AD5868_CHANNEL(chan, bits, _shift) { \
+#define AD5868_CHANNEL(chan, addr, bits, _shift) { \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.output = 1, \
.channel = chan, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\
- .address = AD5686_ADDR_DAC(chan), \
+ .address = addr, \
.scan_type = { \
.sign = 'u', \
.realbits = (bits), \
@@ -283,45 +196,191 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
.ext_info = ad5686_ext_info, \
}
+#define DECLARE_AD5693_CHANNELS(name, bits, _shift) \
+static struct iio_chan_spec name[] = { \
+ AD5868_CHANNEL(0, 0, bits, _shift), \
+}
+
+#define DECLARE_AD5686_CHANNELS(name, bits, _shift) \
+static struct iio_chan_spec name[] = { \
+ AD5868_CHANNEL(0, 1, bits, _shift), \
+ AD5868_CHANNEL(1, 2, bits, _shift), \
+ AD5868_CHANNEL(2, 4, bits, _shift), \
+ AD5868_CHANNEL(3, 8, bits, _shift), \
+}
+
+#define DECLARE_AD5676_CHANNELS(name, bits, _shift) \
+static struct iio_chan_spec name[] = { \
+ AD5868_CHANNEL(0, 0, bits, _shift), \
+ AD5868_CHANNEL(1, 1, bits, _shift), \
+ AD5868_CHANNEL(2, 2, bits, _shift), \
+ AD5868_CHANNEL(3, 3, bits, _shift), \
+ AD5868_CHANNEL(4, 4, bits, _shift), \
+ AD5868_CHANNEL(5, 5, bits, _shift), \
+ AD5868_CHANNEL(6, 6, bits, _shift), \
+ AD5868_CHANNEL(7, 7, bits, _shift), \
+}
+
+DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4);
+DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0);
+DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4);
+DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2);
+DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0);
+DECLARE_AD5693_CHANNELS(ad5693_channels, 16, 0);
+DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2);
+DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4);
+
static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
+ [ID_AD5671R] = {
+ .channels = ad5672_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5672R] = {
+ .channels = ad5672_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5675R] = {
+ .channels = ad5676_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5676] = {
+ .channels = ad5676_channels,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5676R] = {
+ .channels = ad5676_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5681R] = {
+ .channels = ad5691r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+ },
+ [ID_AD5682R] = {
+ .channels = ad5692r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+ },
+ [ID_AD5683] = {
+ .channels = ad5693_channels,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+ },
+ [ID_AD5683R] = {
+ .channels = ad5693_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+ },
[ID_AD5684] = {
- .channel[0] = AD5868_CHANNEL(0, 12, 4),
- .channel[1] = AD5868_CHANNEL(1, 12, 4),
- .channel[2] = AD5868_CHANNEL(2, 12, 4),
- .channel[3] = AD5868_CHANNEL(3, 12, 4),
+ .channels = ad5684_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5684R] = {
+ .channels = ad5684_channels,
.int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
},
- [ID_AD5685] = {
- .channel[0] = AD5868_CHANNEL(0, 14, 2),
- .channel[1] = AD5868_CHANNEL(1, 14, 2),
- .channel[2] = AD5868_CHANNEL(2, 14, 2),
- .channel[3] = AD5868_CHANNEL(3, 14, 2),
+ [ID_AD5685R] = {
+ .channels = ad5685r_channels,
.int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
},
[ID_AD5686] = {
- .channel[0] = AD5868_CHANNEL(0, 16, 0),
- .channel[1] = AD5868_CHANNEL(1, 16, 0),
- .channel[2] = AD5868_CHANNEL(2, 16, 0),
- .channel[3] = AD5868_CHANNEL(3, 16, 0),
+ .channels = ad5686_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5686R] = {
+ .channels = ad5686_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5691R] = {
+ .channels = ad5691r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5693_REGMAP,
+ },
+ [ID_AD5692R] = {
+ .channels = ad5692r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5693_REGMAP,
+ },
+ [ID_AD5693] = {
+ .channels = ad5693_channels,
+ .num_channels = 1,
+ .regmap_type = AD5693_REGMAP,
+ },
+ [ID_AD5693R] = {
+ .channels = ad5693_channels,
.int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5693_REGMAP,
+ },
+ [ID_AD5694] = {
+ .channels = ad5684_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5694R] = {
+ .channels = ad5684_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5696] = {
+ .channels = ad5686_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+ },
+ [ID_AD5696R] = {
+ .channels = ad5686_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
},
};
-
-static int ad5686_probe(struct spi_device *spi)
+int ad5686_probe(struct device *dev,
+ enum ad5686_supported_device_ids chip_type,
+ const char *name, ad5686_write_func write,
+ ad5686_read_func read)
{
struct ad5686_state *st;
struct iio_dev *indio_dev;
- int ret, voltage_uv = 0;
+ unsigned int val, ref_bit_msk;
+ u8 cmd;
+ int ret, i, voltage_uv = 0;
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
+ dev_set_drvdata(dev, indio_dev);
+
+ st->dev = dev;
+ st->write = write;
+ st->read = read;
- st->reg = devm_regulator_get_optional(&spi->dev, "vcc");
+ st->reg = devm_regulator_get_optional(dev, "vcc");
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
@@ -334,28 +393,47 @@ static int ad5686_probe(struct spi_device *spi)
voltage_uv = ret;
}
- st->chip_info =
- &ad5686_chip_info_tbl[spi_get_device_id(spi)->driver_data];
+ st->chip_info = &ad5686_chip_info_tbl[chip_type];
if (voltage_uv)
st->vref_mv = voltage_uv / 1000;
else
st->vref_mv = st->chip_info->int_vref_mv;
- st->spi = spi;
-
/* Set all the power down mode for all channels to 1K pulldown */
- st->pwr_down_mode = 0x55;
+ for (i = 0; i < st->chip_info->num_channels; i++)
+ st->pwr_down_mode |= (0x01 << (i * 2));
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
+ indio_dev->dev.parent = dev;
+ indio_dev->name = name;
indio_dev->info = &ad5686_info;
indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = st->chip_info->channel;
- indio_dev->num_channels = AD5686_DAC_CHANNELS;
+ indio_dev->channels = st->chip_info->channels;
+ indio_dev->num_channels = st->chip_info->num_channels;
+
+ switch (st->chip_info->regmap_type) {
+ case AD5683_REGMAP:
+ cmd = AD5686_CMD_CONTROL_REG;
+ ref_bit_msk = AD5683_REF_BIT_MSK;
+ st->use_internal_vref = !voltage_uv;
+ break;
+ case AD5686_REGMAP:
+ cmd = AD5686_CMD_INTERNAL_REFER_SETUP;
+ ref_bit_msk = 0;
+ break;
+ case AD5693_REGMAP:
+ cmd = AD5686_CMD_CONTROL_REG;
+ ref_bit_msk = AD5693_REF_BIT_MSK;
+ st->use_internal_vref = !voltage_uv;
+ break;
+ default:
+ ret = -EINVAL;
+ goto error_disable_reg;
+ }
+
+ val = (voltage_uv | ref_bit_msk);
- ret = ad5686_spi_write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0,
- !!voltage_uv, 0);
+ ret = st->write(st, cmd, 0, !!val);
if (ret)
goto error_disable_reg;
@@ -370,10 +448,11 @@ error_disable_reg:
regulator_disable(st->reg);
return ret;
}
+EXPORT_SYMBOL_GPL(ad5686_probe);
-static int ad5686_remove(struct spi_device *spi)
+int ad5686_remove(struct device *dev)
{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad5686_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
@@ -382,24 +461,7 @@ static int ad5686_remove(struct spi_device *spi)
return 0;
}
-
-static const struct spi_device_id ad5686_id[] = {
- {"ad5684", ID_AD5684},
- {"ad5685", ID_AD5685},
- {"ad5686", ID_AD5686},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5686_id);
-
-static struct spi_driver ad5686_driver = {
- .driver = {
- .name = "ad5686",
- },
- .probe = ad5686_probe,
- .remove = ad5686_remove,
- .id_table = ad5686_id,
-};
-module_spi_driver(ad5686_driver);
+EXPORT_SYMBOL_GPL(ad5686_remove);
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
MODULE_DESCRIPTION("Analog Devices AD5686/85/84 DAC");
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
new file mode 100644
index 000000000000..d05cda9f1edd
--- /dev/null
+++ b/drivers/iio/dac/ad5686.h
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file is part of AD5686 DAC driver
+ *
+ * Copyright 2018 Analog Devices Inc.
+ */
+
+#ifndef __DRIVERS_IIO_DAC_AD5686_H__
+#define __DRIVERS_IIO_DAC_AD5686_H__
+
+#include <linux/types.h>
+#include <linux/cache.h>
+#include <linux/mutex.h>
+#include <linux/kernel.h>
+
+#define AD5683_DATA(x) ((x) << 4)
+#define AD5686_ADDR(x) ((x) << 16)
+#define AD5686_CMD(x) ((x) << 20)
+
+#define AD5686_ADDR_DAC(chan) (0x1 << (chan))
+#define AD5686_ADDR_ALL_DAC 0xF
+
+#define AD5686_CMD_NOOP 0x0
+#define AD5686_CMD_WRITE_INPUT_N 0x1
+#define AD5686_CMD_UPDATE_DAC_N 0x2
+#define AD5686_CMD_WRITE_INPUT_N_UPDATE_N 0x3
+#define AD5686_CMD_POWERDOWN_DAC 0x4
+#define AD5686_CMD_LDAC_MASK 0x5
+#define AD5686_CMD_RESET 0x6
+#define AD5686_CMD_INTERNAL_REFER_SETUP 0x7
+#define AD5686_CMD_DAISY_CHAIN_ENABLE 0x8
+#define AD5686_CMD_READBACK_ENABLE 0x9
+
+#define AD5686_LDAC_PWRDN_NONE 0x0
+#define AD5686_LDAC_PWRDN_1K 0x1
+#define AD5686_LDAC_PWRDN_100K 0x2
+#define AD5686_LDAC_PWRDN_3STATE 0x3
+
+#define AD5686_CMD_CONTROL_REG 0x4
+#define AD5686_CMD_READBACK_ENABLE_V2 0x5
+#define AD5683_REF_BIT_MSK BIT(12)
+#define AD5693_REF_BIT_MSK BIT(12)
+
+/**
+ * ad5686_supported_device_ids:
+ */
+enum ad5686_supported_device_ids {
+ ID_AD5671R,
+ ID_AD5672R,
+ ID_AD5675R,
+ ID_AD5676,
+ ID_AD5676R,
+ ID_AD5681R,
+ ID_AD5682R,
+ ID_AD5683,
+ ID_AD5683R,
+ ID_AD5684,
+ ID_AD5684R,
+ ID_AD5685R,
+ ID_AD5686,
+ ID_AD5686R,
+ ID_AD5691R,
+ ID_AD5692R,
+ ID_AD5693,
+ ID_AD5693R,
+ ID_AD5694,
+ ID_AD5694R,
+ ID_AD5695R,
+ ID_AD5696,
+ ID_AD5696R,
+};
+
+enum ad5686_regmap_type {
+ AD5683_REGMAP,
+ AD5686_REGMAP,
+ AD5693_REGMAP
+};
+
+struct ad5686_state;
+
+typedef int (*ad5686_write_func)(struct ad5686_state *st,
+ u8 cmd, u8 addr, u16 val);
+
+typedef int (*ad5686_read_func)(struct ad5686_state *st, u8 addr);
+
+/**
+ * struct ad5686_chip_info - chip specific information
+ * @int_vref_mv: AD5620/40/60: the internal reference voltage
+ * @num_channels: number of channels
+ * @channel: channel specification
+ * @regmap_type: register map layout variant
+ */
+
+struct ad5686_chip_info {
+ u16 int_vref_mv;
+ unsigned int num_channels;
+ struct iio_chan_spec *channels;
+ enum ad5686_regmap_type regmap_type;
+};
+
+/**
+ * struct ad5446_state - driver instance specific data
+ * @spi: spi_device
+ * @chip_info: chip model specific constants, available modes etc
+ * @reg: supply regulator
+ * @vref_mv: actual reference voltage used
+ * @pwr_down_mask: power down mask
+ * @pwr_down_mode: current power down mode
+ * @use_internal_vref: set to true if the internal reference voltage is used
+ * @data: spi transfer buffers
+ */
+
+struct ad5686_state {
+ struct device *dev;
+ const struct ad5686_chip_info *chip_info;
+ struct regulator *reg;
+ unsigned short vref_mv;
+ unsigned int pwr_down_mask;
+ unsigned int pwr_down_mode;
+ ad5686_write_func write;
+ ad5686_read_func read;
+ bool use_internal_vref;
+
+ /*
+ * DMA (thus cache coherency maintenance) requires the
+ * transfer buffers to live in their own cache lines.
+ */
+
+ union {
+ __be32 d32;
+ __be16 d16;
+ u8 d8[4];
+ } data[3] ____cacheline_aligned;
+};
+
+
+int ad5686_probe(struct device *dev,
+ enum ad5686_supported_device_ids chip_type,
+ const char *name, ad5686_write_func write,
+ ad5686_read_func read);
+
+int ad5686_remove(struct device *dev);
+
+
+#endif /* __DRIVERS_IIO_DAC_AD5686_H__ */
diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
new file mode 100644
index 000000000000..d18735d7d938
--- /dev/null
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R,
+ * AD5694, AD5694R, AD5695R, AD5696, AD5696R
+ * Digital to analog converters driver
+ *
+ * Copyright 2018 Analog Devices Inc.
+ */
+
+#include "ad5686.h"
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+
+static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
+{
+ struct i2c_client *i2c = to_i2c_client(st->dev);
+ struct i2c_msg msg[2] = {
+ {
+ .addr = i2c->addr,
+ .flags = i2c->flags,
+ .len = 3,
+ .buf = &st->data[0].d8[1],
+ },
+ {
+ .addr = i2c->addr,
+ .flags = i2c->flags | I2C_M_RD,
+ .len = 2,
+ .buf = (char *)&st->data[0].d16,
+ },
+ };
+ int ret;
+
+ st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP) |
+ AD5686_ADDR(addr) |
+ 0x00);
+
+ ret = i2c_transfer(i2c->adapter, msg, 2);
+ if (ret < 0)
+ return ret;
+
+ return be16_to_cpu(st->data[0].d16);
+}
+
+static int ad5686_i2c_write(struct ad5686_state *st,
+ u8 cmd, u8 addr, u16 val)
+{
+ struct i2c_client *i2c = to_i2c_client(st->dev);
+ int ret;
+
+ st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) | AD5686_ADDR(addr)
+ | val);
+
+ ret = i2c_master_send(i2c, &st->data[0].d8[1], 3);
+ if (ret < 0)
+ return ret;
+
+ return (ret != 3) ? -EIO : 0;
+}
+
+static int ad5686_i2c_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
+{
+ return ad5686_probe(&i2c->dev, id->driver_data, id->name,
+ ad5686_i2c_write, ad5686_i2c_read);
+}
+
+static int ad5686_i2c_remove(struct i2c_client *i2c)
+{
+ return ad5686_remove(&i2c->dev);
+}
+
+static const struct i2c_device_id ad5686_i2c_id[] = {
+ {"ad5671r", ID_AD5671R},
+ {"ad5675r", ID_AD5675R},
+ {"ad5691r", ID_AD5691R},
+ {"ad5692r", ID_AD5692R},
+ {"ad5693", ID_AD5693},
+ {"ad5693r", ID_AD5693R},
+ {"ad5694", ID_AD5694},
+ {"ad5694r", ID_AD5694R},
+ {"ad5695r", ID_AD5695R},
+ {"ad5696", ID_AD5696},
+ {"ad5696r", ID_AD5696R},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id);
+
+static struct i2c_driver ad5686_i2c_driver = {
+ .driver = {
+ .name = "ad5696",
+ },
+ .probe = ad5686_i2c_probe,
+ .remove = ad5686_i2c_remove,
+ .id_table = ad5686_i2c_id,
+};
+
+module_i2c_driver(ad5686_i2c_driver);
+
+MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");
+MODULE_DESCRIPTION("Analog Devices AD5686 and similar multi-channel DACs");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c
index af2ddd0dd341..cca278eaa138 100644
--- a/drivers/iio/dac/ltc2632.c
+++ b/drivers/iio/dac/ltc2632.c
@@ -2,6 +2,7 @@
* LTC2632 Digital to analog convertors spi driver
*
* Copyright 2017 Maxime Roussin-Bélanger
+ * expanded by Silvan Murer <silvan.murer@gmail.com>
*
* Licensed under the GPL-2.
*/
@@ -10,6 +11,7 @@
#include <linux/spi/spi.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
+#include <linux/regulator/consumer.h>
#define LTC2632_DAC_CHANNELS 2
@@ -28,7 +30,7 @@
/**
* struct ltc2632_chip_info - chip specific information
* @channels: channel spec for the DAC
- * @vref_mv: reference voltage
+ * @vref_mv: internal reference voltage
*/
struct ltc2632_chip_info {
const struct iio_chan_spec *channels;
@@ -39,10 +41,14 @@ struct ltc2632_chip_info {
* struct ltc2632_state - driver instance specific data
* @spi_dev: pointer to the spi_device struct
* @powerdown_cache_mask used to show current channel powerdown state
+ * @vref_mv used reference voltage (internal or external)
+ * @vref_reg regulator for the reference voltage
*/
struct ltc2632_state {
struct spi_device *spi_dev;
unsigned int powerdown_cache_mask;
+ int vref_mv;
+ struct regulator *vref_reg;
};
enum ltc2632_supported_device_ids {
@@ -90,7 +96,7 @@ static int ltc2632_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_SCALE:
- *val = chip_info->vref_mv;
+ *val = st->vref_mv;
*val2 = chan->scan_type.realbits;
return IIO_VAL_FRACTIONAL_LOG2;
}
@@ -246,6 +252,45 @@ static int ltc2632_probe(struct spi_device *spi)
chip_info = (struct ltc2632_chip_info *)
spi_get_device_id(spi)->driver_data;
+ st->vref_reg = devm_regulator_get_optional(&spi->dev, "vref");
+ if (PTR_ERR(st->vref_reg) == -ENODEV) {
+ /* use internal reference voltage */
+ st->vref_reg = NULL;
+ st->vref_mv = chip_info->vref_mv;
+
+ ret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER,
+ 0, 0, 0);
+ if (ret) {
+ dev_err(&spi->dev,
+ "Set internal reference command failed, %d\n",
+ ret);
+ return ret;
+ }
+ } else if (IS_ERR(st->vref_reg)) {
+ dev_err(&spi->dev,
+ "Error getting voltage reference regulator\n");
+ return PTR_ERR(st->vref_reg);
+ } else {
+ /* use external reference voltage */
+ ret = regulator_enable(st->vref_reg);
+ if (ret) {
+ dev_err(&spi->dev,
+ "enable reference regulator failed, %d\n",
+ ret);
+ return ret;
+ }
+ st->vref_mv = regulator_get_voltage(st->vref_reg) / 1000;
+
+ ret = ltc2632_spi_write(spi, LTC2632_CMD_EXTERNAL_REFER,
+ 0, 0, 0);
+ if (ret) {
+ dev_err(&spi->dev,
+ "Set external reference command failed, %d\n",
+ ret);
+ return ret;
+ }
+ }
+
indio_dev->dev.parent = &spi->dev;
indio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name
: spi_get_device_id(spi)->name;
@@ -254,14 +299,20 @@ static int ltc2632_probe(struct spi_device *spi)
indio_dev->channels = chip_info->channels;
indio_dev->num_channels = LTC2632_DAC_CHANNELS;
- ret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0);
- if (ret) {
- dev_err(&spi->dev,
- "Set internal reference command failed, %d\n", ret);
- return ret;
- }
+ return iio_device_register(indio_dev);
+}
- return devm_iio_device_register(&spi->dev, indio_dev);
+static int ltc2632_remove(struct spi_device *spi)
+{
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
+ struct ltc2632_state *st = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ if (st->vref_reg)
+ regulator_disable(st->vref_reg);
+
+ return 0;
}
static const struct spi_device_id ltc2632_id[] = {
@@ -275,15 +326,6 @@ static const struct spi_device_id ltc2632_id[] = {
};
MODULE_DEVICE_TABLE(spi, ltc2632_id);
-static struct spi_driver ltc2632_driver = {
- .driver = {
- .name = "ltc2632",
- },
- .probe = ltc2632_probe,
- .id_table = ltc2632_id,
-};
-module_spi_driver(ltc2632_driver);
-
static const struct of_device_id ltc2632_of_match[] = {
{
.compatible = "lltc,ltc2632-l12",
@@ -308,6 +350,17 @@ static const struct of_device_id ltc2632_of_match[] = {
};
MODULE_DEVICE_TABLE(of, ltc2632_of_match);
+static struct spi_driver ltc2632_driver = {
+ .driver = {
+ .name = "ltc2632",
+ .of_match_table = of_match_ptr(ltc2632_of_match),
+ },
+ .probe = ltc2632_probe,
+ .remove = ltc2632_remove,
+ .id_table = ltc2632_id,
+};
+module_spi_driver(ltc2632_driver);
+
MODULE_AUTHOR("Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>");
MODULE_DESCRIPTION("LTC2632 DAC SPI driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c
new file mode 100644
index 000000000000..dd21eebed6a8
--- /dev/null
+++ b/drivers/iio/dac/ti-dac5571.c
@@ -0,0 +1,439 @@
+/*
+ * ti-dac5571.c - Texas Instruments 8/10/12-bit 1/4-channel DAC driver
+ *
+ * Copyright (C) 2018 Prevas A/S
+ *
+ * http://www.ti.com/lit/ds/symlink/dac5571.pdf
+ * http://www.ti.com/lit/ds/symlink/dac6571.pdf
+ * http://www.ti.com/lit/ds/symlink/dac7571.pdf
+ * http://www.ti.com/lit/ds/symlink/dac5574.pdf
+ * http://www.ti.com/lit/ds/symlink/dac6574.pdf
+ * http://www.ti.com/lit/ds/symlink/dac7574.pdf
+ * http://www.ti.com/lit/ds/symlink/dac5573.pdf
+ * http://www.ti.com/lit/ds/symlink/dac6573.pdf
+ * http://www.ti.com/lit/ds/symlink/dac7573.pdf
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/iio/iio.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+enum chip_id {
+ single_8bit, single_10bit, single_12bit,
+ quad_8bit, quad_10bit, quad_12bit
+};
+
+struct dac5571_spec {
+ u8 num_channels;
+ u8 resolution;
+};
+
+static const struct dac5571_spec dac5571_spec[] = {
+ [single_8bit] = {.num_channels = 1, .resolution = 8},
+ [single_10bit] = {.num_channels = 1, .resolution = 10},
+ [single_12bit] = {.num_channels = 1, .resolution = 12},
+ [quad_8bit] = {.num_channels = 4, .resolution = 8},
+ [quad_10bit] = {.num_channels = 4, .resolution = 10},
+ [quad_12bit] = {.num_channels = 4, .resolution = 12},
+};
+
+struct dac5571_data {
+ struct i2c_client *client;
+ int id;
+ struct mutex lock;
+ struct regulator *vref;
+ u16 val[4];
+ bool powerdown;
+ u8 powerdown_mode;
+ struct dac5571_spec const *spec;
+ int (*dac5571_cmd)(struct dac5571_data *data, int channel, u16 val);
+ int (*dac5571_pwrdwn)(struct dac5571_data *data, int channel, u8 pwrdwn);
+ u8 buf[3] ____cacheline_aligned;
+};
+
+#define DAC5571_POWERDOWN(mode) ((mode) + 1)
+#define DAC5571_POWERDOWN_FLAG BIT(0)
+#define DAC5571_CHANNEL_SELECT 1
+#define DAC5571_LOADMODE_DIRECT BIT(4)
+#define DAC5571_SINGLE_PWRDWN_BITS 4
+#define DAC5571_QUAD_PWRDWN_BITS 6
+
+static int dac5571_cmd_single(struct dac5571_data *data, int channel, u16 val)
+{
+ unsigned int shift;
+
+ shift = 12 - data->spec->resolution;
+ data->buf[1] = val << shift;
+ data->buf[0] = val >> (8 - shift);
+
+ if (i2c_master_send(data->client, data->buf, 2) != 2)
+ return -EIO;
+
+ return 0;
+}
+
+static int dac5571_cmd_quad(struct dac5571_data *data, int channel, u16 val)
+{
+ unsigned int shift;
+
+ shift = 16 - data->spec->resolution;
+ data->buf[2] = val << shift;
+ data->buf[1] = (val >> (8 - shift));
+ data->buf[0] = (channel << DAC5571_CHANNEL_SELECT) |
+ DAC5571_LOADMODE_DIRECT;
+
+ if (i2c_master_send(data->client, data->buf, 3) != 3)
+ return -EIO;
+
+ return 0;
+}
+
+static int dac5571_pwrdwn_single(struct dac5571_data *data, int channel, u8 pwrdwn)
+{
+ unsigned int shift;
+
+ shift = 12 - data->spec->resolution;
+ data->buf[1] = 0;
+ data->buf[0] = pwrdwn << DAC5571_SINGLE_PWRDWN_BITS;
+
+ if (i2c_master_send(data->client, data->buf, 2) != 2)
+ return -EIO;
+
+ return 0;
+}
+
+static int dac5571_pwrdwn_quad(struct dac5571_data *data, int channel, u8 pwrdwn)
+{
+ unsigned int shift;
+
+ shift = 16 - data->spec->resolution;
+ data->buf[2] = 0;
+ data->buf[1] = pwrdwn << DAC5571_QUAD_PWRDWN_BITS;
+ data->buf[0] = (channel << DAC5571_CHANNEL_SELECT) |
+ DAC5571_LOADMODE_DIRECT | DAC5571_POWERDOWN_FLAG;
+
+ if (i2c_master_send(data->client, data->buf, 3) != 3)
+ return -EIO;
+
+ return 0;
+}
+
+static const char *const dac5571_powerdown_modes[] = {
+ "1kohm_to_gnd", "100kohm_to_gnd", "three_state",
+};
+
+static int dac5571_get_powerdown_mode(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+
+ return data->powerdown_mode;
+}
+
+static int dac5571_set_powerdown_mode(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ unsigned int mode)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+ int ret = 0;
+
+ if (data->powerdown_mode == mode)
+ return 0;
+
+ mutex_lock(&data->lock);
+ if (data->powerdown) {
+ ret = data->dac5571_pwrdwn(data, chan->channel,
+ DAC5571_POWERDOWN(mode));
+ if (ret)
+ goto out;
+ }
+ data->powerdown_mode = mode;
+
+ out:
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
+static const struct iio_enum dac5571_powerdown_mode = {
+ .items = dac5571_powerdown_modes,
+ .num_items = ARRAY_SIZE(dac5571_powerdown_modes),
+ .get = dac5571_get_powerdown_mode,
+ .set = dac5571_set_powerdown_mode,
+};
+
+static ssize_t dac5571_read_powerdown(struct iio_dev *indio_dev,
+ uintptr_t private,
+ const struct iio_chan_spec *chan,
+ char *buf)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+
+ return sprintf(buf, "%d\n", data->powerdown);
+}
+
+static ssize_t dac5571_write_powerdown(struct iio_dev *indio_dev,
+ uintptr_t private,
+ const struct iio_chan_spec *chan,
+ const char *buf, size_t len)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+ bool powerdown;
+ int ret;
+
+ ret = strtobool(buf, &powerdown);
+ if (ret)
+ return ret;
+
+ if (data->powerdown == powerdown)
+ return len;
+
+ mutex_lock(&data->lock);
+ if (powerdown)
+ ret = data->dac5571_pwrdwn(data, chan->channel,
+ DAC5571_POWERDOWN(data->powerdown_mode));
+ else
+ ret = data->dac5571_cmd(data, chan->channel, data->val[0]);
+ if (ret)
+ goto out;
+
+ data->powerdown = powerdown;
+
+ out:
+ mutex_unlock(&data->lock);
+
+ return ret ? ret : len;
+}
+
+
+static const struct iio_chan_spec_ext_info dac5571_ext_info[] = {
+ {
+ .name = "powerdown",
+ .read = dac5571_read_powerdown,
+ .write = dac5571_write_powerdown,
+ .shared = IIO_SHARED_BY_TYPE,
+ },
+ IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, &dac5571_powerdown_mode),
+ IIO_ENUM_AVAILABLE("powerdown_mode", &dac5571_powerdown_mode),
+ {},
+};
+
+#define dac5571_CHANNEL(chan, name) { \
+ .type = IIO_VOLTAGE, \
+ .channel = (chan), \
+ .address = (chan), \
+ .indexed = true, \
+ .output = true, \
+ .datasheet_name = name, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+ .ext_info = dac5571_ext_info, \
+}
+
+static const struct iio_chan_spec dac5571_channels[] = {
+ dac5571_CHANNEL(0, "A"),
+ dac5571_CHANNEL(1, "B"),
+ dac5571_CHANNEL(2, "C"),
+ dac5571_CHANNEL(3, "D"),
+};
+
+static int dac5571_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ *val = data->val[chan->channel];
+ return IIO_VAL_INT;
+
+ case IIO_CHAN_INFO_SCALE:
+ ret = regulator_get_voltage(data->vref);
+ if (ret < 0)
+ return ret;
+
+ *val = ret / 1000;
+ *val2 = data->spec->resolution;
+ return IIO_VAL_FRACTIONAL_LOG2;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static int dac5571_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ struct dac5571_data *data = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (data->val[chan->channel] == val)
+ return 0;
+
+ if (val >= (1 << data->spec->resolution) || val < 0)
+ return -EINVAL;
+
+ if (data->powerdown)
+ return -EBUSY;
+
+ mutex_lock(&data->lock);
+ ret = data->dac5571_cmd(data, chan->channel, val);
+ if (ret == 0)
+ data->val[chan->channel] = val;
+ mutex_unlock(&data->lock);
+ return ret;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static int dac5571_write_raw_get_fmt(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ long mask)
+{
+ return IIO_VAL_INT;
+}
+
+static const struct iio_info dac5571_info = {
+ .read_raw = dac5571_read_raw,
+ .write_raw = dac5571_write_raw,
+ .write_raw_get_fmt = dac5571_write_raw_get_fmt,
+};
+
+static int dac5571_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct device *dev = &client->dev;
+ const struct dac5571_spec *spec;
+ struct dac5571_data *data;
+ struct iio_dev *indio_dev;
+ int ret, i;
+
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(indio_dev);
+ i2c_set_clientdata(client, indio_dev);
+ data->client = client;
+
+ indio_dev->dev.parent = dev;
+ indio_dev->dev.of_node = client->dev.of_node;
+ indio_dev->info = &dac5571_info;
+ indio_dev->name = id->name;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = dac5571_channels;
+
+ spec = &dac5571_spec[id->driver_data];
+ indio_dev->num_channels = spec->num_channels;
+ data->spec = spec;
+
+ data->vref = devm_regulator_get(dev, "vref");
+ if (IS_ERR(data->vref))
+ return PTR_ERR(data->vref);
+
+ ret = regulator_enable(data->vref);
+ if (ret < 0)
+ return ret;
+
+ mutex_init(&data->lock);
+
+ switch (spec->num_channels) {
+ case 1:
+ data->dac5571_cmd = dac5571_cmd_single;
+ data->dac5571_pwrdwn = dac5571_pwrdwn_single;
+ break;
+ case 4:
+ data->dac5571_cmd = dac5571_cmd_quad;
+ data->dac5571_pwrdwn = dac5571_pwrdwn_quad;
+ break;
+ default:
+ goto err;
+ }
+
+ for (i = 0; i < spec->num_channels; i++) {
+ ret = data->dac5571_cmd(data, i, 0);
+ if (ret) {
+ dev_err(dev, "failed to initialize channel %d to 0\n", i);
+ goto err;
+ }
+ }
+
+ ret = iio_device_register(indio_dev);
+ if (ret)
+ goto err;
+
+ return 0;
+
+ err:
+ regulator_disable(data->vref);
+ return ret;
+}
+
+static int dac5571_remove(struct i2c_client *i2c)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(i2c);
+ struct dac5571_data *data = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+ regulator_disable(data->vref);
+
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id dac5571_of_id[] = {
+ {.compatible = "ti,dac5571"},
+ {.compatible = "ti,dac6571"},
+ {.compatible = "ti,dac7571"},
+ {.compatible = "ti,dac5574"},
+ {.compatible = "ti,dac6574"},
+ {.compatible = "ti,dac7574"},
+ {.compatible = "ti,dac5573"},
+ {.compatible = "ti,dac6573"},
+ {.compatible = "ti,dac7573"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, dac5571_of_id);
+#endif
+
+static const struct i2c_device_id dac5571_id[] = {
+ {"dac5571", single_8bit},
+ {"dac6571", single_10bit},
+ {"dac7571", single_12bit},
+ {"dac5574", quad_8bit},
+ {"dac6574", quad_10bit},
+ {"dac7574", quad_12bit},
+ {"dac5573", quad_8bit},
+ {"dac6573", quad_10bit},
+ {"dac7573", quad_12bit},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, dac5571_id);
+
+static struct i2c_driver dac5571_driver = {
+ .driver = {
+ .name = "ti-dac5571",
+ },
+ .probe = dac5571_probe,
+ .remove = dac5571_remove,
+ .id_table = dac5571_id,
+};
+module_i2c_driver(dac5571_driver);
+
+MODULE_AUTHOR("Sean Nyekjaer <sean.nyekjaer@prevas.dk>");
+MODULE_DESCRIPTION("Texas Instruments 8/10/12-bit 1/4-channel DAC driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 7d64be353403..f9c0624505a2 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -24,6 +24,7 @@
#include <linux/spinlock.h>
#include <linux/iio/iio.h>
#include <linux/acpi.h>
+#include <linux/platform_device.h>
#include "inv_mpu_iio.h"
/*
@@ -52,6 +53,7 @@ static const struct inv_mpu6050_reg_map reg_set_6500 = {
.raw_accl = INV_MPU6050_REG_RAW_ACCEL,
.temperature = INV_MPU6050_REG_TEMPERATURE,
.int_enable = INV_MPU6050_REG_INT_ENABLE,
+ .int_status = INV_MPU6050_REG_INT_STATUS,
.pwr_mgmt_1 = INV_MPU6050_REG_PWR_MGMT_1,
.pwr_mgmt_2 = INV_MPU6050_REG_PWR_MGMT_2,
.int_pin_cfg = INV_MPU6050_REG_INT_PIN_CFG,
@@ -86,6 +88,7 @@ static const struct inv_mpu6050_chip_config chip_config_6050 = {
.gyro_fifo_enable = false,
.accl_fifo_enable = false,
.accl_fs = INV_MPU6050_FS_02G,
+ .user_ctrl = 0,
};
/* Indexed by enum inv_devices */
@@ -121,6 +124,12 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6050,
},
{
+ .whoami = INV_MPU9255_WHOAMI_VALUE,
+ .name = "MPU9255",
+ .reg = &reg_set_6500,
+ .config = &chip_config_6050,
+ },
+ {
.whoami = INV_ICM20608_WHOAMI_VALUE,
.name = "ICM20608",
.reg = &reg_set_6500,
@@ -168,7 +177,7 @@ int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
return result;
if (en) {
- /* Wait for output stabilize */
+ /* Wait for output to stabilize */
msleep(INV_MPU6050_TEMP_UP_TIME);
if (mask == INV_MPU6050_BIT_PWR_GYRO_STBY) {
/* switch internal clock to PLL */
@@ -185,26 +194,29 @@ int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on)
{
- int result = 0;
+ int result;
if (power_on) {
- if (!st->powerup_count)
+ if (!st->powerup_count) {
result = regmap_write(st->map, st->reg->pwr_mgmt_1, 0);
- if (!result)
- st->powerup_count++;
+ if (result)
+ return result;
+ usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
+ INV_MPU6050_REG_UP_TIME_MAX);
+ }
+ st->powerup_count++;
} else {
- st->powerup_count--;
- if (!st->powerup_count)
+ if (st->powerup_count == 1) {
result = regmap_write(st->map, st->reg->pwr_mgmt_1,
INV_MPU6050_BIT_SLEEP);
+ if (result)
+ return result;
+ }
+ st->powerup_count--;
}
- if (result)
- return result;
-
- if (power_on)
- usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
- INV_MPU6050_REG_UP_TIME_MAX);
+ dev_dbg(regmap_get_device(st->map), "set power %d, count=%u\n",
+ power_on, st->powerup_count);
return 0;
}
@@ -262,26 +274,33 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
d = (INV_MPU6050_FSR_2000DPS << INV_MPU6050_GYRO_CONFIG_FSR_SHIFT);
result = regmap_write(st->map, st->reg->gyro_config, d);
if (result)
- return result;
+ goto error_power_off;
result = inv_mpu6050_set_lpf_regs(st, INV_MPU6050_FILTER_20HZ);
if (result)
- return result;
+ goto error_power_off;
d = INV_MPU6050_ONE_K_HZ / INV_MPU6050_INIT_FIFO_RATE - 1;
result = regmap_write(st->map, st->reg->sample_rate_div, d);
if (result)
- return result;
+ goto error_power_off;
d = (INV_MPU6050_FS_02G << INV_MPU6050_ACCL_CONFIG_FSR_SHIFT);
result = regmap_write(st->map, st->reg->accl_config, d);
if (result)
+ goto error_power_off;
+
+ result = regmap_write(st->map, st->reg->int_pin_cfg, st->irq_mask);
+ if (result)
return result;
memcpy(&st->chip_config, hw_info[st->chip_type].config,
sizeof(struct inv_mpu6050_chip_config));
- result = inv_mpu6050_set_power_itg(st, false);
+ return inv_mpu6050_set_power_itg(st, false);
+
+error_power_off:
+ inv_mpu6050_set_power_itg(st, false);
return result;
}
@@ -314,6 +333,65 @@ static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg,
return IIO_VAL_INT;
}
+static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val)
+{
+ struct inv_mpu6050_state *st = iio_priv(indio_dev);
+ int result;
+ int ret;
+
+ result = inv_mpu6050_set_power_itg(st, true);
+ if (result)
+ return result;
+
+ switch (chan->type) {
+ case IIO_ANGL_VEL:
+ result = inv_mpu6050_switch_engine(st, true,
+ INV_MPU6050_BIT_PWR_GYRO_STBY);
+ if (result)
+ goto error_power_off;
+ ret = inv_mpu6050_sensor_show(st, st->reg->raw_gyro,
+ chan->channel2, val);
+ result = inv_mpu6050_switch_engine(st, false,
+ INV_MPU6050_BIT_PWR_GYRO_STBY);
+ if (result)
+ goto error_power_off;
+ break;
+ case IIO_ACCEL:
+ result = inv_mpu6050_switch_engine(st, true,
+ INV_MPU6050_BIT_PWR_ACCL_STBY);
+ if (result)
+ goto error_power_off;
+ ret = inv_mpu6050_sensor_show(st, st->reg->raw_accl,
+ chan->channel2, val);
+ result = inv_mpu6050_switch_engine(st, false,
+ INV_MPU6050_BIT_PWR_ACCL_STBY);
+ if (result)
+ goto error_power_off;
+ break;
+ case IIO_TEMP:
+ /* wait for stablization */
+ msleep(INV_MPU6050_SENSOR_UP_TIME);
+ ret = inv_mpu6050_sensor_show(st, st->reg->temperature,
+ IIO_MOD_X, val);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ result = inv_mpu6050_set_power_itg(st, false);
+ if (result)
+ goto error_power_off;
+
+ return ret;
+
+error_power_off:
+ inv_mpu6050_set_power_itg(st, false);
+ return result;
+}
+
static int
inv_mpu6050_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -324,63 +402,14 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- {
- int result;
-
- ret = IIO_VAL_INT;
+ ret = iio_device_claim_direct_mode(indio_dev);
+ if (ret)
+ return ret;
mutex_lock(&st->lock);
- result = iio_device_claim_direct_mode(indio_dev);
- if (result)
- goto error_read_raw_unlock;
- result = inv_mpu6050_set_power_itg(st, true);
- if (result)
- goto error_read_raw_release;
- switch (chan->type) {
- case IIO_ANGL_VEL:
- result = inv_mpu6050_switch_engine(st, true,
- INV_MPU6050_BIT_PWR_GYRO_STBY);
- if (result)
- goto error_read_raw_power_off;
- ret = inv_mpu6050_sensor_show(st, st->reg->raw_gyro,
- chan->channel2, val);
- result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_GYRO_STBY);
- if (result)
- goto error_read_raw_power_off;
- break;
- case IIO_ACCEL:
- result = inv_mpu6050_switch_engine(st, true,
- INV_MPU6050_BIT_PWR_ACCL_STBY);
- if (result)
- goto error_read_raw_power_off;
- ret = inv_mpu6050_sensor_show(st, st->reg->raw_accl,
- chan->channel2, val);
- result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_ACCL_STBY);
- if (result)
- goto error_read_raw_power_off;
- break;
- case IIO_TEMP:
- /* wait for stablization */
- msleep(INV_MPU6050_SENSOR_UP_TIME);
- ret = inv_mpu6050_sensor_show(st, st->reg->temperature,
- IIO_MOD_X, val);
- break;
- default:
- ret = -EINVAL;
- break;
- }
-error_read_raw_power_off:
- result |= inv_mpu6050_set_power_itg(st, false);
-error_read_raw_release:
- iio_device_release_direct_mode(indio_dev);
-error_read_raw_unlock:
+ ret = inv_mpu6050_read_channel_data(indio_dev, chan, val);
mutex_unlock(&st->lock);
- if (result)
- return result;
-
+ iio_device_release_direct_mode(indio_dev);
return ret;
- }
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
@@ -502,17 +531,18 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
struct inv_mpu6050_state *st = iio_priv(indio_dev);
int result;
- mutex_lock(&st->lock);
/*
* we should only update scale when the chip is disabled, i.e.
* not running
*/
result = iio_device_claim_direct_mode(indio_dev);
if (result)
- goto error_write_raw_unlock;
+ return result;
+
+ mutex_lock(&st->lock);
result = inv_mpu6050_set_power_itg(st, true);
if (result)
- goto error_write_raw_release;
+ goto error_write_raw_unlock;
switch (mask) {
case IIO_CHAN_INFO_SCALE:
@@ -551,10 +581,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
}
result |= inv_mpu6050_set_power_itg(st, false);
-error_write_raw_release:
- iio_device_release_direct_mode(indio_dev);
error_write_raw_unlock:
mutex_unlock(&st->lock);
+ iio_device_release_direct_mode(indio_dev);
return result;
}
@@ -613,17 +642,18 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
fifo_rate > INV_MPU6050_MAX_FIFO_RATE)
return -EINVAL;
+ result = iio_device_claim_direct_mode(indio_dev);
+ if (result)
+ return result;
+
mutex_lock(&st->lock);
if (fifo_rate == st->chip_config.fifo_rate) {
result = 0;
goto fifo_rate_fail_unlock;
}
- result = iio_device_claim_direct_mode(indio_dev);
- if (result)
- goto fifo_rate_fail_unlock;
result = inv_mpu6050_set_power_itg(st, true);
if (result)
- goto fifo_rate_fail_release;
+ goto fifo_rate_fail_unlock;
d = INV_MPU6050_ONE_K_HZ / fifo_rate - 1;
result = regmap_write(st->map, st->reg->sample_rate_div, d);
@@ -637,10 +667,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
fifo_rate_fail_power_off:
result |= inv_mpu6050_set_power_itg(st, false);
-fifo_rate_fail_release:
- iio_device_release_direct_mode(indio_dev);
fifo_rate_fail_unlock:
mutex_unlock(&st->lock);
+ iio_device_release_direct_mode(indio_dev);
if (result)
return result;
@@ -769,7 +798,14 @@ static const struct iio_chan_spec inv_mpu_channels[] = {
INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z),
};
-/* constant IIO attribute */
+/*
+ * The user can choose any frequency between INV_MPU6050_MIN_FIFO_RATE and
+ * INV_MPU6050_MAX_FIFO_RATE, but only these frequencies are matched by the
+ * low-pass filter. Specifically, each of these sampling rates are about twice
+ * the bandwidth of a corresponding low-pass filter, which should eliminate
+ * aliasing following the Nyquist principle. By picking a frequency different
+ * from these, the user risks aliasing effects.
+ */
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 20 50 100 200 500");
static IIO_CONST_ATTR(in_anglvel_scale_available,
"0.000133090 0.000266181 0.000532362 0.001064724");
@@ -850,14 +886,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
msleep(INV_MPU6050_POWER_UP_TIME);
/*
- * toggle power state. After reset, the sleep bit could be on
- * or off depending on the OTP settings. Toggling power would
+ * Turn power on. After reset, the sleep bit could be on
+ * or off depending on the OTP settings. Turning power on
* make it in a definite state as well as making the hardware
* state align with the software state
*/
- result = inv_mpu6050_set_power_itg(st, false);
- if (result)
- return result;
result = inv_mpu6050_set_power_itg(st, true);
if (result)
return result;
@@ -865,13 +898,17 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
- return result;
+ goto error_power_off;
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
- return result;
+ goto error_power_off;
- return 0;
+ return inv_mpu6050_set_power_itg(st, false);
+
+error_power_off:
+ inv_mpu6050_set_power_itg(st, false);
+ return result;
}
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
@@ -882,6 +919,8 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
struct inv_mpu6050_platform_data *pdata;
struct device *dev = regmap_get_device(regmap);
int result;
+ struct irq_data *desc;
+ int irq_type;
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev)
@@ -913,20 +952,43 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
st->plat_data = *pdata;
}
+ desc = irq_get_irq_data(irq);
+ if (!desc) {
+ dev_err(dev, "Could not find IRQ %d\n", irq);
+ return -EINVAL;
+ }
+
+ irq_type = irqd_get_trigger_type(desc);
+ if (irq_type == IRQF_TRIGGER_RISING)
+ st->irq_mask = INV_MPU6050_ACTIVE_HIGH;
+ else if (irq_type == IRQF_TRIGGER_FALLING)
+ st->irq_mask = INV_MPU6050_ACTIVE_LOW;
+ else if (irq_type == IRQF_TRIGGER_HIGH)
+ st->irq_mask = INV_MPU6050_ACTIVE_HIGH |
+ INV_MPU6050_LATCH_INT_EN;
+ else if (irq_type == IRQF_TRIGGER_LOW)
+ st->irq_mask = INV_MPU6050_ACTIVE_LOW |
+ INV_MPU6050_LATCH_INT_EN;
+ else {
+ dev_err(dev, "Invalid interrupt type 0x%x specified\n",
+ irq_type);
+ return -EINVAL;
+ }
+
/* power is turned on inside check chip type*/
result = inv_check_and_setup_chip(st);
if (result)
return result;
- if (inv_mpu_bus_setup)
- inv_mpu_bus_setup(indio_dev);
-
result = inv_mpu6050_init_config(indio_dev);
if (result) {
dev_err(dev, "Could not initialize device.\n");
return result;
}
+ if (inv_mpu_bus_setup)
+ inv_mpu_bus_setup(indio_dev);
+
dev_set_drvdata(dev, indio_dev);
indio_dev->dev.parent = dev;
/* name will be NULL when enumerated via ACPI */
@@ -940,50 +1002,32 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
indio_dev->info = &mpu_info;
indio_dev->modes = INDIO_BUFFER_TRIGGERED;
- result = iio_triggered_buffer_setup(indio_dev,
- inv_mpu6050_irq_handler,
- inv_mpu6050_read_fifo,
- NULL);
+ result = devm_iio_triggered_buffer_setup(dev, indio_dev,
+ inv_mpu6050_irq_handler,
+ inv_mpu6050_read_fifo,
+ NULL);
if (result) {
dev_err(dev, "configure buffer fail %d\n", result);
return result;
}
- result = inv_mpu6050_probe_trigger(indio_dev);
+ result = inv_mpu6050_probe_trigger(indio_dev, irq_type);
if (result) {
dev_err(dev, "trigger probe fail %d\n", result);
- goto out_unreg_ring;
+ return result;
}
INIT_KFIFO(st->timestamps);
spin_lock_init(&st->time_stamp_lock);
- result = iio_device_register(indio_dev);
+ result = devm_iio_device_register(dev, indio_dev);
if (result) {
dev_err(dev, "IIO register fail %d\n", result);
- goto out_remove_trigger;
+ return result;
}
return 0;
-
-out_remove_trigger:
- inv_mpu6050_remove_trigger(st);
-out_unreg_ring:
- iio_triggered_buffer_cleanup(indio_dev);
- return result;
}
EXPORT_SYMBOL_GPL(inv_mpu_core_probe);
-int inv_mpu_core_remove(struct device *dev)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- iio_device_unregister(indio_dev);
- inv_mpu6050_remove_trigger(iio_priv(indio_dev));
- iio_triggered_buffer_cleanup(indio_dev);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(inv_mpu_core_remove);
-
#ifdef CONFIG_PM_SLEEP
static int inv_mpu_resume(struct device *dev)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index fcd7a92b6cf8..495409d56207 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -29,25 +29,18 @@ static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
{
struct iio_dev *indio_dev = i2c_mux_priv(muxc);
struct inv_mpu6050_state *st = iio_priv(indio_dev);
- int ret = 0;
+ int ret;
- /* Use the same mutex which was used everywhere to protect power-op */
mutex_lock(&st->lock);
- if (!st->powerup_count) {
- ret = regmap_write(st->map, st->reg->pwr_mgmt_1, 0);
- if (ret)
- goto write_error;
- usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
- INV_MPU6050_REG_UP_TIME_MAX);
- }
- if (!ret) {
- st->powerup_count++;
- ret = regmap_write(st->map, st->reg->int_pin_cfg,
- INV_MPU6050_INT_PIN_CFG |
- INV_MPU6050_BIT_BYPASS_EN);
- }
-write_error:
+ ret = inv_mpu6050_set_power_itg(st, true);
+ if (ret)
+ goto error_unlock;
+
+ ret = regmap_write(st->map, st->reg->int_pin_cfg,
+ st->irq_mask | INV_MPU6050_BIT_BYPASS_EN);
+
+error_unlock:
mutex_unlock(&st->lock);
return ret;
@@ -59,12 +52,11 @@ static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id)
struct inv_mpu6050_state *st = iio_priv(indio_dev);
mutex_lock(&st->lock);
- /* It doesn't really mattter, if any of the calls fails */
- regmap_write(st->map, st->reg->int_pin_cfg, INV_MPU6050_INT_PIN_CFG);
- st->powerup_count--;
- if (!st->powerup_count)
- regmap_write(st->map, st->reg->pwr_mgmt_1,
- INV_MPU6050_BIT_SLEEP);
+
+ /* It doesn't really matter if any of the calls fail */
+ regmap_write(st->map, st->reg->int_pin_cfg, st->irq_mask);
+ inv_mpu6050_set_power_itg(st, false);
+
mutex_unlock(&st->lock);
return 0;
@@ -133,29 +125,32 @@ static int inv_mpu_probe(struct i2c_client *client,
return result;
st = iio_priv(dev_get_drvdata(&client->dev));
- st->muxc = i2c_mux_alloc(client->adapter, &client->dev,
- 1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
- inv_mpu6050_select_bypass,
- inv_mpu6050_deselect_bypass);
- if (!st->muxc) {
- result = -ENOMEM;
- goto out_unreg_device;
+ switch (st->chip_type) {
+ case INV_ICM20608:
+ /* no i2c auxiliary bus on the chip */
+ break;
+ default:
+ /* declare i2c auxiliary bus */
+ st->muxc = i2c_mux_alloc(client->adapter, &client->dev,
+ 1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
+ inv_mpu6050_select_bypass,
+ inv_mpu6050_deselect_bypass);
+ if (!st->muxc)
+ return -ENOMEM;
+ st->muxc->priv = dev_get_drvdata(&client->dev);
+ result = i2c_mux_add_adapter(st->muxc, 0, 0, 0);
+ if (result)
+ return result;
+ result = inv_mpu_acpi_create_mux_client(client);
+ if (result)
+ goto out_del_mux;
+ break;
}
- st->muxc->priv = dev_get_drvdata(&client->dev);
- result = i2c_mux_add_adapter(st->muxc, 0, 0, 0);
- if (result)
- goto out_unreg_device;
-
- result = inv_mpu_acpi_create_mux_client(client);
- if (result)
- goto out_del_mux;
return 0;
out_del_mux:
i2c_mux_del_adapters(st->muxc);
-out_unreg_device:
- inv_mpu_core_remove(&client->dev);
return result;
}
@@ -164,10 +159,12 @@ static int inv_mpu_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct inv_mpu6050_state *st = iio_priv(indio_dev);
- inv_mpu_acpi_delete_mux_client(client);
- i2c_mux_del_adapters(st->muxc);
+ if (st->muxc) {
+ inv_mpu_acpi_delete_mux_client(client);
+ i2c_mux_del_adapters(st->muxc);
+ }
- return inv_mpu_core_remove(&client->dev);
+ return 0;
}
/*
@@ -179,6 +176,7 @@ static const struct i2c_device_id inv_mpu_id[] = {
{"mpu6500", INV_MPU6500},
{"mpu9150", INV_MPU9150},
{"mpu9250", INV_MPU9250},
+ {"mpu9255", INV_MPU9255},
{"icm20608", INV_ICM20608},
{}
};
@@ -203,6 +201,10 @@ static const struct of_device_id inv_of_match[] = {
.data = (void *)INV_MPU9250
},
{
+ .compatible = "invensense,mpu9255",
+ .data = (void *)INV_MPU9255
+ },
+ {
.compatible = "invensense,icm20608",
.data = (void *)INV_ICM20608
},
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 065794162d65..c54da777945d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -40,6 +40,7 @@
* @raw_accl: Address of first accel register.
* @temperature: temperature register
* @int_enable: Interrupt enable register.
+ * @int_status: Interrupt status register.
* @pwr_mgmt_1: Controls chip's power state and clock source.
* @pwr_mgmt_2: Controls power state of individual sensors.
* @int_pin_cfg; Controls interrupt pin configuration.
@@ -60,6 +61,7 @@ struct inv_mpu6050_reg_map {
u8 raw_accl;
u8 temperature;
u8 int_enable;
+ u8 int_status;
u8 pwr_mgmt_1;
u8 pwr_mgmt_2;
u8 int_pin_cfg;
@@ -74,6 +76,7 @@ enum inv_devices {
INV_MPU6000,
INV_MPU9150,
INV_MPU9250,
+ INV_MPU9255,
INV_ICM20608,
INV_NUM_PARTS
};
@@ -94,6 +97,7 @@ struct inv_mpu6050_chip_config {
unsigned int accl_fifo_enable:1;
unsigned int gyro_fifo_enable:1;
u16 fifo_rate;
+ u8 user_ctrl;
};
/**
@@ -125,6 +129,7 @@ struct inv_mpu6050_hw {
* @timestamps: kfifo queue to store time stamp.
* @map regmap pointer.
* @irq interrupt number.
+ * @irq_mask the int_pin_cfg mask to configure interrupt type.
*/
struct inv_mpu6050_state {
#define TIMESTAMP_FIFO_SIZE 16
@@ -143,6 +148,8 @@ struct inv_mpu6050_state {
DECLARE_KFIFO(timestamps, long long, TIMESTAMP_FIFO_SIZE);
struct regmap *map;
int irq;
+ u8 irq_mask;
+ unsigned skip_samples;
};
/*register and associated bit definition*/
@@ -166,6 +173,9 @@ struct inv_mpu6050_state {
#define INV_MPU6050_REG_TEMPERATURE 0x41
#define INV_MPU6050_REG_RAW_GYRO 0x43
+#define INV_MPU6050_REG_INT_STATUS 0x3A
+#define INV_MPU6050_BIT_RAW_DATA_RDY_INT 0x01
+
#define INV_MPU6050_REG_USER_CTRL 0x6A
#define INV_MPU6050_BIT_FIFO_RST 0x04
#define INV_MPU6050_BIT_DMP_RST 0x08
@@ -215,8 +225,12 @@ struct inv_mpu6050_state {
#define INV_MPU6050_OUTPUT_DATA_SIZE 24
#define INV_MPU6050_REG_INT_PIN_CFG 0x37
+#define INV_MPU6050_ACTIVE_HIGH 0x00
+#define INV_MPU6050_ACTIVE_LOW 0x80
+/* enable level triggering */
+#define INV_MPU6050_LATCH_INT_EN 0x20
#define INV_MPU6050_BIT_BYPASS_EN 0x2
-#define INV_MPU6050_INT_PIN_CFG 0
+
/* init parameters */
#define INV_MPU6050_INIT_FIFO_RATE 50
@@ -232,6 +246,7 @@ struct inv_mpu6050_state {
#define INV_MPU6500_WHOAMI_VALUE 0x70
#define INV_MPU9150_WHOAMI_VALUE 0x68
#define INV_MPU9250_WHOAMI_VALUE 0x71
+#define INV_MPU9255_WHOAMI_VALUE 0x73
#define INV_ICM20608_WHOAMI_VALUE 0xAF
/* scan element definition */
@@ -287,8 +302,7 @@ enum inv_mpu6050_clock_sel_e {
irqreturn_t inv_mpu6050_irq_handler(int irq, void *p);
irqreturn_t inv_mpu6050_read_fifo(int irq, void *p);
-int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev);
-void inv_mpu6050_remove_trigger(struct inv_mpu6050_state *st);
+int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type);
int inv_reset_fifo(struct iio_dev *indio_dev);
int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask);
int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 val);
@@ -297,6 +311,4 @@ int inv_mpu_acpi_create_mux_client(struct i2c_client *client);
void inv_mpu_acpi_delete_mux_client(struct i2c_client *client);
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type);
-int inv_mpu_core_remove(struct device *dev);
-int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
extern const struct dev_pm_ops inv_mpu_pmops;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
index ff81c6aa009d..1795418438e4 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
@@ -51,13 +51,14 @@ int inv_reset_fifo(struct iio_dev *indio_dev)
if (result)
goto reset_fifo_fail;
/* disable fifo reading */
- result = regmap_write(st->map, st->reg->user_ctrl, 0);
+ result = regmap_write(st->map, st->reg->user_ctrl,
+ st->chip_config.user_ctrl);
if (result)
goto reset_fifo_fail;
/* reset FIFO*/
- result = regmap_write(st->map, st->reg->user_ctrl,
- INV_MPU6050_BIT_FIFO_RST);
+ d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_RST;
+ result = regmap_write(st->map, st->reg->user_ctrl, d);
if (result)
goto reset_fifo_fail;
@@ -72,9 +73,9 @@ int inv_reset_fifo(struct iio_dev *indio_dev)
if (result)
return result;
}
- /* enable FIFO reading and I2C master interface*/
- result = regmap_write(st->map, st->reg->user_ctrl,
- INV_MPU6050_BIT_FIFO_EN);
+ /* enable FIFO reading */
+ d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_EN;
+ result = regmap_write(st->map, st->reg->user_ctrl, d);
if (result)
goto reset_fifo_fail;
/* enable sensor output to FIFO */
@@ -127,8 +128,23 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
u8 data[INV_MPU6050_OUTPUT_DATA_SIZE];
u16 fifo_count;
s64 timestamp;
+ int int_status;
mutex_lock(&st->lock);
+
+ /* ack interrupt and check status */
+ result = regmap_read(st->map, st->reg->int_status, &int_status);
+ if (result) {
+ dev_err(regmap_get_device(st->map),
+ "failed to ack interrupt\n");
+ goto flush_fifo;
+ }
+ if (!(int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT)) {
+ dev_warn(regmap_get_device(st->map),
+ "spurious interrupt with status 0x%x\n", int_status);
+ goto end_session;
+ }
+
if (!(st->chip_config.accl_fifo_enable |
st->chip_config.gyro_fifo_enable))
goto end_session;
@@ -140,7 +156,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
bytes_per_datum += INV_MPU6050_BYTES_PER_3AXIS_SENSOR;
/*
- * read fifo_count register to know how many bytes inside FIFO
+ * read fifo_count register to know how many bytes are inside the FIFO
* right now
*/
result = regmap_bulk_read(st->map, st->reg->fifo_count_h, data,
@@ -150,7 +166,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
fifo_count = be16_to_cpup((__be16 *)(&data[0]));
if (fifo_count < bytes_per_datum)
goto end_session;
- /* fifo count can't be odd number, if it is odd, reset fifo*/
+ /* fifo count can't be an odd number. If it is odd, reset the FIFO. */
if (fifo_count & 1)
goto flush_fifo;
if (fifo_count > INV_MPU6050_FIFO_THRESHOLD)
@@ -159,7 +175,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
if (kfifo_len(&st->timestamps) >
fifo_count / bytes_per_datum + INV_MPU6050_TIME_STAMP_TOR)
goto flush_fifo;
- while (fifo_count >= bytes_per_datum) {
+ do {
result = regmap_bulk_read(st->map, st->reg->fifo_r_w,
data, bytes_per_datum);
if (result)
@@ -170,12 +186,15 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
if (result == 0)
timestamp = 0;
- result = iio_push_to_buffers_with_timestamp(indio_dev, data,
- timestamp);
- if (result)
- goto flush_fifo;
+ /* skip first samples if needed */
+ if (st->skip_samples)
+ st->skip_samples--;
+ else
+ iio_push_to_buffers_with_timestamp(indio_dev, data,
+ timestamp);
+
fifo_count -= bytes_per_datum;
- }
+ } while (fifo_count >= bytes_per_datum);
end_session:
mutex_unlock(&st->lock);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 74506e5ac0db..227f50afff22 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -31,8 +31,9 @@ static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
if (ret)
return ret;
- ret = regmap_write(st->map, INV_MPU6050_REG_USER_CTRL,
- INV_MPU6050_BIT_I2C_IF_DIS);
+ st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
+ ret = regmap_write(st->map, st->reg->user_ctrl,
+ st->chip_config.user_ctrl);
if (ret) {
inv_mpu6050_set_power_itg(st, false);
return ret;
@@ -69,11 +70,6 @@ static int inv_mpu_probe(struct spi_device *spi)
inv_mpu_i2c_disable, chip_type);
}
-static int inv_mpu_remove(struct spi_device *spi)
-{
- return inv_mpu_core_remove(&spi->dev);
-}
-
/*
* device id table is used to identify what device can be
* supported by this driver
@@ -83,6 +79,7 @@ static const struct spi_device_id inv_mpu_id[] = {
{"mpu6500", INV_MPU6500},
{"mpu9150", INV_MPU9150},
{"mpu9250", INV_MPU9250},
+ {"mpu9255", INV_MPU9255},
{"icm20608", INV_ICM20608},
{}
};
@@ -97,7 +94,6 @@ MODULE_DEVICE_TABLE(acpi, inv_acpi_match);
static struct spi_driver inv_mpu_driver = {
.probe = inv_mpu_probe,
- .remove = inv_mpu_remove,
.id_table = inv_mpu_id,
.driver = {
.acpi_match_table = ACPI_PTR(inv_acpi_match),
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
index f963f9fc98c0..6c3e1652a687 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
@@ -49,49 +49,66 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
if (result)
return result;
inv_scan_query(indio_dev);
+ st->skip_samples = 0;
if (st->chip_config.gyro_fifo_enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
- return result;
+ goto error_power_off;
+ /* gyro first sample is out of specs, skip it */
+ st->skip_samples = 1;
}
if (st->chip_config.accl_fifo_enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
- return result;
+ goto error_gyro_off;
}
result = inv_reset_fifo(indio_dev);
if (result)
- return result;
+ goto error_accl_off;
} else {
result = regmap_write(st->map, st->reg->fifo_en, 0);
if (result)
- return result;
+ goto error_accl_off;
result = regmap_write(st->map, st->reg->int_enable, 0);
if (result)
- return result;
+ goto error_accl_off;
- result = regmap_write(st->map, st->reg->user_ctrl, 0);
+ result = regmap_write(st->map, st->reg->user_ctrl,
+ st->chip_config.user_ctrl);
if (result)
- return result;
+ goto error_accl_off;
result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_GYRO_STBY);
+ INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
- return result;
+ goto error_accl_off;
result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_ACCL_STBY);
+ INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
- return result;
+ goto error_gyro_off;
+
result = inv_mpu6050_set_power_itg(st, false);
if (result)
- return result;
+ goto error_power_off;
}
return 0;
+
+error_accl_off:
+ if (st->chip_config.accl_fifo_enable)
+ inv_mpu6050_switch_engine(st, false,
+ INV_MPU6050_BIT_PWR_ACCL_STBY);
+error_gyro_off:
+ if (st->chip_config.gyro_fifo_enable)
+ inv_mpu6050_switch_engine(st, false,
+ INV_MPU6050_BIT_PWR_GYRO_STBY);
+error_power_off:
+ inv_mpu6050_set_power_itg(st, false);
+ return result;
}
/**
@@ -117,7 +134,7 @@ static const struct iio_trigger_ops inv_mpu_trigger_ops = {
.set_trigger_state = &inv_mpu_data_rdy_trigger_set_state,
};
-int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
+int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type)
{
int ret;
struct inv_mpu6050_state *st = iio_priv(indio_dev);
@@ -131,7 +148,7 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
ret = devm_request_irq(&indio_dev->dev, st->irq,
&iio_trigger_generic_data_rdy_poll,
- IRQF_TRIGGER_RISING,
+ irq_type,
"inv_mpu",
st->trig);
if (ret)
@@ -141,7 +158,7 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
st->trig->ops = &inv_mpu_trigger_ops;
iio_trigger_set_drvdata(st->trig, indio_dev);
- ret = iio_trigger_register(st->trig);
+ ret = devm_iio_trigger_register(&indio_dev->dev, st->trig);
if (ret)
return ret;
@@ -149,8 +166,3 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
return 0;
}
-
-void inv_mpu6050_remove_trigger(struct inv_mpu6050_state *st)
-{
- iio_trigger_unregister(st->trig);
-}
diff --git a/drivers/iio/imu/st_lsm6dsx/Kconfig b/drivers/iio/imu/st_lsm6dsx/Kconfig
index 14f2eb6e9fb7..ccc817e17eb8 100644
--- a/drivers/iio/imu/st_lsm6dsx/Kconfig
+++ b/drivers/iio/imu/st_lsm6dsx/Kconfig
@@ -8,7 +8,8 @@ config IIO_ST_LSM6DSX
select IIO_ST_LSM6DSX_SPI if (SPI_MASTER)
help
Say yes here to build support for STMicroelectronics LSM6DSx imu
- sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm
+ sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm,
+ ism330dlc
To compile this driver as a module, choose M here: the module
will be called st_lsm6dsx.
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index a3cc7cd97026..edcd838037cd 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -18,12 +18,14 @@
#define ST_LSM6DS3H_DEV_NAME "lsm6ds3h"
#define ST_LSM6DSL_DEV_NAME "lsm6dsl"
#define ST_LSM6DSM_DEV_NAME "lsm6dsm"
+#define ST_ISM330DLC_DEV_NAME "ism330dlc"
enum st_lsm6dsx_hw_id {
ST_LSM6DS3_ID,
ST_LSM6DS3H_ID,
ST_LSM6DSL_ID,
ST_LSM6DSM_ID,
+ ST_ISM330DLC_ID,
ST_LSM6DSX_MAX_ID,
};
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 1045e025e92b..4994f920a836 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -1,10 +1,10 @@
/*
* STMicroelectronics st_lsm6dsx FIFO buffer library driver
*
- * LSM6DS3/LSM6DS3H/LSM6DSL/LSM6DSM: The FIFO buffer can be configured
- * to store data from gyroscope and accelerometer. Samples are queued
- * without any tag according to a specific pattern based on 'FIFO data sets'
- * (6 bytes each):
+ * LSM6DS3/LSM6DS3H/LSM6DSL/LSM6DSM/ISM330DLC: The FIFO buffer can be
+ * configured to store data from gyroscope and accelerometer. Samples are
+ * queued without any tag according to a specific pattern based on
+ * 'FIFO data sets' (6 bytes each):
* - 1st data set is reserved for gyroscope data
* - 2nd data set is reserved for accelerometer data
* The FIFO pattern changes depending on the ODRs and decimation factors
@@ -276,7 +276,7 @@ static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 *data,
#define ST_LSM6DSX_IIO_BUFF_SIZE (ALIGN(ST_LSM6DSX_SAMPLE_SIZE, \
sizeof(s64)) + sizeof(s64))
/**
- * st_lsm6dsx_read_fifo() - LSM6DS3-LSM6DS3H-LSM6DSL-LSM6DSM read FIFO routine
+ * st_lsm6dsx_read_fifo() - hw FIFO read routine
* @hw: Pointer to instance of struct st_lsm6dsx_hw.
*
* Read samples from the hw FIFO and push them to IIO buffers.
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 8656d72ef4ee..aebbe0ddd8d8 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -17,7 +17,7 @@
* - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000
* - FIFO size: 8KB
*
- * - LSM6DS3H/LSM6DSL/LSM6DSM:
+ * - LSM6DS3H/LSM6DSL/LSM6DSM/ISM330DLC:
* - Accelerometer/Gyroscope supported ODR [Hz]: 13, 26, 52, 104, 208, 416
* - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16
* - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000
@@ -252,6 +252,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.id = {
[0] = ST_LSM6DSL_ID,
[1] = ST_LSM6DSM_ID,
+ [2] = ST_ISM330DLC_ID,
},
.decimator = {
[ST_LSM6DSX_ID_ACC] = {
@@ -266,11 +267,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.fifo_ops = {
.fifo_th = {
.addr = 0x06,
- .mask = GENMASK(11, 0),
+ .mask = GENMASK(10, 0),
},
.fifo_diff = {
.addr = 0x3a,
- .mask = GENMASK(11, 0),
+ .mask = GENMASK(10, 0),
},
.th_wl = 3, /* 1LSB = 2B */
},
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index 41525dd2aab7..377c4e9997da 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -57,6 +57,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
.compatible = "st,lsm6dsm",
.data = (void *)ST_LSM6DSM_ID,
},
+ {
+ .compatible = "st,ism330dlc",
+ .data = (void *)ST_ISM330DLC_ID,
+ },
{},
};
MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match);
@@ -66,6 +70,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = {
{ ST_LSM6DS3H_DEV_NAME, ST_LSM6DS3H_ID },
{ ST_LSM6DSL_DEV_NAME, ST_LSM6DSL_ID },
{ ST_LSM6DSM_DEV_NAME, ST_LSM6DSM_ID },
+ { ST_ISM330DLC_DEV_NAME, ST_ISM330DLC_ID },
{},
};
MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index 2c8135834479..fec5c6ce7eb7 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -57,6 +57,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = {
.compatible = "st,lsm6dsm",
.data = (void *)ST_LSM6DSM_ID,
},
+ {
+ .compatible = "st,ism330dlc",
+ .data = (void *)ST_ISM330DLC_ID,
+ },
{},
};
MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match);
@@ -66,6 +70,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = {
{ ST_LSM6DS3H_DEV_NAME, ST_LSM6DS3H_ID },
{ ST_LSM6DSL_DEV_NAME, ST_LSM6DSL_ID },
{ ST_LSM6DSM_DEV_NAME, ST_LSM6DSM_ID },
+ { ST_ISM330DLC_DEV_NAME, ST_ISM330DLC_ID },
{},
};
MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 074e50657366..c7ef8d1862d6 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -409,6 +409,14 @@ config TSL2583
Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices.
Access ALS data via iio, sysfs.
+config TSL2772
+ tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors"
+ depends on I2C
+ help
+ Support for: tsl2571, tsl2671, tmd2671, tsl2771, tmd2771, tsl2572, tsl2672,
+ tmd2672, tsl2772, tmd2772 devices.
+ Provides iio_events and direct access via sysfs.
+
config TSL4531
tristate "TAOS TSL4531 ambient light sensors"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index f1777036d4f8..80943af5d627 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_ST_UVIS25_SPI) += st_uvis25_spi.o
obj-$(CONFIG_TCS3414) += tcs3414.o
obj-$(CONFIG_TCS3472) += tcs3472.o
obj-$(CONFIG_TSL2583) += tsl2583.o
+obj-$(CONFIG_TSL2772) += tsl2772.o
obj-$(CONFIG_TSL4531) += tsl4531.o
obj-$(CONFIG_US5182D) += us5182d.o
obj-$(CONFIG_VCNL4000) += vcnl4000.o
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 8e8a0e7f78d1..fd1609e975ab 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger.h>
@@ -29,8 +30,6 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
-#include "../common/cros_ec_sensors/cros_ec_sensors_core.h"
-
/*
* We only represent one entry for light or proximity. EC is merging different
* light sensors to return the what the eye would see. For proximity, we
diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
index f2e50edaa242..4b5d9988f025 100644
--- a/drivers/iio/light/tsl2583.c
+++ b/drivers/iio/light/tsl2583.c
@@ -600,7 +600,7 @@ done:
static IIO_CONST_ATTR(in_illuminance_calibscale_available, "1 8 16 111");
static IIO_CONST_ATTR(in_illuminance_integration_time_available,
- "0.000050 0.000100 0.000150 0.000200 0.000250 0.000300 0.000350 0.000400 0.000450 0.000500 0.000550 0.000600 0.000650");
+ "0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500 0.550 0.600 0.650");
static IIO_DEVICE_ATTR_RW(in_illuminance_input_target, 0);
static IIO_DEVICE_ATTR_WO(in_illuminance_calibrate, 0);
static IIO_DEVICE_ATTR_RW(in_illuminance_lux_table, 0);
diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
new file mode 100644
index 000000000000..34d42a2504c9
--- /dev/null
+++ b/drivers/iio/light/tsl2772.c
@@ -0,0 +1,1800 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Device driver for monitoring ambient light intensity in (lux) and proximity
+ * detection (prox) within the TAOS TSL2571, TSL2671, TMD2671, TSL2771, TMD2771,
+ * TSL2572, TSL2672, TMD2672, TSL2772, and TMD2772 devices.
+ *
+ * Copyright (c) 2012, TAOS Corporation.
+ * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
+ */
+
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/iio/events.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/platform_data/tsl2772.h>
+
+/* Cal defs */
+#define PROX_STAT_CAL 0
+#define PROX_STAT_SAMP 1
+#define MAX_SAMPLES_CAL 200
+
+/* TSL2772 Device ID */
+#define TRITON_ID 0x00
+#define SWORDFISH_ID 0x30
+#define HALIBUT_ID 0x20
+
+/* Lux calculation constants */
+#define TSL2772_LUX_CALC_OVER_FLOW 65535
+
+/*
+ * TAOS Register definitions - Note: depending on device, some of these register
+ * are not used and the register address is benign.
+ */
+
+/* Register offsets */
+#define TSL2772_MAX_CONFIG_REG 16
+
+/* Device Registers and Masks */
+#define TSL2772_CNTRL 0x00
+#define TSL2772_ALS_TIME 0X01
+#define TSL2772_PRX_TIME 0x02
+#define TSL2772_WAIT_TIME 0x03
+#define TSL2772_ALS_MINTHRESHLO 0X04
+#define TSL2772_ALS_MINTHRESHHI 0X05
+#define TSL2772_ALS_MAXTHRESHLO 0X06
+#define TSL2772_ALS_MAXTHRESHHI 0X07
+#define TSL2772_PRX_MINTHRESHLO 0X08
+#define TSL2772_PRX_MINTHRESHHI 0X09
+#define TSL2772_PRX_MAXTHRESHLO 0X0A
+#define TSL2772_PRX_MAXTHRESHHI 0X0B
+#define TSL2772_PERSISTENCE 0x0C
+#define TSL2772_ALS_PRX_CONFIG 0x0D
+#define TSL2772_PRX_COUNT 0x0E
+#define TSL2772_GAIN 0x0F
+#define TSL2772_NOTUSED 0x10
+#define TSL2772_REVID 0x11
+#define TSL2772_CHIPID 0x12
+#define TSL2772_STATUS 0x13
+#define TSL2772_ALS_CHAN0LO 0x14
+#define TSL2772_ALS_CHAN0HI 0x15
+#define TSL2772_ALS_CHAN1LO 0x16
+#define TSL2772_ALS_CHAN1HI 0x17
+#define TSL2772_PRX_LO 0x18
+#define TSL2772_PRX_HI 0x19
+
+/* tsl2772 cmd reg masks */
+#define TSL2772_CMD_REG 0x80
+#define TSL2772_CMD_SPL_FN 0x60
+#define TSL2772_CMD_REPEAT_PROTO 0x00
+#define TSL2772_CMD_AUTOINC_PROTO 0x20
+
+#define TSL2772_CMD_PROX_INT_CLR 0X05
+#define TSL2772_CMD_ALS_INT_CLR 0x06
+#define TSL2772_CMD_PROXALS_INT_CLR 0X07
+
+/* tsl2772 cntrl reg masks */
+#define TSL2772_CNTL_ADC_ENBL 0x02
+#define TSL2772_CNTL_PWR_ON 0x01
+
+/* tsl2772 status reg masks */
+#define TSL2772_STA_ADC_VALID 0x01
+#define TSL2772_STA_PRX_VALID 0x02
+#define TSL2772_STA_ADC_PRX_VALID (TSL2772_STA_ADC_VALID | \
+ TSL2772_STA_PRX_VALID)
+#define TSL2772_STA_ALS_INTR 0x10
+#define TSL2772_STA_PRX_INTR 0x20
+
+/* tsl2772 cntrl reg masks */
+#define TSL2772_CNTL_REG_CLEAR 0x00
+#define TSL2772_CNTL_PROX_INT_ENBL 0X20
+#define TSL2772_CNTL_ALS_INT_ENBL 0X10
+#define TSL2772_CNTL_WAIT_TMR_ENBL 0X08
+#define TSL2772_CNTL_PROX_DET_ENBL 0X04
+#define TSL2772_CNTL_PWRON 0x01
+#define TSL2772_CNTL_ALSPON_ENBL 0x03
+#define TSL2772_CNTL_INTALSPON_ENBL 0x13
+#define TSL2772_CNTL_PROXPON_ENBL 0x0F
+#define TSL2772_CNTL_INTPROXPON_ENBL 0x2F
+
+#define TSL2772_ALS_GAIN_TRIM_MIN 250
+#define TSL2772_ALS_GAIN_TRIM_MAX 4000
+
+/* Device family members */
+enum {
+ tsl2571,
+ tsl2671,
+ tmd2671,
+ tsl2771,
+ tmd2771,
+ tsl2572,
+ tsl2672,
+ tmd2672,
+ tsl2772,
+ tmd2772
+};
+
+enum {
+ TSL2772_CHIP_UNKNOWN = 0,
+ TSL2772_CHIP_WORKING = 1,
+ TSL2772_CHIP_SUSPENDED = 2
+};
+
+/* Per-device data */
+struct tsl2772_als_info {
+ u16 als_ch0;
+ u16 als_ch1;
+ u16 lux;
+};
+
+struct tsl2772_chip_info {
+ int chan_table_elements;
+ struct iio_chan_spec channel_with_events[4];
+ struct iio_chan_spec channel_without_events[4];
+ const struct iio_info *info;
+};
+
+struct tsl2772_chip {
+ kernel_ulong_t id;
+ struct mutex prox_mutex;
+ struct mutex als_mutex;
+ struct i2c_client *client;
+ u16 prox_data;
+ struct tsl2772_als_info als_cur_info;
+ struct tsl2772_settings settings;
+ struct tsl2772_platform_data *pdata;
+ int als_gain_time_scale;
+ int als_saturation;
+ int tsl2772_chip_status;
+ u8 tsl2772_config[TSL2772_MAX_CONFIG_REG];
+ const struct tsl2772_chip_info *chip_info;
+ const struct iio_info *info;
+ s64 event_timestamp;
+ /*
+ * This structure is intentionally large to accommodate
+ * updates via sysfs.
+ * Sized to 9 = max 8 segments + 1 termination segment
+ */
+ struct tsl2772_lux tsl2772_device_lux[TSL2772_MAX_LUX_TABLE_SIZE];
+};
+
+/*
+ * Different devices require different coefficents, and these numbers were
+ * derived from the 'Lux Equation' section of the various device datasheets.
+ * All of these coefficients assume a Glass Attenuation (GA) factor of 1.
+ * The coefficients are multiplied by 1000 to avoid floating point operations.
+ * The two rows in each table correspond to the Lux1 and Lux2 equations from
+ * the datasheets.
+ */
+static const struct tsl2772_lux tsl2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
+ { 53000, 106000 },
+ { 31800, 53000 },
+ { 0, 0 },
+};
+
+static const struct tsl2772_lux tmd2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
+ { 24000, 48000 },
+ { 14400, 24000 },
+ { 0, 0 },
+};
+
+static const struct tsl2772_lux tsl2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
+ { 60000, 112200 },
+ { 37800, 60000 },
+ { 0, 0 },
+};
+
+static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = {
+ { 20000, 35000 },
+ { 12600, 20000 },
+ { 0, 0 },
+};
+
+static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = {
+ [tsl2571] = tsl2x71_lux_table,
+ [tsl2671] = tsl2x71_lux_table,
+ [tmd2671] = tmd2x71_lux_table,
+ [tsl2771] = tsl2x71_lux_table,
+ [tmd2771] = tmd2x71_lux_table,
+ [tsl2572] = tsl2x72_lux_table,
+ [tsl2672] = tsl2x72_lux_table,
+ [tmd2672] = tmd2x72_lux_table,
+ [tsl2772] = tsl2x72_lux_table,
+ [tmd2772] = tmd2x72_lux_table,
+};
+
+static const struct tsl2772_settings tsl2772_default_settings = {
+ .als_time = 255, /* 2.72 / 2.73 ms */
+ .als_gain = 0,
+ .prox_time = 255, /* 2.72 / 2.73 ms */
+ .prox_gain = 0,
+ .wait_time = 255,
+ .als_prox_config = 0,
+ .als_gain_trim = 1000,
+ .als_cal_target = 150,
+ .als_persistence = 1,
+ .als_interrupt_en = false,
+ .als_thresh_low = 200,
+ .als_thresh_high = 256,
+ .prox_persistence = 1,
+ .prox_interrupt_en = false,
+ .prox_thres_low = 0,
+ .prox_thres_high = 512,
+ .prox_max_samples_cal = 30,
+ .prox_pulse_count = 8,
+ .prox_diode = TSL2772_DIODE1,
+ .prox_power = TSL2772_100_mA
+};
+
+static const s16 tsl2772_als_gain[] = {
+ 1,
+ 8,
+ 16,
+ 120
+};
+
+static const s16 tsl2772_prox_gain[] = {
+ 1,
+ 2,
+ 4,
+ 8
+};
+
+static const int tsl2772_int_time_avail[][6] = {
+ [tsl2571] = { 0, 2720, 0, 2720, 0, 696000 },
+ [tsl2671] = { 0, 2720, 0, 2720, 0, 696000 },
+ [tmd2671] = { 0, 2720, 0, 2720, 0, 696000 },
+ [tsl2771] = { 0, 2720, 0, 2720, 0, 696000 },
+ [tmd2771] = { 0, 2720, 0, 2720, 0, 696000 },
+ [tsl2572] = { 0, 2730, 0, 2730, 0, 699000 },
+ [tsl2672] = { 0, 2730, 0, 2730, 0, 699000 },
+ [tmd2672] = { 0, 2730, 0, 2730, 0, 699000 },
+ [tsl2772] = { 0, 2730, 0, 2730, 0, 699000 },
+ [tmd2772] = { 0, 2730, 0, 2730, 0, 699000 },
+};
+
+static int tsl2772_int_calibscale_avail[] = { 1, 8, 16, 120 };
+
+static int tsl2772_prox_calibscale_avail[] = { 1, 2, 4, 8 };
+
+/* Channel variations */
+enum {
+ ALS,
+ PRX,
+ ALSPRX,
+ PRX2,
+ ALSPRX2,
+};
+
+static const u8 device_channel_config[] = {
+ [tsl2571] = ALS,
+ [tsl2671] = PRX,
+ [tmd2671] = PRX,
+ [tsl2771] = ALSPRX,
+ [tmd2771] = ALSPRX,
+ [tsl2572] = ALS,
+ [tsl2672] = PRX2,
+ [tmd2672] = PRX2,
+ [tsl2772] = ALSPRX2,
+ [tmd2772] = ALSPRX2
+};
+
+static int tsl2772_read_status(struct tsl2772_chip *chip)
+{
+ int ret;
+
+ ret = i2c_smbus_read_byte_data(chip->client,
+ TSL2772_CMD_REG | TSL2772_STATUS);
+ if (ret < 0)
+ dev_err(&chip->client->dev,
+ "%s: failed to read STATUS register: %d\n", __func__,
+ ret);
+
+ return ret;
+}
+
+static int tsl2772_write_control_reg(struct tsl2772_chip *chip, u8 data)
+{
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(chip->client,
+ TSL2772_CMD_REG | TSL2772_CNTRL, data);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to write to control register %x: %d\n",
+ __func__, data, ret);
+ }
+
+ return ret;
+}
+
+static int tsl2772_read_autoinc_regs(struct tsl2772_chip *chip, int lower_reg,
+ int upper_reg)
+{
+ u8 buf[2];
+ int ret;
+
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2772_CMD_REG | TSL2772_CMD_AUTOINC_PROTO |
+ lower_reg);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to enable auto increment protocol: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = i2c_smbus_read_byte_data(chip->client,
+ TSL2772_CMD_REG | lower_reg);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to read from register %x: %d\n", __func__,
+ lower_reg, ret);
+ return ret;
+ }
+ buf[0] = ret;
+
+ ret = i2c_smbus_read_byte_data(chip->client,
+ TSL2772_CMD_REG | upper_reg);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to read from register %x: %d\n", __func__,
+ upper_reg, ret);
+ return ret;
+ }
+ buf[1] = ret;
+
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2772_CMD_REG | TSL2772_CMD_REPEAT_PROTO |
+ lower_reg);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to enable repeated byte protocol: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ return le16_to_cpup((const __le16 *)&buf[0]);
+}
+
+/**
+ * tsl2772_get_lux() - Reads and calculates current lux value.
+ * @indio_dev: pointer to IIO device
+ *
+ * The raw ch0 and ch1 values of the ambient light sensed in the last
+ * integration cycle are read from the device. The raw values are multiplied
+ * by a device-specific scale factor, and divided by the integration time and
+ * device gain. The code supports multiple lux equations through the lux table
+ * coefficients. A lux gain trim is applied to each lux equation, and then the
+ * maximum lux within the interval 0..65535 is selected.
+ */
+static int tsl2772_get_lux(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ struct tsl2772_lux *p;
+ int max_lux, ret;
+ bool overflow;
+
+ mutex_lock(&chip->als_mutex);
+
+ if (chip->tsl2772_chip_status != TSL2772_CHIP_WORKING) {
+ dev_err(&chip->client->dev, "%s: device is not enabled\n",
+ __func__);
+ ret = -EBUSY;
+ goto out_unlock;
+ }
+
+ ret = tsl2772_read_status(chip);
+ if (ret < 0)
+ goto out_unlock;
+
+ if (!(ret & TSL2772_STA_ADC_VALID)) {
+ dev_err(&chip->client->dev,
+ "%s: data not valid yet\n", __func__);
+ ret = chip->als_cur_info.lux; /* return LAST VALUE */
+ goto out_unlock;
+ }
+
+ ret = tsl2772_read_autoinc_regs(chip, TSL2772_ALS_CHAN0LO,
+ TSL2772_ALS_CHAN0HI);
+ if (ret < 0)
+ goto out_unlock;
+ chip->als_cur_info.als_ch0 = ret;
+
+ ret = tsl2772_read_autoinc_regs(chip, TSL2772_ALS_CHAN1LO,
+ TSL2772_ALS_CHAN1HI);
+ if (ret < 0)
+ goto out_unlock;
+ chip->als_cur_info.als_ch1 = ret;
+
+ if (chip->als_cur_info.als_ch0 >= chip->als_saturation) {
+ max_lux = TSL2772_LUX_CALC_OVER_FLOW;
+ goto update_struct_with_max_lux;
+ }
+
+ if (!chip->als_cur_info.als_ch0) {
+ /* have no data, so return LAST VALUE */
+ ret = chip->als_cur_info.lux;
+ goto out_unlock;
+ }
+
+ max_lux = 0;
+ overflow = false;
+ for (p = (struct tsl2772_lux *)chip->tsl2772_device_lux; p->ch0 != 0;
+ p++) {
+ int lux;
+
+ lux = ((chip->als_cur_info.als_ch0 * p->ch0) -
+ (chip->als_cur_info.als_ch1 * p->ch1)) /
+ chip->als_gain_time_scale;
+
+ /*
+ * The als_gain_trim can have a value within the range 250..4000
+ * and is a multiplier for the lux. A trim of 1000 makes no
+ * changes to the lux, less than 1000 scales it down, and
+ * greater than 1000 scales it up.
+ */
+ lux = (lux * chip->settings.als_gain_trim) / 1000;
+
+ if (lux > TSL2772_LUX_CALC_OVER_FLOW) {
+ overflow = true;
+ continue;
+ }
+
+ max_lux = max(max_lux, lux);
+ }
+
+ if (overflow && max_lux == 0)
+ max_lux = TSL2772_LUX_CALC_OVER_FLOW;
+
+update_struct_with_max_lux:
+ chip->als_cur_info.lux = max_lux;
+ ret = max_lux;
+
+out_unlock:
+ mutex_unlock(&chip->als_mutex);
+
+ return ret;
+}
+
+/**
+ * tsl2772_get_prox() - Reads proximity data registers and updates
+ * chip->prox_data.
+ *
+ * @indio_dev: pointer to IIO device
+ */
+static int tsl2772_get_prox(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&chip->prox_mutex);
+
+ ret = tsl2772_read_status(chip);
+ if (ret < 0)
+ goto prox_poll_err;
+
+ switch (chip->id) {
+ case tsl2571:
+ case tsl2671:
+ case tmd2671:
+ case tsl2771:
+ case tmd2771:
+ if (!(ret & TSL2772_STA_ADC_VALID)) {
+ ret = -EINVAL;
+ goto prox_poll_err;
+ }
+ break;
+ case tsl2572:
+ case tsl2672:
+ case tmd2672:
+ case tsl2772:
+ case tmd2772:
+ if (!(ret & TSL2772_STA_PRX_VALID)) {
+ ret = -EINVAL;
+ goto prox_poll_err;
+ }
+ break;
+ }
+
+ ret = tsl2772_read_autoinc_regs(chip, TSL2772_PRX_LO, TSL2772_PRX_HI);
+ if (ret < 0)
+ goto prox_poll_err;
+ chip->prox_data = ret;
+
+prox_poll_err:
+ mutex_unlock(&chip->prox_mutex);
+
+ return ret;
+}
+
+/**
+ * tsl2772_defaults() - Populates the device nominal operating parameters
+ * with those provided by a 'platform' data struct or
+ * with prefined defaults.
+ *
+ * @chip: pointer to device structure.
+ */
+static void tsl2772_defaults(struct tsl2772_chip *chip)
+{
+ /* If Operational settings defined elsewhere.. */
+ if (chip->pdata && chip->pdata->platform_default_settings)
+ memcpy(&chip->settings, chip->pdata->platform_default_settings,
+ sizeof(tsl2772_default_settings));
+ else
+ memcpy(&chip->settings, &tsl2772_default_settings,
+ sizeof(tsl2772_default_settings));
+
+ /* Load up the proper lux table. */
+ if (chip->pdata && chip->pdata->platform_lux_table[0].ch0 != 0)
+ memcpy(chip->tsl2772_device_lux,
+ chip->pdata->platform_lux_table,
+ sizeof(chip->pdata->platform_lux_table));
+ else
+ memcpy(chip->tsl2772_device_lux,
+ tsl2772_default_lux_table_group[chip->id],
+ TSL2772_DEFAULT_TABLE_BYTES);
+}
+
+/**
+ * tsl2772_als_calibrate() - Obtain single reading and calculate
+ * the als_gain_trim.
+ *
+ * @indio_dev: pointer to IIO device
+ */
+static int tsl2772_als_calibrate(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int ret, lux_val;
+
+ ret = i2c_smbus_read_byte_data(chip->client,
+ TSL2772_CMD_REG | TSL2772_CNTRL);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to read from the CNTRL register\n",
+ __func__);
+ return ret;
+ }
+
+ if ((ret & (TSL2772_CNTL_ADC_ENBL | TSL2772_CNTL_PWR_ON))
+ != (TSL2772_CNTL_ADC_ENBL | TSL2772_CNTL_PWR_ON)) {
+ dev_err(&chip->client->dev,
+ "%s: Device is not powered on and/or ADC is not enabled\n",
+ __func__);
+ return -EINVAL;
+ } else if ((ret & TSL2772_STA_ADC_VALID) != TSL2772_STA_ADC_VALID) {
+ dev_err(&chip->client->dev,
+ "%s: The two ADC channels have not completed an integration cycle\n",
+ __func__);
+ return -ENODATA;
+ }
+
+ lux_val = tsl2772_get_lux(indio_dev);
+ if (lux_val < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to get lux\n", __func__);
+ return lux_val;
+ }
+
+ ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) /
+ lux_val;
+ if (ret < TSL2772_ALS_GAIN_TRIM_MIN || ret > TSL2772_ALS_GAIN_TRIM_MAX)
+ return -ERANGE;
+
+ chip->settings.als_gain_trim = ret;
+
+ return ret;
+}
+
+static int tsl2772_chip_on(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int ret, i, als_count, als_time_us;
+ u8 *dev_reg, reg_val;
+
+ /* Non calculated parameters */
+ chip->tsl2772_config[TSL2772_ALS_TIME] = chip->settings.als_time;
+ chip->tsl2772_config[TSL2772_PRX_TIME] = chip->settings.prox_time;
+ chip->tsl2772_config[TSL2772_WAIT_TIME] = chip->settings.wait_time;
+ chip->tsl2772_config[TSL2772_ALS_PRX_CONFIG] =
+ chip->settings.als_prox_config;
+
+ chip->tsl2772_config[TSL2772_ALS_MINTHRESHLO] =
+ (chip->settings.als_thresh_low) & 0xFF;
+ chip->tsl2772_config[TSL2772_ALS_MINTHRESHHI] =
+ (chip->settings.als_thresh_low >> 8) & 0xFF;
+ chip->tsl2772_config[TSL2772_ALS_MAXTHRESHLO] =
+ (chip->settings.als_thresh_high) & 0xFF;
+ chip->tsl2772_config[TSL2772_ALS_MAXTHRESHHI] =
+ (chip->settings.als_thresh_high >> 8) & 0xFF;
+ chip->tsl2772_config[TSL2772_PERSISTENCE] =
+ (chip->settings.prox_persistence & 0xFF) << 4 |
+ (chip->settings.als_persistence & 0xFF);
+
+ chip->tsl2772_config[TSL2772_PRX_COUNT] =
+ chip->settings.prox_pulse_count;
+ chip->tsl2772_config[TSL2772_PRX_MINTHRESHLO] =
+ (chip->settings.prox_thres_low) & 0xFF;
+ chip->tsl2772_config[TSL2772_PRX_MINTHRESHHI] =
+ (chip->settings.prox_thres_low >> 8) & 0xFF;
+ chip->tsl2772_config[TSL2772_PRX_MAXTHRESHLO] =
+ (chip->settings.prox_thres_high) & 0xFF;
+ chip->tsl2772_config[TSL2772_PRX_MAXTHRESHHI] =
+ (chip->settings.prox_thres_high >> 8) & 0xFF;
+
+ /* and make sure we're not already on */
+ if (chip->tsl2772_chip_status == TSL2772_CHIP_WORKING) {
+ /* if forcing a register update - turn off, then on */
+ dev_info(&chip->client->dev, "device is already enabled\n");
+ return -EINVAL;
+ }
+
+ /* Set the gain based on tsl2772_settings struct */
+ chip->tsl2772_config[TSL2772_GAIN] =
+ (chip->settings.als_gain & 0xFF) |
+ ((chip->settings.prox_gain & 0xFF) << 2) |
+ (chip->settings.prox_diode << 4) |
+ (chip->settings.prox_power << 6);
+
+ /* set chip time scaling and saturation */
+ als_count = 256 - chip->settings.als_time;
+ als_time_us = als_count * tsl2772_int_time_avail[chip->id][3];
+ chip->als_saturation = als_count * 768; /* 75% of full scale */
+ chip->als_gain_time_scale = als_time_us *
+ tsl2772_als_gain[chip->settings.als_gain];
+
+ /*
+ * TSL2772 Specific power-on / adc enable sequence
+ * Power on the device 1st.
+ */
+ ret = tsl2772_write_control_reg(chip, TSL2772_CNTL_PWR_ON);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * Use the following shadow copy for our delay before enabling ADC.
+ * Write all the registers.
+ */
+ for (i = 0, dev_reg = chip->tsl2772_config;
+ i < TSL2772_MAX_CONFIG_REG; i++) {
+ int reg = TSL2772_CMD_REG + i;
+
+ ret = i2c_smbus_write_byte_data(chip->client, reg,
+ *dev_reg++);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to write to register %x: %d\n",
+ __func__, reg, ret);
+ return ret;
+ }
+ }
+
+ /* Power-on settling time */
+ usleep_range(3000, 3500);
+
+ reg_val = TSL2772_CNTL_PWR_ON | TSL2772_CNTL_ADC_ENBL |
+ TSL2772_CNTL_PROX_DET_ENBL;
+ if (chip->settings.als_interrupt_en)
+ reg_val |= TSL2772_CNTL_ALS_INT_ENBL;
+ if (chip->settings.prox_interrupt_en)
+ reg_val |= TSL2772_CNTL_PROX_INT_ENBL;
+
+ ret = tsl2772_write_control_reg(chip, reg_val);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2772_CMD_REG | TSL2772_CMD_SPL_FN |
+ TSL2772_CMD_PROXALS_INT_CLR);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to clear interrupt status: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ chip->tsl2772_chip_status = TSL2772_CHIP_WORKING;
+
+ return ret;
+}
+
+static int tsl2772_chip_off(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ /* turn device off */
+ chip->tsl2772_chip_status = TSL2772_CHIP_SUSPENDED;
+ return tsl2772_write_control_reg(chip, 0x00);
+}
+
+/**
+ * tsl2772_invoke_change - power cycle the device to implement the user
+ * parameters
+ * @indio_dev: pointer to IIO device
+ *
+ * Obtain and lock both ALS and PROX resources, determine and save device state
+ * (On/Off), cycle device to implement updated parameter, put device back into
+ * proper state, and unlock resource.
+ */
+static int tsl2772_invoke_change(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int device_status = chip->tsl2772_chip_status;
+ int ret;
+
+ mutex_lock(&chip->als_mutex);
+ mutex_lock(&chip->prox_mutex);
+
+ if (device_status == TSL2772_CHIP_WORKING) {
+ ret = tsl2772_chip_off(indio_dev);
+ if (ret < 0)
+ goto unlock;
+ }
+
+ ret = tsl2772_chip_on(indio_dev);
+
+unlock:
+ mutex_unlock(&chip->prox_mutex);
+ mutex_unlock(&chip->als_mutex);
+
+ return ret;
+}
+
+static int tsl2772_prox_cal(struct iio_dev *indio_dev)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int prox_history[MAX_SAMPLES_CAL + 1];
+ int i, ret, mean, max, sample_sum;
+
+ if (chip->settings.prox_max_samples_cal < 1 ||
+ chip->settings.prox_max_samples_cal > MAX_SAMPLES_CAL)
+ return -EINVAL;
+
+ for (i = 0; i < chip->settings.prox_max_samples_cal; i++) {
+ usleep_range(15000, 17500);
+ ret = tsl2772_get_prox(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ prox_history[i] = chip->prox_data;
+ }
+
+ sample_sum = 0;
+ max = INT_MIN;
+ for (i = 0; i < chip->settings.prox_max_samples_cal; i++) {
+ sample_sum += prox_history[i];
+ max = max(max, prox_history[i]);
+ }
+ mean = sample_sum / chip->settings.prox_max_samples_cal;
+
+ chip->settings.prox_thres_high = (max << 1) - mean;
+
+ return tsl2772_invoke_change(indio_dev);
+}
+
+static int tsl2772_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_INTENSITY) {
+ *length = ARRAY_SIZE(tsl2772_int_calibscale_avail);
+ *vals = tsl2772_int_calibscale_avail;
+ } else {
+ *length = ARRAY_SIZE(tsl2772_prox_calibscale_avail);
+ *vals = tsl2772_prox_calibscale_avail;
+ }
+ *type = IIO_VAL_INT;
+ return IIO_AVAIL_LIST;
+ case IIO_CHAN_INFO_INT_TIME:
+ *length = ARRAY_SIZE(tsl2772_int_time_avail[chip->id]);
+ *vals = tsl2772_int_time_avail[chip->id];
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ return IIO_AVAIL_RANGE;
+ }
+
+ return -EINVAL;
+}
+
+static ssize_t in_illuminance0_target_input_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct tsl2772_chip *chip = iio_priv(dev_to_iio_dev(dev));
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", chip->settings.als_cal_target);
+}
+
+static ssize_t in_illuminance0_target_input_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ u16 value;
+ int ret;
+
+ if (kstrtou16(buf, 0, &value))
+ return -EINVAL;
+
+ chip->settings.als_cal_target = value;
+ ret = tsl2772_invoke_change(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+
+static ssize_t in_illuminance0_calibrate_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ bool value;
+ int ret;
+
+ if (kstrtobool(buf, &value) || !value)
+ return -EINVAL;
+
+ ret = tsl2772_als_calibrate(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ ret = tsl2772_invoke_change(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+
+static ssize_t in_illuminance0_lux_table_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct tsl2772_chip *chip = iio_priv(dev_to_iio_dev(dev));
+ int i = 0;
+ int offset = 0;
+
+ while (i < TSL2772_MAX_LUX_TABLE_SIZE) {
+ offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,",
+ chip->tsl2772_device_lux[i].ch0,
+ chip->tsl2772_device_lux[i].ch1);
+ if (chip->tsl2772_device_lux[i].ch0 == 0) {
+ /*
+ * We just printed the first "0" entry.
+ * Now get rid of the extra "," and break.
+ */
+ offset--;
+ break;
+ }
+ i++;
+ }
+
+ offset += snprintf(buf + offset, PAGE_SIZE, "\n");
+ return offset;
+}
+
+static ssize_t in_illuminance0_lux_table_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int value[ARRAY_SIZE(chip->tsl2772_device_lux) * 2 + 1];
+ int n, ret;
+
+ get_options(buf, ARRAY_SIZE(value), value);
+
+ /*
+ * We now have an array of ints starting at value[1], and
+ * enumerated by value[0].
+ * We expect each group of two ints to be one table entry,
+ * and the last table entry is all 0.
+ */
+ n = value[0];
+ if ((n % 2) || n < 4 ||
+ n > ((ARRAY_SIZE(chip->tsl2772_device_lux) - 1) * 2))
+ return -EINVAL;
+
+ if ((value[(n - 1)] | value[n]) != 0)
+ return -EINVAL;
+
+ if (chip->tsl2772_chip_status == TSL2772_CHIP_WORKING) {
+ ret = tsl2772_chip_off(indio_dev);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Zero out the table */
+ memset(chip->tsl2772_device_lux, 0, sizeof(chip->tsl2772_device_lux));
+ memcpy(chip->tsl2772_device_lux, &value[1], (value[0] * 4));
+
+ ret = tsl2772_invoke_change(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+
+static ssize_t in_proximity0_calibrate_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ bool value;
+ int ret;
+
+ if (kstrtobool(buf, &value) || !value)
+ return -EINVAL;
+
+ ret = tsl2772_prox_cal(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ ret = tsl2772_invoke_change(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+
+static int tsl2772_read_interrupt_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ if (chan->type == IIO_INTENSITY)
+ return chip->settings.als_interrupt_en;
+ else
+ return chip->settings.prox_interrupt_en;
+}
+
+static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ int val)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ if (chan->type == IIO_INTENSITY)
+ chip->settings.als_interrupt_en = val ? true : false;
+ else
+ chip->settings.prox_interrupt_en = val ? true : false;
+
+ return tsl2772_invoke_change(indio_dev);
+}
+
+static int tsl2772_write_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int ret = -EINVAL, count, persistence;
+ u8 time;
+
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ if (chan->type == IIO_INTENSITY) {
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ chip->settings.als_thresh_high = val;
+ ret = 0;
+ break;
+ case IIO_EV_DIR_FALLING:
+ chip->settings.als_thresh_low = val;
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ chip->settings.prox_thres_high = val;
+ ret = 0;
+ break;
+ case IIO_EV_DIR_FALLING:
+ chip->settings.prox_thres_low = val;
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case IIO_EV_INFO_PERIOD:
+ if (chan->type == IIO_INTENSITY)
+ time = chip->settings.als_time;
+ else
+ time = chip->settings.prox_time;
+
+ count = 256 - time;
+ persistence = ((val * 1000000) + val2) /
+ (count * tsl2772_int_time_avail[chip->id][3]);
+
+ if (chan->type == IIO_INTENSITY) {
+ /* ALS filter values are 1, 2, 3, 5, 10, 15, ..., 60 */
+ if (persistence > 3)
+ persistence = (persistence / 5) + 3;
+
+ chip->settings.als_persistence = persistence;
+ } else {
+ chip->settings.prox_persistence = persistence;
+ }
+
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+
+ if (ret < 0)
+ return ret;
+
+ return tsl2772_invoke_change(indio_dev);
+}
+
+static int tsl2772_read_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int *val, int *val2)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ int filter_delay, persistence;
+ u8 time;
+
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ if (chan->type == IIO_INTENSITY) {
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ *val = chip->settings.als_thresh_high;
+ return IIO_VAL_INT;
+ case IIO_EV_DIR_FALLING:
+ *val = chip->settings.als_thresh_low;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ *val = chip->settings.prox_thres_high;
+ return IIO_VAL_INT;
+ case IIO_EV_DIR_FALLING:
+ *val = chip->settings.prox_thres_low;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ }
+ break;
+ case IIO_EV_INFO_PERIOD:
+ if (chan->type == IIO_INTENSITY) {
+ time = chip->settings.als_time;
+ persistence = chip->settings.als_persistence;
+
+ /* ALS filter values are 1, 2, 3, 5, 10, 15, ..., 60 */
+ if (persistence > 3)
+ persistence = (persistence - 3) * 5;
+ } else {
+ time = chip->settings.prox_time;
+ persistence = chip->settings.prox_persistence;
+ }
+
+ filter_delay = persistence * (256 - time) *
+ tsl2772_int_time_avail[chip->id][3];
+
+ *val = filter_delay / 1000000;
+ *val2 = filter_delay % 1000000;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int tsl2772_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val,
+ int *val2,
+ long mask)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_PROCESSED:
+ switch (chan->type) {
+ case IIO_LIGHT:
+ tsl2772_get_lux(indio_dev);
+ *val = chip->als_cur_info.lux;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_RAW:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ tsl2772_get_lux(indio_dev);
+ if (chan->channel == 0)
+ *val = chip->als_cur_info.als_ch0;
+ else
+ *val = chip->als_cur_info.als_ch1;
+ return IIO_VAL_INT;
+ case IIO_PROXIMITY:
+ tsl2772_get_prox(indio_dev);
+ *val = chip->prox_data;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ break;
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_LIGHT)
+ *val = tsl2772_als_gain[chip->settings.als_gain];
+ else
+ *val = tsl2772_prox_gain[chip->settings.prox_gain];
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ *val = chip->settings.als_gain_trim;
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_INT_TIME:
+ *val = 0;
+ *val2 = (256 - chip->settings.als_time) *
+ tsl2772_int_time_avail[chip->id][3];
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int tsl2772_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
+{
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_INTENSITY) {
+ switch (val) {
+ case 1:
+ chip->settings.als_gain = 0;
+ break;
+ case 8:
+ chip->settings.als_gain = 1;
+ break;
+ case 16:
+ chip->settings.als_gain = 2;
+ break;
+ case 120:
+ chip->settings.als_gain = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (val) {
+ case 1:
+ chip->settings.prox_gain = 0;
+ break;
+ case 2:
+ chip->settings.prox_gain = 1;
+ break;
+ case 4:
+ chip->settings.prox_gain = 2;
+ break;
+ case 8:
+ chip->settings.prox_gain = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+ break;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ if (val < TSL2772_ALS_GAIN_TRIM_MIN ||
+ val > TSL2772_ALS_GAIN_TRIM_MAX)
+ return -EINVAL;
+
+ chip->settings.als_gain_trim = val;
+ break;
+ case IIO_CHAN_INFO_INT_TIME:
+ if (val != 0 || val2 < tsl2772_int_time_avail[chip->id][1] ||
+ val2 > tsl2772_int_time_avail[chip->id][5])
+ return -EINVAL;
+
+ chip->settings.als_time = 256 -
+ (val2 / tsl2772_int_time_avail[chip->id][3]);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return tsl2772_invoke_change(indio_dev);
+}
+
+static DEVICE_ATTR_RW(in_illuminance0_target_input);
+
+static DEVICE_ATTR_WO(in_illuminance0_calibrate);
+
+static DEVICE_ATTR_WO(in_proximity0_calibrate);
+
+static DEVICE_ATTR_RW(in_illuminance0_lux_table);
+
+/* Use the default register values to identify the Taos device */
+static int tsl2772_device_id_verif(int id, int target)
+{
+ switch (target) {
+ case tsl2571:
+ case tsl2671:
+ case tsl2771:
+ return (id & 0xf0) == TRITON_ID;
+ case tmd2671:
+ case tmd2771:
+ return (id & 0xf0) == HALIBUT_ID;
+ case tsl2572:
+ case tsl2672:
+ case tmd2672:
+ case tsl2772:
+ case tmd2772:
+ return (id & 0xf0) == SWORDFISH_ID;
+ }
+
+ return -EINVAL;
+}
+
+static irqreturn_t tsl2772_event_handler(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct tsl2772_chip *chip = iio_priv(indio_dev);
+ s64 timestamp = iio_get_time_ns(indio_dev);
+ int ret;
+
+ ret = tsl2772_read_status(chip);
+ if (ret < 0)
+ return IRQ_HANDLED;
+
+ /* What type of interrupt do we need to process */
+ if (ret & TSL2772_STA_PRX_INTR) {
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY,
+ 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ timestamp);
+ }
+
+ if (ret & TSL2772_STA_ALS_INTR) {
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
+ 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ timestamp);
+ }
+
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2772_CMD_REG | TSL2772_CMD_SPL_FN |
+ TSL2772_CMD_PROXALS_INT_CLR);
+ if (ret < 0)
+ dev_err(&chip->client->dev,
+ "%s: failed to clear interrupt status: %d\n",
+ __func__, ret);
+
+ return IRQ_HANDLED;
+}
+
+static struct attribute *tsl2772_ALS_device_attrs[] = {
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ NULL
+};
+
+static struct attribute *tsl2772_PRX_device_attrs[] = {
+ &dev_attr_in_proximity0_calibrate.attr,
+ NULL
+};
+
+static struct attribute *tsl2772_ALSPRX_device_attrs[] = {
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ NULL
+};
+
+static struct attribute *tsl2772_PRX2_device_attrs[] = {
+ &dev_attr_in_proximity0_calibrate.attr,
+ NULL
+};
+
+static struct attribute *tsl2772_ALSPRX2_device_attrs[] = {
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ &dev_attr_in_proximity0_calibrate.attr,
+ NULL
+};
+
+static const struct attribute_group tsl2772_device_attr_group_tbl[] = {
+ [ALS] = {
+ .attrs = tsl2772_ALS_device_attrs,
+ },
+ [PRX] = {
+ .attrs = tsl2772_PRX_device_attrs,
+ },
+ [ALSPRX] = {
+ .attrs = tsl2772_ALSPRX_device_attrs,
+ },
+ [PRX2] = {
+ .attrs = tsl2772_PRX2_device_attrs,
+ },
+ [ALSPRX2] = {
+ .attrs = tsl2772_ALSPRX2_device_attrs,
+ },
+};
+
+#define TSL2772_DEVICE_INFO(type)[type] = \
+ { \
+ .attrs = &tsl2772_device_attr_group_tbl[type], \
+ .read_raw = &tsl2772_read_raw, \
+ .read_avail = &tsl2772_read_avail, \
+ .write_raw = &tsl2772_write_raw, \
+ .read_event_value = &tsl2772_read_event_value, \
+ .write_event_value = &tsl2772_write_event_value, \
+ .read_event_config = &tsl2772_read_interrupt_config, \
+ .write_event_config = &tsl2772_write_interrupt_config, \
+ }
+
+static const struct iio_info tsl2772_device_info[] = {
+ TSL2772_DEVICE_INFO(ALS),
+ TSL2772_DEVICE_INFO(PRX),
+ TSL2772_DEVICE_INFO(ALSPRX),
+ TSL2772_DEVICE_INFO(PRX2),
+ TSL2772_DEVICE_INFO(ALSPRX2),
+};
+
+static const struct iio_event_spec tsl2772_events[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_EITHER,
+ .mask_separate = BIT(IIO_EV_INFO_PERIOD) |
+ BIT(IIO_EV_INFO_ENABLE),
+ },
+};
+
+static const struct tsl2772_chip_info tsl2772_chip_info_tbl[] = {
+ [ALS] = {
+ .channel_with_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ },
+ },
+ .channel_without_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ },
+ },
+ .chan_table_elements = 3,
+ .info = &tsl2772_device_info[ALS],
+ },
+ [PRX] = {
+ .channel_with_events = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ },
+ },
+ .channel_without_events = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ },
+ },
+ .chan_table_elements = 1,
+ .info = &tsl2772_device_info[PRX],
+ },
+ [ALSPRX] = {
+ .channel_with_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ },
+ },
+ .channel_without_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ },
+ },
+ .chan_table_elements = 4,
+ .info = &tsl2772_device_info[ALSPRX],
+ },
+ [PRX2] = {
+ .channel_with_events = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ },
+ },
+ .channel_without_events = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ },
+ },
+ .chan_table_elements = 1,
+ .info = &tsl2772_device_info[PRX2],
+ },
+ [ALSPRX2] = {
+ .channel_with_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .event_spec = tsl2772_events,
+ .num_event_specs = ARRAY_SIZE(tsl2772_events),
+ },
+ },
+ .channel_without_events = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
+ BIT(IIO_CHAN_INFO_CALIBBIAS),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_CALIBSCALE),
+ },
+ },
+ .chan_table_elements = 4,
+ .info = &tsl2772_device_info[ALSPRX2],
+ },
+};
+
+static int tsl2772_probe(struct i2c_client *clientp,
+ const struct i2c_device_id *id)
+{
+ struct iio_dev *indio_dev;
+ struct tsl2772_chip *chip;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ chip = iio_priv(indio_dev);
+ chip->client = clientp;
+ i2c_set_clientdata(clientp, indio_dev);
+
+ ret = i2c_smbus_read_byte_data(chip->client,
+ TSL2772_CMD_REG | TSL2772_CHIPID);
+ if (ret < 0)
+ return ret;
+
+ if (tsl2772_device_id_verif(ret, id->driver_data) <= 0) {
+ dev_info(&chip->client->dev,
+ "%s: i2c device found does not match expected id\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ ret = i2c_smbus_write_byte(clientp, TSL2772_CMD_REG | TSL2772_CNTRL);
+ if (ret < 0) {
+ dev_err(&clientp->dev,
+ "%s: Failed to write to CMD register: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ mutex_init(&chip->als_mutex);
+ mutex_init(&chip->prox_mutex);
+
+ chip->tsl2772_chip_status = TSL2772_CHIP_UNKNOWN;
+ chip->pdata = dev_get_platdata(&clientp->dev);
+ chip->id = id->driver_data;
+ chip->chip_info =
+ &tsl2772_chip_info_tbl[device_channel_config[id->driver_data]];
+
+ indio_dev->info = chip->chip_info->info;
+ indio_dev->dev.parent = &clientp->dev;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->name = chip->client->name;
+ indio_dev->num_channels = chip->chip_info->chan_table_elements;
+
+ if (clientp->irq) {
+ indio_dev->channels = chip->chip_info->channel_with_events;
+
+ ret = devm_request_threaded_irq(&clientp->dev, clientp->irq,
+ NULL,
+ &tsl2772_event_handler,
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "TSL2772_event",
+ indio_dev);
+ if (ret) {
+ dev_err(&clientp->dev,
+ "%s: irq request failed\n", __func__);
+ return ret;
+ }
+ } else {
+ indio_dev->channels = chip->chip_info->channel_without_events;
+ }
+
+ tsl2772_defaults(chip);
+ ret = tsl2772_chip_on(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ ret = iio_device_register(indio_dev);
+ if (ret) {
+ tsl2772_chip_off(indio_dev);
+ dev_err(&clientp->dev,
+ "%s: iio registration failed\n", __func__);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int tsl2772_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return tsl2772_chip_off(indio_dev);
+}
+
+static int tsl2772_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return tsl2772_chip_on(indio_dev);
+}
+
+static int tsl2772_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ tsl2772_chip_off(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ return 0;
+}
+
+static const struct i2c_device_id tsl2772_idtable[] = {
+ { "tsl2571", tsl2571 },
+ { "tsl2671", tsl2671 },
+ { "tmd2671", tmd2671 },
+ { "tsl2771", tsl2771 },
+ { "tmd2771", tmd2771 },
+ { "tsl2572", tsl2572 },
+ { "tsl2672", tsl2672 },
+ { "tmd2672", tmd2672 },
+ { "tsl2772", tsl2772 },
+ { "tmd2772", tmd2772 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, tsl2772_idtable);
+
+static const struct of_device_id tsl2772_of_match[] = {
+ { .compatible = "amstaos,tsl2571" },
+ { .compatible = "amstaos,tsl2671" },
+ { .compatible = "amstaos,tmd2671" },
+ { .compatible = "amstaos,tsl2771" },
+ { .compatible = "amstaos,tmd2771" },
+ { .compatible = "amstaos,tsl2572" },
+ { .compatible = "amstaos,tsl2672" },
+ { .compatible = "amstaos,tmd2672" },
+ { .compatible = "amstaos,tsl2772" },
+ { .compatible = "amstaos,tmd2772" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, tsl2772_of_match);
+
+static const struct dev_pm_ops tsl2772_pm_ops = {
+ .suspend = tsl2772_suspend,
+ .resume = tsl2772_resume,
+};
+
+static struct i2c_driver tsl2772_driver = {
+ .driver = {
+ .name = "tsl2772",
+ .of_match_table = tsl2772_of_match,
+ .pm = &tsl2772_pm_ops,
+ },
+ .id_table = tsl2772_idtable,
+ .probe = tsl2772_probe,
+ .remove = tsl2772_remove,
+};
+
+module_i2c_driver(tsl2772_driver);
+
+MODULE_AUTHOR("J. August Brenner <Jon.Brenner@ams.com>");
+MODULE_AUTHOR("Brian Masney <masneyb@onstation.org>");
+MODULE_DESCRIPTION("TAOS tsl2772 ambient and proximity light sensor driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index b34ace76d31b..f063355480ba 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -26,6 +26,7 @@
#define MAG3110_OUT_Y 0x03
#define MAG3110_OUT_Z 0x05
#define MAG3110_WHO_AM_I 0x07
+#define MAG3110_SYSMOD 0x08
#define MAG3110_OFF_X 0x09 /* MSB first */
#define MAG3110_OFF_Y 0x0b
#define MAG3110_OFF_Z 0x0d
@@ -39,6 +40,8 @@
#define MAG3110_CTRL_DR_SHIFT 5
#define MAG3110_CTRL_DR_DEFAULT 0
+#define MAG3110_SYSMOD_MODE_MASK GENMASK(1, 0)
+
#define MAG3110_CTRL_TM BIT(1) /* trigger single measurement */
#define MAG3110_CTRL_AC BIT(0) /* continuous measurements */
@@ -52,17 +55,20 @@ struct mag3110_data {
struct i2c_client *client;
struct mutex lock;
u8 ctrl_reg1;
+ int sleep_val;
};
static int mag3110_request(struct mag3110_data *data)
{
int ret, tries = 150;
- /* trigger measurement */
- ret = i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
- data->ctrl_reg1 | MAG3110_CTRL_TM);
- if (ret < 0)
- return ret;
+ if ((data->ctrl_reg1 & MAG3110_CTRL_AC) == 0) {
+ /* trigger measurement */
+ ret = i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
+ data->ctrl_reg1 | MAG3110_CTRL_TM);
+ if (ret < 0)
+ return ret;
+ }
while (tries-- > 0) {
ret = i2c_smbus_read_byte_data(data->client, MAG3110_STATUS);
@@ -71,7 +77,11 @@ static int mag3110_request(struct mag3110_data *data)
/* wait for data ready */
if ((ret & MAG3110_STATUS_DRDY) == MAG3110_STATUS_DRDY)
break;
- msleep(20);
+
+ if (data->sleep_val <= 20)
+ usleep_range(data->sleep_val * 250, data->sleep_val * 500);
+ else
+ msleep(20);
}
if (tries < 0) {
@@ -144,6 +154,117 @@ static int mag3110_get_samp_freq_index(struct mag3110_data *data,
val2);
}
+static int mag3110_calculate_sleep(struct mag3110_data *data)
+{
+ int ret, i = data->ctrl_reg1 >> MAG3110_CTRL_DR_SHIFT;
+
+ if (mag3110_samp_freq[i][0] > 0)
+ ret = 1000 / mag3110_samp_freq[i][0];
+ else
+ ret = 1000;
+
+ return ret == 0 ? 1 : ret;
+}
+
+static int mag3110_standby(struct mag3110_data *data)
+{
+ return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
+ data->ctrl_reg1 & ~MAG3110_CTRL_AC);
+}
+
+static int mag3110_wait_standby(struct mag3110_data *data)
+{
+ int ret, tries = 30;
+
+ /*
+ * Takes up to 1/ODR to come out of active mode into stby
+ * Longest expected period is 12.5seconds.
+ * We'll sleep for 500ms between checks
+ */
+ while (tries-- > 0) {
+ ret = i2c_smbus_read_byte_data(data->client, MAG3110_SYSMOD);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "i2c error\n");
+ return ret;
+ }
+ /* wait for standby */
+ if ((ret & MAG3110_SYSMOD_MODE_MASK) == 0)
+ break;
+
+ msleep_interruptible(500);
+ }
+
+ if (tries < 0) {
+ dev_err(&data->client->dev, "device not entering standby mode\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int mag3110_active(struct mag3110_data *data)
+{
+ return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
+ data->ctrl_reg1);
+}
+
+/* returns >0 if active, 0 if in standby and <0 on error */
+static int mag3110_is_active(struct mag3110_data *data)
+{
+ int reg;
+
+ reg = i2c_smbus_read_byte_data(data->client, MAG3110_CTRL_REG1);
+ if (reg < 0)
+ return reg;
+
+ return reg & MAG3110_CTRL_AC;
+}
+
+static int mag3110_change_config(struct mag3110_data *data, u8 reg, u8 val)
+{
+ int ret;
+ int is_active;
+
+ mutex_lock(&data->lock);
+
+ is_active = mag3110_is_active(data);
+ if (is_active < 0) {
+ ret = is_active;
+ goto fail;
+ }
+
+ /* config can only be changed when in standby */
+ if (is_active > 0) {
+ ret = mag3110_standby(data);
+ if (ret < 0)
+ goto fail;
+ }
+
+ /*
+ * After coming out of active we must wait for the part
+ * to transition to STBY. This can take up to 1 /ODR to occur
+ */
+ ret = mag3110_wait_standby(data);
+ if (ret < 0)
+ goto fail;
+
+ ret = i2c_smbus_write_byte_data(data->client, reg, val);
+ if (ret < 0)
+ goto fail;
+
+ if (is_active > 0) {
+ ret = mag3110_active(data);
+ if (ret < 0)
+ goto fail;
+ }
+
+ ret = 0;
+fail:
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
static int mag3110_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
@@ -235,11 +356,15 @@ static int mag3110_write_raw(struct iio_dev *indio_dev,
ret = -EINVAL;
break;
}
-
- data->ctrl_reg1 &= ~MAG3110_CTRL_DR_MASK;
+ data->ctrl_reg1 &= 0xff & ~MAG3110_CTRL_DR_MASK
+ & ~MAG3110_CTRL_AC;
data->ctrl_reg1 |= rate << MAG3110_CTRL_DR_SHIFT;
- ret = i2c_smbus_write_byte_data(data->client,
- MAG3110_CTRL_REG1, data->ctrl_reg1);
+ data->sleep_val = mag3110_calculate_sleep(data);
+ if (data->sleep_val < 40)
+ data->ctrl_reg1 |= MAG3110_CTRL_AC;
+
+ ret = mag3110_change_config(data, MAG3110_CTRL_REG1,
+ data->ctrl_reg1);
break;
case IIO_CHAN_INFO_CALIBBIAS:
if (val < -10000 || val > 10000) {
@@ -337,12 +462,6 @@ static const struct iio_info mag3110_info = {
static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0};
-static int mag3110_standby(struct mag3110_data *data)
-{
- return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
- data->ctrl_reg1 & ~MAG3110_CTRL_AC);
-}
-
static int mag3110_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -374,8 +493,11 @@ static int mag3110_probe(struct i2c_client *client,
indio_dev->available_scan_masks = mag3110_scan_masks;
data->ctrl_reg1 = MAG3110_CTRL_DR_DEFAULT << MAG3110_CTRL_DR_SHIFT;
- ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG1,
- data->ctrl_reg1);
+ data->sleep_val = mag3110_calculate_sleep(data);
+ if (data->sleep_val < 40)
+ data->ctrl_reg1 |= MAG3110_CTRL_AC;
+
+ ret = mag3110_change_config(data, MAG3110_CTRL_REG1, data->ctrl_reg1);
if (ret < 0)
return ret;
diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index 601b25d1f387..320a7c929777 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -99,6 +99,23 @@ static const struct iio_info mcp4018_info = {
.write_raw = mcp4018_write_raw,
};
+static const struct i2c_device_id mcp4018_id[] = {
+ { "mcp4017-502", MCP4018_502 },
+ { "mcp4017-103", MCP4018_103 },
+ { "mcp4017-503", MCP4018_503 },
+ { "mcp4017-104", MCP4018_104 },
+ { "mcp4018-502", MCP4018_502 },
+ { "mcp4018-103", MCP4018_103 },
+ { "mcp4018-503", MCP4018_503 },
+ { "mcp4018-104", MCP4018_104 },
+ { "mcp4019-502", MCP4018_502 },
+ { "mcp4019-103", MCP4018_103 },
+ { "mcp4019-503", MCP4018_503 },
+ { "mcp4019-104", MCP4018_104 },
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, mcp4018_id);
+
#ifdef CONFIG_OF
#define MCP4018_COMPATIBLE(of_compatible, cfg) { \
@@ -125,8 +142,7 @@ MODULE_DEVICE_TABLE(of, mcp4018_of_match);
#endif
-static int mcp4018_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int mcp4018_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct mcp4018_data *data;
@@ -150,7 +166,7 @@ static int mcp4018_probe(struct i2c_client *client,
if (match)
data->cfg = of_device_get_match_data(dev);
else
- data->cfg = &mcp4018_cfg[id->driver_data];
+ data->cfg = &mcp4018_cfg[i2c_match_id(mcp4018_id, client)->driver_data];
indio_dev->dev.parent = dev;
indio_dev->info = &mcp4018_info;
@@ -161,29 +177,12 @@ static int mcp4018_probe(struct i2c_client *client,
return devm_iio_device_register(dev, indio_dev);
}
-static const struct i2c_device_id mcp4018_id[] = {
- { "mcp4017-502", MCP4018_502 },
- { "mcp4017-103", MCP4018_103 },
- { "mcp4017-503", MCP4018_503 },
- { "mcp4017-104", MCP4018_104 },
- { "mcp4018-502", MCP4018_502 },
- { "mcp4018-103", MCP4018_103 },
- { "mcp4018-503", MCP4018_503 },
- { "mcp4018-104", MCP4018_104 },
- { "mcp4019-502", MCP4018_502 },
- { "mcp4019-103", MCP4018_103 },
- { "mcp4019-503", MCP4018_503 },
- { "mcp4019-104", MCP4018_104 },
- {}
-};
-MODULE_DEVICE_TABLE(i2c, mcp4018_id);
-
static struct i2c_driver mcp4018_driver = {
.driver = {
.name = "mcp4018",
.of_match_table = of_match_ptr(mcp4018_of_match),
},
- .probe = mcp4018_probe,
+ .probe_new = mcp4018_probe,
.id_table = mcp4018_id,
};
diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c
index 114ab876fcc6..df894af6cccb 100644
--- a/drivers/iio/potentiometer/mcp4531.c
+++ b/drivers/iio/potentiometer/mcp4531.c
@@ -209,6 +209,75 @@ static const struct iio_info mcp4531_info = {
.write_raw = mcp4531_write_raw,
};
+static const struct i2c_device_id mcp4531_id[] = {
+ { "mcp4531-502", MCP453x_502 },
+ { "mcp4531-103", MCP453x_103 },
+ { "mcp4531-503", MCP453x_503 },
+ { "mcp4531-104", MCP453x_104 },
+ { "mcp4532-502", MCP453x_502 },
+ { "mcp4532-103", MCP453x_103 },
+ { "mcp4532-503", MCP453x_503 },
+ { "mcp4532-104", MCP453x_104 },
+ { "mcp4541-502", MCP454x_502 },
+ { "mcp4541-103", MCP454x_103 },
+ { "mcp4541-503", MCP454x_503 },
+ { "mcp4541-104", MCP454x_104 },
+ { "mcp4542-502", MCP454x_502 },
+ { "mcp4542-103", MCP454x_103 },
+ { "mcp4542-503", MCP454x_503 },
+ { "mcp4542-104", MCP454x_104 },
+ { "mcp4551-502", MCP455x_502 },
+ { "mcp4551-103", MCP455x_103 },
+ { "mcp4551-503", MCP455x_503 },
+ { "mcp4551-104", MCP455x_104 },
+ { "mcp4552-502", MCP455x_502 },
+ { "mcp4552-103", MCP455x_103 },
+ { "mcp4552-503", MCP455x_503 },
+ { "mcp4552-104", MCP455x_104 },
+ { "mcp4561-502", MCP456x_502 },
+ { "mcp4561-103", MCP456x_103 },
+ { "mcp4561-503", MCP456x_503 },
+ { "mcp4561-104", MCP456x_104 },
+ { "mcp4562-502", MCP456x_502 },
+ { "mcp4562-103", MCP456x_103 },
+ { "mcp4562-503", MCP456x_503 },
+ { "mcp4562-104", MCP456x_104 },
+ { "mcp4631-502", MCP463x_502 },
+ { "mcp4631-103", MCP463x_103 },
+ { "mcp4631-503", MCP463x_503 },
+ { "mcp4631-104", MCP463x_104 },
+ { "mcp4632-502", MCP463x_502 },
+ { "mcp4632-103", MCP463x_103 },
+ { "mcp4632-503", MCP463x_503 },
+ { "mcp4632-104", MCP463x_104 },
+ { "mcp4641-502", MCP464x_502 },
+ { "mcp4641-103", MCP464x_103 },
+ { "mcp4641-503", MCP464x_503 },
+ { "mcp4641-104", MCP464x_104 },
+ { "mcp4642-502", MCP464x_502 },
+ { "mcp4642-103", MCP464x_103 },
+ { "mcp4642-503", MCP464x_503 },
+ { "mcp4642-104", MCP464x_104 },
+ { "mcp4651-502", MCP465x_502 },
+ { "mcp4651-103", MCP465x_103 },
+ { "mcp4651-503", MCP465x_503 },
+ { "mcp4651-104", MCP465x_104 },
+ { "mcp4652-502", MCP465x_502 },
+ { "mcp4652-103", MCP465x_103 },
+ { "mcp4652-503", MCP465x_503 },
+ { "mcp4652-104", MCP465x_104 },
+ { "mcp4661-502", MCP466x_502 },
+ { "mcp4661-103", MCP466x_103 },
+ { "mcp4661-503", MCP466x_503 },
+ { "mcp4661-104", MCP466x_104 },
+ { "mcp4662-502", MCP466x_502 },
+ { "mcp4662-103", MCP466x_103 },
+ { "mcp4662-503", MCP466x_503 },
+ { "mcp4662-104", MCP466x_104 },
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, mcp4531_id);
+
#ifdef CONFIG_OF
#define MCP4531_COMPATIBLE(of_compatible, cfg) { \
@@ -286,8 +355,7 @@ static const struct of_device_id mcp4531_of_match[] = {
MODULE_DEVICE_TABLE(of, mcp4531_of_match);
#endif
-static int mcp4531_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int mcp4531_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct mcp4531_data *data;
@@ -311,7 +379,7 @@ static int mcp4531_probe(struct i2c_client *client,
if (match)
data->cfg = of_device_get_match_data(dev);
else
- data->cfg = &mcp4531_cfg[id->driver_data];
+ data->cfg = &mcp4531_cfg[i2c_match_id(mcp4531_id, client)->driver_data];
indio_dev->dev.parent = dev;
indio_dev->info = &mcp4531_info;
@@ -322,81 +390,12 @@ static int mcp4531_probe(struct i2c_client *client,
return devm_iio_device_register(dev, indio_dev);
}
-static const struct i2c_device_id mcp4531_id[] = {
- { "mcp4531-502", MCP453x_502 },
- { "mcp4531-103", MCP453x_103 },
- { "mcp4531-503", MCP453x_503 },
- { "mcp4531-104", MCP453x_104 },
- { "mcp4532-502", MCP453x_502 },
- { "mcp4532-103", MCP453x_103 },
- { "mcp4532-503", MCP453x_503 },
- { "mcp4532-104", MCP453x_104 },
- { "mcp4541-502", MCP454x_502 },
- { "mcp4541-103", MCP454x_103 },
- { "mcp4541-503", MCP454x_503 },
- { "mcp4541-104", MCP454x_104 },
- { "mcp4542-502", MCP454x_502 },
- { "mcp4542-103", MCP454x_103 },
- { "mcp4542-503", MCP454x_503 },
- { "mcp4542-104", MCP454x_104 },
- { "mcp4551-502", MCP455x_502 },
- { "mcp4551-103", MCP455x_103 },
- { "mcp4551-503", MCP455x_503 },
- { "mcp4551-104", MCP455x_104 },
- { "mcp4552-502", MCP455x_502 },
- { "mcp4552-103", MCP455x_103 },
- { "mcp4552-503", MCP455x_503 },
- { "mcp4552-104", MCP455x_104 },
- { "mcp4561-502", MCP456x_502 },
- { "mcp4561-103", MCP456x_103 },
- { "mcp4561-503", MCP456x_503 },
- { "mcp4561-104", MCP456x_104 },
- { "mcp4562-502", MCP456x_502 },
- { "mcp4562-103", MCP456x_103 },
- { "mcp4562-503", MCP456x_503 },
- { "mcp4562-104", MCP456x_104 },
- { "mcp4631-502", MCP463x_502 },
- { "mcp4631-103", MCP463x_103 },
- { "mcp4631-503", MCP463x_503 },
- { "mcp4631-104", MCP463x_104 },
- { "mcp4632-502", MCP463x_502 },
- { "mcp4632-103", MCP463x_103 },
- { "mcp4632-503", MCP463x_503 },
- { "mcp4632-104", MCP463x_104 },
- { "mcp4641-502", MCP464x_502 },
- { "mcp4641-103", MCP464x_103 },
- { "mcp4641-503", MCP464x_503 },
- { "mcp4641-104", MCP464x_104 },
- { "mcp4642-502", MCP464x_502 },
- { "mcp4642-103", MCP464x_103 },
- { "mcp4642-503", MCP464x_503 },
- { "mcp4642-104", MCP464x_104 },
- { "mcp4651-502", MCP465x_502 },
- { "mcp4651-103", MCP465x_103 },
- { "mcp4651-503", MCP465x_503 },
- { "mcp4651-104", MCP465x_104 },
- { "mcp4652-502", MCP465x_502 },
- { "mcp4652-103", MCP465x_103 },
- { "mcp4652-503", MCP465x_503 },
- { "mcp4652-104", MCP465x_104 },
- { "mcp4661-502", MCP466x_502 },
- { "mcp4661-103", MCP466x_103 },
- { "mcp4661-503", MCP466x_503 },
- { "mcp4661-104", MCP466x_104 },
- { "mcp4662-502", MCP466x_502 },
- { "mcp4662-103", MCP466x_103 },
- { "mcp4662-503", MCP466x_503 },
- { "mcp4662-104", MCP466x_104 },
- {}
-};
-MODULE_DEVICE_TABLE(i2c, mcp4531_id);
-
static struct i2c_driver mcp4531_driver = {
.driver = {
.name = "mcp4531",
.of_match_table = of_match_ptr(mcp4531_of_match),
},
- .probe = mcp4531_probe,
+ .probe_new = mcp4531_probe,
.id_table = mcp4531_id,
};
diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
index 85714055cc74..90e895adf997 100644
--- a/drivers/iio/potentiostat/lmp91000.c
+++ b/drivers/iio/potentiostat/lmp91000.c
@@ -411,12 +411,14 @@ static int lmp91000_remove(struct i2c_client *client)
static const struct of_device_id lmp91000_of_match[] = {
{ .compatible = "ti,lmp91000", },
+ { .compatible = "ti,lmp91002", },
{ },
};
MODULE_DEVICE_TABLE(of, lmp91000_of_match);
static const struct i2c_device_id lmp91000_id[] = {
{ "lmp91000", 0 },
+ { "lmp91002", 0 },
{}
};
MODULE_DEVICE_TABLE(i2c, lmp91000_id);
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 4599fde4dd25..87c07af9181f 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger.h>
@@ -28,8 +29,6 @@
#include <linux/slab.h>
#include <linux/platform_device.h>
-#include "../common/cros_ec_sensors/cros_ec_sensors_core.h"
-
/*
* One channel for pressure, the other for timestamp.
*/
diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
new file mode 100644
index 000000000000..2ced9f22aa70
--- /dev/null
+++ b/drivers/iio/resolver/Kconfig
@@ -0,0 +1,17 @@
+#
+# Resolver/Synchro drivers
+#
+menu "Resolver to digital converters"
+
+config AD2S1200
+ tristate "Analog Devices ad2s1200/ad2s1205 driver"
+ depends on SPI
+ depends on GPIOLIB || COMPILE_TEST
+ help
+ Say yes here to build support for Analog Devices spi resolver
+ to digital converters, ad2s1200 and ad2s1205, provides direct access
+ via sysfs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad2s1200.
+endmenu
diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile
new file mode 100644
index 000000000000..4e1dccae07e7
--- /dev/null
+++ b/drivers/iio/resolver/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for Resolver/Synchro drivers
+#
+
+obj-$(CONFIG_AD2S1200) += ad2s1200.o
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/iio/resolver/ad2s1200.c
index aa62c64e9bc4..28e618af9939 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/iio/resolver/ad2s1200.c
@@ -2,43 +2,49 @@
* ad2s1200.c simple support for the ADI Resolver to Digital Converters:
* AD2S1200/1205
*
+ * Copyright (c) 2018-2018 David Veenstra <davidjulianveenstra@gmail.com>
* Copyright (c) 2010-2010 Analog Devices Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
- *
*/
-#include <linux/types.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
+
+#include <linux/bitops.h>
#include <linux/delay.h>
+#include <linux/device.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/module.h>
-#include <linux/bitops.h>
+#include <linux/mutex.h>
+#include <linux/spi/spi.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#define DRV_NAME "ad2s1200"
-/* input pin sample and rdvel is controlled by driver */
-#define AD2S1200_PN 2
-
/* input clock on serial interface */
#define AD2S1200_HZ 8192000
/* clock period in nano second */
#define AD2S1200_TSCLK (1000000000 / AD2S1200_HZ)
+/**
+ * struct ad2s1200_state - driver instance specific data.
+ * @lock: protects both the GPIO pins and the rx buffer.
+ * @sdev: spi device.
+ * @sample: GPIO pin SAMPLE.
+ * @rdvel: GPIO pin RDVEL.
+ * @rx: buffer for spi transfers.
+ */
struct ad2s1200_state {
struct mutex lock;
struct spi_device *sdev;
- int sample;
- int rdvel;
- u8 rx[2] ____cacheline_aligned;
+ struct gpio_desc *sample;
+ struct gpio_desc *rdvel;
+ __be16 rx ____cacheline_aligned;
};
static int ad2s1200_read_raw(struct iio_dev *indio_dev,
@@ -47,39 +53,63 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
int *val2,
long m)
{
- int ret = 0;
- s16 vel;
struct ad2s1200_state *st = iio_priv(indio_dev);
+ int ret;
+
+ switch (m) {
+ case IIO_CHAN_INFO_SCALE:
+ switch (chan->type) {
+ case IIO_ANGL:
+ /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */
+ *val = 0;
+ *val2 = 1534355;
+ return IIO_VAL_INT_PLUS_NANO;
+ case IIO_ANGL_VEL:
+ /* 2 * Pi ~= 6.283185 */
+ *val = 6;
+ *val2 = 283185;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+ break;
+ case IIO_CHAN_INFO_RAW:
+ mutex_lock(&st->lock);
+ gpiod_set_value(st->sample, 0);
+
+ /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
+ udelay(1);
+ gpiod_set_value(st->sample, 1);
+ gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+
+ ret = spi_read(st->sdev, &st->rx, 2);
+ if (ret < 0) {
+ mutex_unlock(&st->lock);
+ return ret;
+ }
- mutex_lock(&st->lock);
- gpio_set_value(st->sample, 0);
- /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
- udelay(1);
- gpio_set_value(st->sample, 1);
- gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
- ret = spi_read(st->sdev, st->rx, 2);
- if (ret < 0) {
+ switch (chan->type) {
+ case IIO_ANGL:
+ *val = be16_to_cpup(&st->rx) >> 4;
+ break;
+ case IIO_ANGL_VEL:
+ *val = sign_extend32(be16_to_cpup(&st->rx) >> 4, 11);
+ break;
+ default:
+ mutex_unlock(&st->lock);
+ return -EINVAL;
+ }
+
+ /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
+ udelay(1);
mutex_unlock(&st->lock);
- return ret;
- }
- switch (chan->type) {
- case IIO_ANGL:
- *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
- break;
- case IIO_ANGL_VEL:
- vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
- vel = sign_extend32(vel, 11);
- *val = vel;
- break;
+ return IIO_VAL_INT;
default:
- mutex_unlock(&st->lock);
- return -EINVAL;
+ break;
}
- /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
- udelay(1);
- mutex_unlock(&st->lock);
- return IIO_VAL_INT;
+
+ return -EINVAL;
}
static const struct iio_chan_spec ad2s1200_channels[] = {
@@ -88,11 +118,13 @@ static const struct iio_chan_spec ad2s1200_channels[] = {
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
}, {
.type = IIO_ANGL_VEL,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
}
};
@@ -104,27 +136,30 @@ static int ad2s1200_probe(struct spi_device *spi)
{
struct ad2s1200_state *st;
struct iio_dev *indio_dev;
- int pn, ret = 0;
- unsigned short *pins = spi->dev.platform_data;
-
- for (pn = 0; pn < AD2S1200_PN; pn++) {
- ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT,
- DRV_NAME);
- if (ret) {
- dev_err(&spi->dev, "request gpio pin %d failed\n",
- pins[pn]);
- return ret;
- }
- }
+ int ret;
+
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
+
spi_set_drvdata(spi, indio_dev);
st = iio_priv(indio_dev);
mutex_init(&st->lock);
st->sdev = spi;
- st->sample = pins[0];
- st->rdvel = pins[1];
+
+ st->sample = devm_gpiod_get(&spi->dev, "adi,sample", GPIOD_OUT_LOW);
+ if (IS_ERR(st->sample)) {
+ dev_err(&spi->dev, "Failed to claim SAMPLE gpio: err=%ld\n",
+ PTR_ERR(st->sample));
+ return PTR_ERR(st->sample);
+ }
+
+ st->rdvel = devm_gpiod_get(&spi->dev, "adi,rdvel", GPIOD_OUT_LOW);
+ if (IS_ERR(st->rdvel)) {
+ dev_err(&spi->dev, "Failed to claim RDVEL gpio: err=%ld\n",
+ PTR_ERR(st->rdvel));
+ return PTR_ERR(st->rdvel);
+ }
indio_dev->dev.parent = &spi->dev;
indio_dev->info = &ad2s1200_info;
@@ -133,17 +168,25 @@ static int ad2s1200_probe(struct spi_device *spi)
indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
indio_dev->name = spi_get_device_id(spi)->name;
- ret = devm_iio_device_register(&spi->dev, indio_dev);
- if (ret)
- return ret;
-
spi->max_speed_hz = AD2S1200_HZ;
spi->mode = SPI_MODE_3;
- spi_setup(spi);
+ ret = spi_setup(spi);
- return 0;
+ if (ret < 0) {
+ dev_err(&spi->dev, "spi_setup failed!\n");
+ return ret;
+ }
+
+ return devm_iio_device_register(&spi->dev, indio_dev);
}
+static const struct of_device_id ad2s1200_of_match[] = {
+ { .compatible = "adi,ad2s1200", },
+ { .compatible = "adi,ad2s1205", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad2s1200_of_match);
+
static const struct spi_device_id ad2s1200_id[] = {
{ "ad2s1200" },
{ "ad2s1205" },
@@ -154,12 +197,14 @@ MODULE_DEVICE_TABLE(spi, ad2s1200_id);
static struct spi_driver ad2s1200_driver = {
.driver = {
.name = DRV_NAME,
+ .of_match_table = of_match_ptr(ad2s1200_of_match),
},
.probe = ad2s1200_probe,
.id_table = ad2s1200_id,
};
module_spi_driver(ad2s1200_driver);
+MODULE_AUTHOR("David Veenstra <davidjulianveenstra@gmail.com>");
MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
MODULE_DESCRIPTION("Analog Devices AD2S1200/1205 Resolver to Digital SPI driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 71a50b99caff..17c5587805f5 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -6,7 +6,7 @@ config ASHMEM
bool "Enable the Anonymous Shared Memory Subsystem"
default n
depends on SHMEM
- ---help---
+ help
The ashmem subsystem is a new shared memory allocator, similar to
POSIX SHM but with different behavior and sporting a simpler
file-based API.
@@ -14,6 +14,15 @@ config ASHMEM
It is, in theory, a good memory allocator for low-memory devices,
because it can discard shared memory units when under memory pressure.
+config ANDROID_VSOC
+ tristate "Android Virtual SoC support"
+ default n
+ depends on PCI_MSI
+ help
+ This option adds support for the Virtual SoC driver needed to boot
+ a 'cuttlefish' Android image inside QEmu. The driver interacts with
+ a QEmu ivshmem device. If built as a module, it will be called vsoc.
+
source "drivers/staging/android/ion/Kconfig"
endif # if ANDROID
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 7cf1564a49a5..90e6154f11a4 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -3,3 +3,4 @@ ccflags-y += -I$(src) # needed for trace events
obj-y += ion/
obj-$(CONFIG_ASHMEM) += ashmem.o
+obj-$(CONFIG_ANDROID_VSOC) += vsoc.o
diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO
index 687e0eac85bf..fbf015cc6d62 100644
--- a/drivers/staging/android/TODO
+++ b/drivers/staging/android/TODO
@@ -11,5 +11,14 @@ ion/
- Split /dev/ion up into multiple nodes (e.g. /dev/ion/heap0)
- Better test framework (integration with VGEM was suggested)
+vsoc.c, uapi/vsoc_shm.h
+ - The current driver uses the same wait queue for all of the futexes in a
+ region. This will cause false wakeups in regions with a large number of
+ waiting threads. We should eventually use multiple queues and select the
+ queue based on the region.
+ - Add debugfs support for examining the permissions of regions.
+ - Remove VSOC_WAIT_FOR_INCOMING_INTERRUPT ioctl. This functionality has been
+ superseded by the futex and is there for legacy reasons.
+
Please send patches to Greg Kroah-Hartman <greg@kroah.com> and Cc:
Arve Hjønnevåg <arve@android.com> and Riley Andrews <riandrews@android.com>
diff --git a/drivers/staging/android/ashmem.h b/drivers/staging/android/ashmem.h
index 60d7208f110a..1a478173cd21 100644
--- a/drivers/staging/android/ashmem.h
+++ b/drivers/staging/android/ashmem.h
@@ -1,13 +1,9 @@
-// SPDX-License-Identifier: (GPL-2.0 OR Apache-2.0)
+/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
/*
* include/linux/ashmem.h
*
* Copyright 2008 Google Inc.
* Author: Robert Love
- *
- * This file is dual licensed. It may be redistributed and/or modified
- * under the terms of the Apache 2.0 License OR version 2 of the GNU
- * General Public License.
*/
#ifndef _LINUX_ASHMEM_H
diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 898e9a834ccc..c16dd16afe6a 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -3,7 +3,7 @@ menuconfig ION
depends on HAVE_MEMBLOCK && HAS_DMA && MMU
select GENERIC_ALLOCATOR
select DMA_SHARED_BUFFER
- ---help---
+ help
Choose this option to enable the ION Memory Manager,
used by Android to efficiently allocate buffers
from userspace that can be shared between drivers.
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e74db7902549..9d1109e43ed4 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -74,6 +74,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
buffer->heap = heap;
buffer->flags = flags;
+ buffer->dev = dev;
+ buffer->size = len;
ret = heap->ops->allocate(heap, buffer, len, flags);
@@ -93,11 +95,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
goto err1;
}
- buffer->dev = dev;
- buffer->size = len;
-
- buffer->dev = dev;
- buffer->size = len;
INIT_LIST_HEAD(&buffer->attachments);
mutex_init(&buffer->lock);
mutex_lock(&dev->buffer_lock);
@@ -114,8 +111,11 @@ err2:
void ion_buffer_destroy(struct ion_buffer *buffer)
{
- if (WARN_ON(buffer->kmap_cnt > 0))
+ if (buffer->kmap_cnt > 0) {
+ pr_warn_once("%s: buffer still mapped in the kernel\n",
+ __func__);
buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
+ }
buffer->heap->ops->free(buffer);
kfree(buffer);
}
@@ -318,6 +318,7 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
struct ion_buffer *buffer = dmabuf->priv;
void *vaddr;
struct ion_dma_buf_attachment *a;
+ int ret = 0;
/*
* TODO: Move this elsewhere because we don't always need a vaddr
@@ -325,6 +326,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
if (buffer->heap->ops->map_kernel) {
mutex_lock(&buffer->lock);
vaddr = ion_buffer_kmap_get(buffer);
+ if (IS_ERR(vaddr)) {
+ ret = PTR_ERR(vaddr);
+ goto unlock;
+ }
mutex_unlock(&buffer->lock);
}
@@ -333,9 +338,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
direction);
}
- mutex_unlock(&buffer->lock);
- return 0;
+unlock:
+ mutex_unlock(&buffer->lock);
+ return ret;
}
static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index ea0897812780..16cbd38a7160 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* drivers/staging/android/ion/ion.h
*
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index db8f61446917..9bc56eb48d2a 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -32,6 +32,9 @@ static void ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
list_add_tail(&page->lru, &pool->low_items);
pool->low_count++;
}
+
+ mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+ (1 << (PAGE_SHIFT + pool->order)));
mutex_unlock(&pool->mutex);
}
@@ -50,6 +53,8 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high)
}
list_del(&page->lru);
+ mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+ -(1 << (PAGE_SHIFT + pool->order)));
return page;
}
diff --git a/drivers/staging/android/uapi/ashmem.h b/drivers/staging/android/uapi/ashmem.h
index 5b531af6820e..5442e0019dcd 100644
--- a/drivers/staging/android/uapi/ashmem.h
+++ b/drivers/staging/android/uapi/ashmem.h
@@ -1,13 +1,9 @@
-// SPDX-License-Identifier: (GPL-2.0 OR Apache-2.0)
+/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
/*
* drivers/staging/android/uapi/ashmem.h
*
* Copyright 2008 Google Inc.
* Author: Robert Love
- *
- * This file is dual licensed. It may be redistributed and/or modified
- * under the terms of the Apache 2.0 License OR version 2 of the GNU
- * General Public License.
*/
#ifndef _UAPI_LINUX_ASHMEM_H
diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h
index 825d3e95ccd3..5d7009884c13 100644
--- a/drivers/staging/android/uapi/ion.h
+++ b/drivers/staging/android/uapi/ion.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* drivers/staging/android/uapi/ion.h
*
diff --git a/drivers/staging/android/uapi/vsoc_shm.h b/drivers/staging/android/uapi/vsoc_shm.h
new file mode 100644
index 000000000000..6291fb24efb2
--- /dev/null
+++ b/drivers/staging/android/uapi/vsoc_shm.h
@@ -0,0 +1,295 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2017 Google, Inc.
+ *
+ */
+
+#ifndef _UAPI_LINUX_VSOC_SHM_H
+#define _UAPI_LINUX_VSOC_SHM_H
+
+#include <linux/types.h>
+
+/**
+ * A permission is a token that permits a receiver to read and/or write an area
+ * of memory within a Vsoc region.
+ *
+ * An fd_scoped permission grants both read and write access, and can be
+ * attached to a file description (see open(2)).
+ * Ownership of the area can then be shared by passing a file descriptor
+ * among processes.
+ *
+ * begin_offset and end_offset define the area of memory that is controlled by
+ * the permission. owner_offset points to a word, also in shared memory, that
+ * controls ownership of the area.
+ *
+ * ownership of the region expires when the associated file description is
+ * released.
+ *
+ * At most one permission can be attached to each file description.
+ *
+ * This is useful when implementing HALs like gralloc that scope and pass
+ * ownership of shared resources via file descriptors.
+ *
+ * The caller is responsibe for doing any fencing.
+ *
+ * The calling process will normally identify a currently free area of
+ * memory. It will construct a proposed fd_scoped_permission_arg structure:
+ *
+ * begin_offset and end_offset describe the area being claimed
+ *
+ * owner_offset points to the location in shared memory that indicates the
+ * owner of the area.
+ *
+ * owned_value is the value that will be stored in owner_offset iff the
+ * permission can be granted. It must be different than VSOC_REGION_FREE.
+ *
+ * Two fd_scoped_permission structures are compatible if they vary only by
+ * their owned_value fields.
+ *
+ * The driver ensures that, for any group of simultaneous callers proposing
+ * compatible fd_scoped_permissions, it will accept exactly one of the
+ * propopsals. The other callers will get a failure with errno of EAGAIN.
+ *
+ * A process receiving a file descriptor can identify the region being
+ * granted using the VSOC_GET_FD_SCOPED_PERMISSION ioctl.
+ */
+struct fd_scoped_permission {
+ __u32 begin_offset;
+ __u32 end_offset;
+ __u32 owner_offset;
+ __u32 owned_value;
+};
+
+/*
+ * This value represents a free area of memory. The driver expects to see this
+ * value at owner_offset when creating a permission otherwise it will not do it,
+ * and will write this value back once the permission is no longer needed.
+ */
+#define VSOC_REGION_FREE ((__u32)0)
+
+/**
+ * ioctl argument for VSOC_CREATE_FD_SCOPE_PERMISSION
+ */
+struct fd_scoped_permission_arg {
+ struct fd_scoped_permission perm;
+ __s32 managed_region_fd;
+};
+
+#define VSOC_NODE_FREE ((__u32)0)
+
+/*
+ * Describes a signal table in shared memory. Each non-zero entry in the
+ * table indicates that the receiver should signal the futex at the given
+ * offset. Offsets are relative to the region, not the shared memory window.
+ *
+ * interrupt_signalled_offset is used to reliably signal interrupts across the
+ * vmm boundary. There are two roles: transmitter and receiver. For example,
+ * in the host_to_guest_signal_table the host is the transmitter and the
+ * guest is the receiver. The protocol is as follows:
+ *
+ * 1. The transmitter should convert the offset of the futex to an offset
+ * in the signal table [0, (1 << num_nodes_lg2))
+ * The transmitter can choose any appropriate hashing algorithm, including
+ * hash = futex_offset & ((1 << num_nodes_lg2) - 1)
+ *
+ * 3. The transmitter should atomically compare and swap futex_offset with 0
+ * at hash. There are 3 possible outcomes
+ * a. The swap fails because the futex_offset is already in the table.
+ * The transmitter should stop.
+ * b. Some other offset is in the table. This is a hash collision. The
+ * transmitter should move to another table slot and try again. One
+ * possible algorithm:
+ * hash = (hash + 1) & ((1 << num_nodes_lg2) - 1)
+ * c. The swap worked. Continue below.
+ *
+ * 3. The transmitter atomically swaps 1 with the value at the
+ * interrupt_signalled_offset. There are two outcomes:
+ * a. The prior value was 1. In this case an interrupt has already been
+ * posted. The transmitter is done.
+ * b. The prior value was 0, indicating that the receiver may be sleeping.
+ * The transmitter will issue an interrupt.
+ *
+ * 4. On waking the receiver immediately exchanges a 0 with the
+ * interrupt_signalled_offset. If it receives a 0 then this a spurious
+ * interrupt. That may occasionally happen in the current protocol, but
+ * should be rare.
+ *
+ * 5. The receiver scans the signal table by atomicaly exchanging 0 at each
+ * location. If a non-zero offset is returned from the exchange the
+ * receiver wakes all sleepers at the given offset:
+ * futex((int*)(region_base + old_value), FUTEX_WAKE, MAX_INT);
+ *
+ * 6. The receiver thread then does a conditional wait, waking immediately
+ * if the value at interrupt_signalled_offset is non-zero. This catches cases
+ * here additional signals were posted while the table was being scanned.
+ * On the guest the wait is handled via the VSOC_WAIT_FOR_INCOMING_INTERRUPT
+ * ioctl.
+ */
+struct vsoc_signal_table_layout {
+ /* log_2(Number of signal table entries) */
+ __u32 num_nodes_lg2;
+ /*
+ * Offset to the first signal table entry relative to the start of the
+ * region
+ */
+ __u32 futex_uaddr_table_offset;
+ /*
+ * Offset to an atomic_t / atomic uint32_t. A non-zero value indicates
+ * that one or more offsets are currently posted in the table.
+ * semi-unique access to an entry in the table
+ */
+ __u32 interrupt_signalled_offset;
+};
+
+#define VSOC_REGION_WHOLE ((__s32)0)
+#define VSOC_DEVICE_NAME_SZ 16
+
+/**
+ * Each HAL would (usually) talk to a single device region
+ * Mulitple entities care about these regions:
+ * - The ivshmem_server will populate the regions in shared memory
+ * - The guest kernel will read the region, create minor device nodes, and
+ * allow interested parties to register for FUTEX_WAKE events in the region
+ * - HALs will access via the minor device nodes published by the guest kernel
+ * - Host side processes will access the region via the ivshmem_server:
+ * 1. Pass name to ivshmem_server at a UNIX socket
+ * 2. ivshmemserver will reply with 2 fds:
+ * - host->guest doorbell fd
+ * - guest->host doorbell fd
+ * - fd for the shared memory region
+ * - region offset
+ * 3. Start a futex receiver thread on the doorbell fd pointed at the
+ * signal_nodes
+ */
+struct vsoc_device_region {
+ __u16 current_version;
+ __u16 min_compatible_version;
+ __u32 region_begin_offset;
+ __u32 region_end_offset;
+ __u32 offset_of_region_data;
+ struct vsoc_signal_table_layout guest_to_host_signal_table;
+ struct vsoc_signal_table_layout host_to_guest_signal_table;
+ /* Name of the device. Must always be terminated with a '\0', so
+ * the longest supported device name is 15 characters.
+ */
+ char device_name[VSOC_DEVICE_NAME_SZ];
+ /* There are two ways that permissions to access regions are handled:
+ * - When subdivided_by is VSOC_REGION_WHOLE, any process that can
+ * open the device node for the region gains complete access to it.
+ * - When subdivided is set processes that open the region cannot
+ * access it. Access to a sub-region must be established by invoking
+ * the VSOC_CREATE_FD_SCOPE_PERMISSION ioctl on the region
+ * referenced in subdivided_by, providing a fileinstance
+ * (represented by a fd) opened on this region.
+ */
+ __u32 managed_by;
+};
+
+/*
+ * The vsoc layout descriptor.
+ * The first 4K should be reserved for the shm header and region descriptors.
+ * The regions should be page aligned.
+ */
+
+struct vsoc_shm_layout_descriptor {
+ __u16 major_version;
+ __u16 minor_version;
+
+ /* size of the shm. This may be redundant but nice to have */
+ __u32 size;
+
+ /* number of shared memory regions */
+ __u32 region_count;
+
+ /* The offset to the start of region descriptors */
+ __u32 vsoc_region_desc_offset;
+};
+
+/*
+ * This specifies the current version that should be stored in
+ * vsoc_shm_layout_descriptor.major_version and
+ * vsoc_shm_layout_descriptor.minor_version.
+ * It should be updated only if the vsoc_device_region and
+ * vsoc_shm_layout_descriptor structures have changed.
+ * Versioning within each region is transferred
+ * via the min_compatible_version and current_version fields in
+ * vsoc_device_region. The driver does not consult these fields: they are left
+ * for the HALs and host processes and will change independently of the layout
+ * version.
+ */
+#define CURRENT_VSOC_LAYOUT_MAJOR_VERSION 2
+#define CURRENT_VSOC_LAYOUT_MINOR_VERSION 0
+
+#define VSOC_CREATE_FD_SCOPED_PERMISSION \
+ _IOW(0xF5, 0, struct fd_scoped_permission)
+#define VSOC_GET_FD_SCOPED_PERMISSION _IOR(0xF5, 1, struct fd_scoped_permission)
+
+/*
+ * This is used to signal the host to scan the guest_to_host_signal_table
+ * for new futexes to wake. This sends an interrupt if one is not already
+ * in flight.
+ */
+#define VSOC_MAYBE_SEND_INTERRUPT_TO_HOST _IO(0xF5, 2)
+
+/*
+ * When this returns the guest will scan host_to_guest_signal_table to
+ * check for new futexes to wake.
+ */
+/* TODO(ghartman): Consider moving this to the bottom half */
+#define VSOC_WAIT_FOR_INCOMING_INTERRUPT _IO(0xF5, 3)
+
+/*
+ * Guest HALs will use this to retrieve the region description after
+ * opening their device node.
+ */
+#define VSOC_DESCRIBE_REGION _IOR(0xF5, 4, struct vsoc_device_region)
+
+/*
+ * Wake any threads that may be waiting for a host interrupt on this region.
+ * This is mostly used during shutdown.
+ */
+#define VSOC_SELF_INTERRUPT _IO(0xF5, 5)
+
+/*
+ * This is used to signal the host to scan the guest_to_host_signal_table
+ * for new futexes to wake. This sends an interrupt unconditionally.
+ */
+#define VSOC_SEND_INTERRUPT_TO_HOST _IO(0xF5, 6)
+
+enum wait_types {
+ VSOC_WAIT_UNDEFINED = 0,
+ VSOC_WAIT_IF_EQUAL = 1,
+ VSOC_WAIT_IF_EQUAL_TIMEOUT = 2
+};
+
+/*
+ * Wait for a condition to be true
+ *
+ * Note, this is sized and aligned so the 32 bit and 64 bit layouts are
+ * identical.
+ */
+struct vsoc_cond_wait {
+ /* Input: Offset of the 32 bit word to check */
+ __u32 offset;
+ /* Input: Value that will be compared with the offset */
+ __u32 value;
+ /* Monotonic time to wake at in seconds */
+ __u64 wake_time_sec;
+ /* Input: Monotonic time to wait in nanoseconds */
+ __u32 wake_time_nsec;
+ /* Input: Type of wait */
+ __u32 wait_type;
+ /* Output: Number of times the thread woke before returning. */
+ __u32 wakes;
+ /* Ensure that we're 8-byte aligned and 8 byte length for 32/64 bit
+ * compatibility.
+ */
+ __u32 reserved_1;
+};
+
+#define VSOC_COND_WAIT _IOWR(0xF5, 7, struct vsoc_cond_wait)
+
+/* Wake any local threads waiting at the offset given in arg */
+#define VSOC_COND_WAKE _IO(0xF5, 8)
+
+#endif /* _UAPI_LINUX_VSOC_SHM_H */
diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
new file mode 100644
index 000000000000..806beda1040b
--- /dev/null
+++ b/drivers/staging/android/vsoc.c
@@ -0,0 +1,1152 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * drivers/android/staging/vsoc.c
+ *
+ * Android Virtual System on a Chip (VSoC) driver
+ *
+ * Copyright (C) 2017 Google, Inc.
+ *
+ * Author: ghartman@google.com
+ *
+ * Based on drivers/char/kvm_ivshmem.c - driver for KVM Inter-VM shared memory
+ * Copyright 2009 Cam Macdonell <cam@cs.ualberta.ca>
+ *
+ * Based on cirrusfb.c and 8139cp.c:
+ * Copyright 1999-2001 Jeff Garzik
+ * Copyright 2001-2004 Jeff Garzik
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/freezer.h>
+#include <linux/futex.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/sched.h>
+#include <linux/syscalls.h>
+#include <linux/uaccess.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/cdev.h>
+#include <linux/file.h>
+#include "uapi/vsoc_shm.h"
+
+#define VSOC_DEV_NAME "vsoc"
+
+/*
+ * Description of the ivshmem-doorbell PCI device used by QEmu. These
+ * constants follow docs/specs/ivshmem-spec.txt, which can be found in
+ * the QEmu repository. This was last reconciled with the version that
+ * came out with 2.8
+ */
+
+/*
+ * These constants are determined KVM Inter-VM shared memory device
+ * register offsets
+ */
+enum {
+ INTR_MASK = 0x00, /* Interrupt Mask */
+ INTR_STATUS = 0x04, /* Interrupt Status */
+ IV_POSITION = 0x08, /* VM ID */
+ DOORBELL = 0x0c, /* Doorbell */
+};
+
+static const int REGISTER_BAR; /* Equal to 0 */
+static const int MAX_REGISTER_BAR_LEN = 0x100;
+/*
+ * The MSI-x BAR is not used directly.
+ *
+ * static const int MSI_X_BAR = 1;
+ */
+static const int SHARED_MEMORY_BAR = 2;
+
+struct vsoc_region_data {
+ char name[VSOC_DEVICE_NAME_SZ + 1];
+ wait_queue_head_t interrupt_wait_queue;
+ /* TODO(b/73664181): Use multiple futex wait queues */
+ wait_queue_head_t futex_wait_queue;
+ /* Flag indicating that an interrupt has been signalled by the host. */
+ atomic_t *incoming_signalled;
+ /* Flag indicating the guest has signalled the host. */
+ atomic_t *outgoing_signalled;
+ bool irq_requested;
+ bool device_created;
+};
+
+struct vsoc_device {
+ /* Kernel virtual address of REGISTER_BAR. */
+ void __iomem *regs;
+ /* Physical address of SHARED_MEMORY_BAR. */
+ phys_addr_t shm_phys_start;
+ /* Kernel virtual address of SHARED_MEMORY_BAR. */
+ void __iomem *kernel_mapped_shm;
+ /* Size of the entire shared memory window in bytes. */
+ size_t shm_size;
+ /*
+ * Pointer to the virtual address of the shared memory layout structure.
+ * This is probably identical to kernel_mapped_shm, but saving this
+ * here saves a lot of annoying casts.
+ */
+ struct vsoc_shm_layout_descriptor *layout;
+ /*
+ * Points to a table of region descriptors in the kernel's virtual
+ * address space. Calculated from
+ * vsoc_shm_layout_descriptor.vsoc_region_desc_offset
+ */
+ struct vsoc_device_region *regions;
+ /* Head of a list of permissions that have been granted. */
+ struct list_head permissions;
+ struct pci_dev *dev;
+ /* Per-region (and therefore per-interrupt) information. */
+ struct vsoc_region_data *regions_data;
+ /*
+ * Table of msi-x entries. This has to be separated from struct
+ * vsoc_region_data because the kernel deals with them as an array.
+ */
+ struct msix_entry *msix_entries;
+ /* Mutex that protectes the permission list */
+ struct mutex mtx;
+ /* Major number assigned by the kernel */
+ int major;
+ /* Character device assigned by the kernel */
+ struct cdev cdev;
+ /* Device class assigned by the kernel */
+ struct class *class;
+ /*
+ * Flags that indicate what we've initialized. These are used to do an
+ * orderly cleanup of the device.
+ */
+ bool enabled_device;
+ bool requested_regions;
+ bool cdev_added;
+ bool class_added;
+ bool msix_enabled;
+};
+
+static struct vsoc_device vsoc_dev;
+
+/*
+ * TODO(ghartman): Add a /sys filesystem entry that summarizes the permissions.
+ */
+
+struct fd_scoped_permission_node {
+ struct fd_scoped_permission permission;
+ struct list_head list;
+};
+
+struct vsoc_private_data {
+ struct fd_scoped_permission_node *fd_scoped_permission_node;
+};
+
+static long vsoc_ioctl(struct file *, unsigned int, unsigned long);
+static int vsoc_mmap(struct file *, struct vm_area_struct *);
+static int vsoc_open(struct inode *, struct file *);
+static int vsoc_release(struct inode *, struct file *);
+static ssize_t vsoc_read(struct file *, char __user *, size_t, loff_t *);
+static ssize_t vsoc_write(struct file *, const char __user *, size_t, loff_t *);
+static loff_t vsoc_lseek(struct file *filp, loff_t offset, int origin);
+static int
+do_create_fd_scoped_permission(struct vsoc_device_region *region_p,
+ struct fd_scoped_permission_node *np,
+ struct fd_scoped_permission_arg __user *arg);
+static void
+do_destroy_fd_scoped_permission(struct vsoc_device_region *owner_region_p,
+ struct fd_scoped_permission *perm);
+static long do_vsoc_describe_region(struct file *,
+ struct vsoc_device_region __user *);
+static ssize_t vsoc_get_area(struct file *filp, __u32 *perm_off);
+
+/**
+ * Validate arguments on entry points to the driver.
+ */
+inline int vsoc_validate_inode(struct inode *inode)
+{
+ if (iminor(inode) >= vsoc_dev.layout->region_count) {
+ dev_err(&vsoc_dev.dev->dev,
+ "describe_region: invalid region %d\n", iminor(inode));
+ return -ENODEV;
+ }
+ return 0;
+}
+
+inline int vsoc_validate_filep(struct file *filp)
+{
+ int ret = vsoc_validate_inode(file_inode(filp));
+
+ if (ret)
+ return ret;
+ if (!filp->private_data) {
+ dev_err(&vsoc_dev.dev->dev,
+ "No private data on fd, region %d\n",
+ iminor(file_inode(filp)));
+ return -EBADFD;
+ }
+ return 0;
+}
+
+/* Converts from shared memory offset to virtual address */
+static inline void *shm_off_to_virtual_addr(__u32 offset)
+{
+ return (void __force *)vsoc_dev.kernel_mapped_shm + offset;
+}
+
+/* Converts from shared memory offset to physical address */
+static inline phys_addr_t shm_off_to_phys_addr(__u32 offset)
+{
+ return vsoc_dev.shm_phys_start + offset;
+}
+
+/**
+ * Convenience functions to obtain the region from the inode or file.
+ * Dangerous to call before validating the inode/file.
+ */
+static
+inline struct vsoc_device_region *vsoc_region_from_inode(struct inode *inode)
+{
+ return &vsoc_dev.regions[iminor(inode)];
+}
+
+static
+inline struct vsoc_device_region *vsoc_region_from_filep(struct file *inode)
+{
+ return vsoc_region_from_inode(file_inode(inode));
+}
+
+static inline uint32_t vsoc_device_region_size(struct vsoc_device_region *r)
+{
+ return r->region_end_offset - r->region_begin_offset;
+}
+
+static const struct file_operations vsoc_ops = {
+ .owner = THIS_MODULE,
+ .open = vsoc_open,
+ .mmap = vsoc_mmap,
+ .read = vsoc_read,
+ .unlocked_ioctl = vsoc_ioctl,
+ .compat_ioctl = vsoc_ioctl,
+ .write = vsoc_write,
+ .llseek = vsoc_lseek,
+ .release = vsoc_release,
+};
+
+static struct pci_device_id vsoc_id_table[] = {
+ {0x1af4, 0x1110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {0},
+};
+
+MODULE_DEVICE_TABLE(pci, vsoc_id_table);
+
+static void vsoc_remove_device(struct pci_dev *pdev);
+static int vsoc_probe_device(struct pci_dev *pdev,
+ const struct pci_device_id *ent);
+
+static struct pci_driver vsoc_pci_driver = {
+ .name = "vsoc",
+ .id_table = vsoc_id_table,
+ .probe = vsoc_probe_device,
+ .remove = vsoc_remove_device,
+};
+
+static int
+do_create_fd_scoped_permission(struct vsoc_device_region *region_p,
+ struct fd_scoped_permission_node *np,
+ struct fd_scoped_permission_arg __user *arg)
+{
+ struct file *managed_filp;
+ s32 managed_fd;
+ atomic_t *owner_ptr = NULL;
+ struct vsoc_device_region *managed_region_p;
+
+ if (copy_from_user(&np->permission, &arg->perm, sizeof(*np)) ||
+ copy_from_user(&managed_fd,
+ &arg->managed_region_fd, sizeof(managed_fd))) {
+ return -EFAULT;
+ }
+ managed_filp = fdget(managed_fd).file;
+ /* Check that it's a valid fd, */
+ if (!managed_filp || vsoc_validate_filep(managed_filp))
+ return -EPERM;
+ /* EEXIST if the given fd already has a permission. */
+ if (((struct vsoc_private_data *)managed_filp->private_data)->
+ fd_scoped_permission_node)
+ return -EEXIST;
+ managed_region_p = vsoc_region_from_filep(managed_filp);
+ /* Check that the provided region is managed by this one */
+ if (&vsoc_dev.regions[managed_region_p->managed_by] != region_p)
+ return -EPERM;
+ /* The area must be well formed and have non-zero size */
+ if (np->permission.begin_offset >= np->permission.end_offset)
+ return -EINVAL;
+ /* The area must fit in the memory window */
+ if (np->permission.end_offset >
+ vsoc_device_region_size(managed_region_p))
+ return -ERANGE;
+ /* The area must be in the region data section */
+ if (np->permission.begin_offset <
+ managed_region_p->offset_of_region_data)
+ return -ERANGE;
+ /* The area must be page aligned */
+ if (!PAGE_ALIGNED(np->permission.begin_offset) ||
+ !PAGE_ALIGNED(np->permission.end_offset))
+ return -EINVAL;
+ /* Owner offset must be naturally aligned in the window */
+ if (np->permission.owner_offset &
+ (sizeof(np->permission.owner_offset) - 1))
+ return -EINVAL;
+ /* The owner flag must reside in the owner memory */
+ if (np->permission.owner_offset + sizeof(np->permission.owner_offset) >
+ vsoc_device_region_size(region_p))
+ return -ERANGE;
+ /* The owner flag must reside in the data section */
+ if (np->permission.owner_offset < region_p->offset_of_region_data)
+ return -EINVAL;
+ /* The owner value must change to claim the memory */
+ if (np->permission.owned_value == VSOC_REGION_FREE)
+ return -EINVAL;
+ owner_ptr =
+ (atomic_t *)shm_off_to_virtual_addr(region_p->region_begin_offset +
+ np->permission.owner_offset);
+ /* We've already verified that this is in the shared memory window, so
+ * it should be safe to write to this address.
+ */
+ if (atomic_cmpxchg(owner_ptr,
+ VSOC_REGION_FREE,
+ np->permission.owned_value) != VSOC_REGION_FREE) {
+ return -EBUSY;
+ }
+ ((struct vsoc_private_data *)managed_filp->private_data)->
+ fd_scoped_permission_node = np;
+ /* The file offset needs to be adjusted if the calling
+ * process did any read/write operations on the fd
+ * before creating the permission.
+ */
+ if (managed_filp->f_pos) {
+ if (managed_filp->f_pos > np->permission.end_offset) {
+ /* If the offset is beyond the permission end, set it
+ * to the end.
+ */
+ managed_filp->f_pos = np->permission.end_offset;
+ } else {
+ /* If the offset is within the permission interval
+ * keep it there otherwise reset it to zero.
+ */
+ if (managed_filp->f_pos < np->permission.begin_offset) {
+ managed_filp->f_pos = 0;
+ } else {
+ managed_filp->f_pos -=
+ np->permission.begin_offset;
+ }
+ }
+ }
+ return 0;
+}
+
+static void
+do_destroy_fd_scoped_permission_node(struct vsoc_device_region *owner_region_p,
+ struct fd_scoped_permission_node *node)
+{
+ if (node) {
+ do_destroy_fd_scoped_permission(owner_region_p,
+ &node->permission);
+ mutex_lock(&vsoc_dev.mtx);
+ list_del(&node->list);
+ mutex_unlock(&vsoc_dev.mtx);
+ kfree(node);
+ }
+}
+
+static void
+do_destroy_fd_scoped_permission(struct vsoc_device_region *owner_region_p,
+ struct fd_scoped_permission *perm)
+{
+ atomic_t *owner_ptr = NULL;
+ int prev = 0;
+
+ if (!perm)
+ return;
+ owner_ptr = (atomic_t *)shm_off_to_virtual_addr
+ (owner_region_p->region_begin_offset + perm->owner_offset);
+ prev = atomic_xchg(owner_ptr, VSOC_REGION_FREE);
+ if (prev != perm->owned_value)
+ dev_err(&vsoc_dev.dev->dev,
+ "%x-%x: owner (%s) %x: expected to be %x was %x",
+ perm->begin_offset, perm->end_offset,
+ owner_region_p->device_name, perm->owner_offset,
+ perm->owned_value, prev);
+}
+
+static long do_vsoc_describe_region(struct file *filp,
+ struct vsoc_device_region __user *dest)
+{
+ struct vsoc_device_region *region_p;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ region_p = vsoc_region_from_filep(filp);
+ if (copy_to_user(dest, region_p, sizeof(*region_p)))
+ return -EFAULT;
+ return 0;
+}
+
+/**
+ * Implements the inner logic of cond_wait. Copies to and from userspace are
+ * done in the helper function below.
+ */
+static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg)
+{
+ DEFINE_WAIT(wait);
+ u32 region_number = iminor(file_inode(filp));
+ struct vsoc_region_data *data = vsoc_dev.regions_data + region_number;
+ struct hrtimer_sleeper timeout, *to = NULL;
+ int ret = 0;
+ struct vsoc_device_region *region_p = vsoc_region_from_filep(filp);
+ atomic_t *address = NULL;
+ struct timespec ts;
+
+ /* Ensure that the offset is aligned */
+ if (arg->offset & (sizeof(uint32_t) - 1))
+ return -EADDRNOTAVAIL;
+ /* Ensure that the offset is within shared memory */
+ if (((uint64_t)arg->offset) + region_p->region_begin_offset +
+ sizeof(uint32_t) > region_p->region_end_offset)
+ return -E2BIG;
+ address = shm_off_to_virtual_addr(region_p->region_begin_offset +
+ arg->offset);
+
+ /* Ensure that the type of wait is valid */
+ switch (arg->wait_type) {
+ case VSOC_WAIT_IF_EQUAL:
+ break;
+ case VSOC_WAIT_IF_EQUAL_TIMEOUT:
+ to = &timeout;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (to) {
+ /* Copy the user-supplied timesec into the kernel structure.
+ * We do things this way to flatten differences between 32 bit
+ * and 64 bit timespecs.
+ */
+ ts.tv_sec = arg->wake_time_sec;
+ ts.tv_nsec = arg->wake_time_nsec;
+
+ if (!timespec_valid(&ts))
+ return -EINVAL;
+ hrtimer_init_on_stack(&to->timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS);
+ hrtimer_set_expires_range_ns(&to->timer, timespec_to_ktime(ts),
+ current->timer_slack_ns);
+
+ hrtimer_init_sleeper(to, current);
+ }
+
+ while (1) {
+ prepare_to_wait(&data->futex_wait_queue, &wait,
+ TASK_INTERRUPTIBLE);
+ /*
+ * Check the sentinel value after prepare_to_wait. If the value
+ * changes after this check the writer will call signal,
+ * changing the task state from INTERRUPTIBLE to RUNNING. That
+ * will ensure that schedule() will eventually schedule this
+ * task.
+ */
+ if (atomic_read(address) != arg->value) {
+ ret = 0;
+ break;
+ }
+ if (to) {
+ hrtimer_start_expires(&to->timer, HRTIMER_MODE_ABS);
+ if (likely(to->task))
+ freezable_schedule();
+ hrtimer_cancel(&to->timer);
+ if (!to->task) {
+ ret = -ETIMEDOUT;
+ break;
+ }
+ } else {
+ freezable_schedule();
+ }
+ /* Count the number of times that we woke up. This is useful
+ * for unit testing.
+ */
+ ++arg->wakes;
+ if (signal_pending(current)) {
+ ret = -EINTR;
+ break;
+ }
+ }
+ finish_wait(&data->futex_wait_queue, &wait);
+ if (to)
+ destroy_hrtimer_on_stack(&to->timer);
+ return ret;
+}
+
+/**
+ * Handles the details of copying from/to userspace to ensure that the copies
+ * happen on all of the return paths of cond_wait.
+ */
+static int do_vsoc_cond_wait(struct file *filp,
+ struct vsoc_cond_wait __user *untrusted_in)
+{
+ struct vsoc_cond_wait arg;
+ int rval = 0;
+
+ if (copy_from_user(&arg, untrusted_in, sizeof(arg)))
+ return -EFAULT;
+ /* wakes is an out parameter. Initialize it to something sensible. */
+ arg.wakes = 0;
+ rval = handle_vsoc_cond_wait(filp, &arg);
+ if (copy_to_user(untrusted_in, &arg, sizeof(arg)))
+ return -EFAULT;
+ return rval;
+}
+
+static int do_vsoc_cond_wake(struct file *filp, uint32_t offset)
+{
+ struct vsoc_device_region *region_p = vsoc_region_from_filep(filp);
+ u32 region_number = iminor(file_inode(filp));
+ struct vsoc_region_data *data = vsoc_dev.regions_data + region_number;
+ /* Ensure that the offset is aligned */
+ if (offset & (sizeof(uint32_t) - 1))
+ return -EADDRNOTAVAIL;
+ /* Ensure that the offset is within shared memory */
+ if (((uint64_t)offset) + region_p->region_begin_offset +
+ sizeof(uint32_t) > region_p->region_end_offset)
+ return -E2BIG;
+ /*
+ * TODO(b/73664181): Use multiple futex wait queues.
+ * We need to wake every sleeper when the condition changes. Typically
+ * only a single thread will be waiting on the condition, but there
+ * are exceptions. The worst case is about 10 threads.
+ */
+ wake_up_interruptible_all(&data->futex_wait_queue);
+ return 0;
+}
+
+static long vsoc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ int rv = 0;
+ struct vsoc_device_region *region_p;
+ u32 reg_num;
+ struct vsoc_region_data *reg_data;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ region_p = vsoc_region_from_filep(filp);
+ reg_num = iminor(file_inode(filp));
+ reg_data = vsoc_dev.regions_data + reg_num;
+ switch (cmd) {
+ case VSOC_CREATE_FD_SCOPED_PERMISSION:
+ {
+ struct fd_scoped_permission_node *node = NULL;
+
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
+ /* We can't allocate memory for the permission */
+ if (!node)
+ return -ENOMEM;
+ INIT_LIST_HEAD(&node->list);
+ rv = do_create_fd_scoped_permission
+ (region_p,
+ node,
+ (struct fd_scoped_permission_arg __user *)arg);
+ if (!rv) {
+ mutex_lock(&vsoc_dev.mtx);
+ list_add(&node->list, &vsoc_dev.permissions);
+ mutex_unlock(&vsoc_dev.mtx);
+ } else {
+ kfree(node);
+ return rv;
+ }
+ }
+ break;
+
+ case VSOC_GET_FD_SCOPED_PERMISSION:
+ {
+ struct fd_scoped_permission_node *node =
+ ((struct vsoc_private_data *)filp->private_data)->
+ fd_scoped_permission_node;
+ if (!node)
+ return -ENOENT;
+ if (copy_to_user
+ ((struct fd_scoped_permission __user *)arg,
+ &node->permission, sizeof(node->permission)))
+ return -EFAULT;
+ }
+ break;
+
+ case VSOC_MAYBE_SEND_INTERRUPT_TO_HOST:
+ if (!atomic_xchg(reg_data->outgoing_signalled, 1)) {
+ writel(reg_num, vsoc_dev.regs + DOORBELL);
+ return 0;
+ } else {
+ return -EBUSY;
+ }
+ break;
+
+ case VSOC_SEND_INTERRUPT_TO_HOST:
+ writel(reg_num, vsoc_dev.regs + DOORBELL);
+ return 0;
+ case VSOC_WAIT_FOR_INCOMING_INTERRUPT:
+ wait_event_interruptible
+ (reg_data->interrupt_wait_queue,
+ (atomic_read(reg_data->incoming_signalled) != 0));
+ break;
+
+ case VSOC_DESCRIBE_REGION:
+ return do_vsoc_describe_region
+ (filp,
+ (struct vsoc_device_region __user *)arg);
+
+ case VSOC_SELF_INTERRUPT:
+ atomic_set(reg_data->incoming_signalled, 1);
+ wake_up_interruptible(&reg_data->interrupt_wait_queue);
+ break;
+
+ case VSOC_COND_WAIT:
+ return do_vsoc_cond_wait(filp,
+ (struct vsoc_cond_wait __user *)arg);
+ case VSOC_COND_WAKE:
+ return do_vsoc_cond_wake(filp, arg);
+
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static ssize_t vsoc_read(struct file *filp, char __user *buffer, size_t len,
+ loff_t *poffset)
+{
+ __u32 area_off;
+ const void *area_p;
+ ssize_t area_len;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ area_len = vsoc_get_area(filp, &area_off);
+ area_p = shm_off_to_virtual_addr(area_off);
+ area_p += *poffset;
+ area_len -= *poffset;
+ if (area_len <= 0)
+ return 0;
+ if (area_len < len)
+ len = area_len;
+ if (copy_to_user(buffer, area_p, len))
+ return -EFAULT;
+ *poffset += len;
+ return len;
+}
+
+static loff_t vsoc_lseek(struct file *filp, loff_t offset, int origin)
+{
+ ssize_t area_len = 0;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ area_len = vsoc_get_area(filp, NULL);
+ switch (origin) {
+ case SEEK_SET:
+ break;
+
+ case SEEK_CUR:
+ if (offset > 0 && offset + filp->f_pos < 0)
+ return -EOVERFLOW;
+ offset += filp->f_pos;
+ break;
+
+ case SEEK_END:
+ if (offset > 0 && offset + area_len < 0)
+ return -EOVERFLOW;
+ offset += area_len;
+ break;
+
+ case SEEK_DATA:
+ if (offset >= area_len)
+ return -EINVAL;
+ if (offset < 0)
+ offset = 0;
+ break;
+
+ case SEEK_HOLE:
+ /* Next hole is always the end of the region, unless offset is
+ * beyond that
+ */
+ if (offset < area_len)
+ offset = area_len;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ if (offset < 0 || offset > area_len)
+ return -EINVAL;
+ filp->f_pos = offset;
+
+ return offset;
+}
+
+static ssize_t vsoc_write(struct file *filp, const char __user *buffer,
+ size_t len, loff_t *poffset)
+{
+ __u32 area_off;
+ void *area_p;
+ ssize_t area_len;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ area_len = vsoc_get_area(filp, &area_off);
+ area_p = shm_off_to_virtual_addr(area_off);
+ area_p += *poffset;
+ area_len -= *poffset;
+ if (area_len <= 0)
+ return 0;
+ if (area_len < len)
+ len = area_len;
+ if (copy_from_user(area_p, buffer, len))
+ return -EFAULT;
+ *poffset += len;
+ return len;
+}
+
+static irqreturn_t vsoc_interrupt(int irq, void *region_data_v)
+{
+ struct vsoc_region_data *region_data =
+ (struct vsoc_region_data *)region_data_v;
+ int reg_num = region_data - vsoc_dev.regions_data;
+
+ if (unlikely(!region_data))
+ return IRQ_NONE;
+
+ if (unlikely(reg_num < 0 ||
+ reg_num >= vsoc_dev.layout->region_count)) {
+ dev_err(&vsoc_dev.dev->dev,
+ "invalid irq @%p reg_num=0x%04x\n",
+ region_data, reg_num);
+ return IRQ_NONE;
+ }
+ if (unlikely(vsoc_dev.regions_data + reg_num != region_data)) {
+ dev_err(&vsoc_dev.dev->dev,
+ "irq not aligned @%p reg_num=0x%04x\n",
+ region_data, reg_num);
+ return IRQ_NONE;
+ }
+ wake_up_interruptible(&region_data->interrupt_wait_queue);
+ return IRQ_HANDLED;
+}
+
+static int vsoc_probe_device(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int result;
+ int i;
+ resource_size_t reg_size;
+ dev_t devt;
+
+ vsoc_dev.dev = pdev;
+ result = pci_enable_device(pdev);
+ if (result) {
+ dev_err(&pdev->dev,
+ "pci_enable_device failed %s: error %d\n",
+ pci_name(pdev), result);
+ return result;
+ }
+ vsoc_dev.enabled_device = true;
+ result = pci_request_regions(pdev, "vsoc");
+ if (result < 0) {
+ dev_err(&pdev->dev, "pci_request_regions failed\n");
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+ vsoc_dev.requested_regions = true;
+ /* Set up the control registers in BAR 0 */
+ reg_size = pci_resource_len(pdev, REGISTER_BAR);
+ if (reg_size > MAX_REGISTER_BAR_LEN)
+ vsoc_dev.regs =
+ pci_iomap(pdev, REGISTER_BAR, MAX_REGISTER_BAR_LEN);
+ else
+ vsoc_dev.regs = pci_iomap(pdev, REGISTER_BAR, reg_size);
+
+ if (!vsoc_dev.regs) {
+ dev_err(&pdev->dev,
+ "cannot map registers of size %zu\n",
+ (size_t)reg_size);
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+
+ /* Map the shared memory in BAR 2 */
+ vsoc_dev.shm_phys_start = pci_resource_start(pdev, SHARED_MEMORY_BAR);
+ vsoc_dev.shm_size = pci_resource_len(pdev, SHARED_MEMORY_BAR);
+
+ dev_info(&pdev->dev, "shared memory @ DMA %pa size=0x%zx\n",
+ &vsoc_dev.shm_phys_start, vsoc_dev.shm_size);
+ vsoc_dev.kernel_mapped_shm = pci_iomap_wc(pdev, SHARED_MEMORY_BAR, 0);
+ if (!vsoc_dev.kernel_mapped_shm) {
+ dev_err(&vsoc_dev.dev->dev, "cannot iomap region\n");
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+
+ vsoc_dev.layout = (struct vsoc_shm_layout_descriptor __force *)
+ vsoc_dev.kernel_mapped_shm;
+ dev_info(&pdev->dev, "major_version: %d\n",
+ vsoc_dev.layout->major_version);
+ dev_info(&pdev->dev, "minor_version: %d\n",
+ vsoc_dev.layout->minor_version);
+ dev_info(&pdev->dev, "size: 0x%x\n", vsoc_dev.layout->size);
+ dev_info(&pdev->dev, "regions: %d\n", vsoc_dev.layout->region_count);
+ if (vsoc_dev.layout->major_version !=
+ CURRENT_VSOC_LAYOUT_MAJOR_VERSION) {
+ dev_err(&vsoc_dev.dev->dev,
+ "driver supports only major_version %d\n",
+ CURRENT_VSOC_LAYOUT_MAJOR_VERSION);
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+ result = alloc_chrdev_region(&devt, 0, vsoc_dev.layout->region_count,
+ VSOC_DEV_NAME);
+ if (result) {
+ dev_err(&vsoc_dev.dev->dev, "alloc_chrdev_region failed\n");
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+ vsoc_dev.major = MAJOR(devt);
+ cdev_init(&vsoc_dev.cdev, &vsoc_ops);
+ vsoc_dev.cdev.owner = THIS_MODULE;
+ result = cdev_add(&vsoc_dev.cdev, devt, vsoc_dev.layout->region_count);
+ if (result) {
+ dev_err(&vsoc_dev.dev->dev, "cdev_add error\n");
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+ vsoc_dev.cdev_added = true;
+ vsoc_dev.class = class_create(THIS_MODULE, VSOC_DEV_NAME);
+ if (IS_ERR(vsoc_dev.class)) {
+ dev_err(&vsoc_dev.dev->dev, "class_create failed\n");
+ vsoc_remove_device(pdev);
+ return PTR_ERR(vsoc_dev.class);
+ }
+ vsoc_dev.class_added = true;
+ vsoc_dev.regions = (struct vsoc_device_region __force *)
+ ((void *)vsoc_dev.layout +
+ vsoc_dev.layout->vsoc_region_desc_offset);
+ vsoc_dev.msix_entries =
+ kcalloc(vsoc_dev.layout->region_count,
+ sizeof(vsoc_dev.msix_entries[0]), GFP_KERNEL);
+ if (!vsoc_dev.msix_entries) {
+ dev_err(&vsoc_dev.dev->dev,
+ "unable to allocate msix_entries\n");
+ vsoc_remove_device(pdev);
+ return -ENOSPC;
+ }
+ vsoc_dev.regions_data =
+ kcalloc(vsoc_dev.layout->region_count,
+ sizeof(vsoc_dev.regions_data[0]), GFP_KERNEL);
+ if (!vsoc_dev.regions_data) {
+ dev_err(&vsoc_dev.dev->dev,
+ "unable to allocate regions' data\n");
+ vsoc_remove_device(pdev);
+ return -ENOSPC;
+ }
+ for (i = 0; i < vsoc_dev.layout->region_count; ++i)
+ vsoc_dev.msix_entries[i].entry = i;
+
+ result = pci_enable_msix_exact(vsoc_dev.dev, vsoc_dev.msix_entries,
+ vsoc_dev.layout->region_count);
+ if (result) {
+ dev_info(&pdev->dev, "pci_enable_msix failed: %d\n", result);
+ vsoc_remove_device(pdev);
+ return -ENOSPC;
+ }
+ /* Check that all regions are well formed */
+ for (i = 0; i < vsoc_dev.layout->region_count; ++i) {
+ const struct vsoc_device_region *region = vsoc_dev.regions + i;
+
+ if (!PAGE_ALIGNED(region->region_begin_offset) ||
+ !PAGE_ALIGNED(region->region_end_offset)) {
+ dev_err(&vsoc_dev.dev->dev,
+ "region %d not aligned (%x:%x)", i,
+ region->region_begin_offset,
+ region->region_end_offset);
+ vsoc_remove_device(pdev);
+ return -EFAULT;
+ }
+ if (region->region_begin_offset >= region->region_end_offset ||
+ region->region_end_offset > vsoc_dev.shm_size) {
+ dev_err(&vsoc_dev.dev->dev,
+ "region %d offsets are wrong: %x %x %zx",
+ i, region->region_begin_offset,
+ region->region_end_offset, vsoc_dev.shm_size);
+ vsoc_remove_device(pdev);
+ return -EFAULT;
+ }
+ if (region->managed_by >= vsoc_dev.layout->region_count) {
+ dev_err(&vsoc_dev.dev->dev,
+ "region %d has invalid owner: %u",
+ i, region->managed_by);
+ vsoc_remove_device(pdev);
+ return -EFAULT;
+ }
+ }
+ vsoc_dev.msix_enabled = true;
+ for (i = 0; i < vsoc_dev.layout->region_count; ++i) {
+ const struct vsoc_device_region *region = vsoc_dev.regions + i;
+ size_t name_sz = sizeof(vsoc_dev.regions_data[i].name) - 1;
+ const struct vsoc_signal_table_layout *h_to_g_signal_table =
+ &region->host_to_guest_signal_table;
+ const struct vsoc_signal_table_layout *g_to_h_signal_table =
+ &region->guest_to_host_signal_table;
+
+ vsoc_dev.regions_data[i].name[name_sz] = '\0';
+ memcpy(vsoc_dev.regions_data[i].name, region->device_name,
+ name_sz);
+ dev_info(&pdev->dev, "region %d name=%s\n",
+ i, vsoc_dev.regions_data[i].name);
+ init_waitqueue_head
+ (&vsoc_dev.regions_data[i].interrupt_wait_queue);
+ init_waitqueue_head(&vsoc_dev.regions_data[i].futex_wait_queue);
+ vsoc_dev.regions_data[i].incoming_signalled =
+ shm_off_to_virtual_addr(region->region_begin_offset) +
+ h_to_g_signal_table->interrupt_signalled_offset;
+ vsoc_dev.regions_data[i].outgoing_signalled =
+ shm_off_to_virtual_addr(region->region_begin_offset) +
+ g_to_h_signal_table->interrupt_signalled_offset;
+ result = request_irq(vsoc_dev.msix_entries[i].vector,
+ vsoc_interrupt, 0,
+ vsoc_dev.regions_data[i].name,
+ vsoc_dev.regions_data + i);
+ if (result) {
+ dev_info(&pdev->dev,
+ "request_irq failed irq=%d vector=%d\n",
+ i, vsoc_dev.msix_entries[i].vector);
+ vsoc_remove_device(pdev);
+ return -ENOSPC;
+ }
+ vsoc_dev.regions_data[i].irq_requested = true;
+ if (!device_create(vsoc_dev.class, NULL,
+ MKDEV(vsoc_dev.major, i),
+ NULL, vsoc_dev.regions_data[i].name)) {
+ dev_err(&vsoc_dev.dev->dev, "device_create failed\n");
+ vsoc_remove_device(pdev);
+ return -EBUSY;
+ }
+ vsoc_dev.regions_data[i].device_created = true;
+ }
+ return 0;
+}
+
+/*
+ * This should undo all of the allocations in the probe function in reverse
+ * order.
+ *
+ * Notes:
+ *
+ * The device may have been partially initialized, so double check
+ * that the allocations happened.
+ *
+ * This function may be called multiple times, so mark resources as freed
+ * as they are deallocated.
+ */
+static void vsoc_remove_device(struct pci_dev *pdev)
+{
+ int i;
+ /*
+ * pdev is the first thing to be set on probe and the last thing
+ * to be cleared here. If it's NULL then there is no cleanup.
+ */
+ if (!pdev || !vsoc_dev.dev)
+ return;
+ dev_info(&pdev->dev, "remove_device\n");
+ if (vsoc_dev.regions_data) {
+ for (i = 0; i < vsoc_dev.layout->region_count; ++i) {
+ if (vsoc_dev.regions_data[i].device_created) {
+ device_destroy(vsoc_dev.class,
+ MKDEV(vsoc_dev.major, i));
+ vsoc_dev.regions_data[i].device_created = false;
+ }
+ if (vsoc_dev.regions_data[i].irq_requested)
+ free_irq(vsoc_dev.msix_entries[i].vector, NULL);
+ vsoc_dev.regions_data[i].irq_requested = false;
+ }
+ kfree(vsoc_dev.regions_data);
+ vsoc_dev.regions_data = NULL;
+ }
+ if (vsoc_dev.msix_enabled) {
+ pci_disable_msix(pdev);
+ vsoc_dev.msix_enabled = false;
+ }
+ kfree(vsoc_dev.msix_entries);
+ vsoc_dev.msix_entries = NULL;
+ vsoc_dev.regions = NULL;
+ if (vsoc_dev.class_added) {
+ class_destroy(vsoc_dev.class);
+ vsoc_dev.class_added = false;
+ }
+ if (vsoc_dev.cdev_added) {
+ cdev_del(&vsoc_dev.cdev);
+ vsoc_dev.cdev_added = false;
+ }
+ if (vsoc_dev.major && vsoc_dev.layout) {
+ unregister_chrdev_region(MKDEV(vsoc_dev.major, 0),
+ vsoc_dev.layout->region_count);
+ vsoc_dev.major = 0;
+ }
+ vsoc_dev.layout = NULL;
+ if (vsoc_dev.kernel_mapped_shm) {
+ pci_iounmap(pdev, vsoc_dev.kernel_mapped_shm);
+ vsoc_dev.kernel_mapped_shm = NULL;
+ }
+ if (vsoc_dev.regs) {
+ pci_iounmap(pdev, vsoc_dev.regs);
+ vsoc_dev.regs = NULL;
+ }
+ if (vsoc_dev.requested_regions) {
+ pci_release_regions(pdev);
+ vsoc_dev.requested_regions = false;
+ }
+ if (vsoc_dev.enabled_device) {
+ pci_disable_device(pdev);
+ vsoc_dev.enabled_device = false;
+ }
+ /* Do this last: it indicates that the device is not initialized. */
+ vsoc_dev.dev = NULL;
+}
+
+static void __exit vsoc_cleanup_module(void)
+{
+ vsoc_remove_device(vsoc_dev.dev);
+ pci_unregister_driver(&vsoc_pci_driver);
+}
+
+static int __init vsoc_init_module(void)
+{
+ int err = -ENOMEM;
+
+ INIT_LIST_HEAD(&vsoc_dev.permissions);
+ mutex_init(&vsoc_dev.mtx);
+
+ err = pci_register_driver(&vsoc_pci_driver);
+ if (err < 0)
+ return err;
+ return 0;
+}
+
+static int vsoc_open(struct inode *inode, struct file *filp)
+{
+ /* Can't use vsoc_validate_filep because filp is still incomplete */
+ int ret = vsoc_validate_inode(inode);
+
+ if (ret)
+ return ret;
+ filp->private_data =
+ kzalloc(sizeof(struct vsoc_private_data), GFP_KERNEL);
+ if (!filp->private_data)
+ return -ENOMEM;
+ return 0;
+}
+
+static int vsoc_release(struct inode *inode, struct file *filp)
+{
+ struct vsoc_private_data *private_data = NULL;
+ struct fd_scoped_permission_node *node = NULL;
+ struct vsoc_device_region *owner_region_p = NULL;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ private_data = (struct vsoc_private_data *)filp->private_data;
+ if (!private_data)
+ return 0;
+
+ node = private_data->fd_scoped_permission_node;
+ if (node) {
+ owner_region_p = vsoc_region_from_inode(inode);
+ if (owner_region_p->managed_by != VSOC_REGION_WHOLE) {
+ owner_region_p =
+ &vsoc_dev.regions[owner_region_p->managed_by];
+ }
+ do_destroy_fd_scoped_permission_node(owner_region_p, node);
+ private_data->fd_scoped_permission_node = NULL;
+ }
+ kfree(private_data);
+ filp->private_data = NULL;
+
+ return 0;
+}
+
+/*
+ * Returns the device relative offset and length of the area specified by the
+ * fd scoped permission. If there is no fd scoped permission set, a default
+ * permission covering the entire region is assumed, unless the region is owned
+ * by another one, in which case the default is a permission with zero size.
+ */
+static ssize_t vsoc_get_area(struct file *filp, __u32 *area_offset)
+{
+ __u32 off = 0;
+ ssize_t length = 0;
+ struct vsoc_device_region *region_p;
+ struct fd_scoped_permission *perm;
+
+ region_p = vsoc_region_from_filep(filp);
+ off = region_p->region_begin_offset;
+ perm = &((struct vsoc_private_data *)filp->private_data)->
+ fd_scoped_permission_node->permission;
+ if (perm) {
+ off += perm->begin_offset;
+ length = perm->end_offset - perm->begin_offset;
+ } else if (region_p->managed_by == VSOC_REGION_WHOLE) {
+ /* No permission set and the regions is not owned by another,
+ * default to full region access.
+ */
+ length = vsoc_device_region_size(region_p);
+ } else {
+ /* return zero length, access is denied. */
+ length = 0;
+ }
+ if (area_offset)
+ *area_offset = off;
+ return length;
+}
+
+static int vsoc_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+ unsigned long len = vma->vm_end - vma->vm_start;
+ __u32 area_off;
+ phys_addr_t mem_off;
+ ssize_t area_len;
+ int retval = vsoc_validate_filep(filp);
+
+ if (retval)
+ return retval;
+ area_len = vsoc_get_area(filp, &area_off);
+ /* Add the requested offset */
+ area_off += (vma->vm_pgoff << PAGE_SHIFT);
+ area_len -= (vma->vm_pgoff << PAGE_SHIFT);
+ if (area_len < len)
+ return -EINVAL;
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ mem_off = shm_off_to_phys_addr(area_off);
+ if (io_remap_pfn_range(vma, vma->vm_start, mem_off >> PAGE_SHIFT,
+ len, vma->vm_page_prot))
+ return -EAGAIN;
+ return 0;
+}
+
+module_init(vsoc_init_module);
+module_exit(vsoc_cleanup_module);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Greg Hartman <ghartman@google.com>");
+MODULE_DESCRIPTION("VSoC interpretation of QEmu's ivshmem device");
+MODULE_VERSION("1.0");
diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
index 4de4fd06eebc..962cc0c79988 100644
--- a/drivers/staging/board/armadillo800eva.c
+++ b/drivers/staging/board/armadillo800eva.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Staging board support for Armadillo 800 eva.
* Enable not-yet-DT-capable devices here.
@@ -6,15 +7,6 @@
*
* Copyright (C) 2012 Renesas Solutions Corp.
* Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*/
#include <linux/dma-mapping.h>
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 86dc41101610..cb6feb34dd40 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -1,10 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2014 Magnus Damm
* Copyright (C) 2015 Glider bvba
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
*/
#define pr_fmt(fmt) "board_staging: " fmt
diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 97fb9388bc22..fa9d239474ee 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -34,7 +34,7 @@
struct comedi32_chaninfo_struct {
unsigned int subdev;
compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */
- compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
+ compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
compat_uptr_t rangelist; /* 32-bit 'unsigned int *' */
unsigned int unused[4];
};
@@ -57,16 +57,16 @@ struct comedi32_cmd_struct {
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
- compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
+ compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
unsigned int chanlist_len;
- compat_uptr_t data; /* 32-bit 'short *' */
+ compat_uptr_t data; /* 32-bit 'short *' */
unsigned int data_len;
};
struct comedi32_insn_struct {
unsigned int insn;
unsigned int n;
- compat_uptr_t data; /* 32-bit 'unsigned int *' */
+ compat_uptr_t data; /* 32-bit 'unsigned int *' */
unsigned int subdev;
unsigned int chanspec;
unsigned int unused[3];
@@ -74,7 +74,7 @@ struct comedi32_insn_struct {
struct comedi32_insnlist_struct {
unsigned int n_insns;
- compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
+ compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
};
/* Handle translated ioctl. */
@@ -194,7 +194,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
err |= __put_user(temp.uint, &cmd->stop_arg);
err |= __get_user(temp.uptr, &cmd32->chanlist);
err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr),
- &cmd->chanlist);
+ &cmd->chanlist);
err |= __get_user(temp.uint, &cmd32->chanlist_len);
err |= __put_user(temp.uint, &cmd->chanlist_len);
err |= __get_user(temp.uptr, &cmd32->data);
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index f3474a4ba69e..c54ac94d89d2 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
* comedidev.h
* header file for kernel-only structures, variables, and constants
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index fdd81c3beb51..631a703b345d 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -2268,14 +2268,14 @@ static inline unsigned int dma_transfer_size(struct comedi_device *dev)
}
static u32 ai_convert_counter_6xxx(const struct comedi_device *dev,
- const struct comedi_cmd *cmd)
+ const struct comedi_cmd *cmd)
{
/* supposed to load counter with desired divisor minus 3 */
return cmd->convert_arg / TIMER_BASE - 3;
}
static u32 ai_scan_counter_6xxx(struct comedi_device *dev,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
u32 count;
@@ -2296,7 +2296,7 @@ static u32 ai_scan_counter_6xxx(struct comedi_device *dev,
}
static u32 ai_convert_counter_4020(struct comedi_device *dev,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
struct pcidas64_private *devpriv = dev->private;
unsigned int divisor;
diff --git a/drivers/staging/emxx_udc/Kconfig b/drivers/staging/emxx_udc/Kconfig
index d7577096fb25..e50e72218364 100644
--- a/drivers/staging/emxx_udc/Kconfig
+++ b/drivers/staging/emxx_udc/Kconfig
@@ -1,6 +1,6 @@
config USB_EMXX
tristate "EMXX USB Function Device Controller"
- depends on USB_GADGET && (ARCH_SHMOBILE || (ARM && COMPILE_TEST))
+ depends on USB_GADGET && (ARCH_RENESAS || (ARM && COMPILE_TEST))
help
The Emma Mobile series of SoCs from Renesas Electronics and
former NEC Electronics include USB Function hardware.
diff --git a/drivers/staging/emxx_udc/TODO b/drivers/staging/emxx_udc/TODO
index 1319379beb7e..471529a470c7 100644
--- a/drivers/staging/emxx_udc/TODO
+++ b/drivers/staging/emxx_udc/TODO
@@ -1,4 +1,6 @@
* add clock framework support (platform device with CCF needs special care)
* break out board-specific VBUS GPIO to work with multiplatform
+* convert VBUS GPIO to use GPIO descriptors from <linux/gpio/consumer.h>
+ and stop using the old GPIO API
* DT bindings
* move driver into drivers/usb/gadget/
diff --git a/drivers/staging/fbtft/TODO b/drivers/staging/fbtft/TODO
new file mode 100644
index 000000000000..7e64c7e438f0
--- /dev/null
+++ b/drivers/staging/fbtft/TODO
@@ -0,0 +1,4 @@
+* convert all uses of the old GPIO API from <linux/gpio.h> to the
+ GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
+ lines from device tree, ACPI or board files, board files should
+ use <linux/gpio/machine.h>
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index a263bce260c9..871b307d83cb 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -22,10 +22,13 @@ void func(struct fbtft_par *par, int len, ...) \
if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) { \
va_start(args, len); \
for (i = 0; i < len; i++) { \
- buf[i] = modifier((data_type)va_arg(args, unsigned int)); \
+ buf[i] = modifier((data_type)va_arg(args, \
+ unsigned int)); \
} \
va_end(args); \
- fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, par->info->device, buffer_type, buf, len, "%s: ", __func__); \
+ fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, \
+ par->info->device, buffer_type, buf, len, \
+ "%s: ", __func__); \
} \
\
va_start(args, len); \
@@ -37,7 +40,8 @@ void func(struct fbtft_par *par, int len, ...) \
} \
\
*buf = modifier((data_type)va_arg(args, unsigned int)); \
- ret = fbtft_write_buf_dc(par, par->buf, sizeof(data_type) + offset, 0); \
+ ret = fbtft_write_buf_dc(par, par->buf, sizeof(data_type) + offset, \
+ 0); \
if (ret < 0) \
goto out; \
len--; \
@@ -48,7 +52,8 @@ void func(struct fbtft_par *par, int len, ...) \
if (len) { \
i = len; \
while (i--) \
- *buf++ = modifier((data_type)va_arg(args, unsigned int)); \
+ *buf++ = modifier((data_type)va_arg(args, \
+ unsigned int)); \
fbtft_write_buf_dc(par, par->buf, \
len * (sizeof(data_type) + offset), 1); \
} \
diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-dpaa2/Kconfig
index bbb7af551696..a4c4b83ddc9c 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -24,3 +24,11 @@ config FSL_DPAA2_ETHSW
---help---
Driver for Freescale DPAA2 Ethernet Switch. Select
BRIDGE to have support for bridge tools.
+
+config FSL_DPAA2_PTP_CLOCK
+ tristate "Freescale DPAA2 PTP Clock"
+ depends on FSL_DPAA2_ETH && POSIX_TIMERS
+ select PTP_1588_CLOCK
+ help
+ This driver adds support for using the DPAA2 1588 timer module
+ as a PTP clock.
diff --git a/drivers/staging/fsl-dpaa2/Makefile b/drivers/staging/fsl-dpaa2/Makefile
index 6cfd76b29970..9c7062945758 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -2,5 +2,6 @@
# Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers
#
-obj-$(CONFIG_FSL_DPAA2_ETH) += ethernet/
-obj-$(CONFIG_FSL_DPAA2_ETHSW) += ethsw/
+obj-$(CONFIG_FSL_DPAA2_ETH) += ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += ethsw/
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += rtc/
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 553678d8b2eb..396371728aa1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -38,8 +38,11 @@
#include <linux/msi.h>
#include <linux/kthread.h>
#include <linux/iommu.h>
-
+#include <linux/net_tstamp.h>
#include <linux/fsl/mc.h>
+
+#include <net/sock.h>
+
#include "dpaa2-eth.h"
/* CREATE_TRACE_POINTS only needs to be defined once. Other dpa files
@@ -275,6 +278,18 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
prefetch(skb->data);
+ /* Get the timestamp value */
+ if (priv->rx_tstamp) {
+ struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
+ __le64 *ts = dpaa2_get_ts(vaddr, false);
+ u64 ns;
+
+ memset(shhwtstamps, 0, sizeof(*shhwtstamps));
+
+ ns = DPAA2_PTP_CLK_PERIOD_NS * le64_to_cpup(ts);
+ shhwtstamps->hwtstamp = ns_to_ktime(ns);
+ }
+
/* Check if we need to validate the L4 csum */
if (likely(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV)) {
status = le32_to_cpu(fas->status);
@@ -334,6 +349,28 @@ static int consume_frames(struct dpaa2_eth_channel *ch)
return cleaned;
}
+/* Configure the egress frame annotation for timestamp update */
+static void enable_tx_tstamp(struct dpaa2_fd *fd, void *buf_start)
+{
+ struct dpaa2_faead *faead;
+ u32 ctrl, frc;
+
+ /* Mark the egress frame annotation area as valid */
+ frc = dpaa2_fd_get_frc(fd);
+ dpaa2_fd_set_frc(fd, frc | DPAA2_FD_FRC_FAEADV);
+
+ /* Set hardware annotation size */
+ ctrl = dpaa2_fd_get_ctrl(fd);
+ dpaa2_fd_set_ctrl(fd, ctrl | DPAA2_FD_CTRL_ASAL);
+
+ /* enable UPD (update prepanded data) bit in FAEAD field of
+ * hardware frame annotation area
+ */
+ ctrl = DPAA2_FAEAD_A2V | DPAA2_FAEAD_UPDV | DPAA2_FAEAD_UPD;
+ faead = dpaa2_get_faead(buf_start, true);
+ faead->ctrl = cpu_to_le32(ctrl);
+}
+
/* Create a frame descriptor based on a fragmented skb */
static int build_sg_fd(struct dpaa2_eth_priv *priv,
struct sk_buff *skb,
@@ -420,6 +457,9 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
+ if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
+ enable_tx_tstamp(fd, sgt_buf);
+
return 0;
dma_map_single_failed:
@@ -470,6 +510,9 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_format(fd, dpaa2_fd_single);
dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
+ if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
+ enable_tx_tstamp(fd, buffer_start);
+
return 0;
}
@@ -520,6 +563,19 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
return;
}
+ /* Get the timestamp value */
+ if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
+ struct skb_shared_hwtstamps shhwtstamps;
+ __le64 *ts = dpaa2_get_ts(skbh, true);
+ u64 ns;
+
+ memset(&shhwtstamps, 0, sizeof(shhwtstamps));
+
+ ns = DPAA2_PTP_CLK_PERIOD_NS * le64_to_cpup(ts);
+ shhwtstamps.hwtstamp = ns_to_ktime(ns);
+ skb_tstamp_tx(skb, &shhwtstamps);
+ }
+
/* Free SGT buffer allocated on tx */
if (fd_format != dpaa2_fd_single)
skb_free_frag(skbh);
@@ -552,6 +608,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
goto err_alloc_headroom;
}
percpu_extras->tx_reallocs++;
+
+ if (skb->sk)
+ skb_set_owner_w(ns, skb->sk);
+
dev_kfree_skb(skb);
skb = ns;
}
@@ -1365,6 +1425,45 @@ static int dpaa2_eth_set_features(struct net_device *net_dev,
return 0;
}
+static int dpaa2_eth_ts_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ struct dpaa2_eth_priv *priv = netdev_priv(dev);
+ struct hwtstamp_config config;
+
+ if (copy_from_user(&config, rq->ifr_data, sizeof(config)))
+ return -EFAULT;
+
+ switch (config.tx_type) {
+ case HWTSTAMP_TX_OFF:
+ priv->tx_tstamp = false;
+ break;
+ case HWTSTAMP_TX_ON:
+ priv->tx_tstamp = true;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ if (config.rx_filter == HWTSTAMP_FILTER_NONE) {
+ priv->rx_tstamp = false;
+ } else {
+ priv->rx_tstamp = true;
+ /* TS is set for all frame types, not only those requested */
+ config.rx_filter = HWTSTAMP_FILTER_ALL;
+ }
+
+ return copy_to_user(rq->ifr_data, &config, sizeof(config)) ?
+ -EFAULT : 0;
+}
+
+static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ if (cmd == SIOCSHWTSTAMP)
+ return dpaa2_eth_ts_ioctl(dev, rq, cmd);
+
+ return -EINVAL;
+}
+
static const struct net_device_ops dpaa2_eth_ops = {
.ndo_open = dpaa2_eth_open,
.ndo_start_xmit = dpaa2_eth_tx,
@@ -1375,6 +1474,7 @@ static const struct net_device_ops dpaa2_eth_ops = {
.ndo_change_mtu = dpaa2_eth_change_mtu,
.ndo_set_rx_mode = dpaa2_eth_set_rx_mode,
.ndo_set_features = dpaa2_eth_set_features,
+ .ndo_do_ioctl = dpaa2_eth_ioctl,
};
static void cdan_cb(struct dpaa2_io_notification_ctx *ctx)
@@ -1770,7 +1870,9 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
/* tx buffer */
buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
- buf_layout.options = DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
+ buf_layout.pass_timestamp = true;
+ buf_layout.options = DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
+ DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
DPNI_QUEUE_TX, &buf_layout);
if (err) {
@@ -1779,7 +1881,7 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
}
/* tx-confirm buffer */
- buf_layout.options = 0;
+ buf_layout.options = DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
DPNI_QUEUE_TX_CONFIRM, &buf_layout);
if (err) {
@@ -1810,7 +1912,8 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
- DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM;
+ DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM |
+ DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
DPNI_QUEUE_RX, &buf_layout);
if (err) {
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 54cea2fc6e58..905a4e6be8fa 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -88,8 +88,12 @@
#define DPAA2_ETH_SKB_SIZE \
(DPAA2_ETH_RX_BUF_SIZE + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
-/* Hardware annotation area in RX buffers */
+/* Hardware annotation area in RX/TX buffers */
#define DPAA2_ETH_RX_HWA_SIZE 64
+#define DPAA2_ETH_TX_HWA_SIZE 128
+
+/* PTP nominal frequency 1GHz */
+#define DPAA2_PTP_CLK_PERIOD_NS 1
/* Due to a limitation in WRIOP 1.0.0, the RX buffer data must be aligned
* to 256B. For newer revisions, the requirement is only for 64B alignment
@@ -135,6 +139,7 @@ struct dpaa2_eth_swa {
/* Annotation bits in FD CTRL */
#define DPAA2_FD_CTRL_PTA 0x00800000
#define DPAA2_FD_CTRL_PTV1 0x00400000
+#define DPAA2_FD_CTRL_ASAL 0x00020000 /* ASAL = 128B */
/* Frame annotation status */
struct dpaa2_fas {
@@ -150,6 +155,23 @@ struct dpaa2_fas {
#define DPAA2_FAS_OFFSET 0
#define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas))
+/* Timestamp is located in the next 8 bytes of the buffer's
+ * hardware annotation area
+ */
+#define DPAA2_TS_OFFSET 0x8
+
+/* Frame annotation egress action descriptor */
+#define DPAA2_FAEAD_OFFSET 0x58
+
+struct dpaa2_faead {
+ __le32 conf_fqid;
+ __le32 ctrl;
+};
+
+#define DPAA2_FAEAD_A2V 0x20000000
+#define DPAA2_FAEAD_UPDV 0x00001000
+#define DPAA2_FAEAD_UPD 0x00000010
+
/* Accessors for the hardware annotation fields that we use */
static inline void *dpaa2_get_hwa(void *buf_addr, bool swa)
{
@@ -161,6 +183,16 @@ static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa)
return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET;
}
+static inline __le64 *dpaa2_get_ts(void *buf_addr, bool swa)
+{
+ return dpaa2_get_hwa(buf_addr, swa) + DPAA2_TS_OFFSET;
+}
+
+static inline struct dpaa2_faead *dpaa2_get_faead(void *buf_addr, bool swa)
+{
+ return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAEAD_OFFSET;
+}
+
/* Error and status bits in the frame annotation status word */
/* Debug frame, otherwise supposed to be discarded */
#define DPAA2_FAS_DISC 0x80000000
@@ -319,6 +351,9 @@ struct dpaa2_eth_priv {
u16 bpid;
struct iommu_domain *iommu_domain;
+ bool tx_tstamp; /* Tx timestamping enabled */
+ bool rx_tstamp; /* Rx timestamping enabled */
+
u16 tx_qdid;
u16 rx_buf_align;
struct fsl_mc_io *mc_io;
@@ -355,6 +390,7 @@ struct dpaa2_eth_priv {
extern const struct ethtool_ops dpaa2_ethtool_ops;
extern const char dpaa2_eth_drv_version[];
+extern int dpaa2_phc_index;
static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv,
u16 ver_major, u16 ver_minor)
@@ -377,10 +413,19 @@ static inline
unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
struct sk_buff *skb)
{
+ unsigned int headroom = DPAA2_ETH_SWA_SIZE;
+
+ /* For non-linear skbs we have no headroom requirement, as we build a
+ * SG frame with a newly allocated SGT buffer
+ */
if (skb_is_nonlinear(skb))
return 0;
- return DPAA2_ETH_SWA_SIZE;
+ /* If we have Tx timestamping, need 128B hardware annotation */
+ if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
+ headroom += DPAA2_ETH_TX_HWA_SIZE;
+
+ return headroom;
}
/* Extra headroom space requested to hardware, in order to make sure there's
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index bfc8b64169ca..1ae779ae8c99 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -30,6 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <linux/net_tstamp.h>
+
#include "dpni.h" /* DPNI_LINK_OPT_* */
#include "dpaa2-eth.h"
@@ -274,6 +276,26 @@ static int dpaa2_eth_get_rxnfc(struct net_device *net_dev,
return 0;
}
+int dpaa2_phc_index = -1;
+EXPORT_SYMBOL(dpaa2_phc_index);
+
+static int dpaa2_eth_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info)
+{
+ info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+
+ info->phc_index = dpaa2_phc_index;
+
+ info->tx_types = (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON);
+
+ info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_ALL);
+ return 0;
+}
+
const struct ethtool_ops dpaa2_ethtool_ops = {
.get_drvinfo = dpaa2_eth_get_drvinfo,
.get_link = ethtool_op_get_link,
@@ -283,4 +305,5 @@ const struct ethtool_ops dpaa2_ethtool_ops = {
.get_ethtool_stats = dpaa2_eth_get_ethtool_stats,
.get_strings = dpaa2_eth_get_strings,
.get_rxnfc = dpaa2_eth_get_rxnfc,
+ .get_ts_info = dpaa2_eth_get_ts_info,
};
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 1c203e6e8035..da744f2b0ee6 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -49,6 +49,8 @@
#define DPSW_CMDID_IF_SET_FLOODING DPSW_CMD_ID(0x047)
#define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
+#define DPSW_CMDID_IF_GET_TCI DPSW_CMD_ID(0x04A)
+
#define DPSW_CMDID_IF_SET_LINK_CFG DPSW_CMD_ID(0x04C)
#define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
@@ -206,6 +208,17 @@ struct dpsw_cmd_if_set_tci {
__le16 conf;
};
+struct dpsw_cmd_if_get_tci {
+ __le16 if_id;
+};
+
+struct dpsw_rsp_if_get_tci {
+ __le16 pad;
+ __le16 vlan_id;
+ u8 dei;
+ u8 pcp;
+};
+
#define DPSW_STATE_SHIFT 0
#define DPSW_STATE_SIZE 4
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 9b9bc604b461..cabed77b445d 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -529,6 +529,48 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
}
/**
+ * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface Identifier
+ * @cfg: Tag Control Information Configuration
+ *
+ * Return: Completion status. '0' on Success; Error code otherwise.
+ */
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u16 if_id,
+ struct dpsw_tci_cfg *cfg)
+{
+ struct fsl_mc_command cmd = { 0 };
+ struct dpsw_cmd_if_get_tci *cmd_params;
+ struct dpsw_rsp_if_get_tci *rsp_params;
+ int err;
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
+ cmd_flags,
+ token);
+ cmd_params = (struct dpsw_cmd_if_get_tci *)cmd.params;
+ cmd_params->if_id = cpu_to_le16(if_id);
+
+ /* send command to mc*/
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ /* retrieve response parameters */
+ rsp_params = (struct dpsw_rsp_if_get_tci *)cmd.params;
+ cfg->pcp = rsp_params->pcp;
+ cfg->dei = rsp_params->dei;
+ cfg->vlan_id = le16_to_cpu(rsp_params->vlan_id);
+
+ return 0;
+}
+
+/**
* dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 3335adde0193..82f80c409ec3 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -306,6 +306,12 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
u16 if_id,
const struct dpsw_tci_cfg *cfg);
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u16 if_id,
+ struct dpsw_tci_cfg *cfg);
+
/**
* enum dpsw_stp_state - Spanning Tree Protocol (STP) states
* @DPSW_STP_STATE_BLOCKING: Blocking state
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c723a04bc3d6..1c4fe64026d0 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -50,14 +50,23 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
return 0;
}
-static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
- struct dpsw_tci_cfg *tci_cfg)
+static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid)
{
struct ethsw_core *ethsw = port_priv->ethsw_data;
struct net_device *netdev = port_priv->netdev;
+ struct dpsw_tci_cfg tci_cfg = { 0 };
bool is_oper;
int err, ret;
+ err = dpsw_if_get_tci(ethsw->mc_io, 0, ethsw->dpsw_handle,
+ port_priv->idx, &tci_cfg);
+ if (err) {
+ netdev_err(netdev, "dpsw_if_get_tci err %d\n", err);
+ return err;
+ }
+
+ tci_cfg.vlan_id = pvid;
+
/* Interface needs to be down to change PVID */
is_oper = netif_oper_up(netdev);
if (is_oper) {
@@ -71,17 +80,16 @@ static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
}
err = dpsw_if_set_tci(ethsw->mc_io, 0, ethsw->dpsw_handle,
- port_priv->idx, tci_cfg);
+ port_priv->idx, &tci_cfg);
if (err) {
netdev_err(netdev, "dpsw_if_set_tci err %d\n", err);
goto set_tci_error;
}
/* Delete previous PVID info and mark the new one */
- if (port_priv->pvid)
- port_priv->vlans[port_priv->pvid] &= ~ETHSW_VLAN_PVID;
- port_priv->vlans[tci_cfg->vlan_id] |= ETHSW_VLAN_PVID;
- port_priv->pvid = tci_cfg->vlan_id;
+ port_priv->vlans[port_priv->pvid] &= ~ETHSW_VLAN_PVID;
+ port_priv->vlans[pvid] |= ETHSW_VLAN_PVID;
+ port_priv->pvid = pvid;
set_tci_error:
if (is_oper) {
@@ -133,13 +141,7 @@ static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv,
}
if (flags & BRIDGE_VLAN_INFO_PVID) {
- struct dpsw_tci_cfg tci_cfg = {
- .pcp = 0,
- .dei = 0,
- .vlan_id = vid,
- };
-
- err = ethsw_port_set_tci(port_priv, &tci_cfg);
+ err = ethsw_port_set_pvid(port_priv, vid);
if (err)
return err;
}
@@ -616,10 +618,8 @@ static void ethsw_teardown_irqs(struct fsl_mc_device *sw_dev)
{
struct device *dev = &sw_dev->dev;
struct ethsw_core *ethsw = dev_get_drvdata(dev);
- struct fsl_mc_device_irq *irq;
int err;
- irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF];
err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle,
DPSW_IRQ_INDEX_IF, 0);
if (err)
@@ -819,9 +819,7 @@ static int ethsw_port_del_vlan(struct ethsw_port_priv *port_priv, u16 vid)
return -ENOENT;
if (port_priv->vlans[vid] & ETHSW_VLAN_PVID) {
- struct dpsw_tci_cfg tci_cfg = { 0 };
-
- err = ethsw_port_set_tci(port_priv, &tci_cfg);
+ err = ethsw_port_set_pvid(port_priv, 0);
if (err)
return err;
}
@@ -1254,7 +1252,6 @@ static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port)
const char def_mcast[ETH_ALEN] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0x01};
struct net_device *netdev = port_priv->netdev;
struct ethsw_core *ethsw = port_priv->ethsw_data;
- struct dpsw_tci_cfg tci_cfg = {0};
struct dpsw_vlan_if_cfg vcfg;
int err;
@@ -1272,7 +1269,7 @@ static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port)
return err;
}
- err = ethsw_port_set_tci(port_priv, &tci_cfg);
+ err = ethsw_port_set_pvid(port_priv, 0);
if (err)
return err;
diff --git a/drivers/staging/fsl-dpaa2/rtc/Makefile b/drivers/staging/fsl-dpaa2/rtc/Makefile
new file mode 100644
index 000000000000..5468da071163
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 PTP clock
+#
+
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += dpaa2-rtc.o
+
+dpaa2-rtc-objs := rtc.o dprtc.o
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
new file mode 100644
index 000000000000..db6a473430cc
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#ifndef _FSL_DPRTC_CMD_H
+#define _FSL_DPRTC_CMD_H
+
+/* DPRTC Version */
+#define DPRTC_VER_MAJOR 2
+#define DPRTC_VER_MINOR 0
+
+/* Command versioning */
+#define DPRTC_CMD_BASE_VERSION 1
+#define DPRTC_CMD_ID_OFFSET 4
+
+#define DPRTC_CMD(id) (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPRTC_CMDID_CLOSE DPRTC_CMD(0x800)
+#define DPRTC_CMDID_OPEN DPRTC_CMD(0x810)
+#define DPRTC_CMDID_CREATE DPRTC_CMD(0x910)
+#define DPRTC_CMDID_DESTROY DPRTC_CMD(0x990)
+#define DPRTC_CMDID_GET_API_VERSION DPRTC_CMD(0xa10)
+
+#define DPRTC_CMDID_ENABLE DPRTC_CMD(0x002)
+#define DPRTC_CMDID_DISABLE DPRTC_CMD(0x003)
+#define DPRTC_CMDID_GET_ATTR DPRTC_CMD(0x004)
+#define DPRTC_CMDID_RESET DPRTC_CMD(0x005)
+#define DPRTC_CMDID_IS_ENABLED DPRTC_CMD(0x006)
+
+#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012)
+#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013)
+#define DPRTC_CMDID_SET_IRQ_MASK DPRTC_CMD(0x014)
+#define DPRTC_CMDID_GET_IRQ_MASK DPRTC_CMD(0x015)
+#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016)
+#define DPRTC_CMDID_CLEAR_IRQ_STATUS DPRTC_CMD(0x017)
+
+#define DPRTC_CMDID_SET_CLOCK_OFFSET DPRTC_CMD(0x1d0)
+#define DPRTC_CMDID_SET_FREQ_COMPENSATION DPRTC_CMD(0x1d1)
+#define DPRTC_CMDID_GET_FREQ_COMPENSATION DPRTC_CMD(0x1d2)
+#define DPRTC_CMDID_GET_TIME DPRTC_CMD(0x1d3)
+#define DPRTC_CMDID_SET_TIME DPRTC_CMD(0x1d4)
+#define DPRTC_CMDID_SET_ALARM DPRTC_CMD(0x1d5)
+#define DPRTC_CMDID_SET_PERIODIC_PULSE DPRTC_CMD(0x1d6)
+#define DPRTC_CMDID_CLEAR_PERIODIC_PULSE DPRTC_CMD(0x1d7)
+#define DPRTC_CMDID_SET_EXT_TRIGGER DPRTC_CMD(0x1d8)
+#define DPRTC_CMDID_CLEAR_EXT_TRIGGER DPRTC_CMD(0x1d9)
+#define DPRTC_CMDID_GET_EXT_TRIGGER_TIMESTAMP DPRTC_CMD(0x1dA)
+
+/* Macros for accessing command fields smaller than 1byte */
+#define DPRTC_MASK(field) \
+ GENMASK(DPRTC_##field##_SHIFT + DPRTC_##field##_SIZE - 1, \
+ DPRTC_##field##_SHIFT)
+#define dprtc_get_field(var, field) \
+ (((var) & DPRTC_MASK(field)) >> DPRTC_##field##_SHIFT)
+
+#pragma pack(push, 1)
+struct dprtc_cmd_open {
+ __le32 dprtc_id;
+};
+
+struct dprtc_cmd_destroy {
+ __le32 object_id;
+};
+
+#define DPRTC_ENABLE_SHIFT 0
+#define DPRTC_ENABLE_SIZE 1
+
+struct dprtc_rsp_is_enabled {
+ u8 en;
+};
+
+struct dprtc_cmd_get_irq {
+ __le32 pad;
+ u8 irq_index;
+};
+
+struct dprtc_cmd_set_irq_enable {
+ u8 en;
+ u8 pad[3];
+ u8 irq_index;
+};
+
+struct dprtc_rsp_get_irq_enable {
+ u8 en;
+};
+
+struct dprtc_cmd_set_irq_mask {
+ __le32 mask;
+ u8 irq_index;
+};
+
+struct dprtc_rsp_get_irq_mask {
+ __le32 mask;
+};
+
+struct dprtc_cmd_get_irq_status {
+ __le32 status;
+ u8 irq_index;
+};
+
+struct dprtc_rsp_get_irq_status {
+ __le32 status;
+};
+
+struct dprtc_cmd_clear_irq_status {
+ __le32 status;
+ u8 irq_index;
+};
+
+struct dprtc_rsp_get_attributes {
+ __le32 pad;
+ __le32 id;
+};
+
+struct dprtc_cmd_set_clock_offset {
+ __le64 offset;
+};
+
+struct dprtc_get_freq_compensation {
+ __le32 freq_compensation;
+};
+
+struct dprtc_time {
+ __le64 time;
+};
+
+struct dprtc_rsp_get_api_version {
+ __le16 major;
+ __le16 minor;
+};
+
+#pragma pack(pop)
+
+#endif /* _FSL_DPRTC_CMD_H */
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc.c b/drivers/staging/fsl-dpaa2/rtc/dprtc.c
new file mode 100644
index 000000000000..68ae6ffefbf5
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/dprtc.c
@@ -0,0 +1,701 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#include <linux/fsl/mc.h>
+
+#include "dprtc.h"
+#include "dprtc-cmd.h"
+
+/**
+ * dprtc_open() - Open a control session for the specified object.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @dprtc_id: DPRTC unique ID
+ * @token: Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dprtc_create function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_open(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ int dprtc_id,
+ u16 *token)
+{
+ struct dprtc_cmd_open *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_OPEN,
+ cmd_flags,
+ 0);
+ cmd_params = (struct dprtc_cmd_open *)cmd.params;
+ cmd_params->dprtc_id = cpu_to_le32(dprtc_id);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ *token = mc_cmd_hdr_read_token(&cmd);
+
+ return 0;
+}
+
+/**
+ * dprtc_close() - Close the control session of the object
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_close(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token)
+{
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLOSE, cmd_flags,
+ token);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_create() - Create the DPRTC object.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @dprc_token: Parent container token; '0' for default container
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @cfg: Configuration structure
+ * @obj_id: Returned object id
+ *
+ * Create the DPRTC object, allocate required resources and
+ * perform required initialization.
+ *
+ * The function accepts an authentication token of a parent
+ * container that this object should be assigned to. The token
+ * can be '0' so the object will be assigned to the default container.
+ * The newly created object can be opened with the returned
+ * object id and using the container's associated tokens and MC portals.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_create(struct fsl_mc_io *mc_io,
+ u16 dprc_token,
+ u32 cmd_flags,
+ const struct dprtc_cfg *cfg,
+ u32 *obj_id)
+{
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CREATE,
+ cmd_flags,
+ dprc_token);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ *obj_id = mc_cmd_read_object_id(&cmd);
+
+ return 0;
+}
+
+/**
+ * dprtc_destroy() - Destroy the DPRTC object and release all its resources.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @dprc_token: Parent container token; '0' for default container
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @object_id: The object id; it must be a valid id within the container that
+ * created this object;
+ *
+ * The function accepts the authentication token of the parent container that
+ * created the object (not the one that currently owns the object). The object
+ * is searched within parent using the provided 'object_id'.
+ * All tokens to the object must be closed before calling destroy.
+ *
+ * Return: '0' on Success; error code otherwise.
+ */
+int dprtc_destroy(struct fsl_mc_io *mc_io,
+ u16 dprc_token,
+ u32 cmd_flags,
+ u32 object_id)
+{
+ struct dprtc_cmd_destroy *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_DESTROY,
+ cmd_flags,
+ dprc_token);
+ cmd_params = (struct dprtc_cmd_destroy *)cmd.params;
+ cmd_params->object_id = cpu_to_le32(object_id);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_enable() - Enable the DPRTC.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token)
+{
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_ENABLE, cmd_flags,
+ token);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_disable() - Disable the DPRTC.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_disable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token)
+{
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_DISABLE,
+ cmd_flags,
+ token);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_is_enabled() - Check if the DPRTC is enabled.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @en: Returns '1' if object is enabled; '0' otherwise
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_is_enabled(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ int *en)
+{
+ struct dprtc_rsp_is_enabled *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_IS_ENABLED, cmd_flags,
+ token);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_is_enabled *)cmd.params;
+ *en = dprtc_get_field(rsp_params->en, ENABLE);
+
+ return 0;
+}
+
+/**
+ * dprtc_reset() - Reset the DPRTC, returns the object to initial state.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_reset(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token)
+{
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_RESET,
+ cmd_flags,
+ token);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_set_irq_enable() - Set overall interrupt state.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @en: Interrupt state - enable = 1, disable = 0
+ *
+ * Allows GPP software to control when interrupts are generated.
+ * Each interrupt can have up to 32 causes. The enable/disable control's the
+ * overall interrupt state. if the interrupt is disabled no causes will cause
+ * an interrupt.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_irq_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u8 en)
+{
+ struct dprtc_cmd_set_irq_enable *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_ENABLE,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_set_irq_enable *)cmd.params;
+ cmd_params->irq_index = irq_index;
+ cmd_params->en = en;
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_get_irq_enable() - Get overall interrupt state
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @en: Returned interrupt state - enable = 1, disable = 0
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_irq_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u8 *en)
+{
+ struct dprtc_rsp_get_irq_enable *rsp_params;
+ struct dprtc_cmd_get_irq *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_ENABLE,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_get_irq *)cmd.params;
+ cmd_params->irq_index = irq_index;
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_get_irq_enable *)cmd.params;
+ *en = rsp_params->en;
+
+ return 0;
+}
+
+/**
+ * dprtc_set_irq_mask() - Set interrupt mask.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @mask: Event mask to trigger interrupt;
+ * each bit:
+ * 0 = ignore event
+ * 1 = consider event for asserting IRQ
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_irq_mask(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 mask)
+{
+ struct dprtc_cmd_set_irq_mask *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_MASK,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_set_irq_mask *)cmd.params;
+ cmd_params->mask = cpu_to_le32(mask);
+ cmd_params->irq_index = irq_index;
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_get_irq_mask() - Get interrupt mask.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @mask: Returned event mask to trigger interrupt
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_irq_mask(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 *mask)
+{
+ struct dprtc_rsp_get_irq_mask *rsp_params;
+ struct dprtc_cmd_get_irq *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_MASK,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_get_irq *)cmd.params;
+ cmd_params->irq_index = irq_index;
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_get_irq_mask *)cmd.params;
+ *mask = le32_to_cpu(rsp_params->mask);
+
+ return 0;
+}
+
+/**
+ * dprtc_get_irq_status() - Get the current status of any pending interrupts.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @status: Returned interrupts status - one bit per cause:
+ * 0 = no interrupt pending
+ * 1 = interrupt pending
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_irq_status(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 *status)
+{
+ struct dprtc_cmd_get_irq_status *cmd_params;
+ struct dprtc_rsp_get_irq_status *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_STATUS,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_get_irq_status *)cmd.params;
+ cmd_params->status = cpu_to_le32(*status);
+ cmd_params->irq_index = irq_index;
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_get_irq_status *)cmd.params;
+ *status = le32_to_cpu(rsp_params->status);
+
+ return 0;
+}
+
+/**
+ * dprtc_clear_irq_status() - Clear a pending interrupt's status
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @irq_index: The interrupt index to configure
+ * @status: Bits to clear (W1C) - one bit per cause:
+ * 0 = don't change
+ * 1 = clear status bit
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_clear_irq_status(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 status)
+{
+ struct dprtc_cmd_clear_irq_status *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLEAR_IRQ_STATUS,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_clear_irq_status *)cmd.params;
+ cmd_params->irq_index = irq_index;
+ cmd_params->status = cpu_to_le32(status);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_get_attributes - Retrieve DPRTC attributes.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @attr: Returned object's attributes
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_attributes(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ struct dprtc_attr *attr)
+{
+ struct dprtc_rsp_get_attributes *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_ATTR,
+ cmd_flags,
+ token);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_get_attributes *)cmd.params;
+ attr->id = le32_to_cpu(rsp_params->id);
+
+ return 0;
+}
+
+/**
+ * dprtc_set_clock_offset() - Sets the clock's offset
+ * (usually relative to another clock).
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @offset: New clock offset (in nanoseconds).
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_clock_offset(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ int64_t offset)
+{
+ struct dprtc_cmd_set_clock_offset *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_CLOCK_OFFSET,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_cmd_set_clock_offset *)cmd.params;
+ cmd_params->offset = cpu_to_le64(offset);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_set_freq_compensation() - Sets a new frequency compensation value.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @freq_compensation: The new frequency compensation value to set.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_freq_compensation(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u32 freq_compensation)
+{
+ struct dprtc_get_freq_compensation *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_FREQ_COMPENSATION,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_get_freq_compensation *)cmd.params;
+ cmd_params->freq_compensation = cpu_to_le32(freq_compensation);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_get_freq_compensation() - Retrieves the frequency compensation value
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @freq_compensation: Frequency compensation value
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_freq_compensation(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u32 *freq_compensation)
+{
+ struct dprtc_get_freq_compensation *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_FREQ_COMPENSATION,
+ cmd_flags,
+ token);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_get_freq_compensation *)cmd.params;
+ *freq_compensation = le32_to_cpu(rsp_params->freq_compensation);
+
+ return 0;
+}
+
+/**
+ * dprtc_get_time() - Returns the current RTC time.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @time: Current RTC time.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_time(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ uint64_t *time)
+{
+ struct dprtc_time *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_TIME,
+ cmd_flags,
+ token);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_time *)cmd.params;
+ *time = le64_to_cpu(rsp_params->time);
+
+ return 0;
+}
+
+/**
+ * dprtc_set_time() - Updates current RTC time.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @time: New RTC time.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_time(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ uint64_t time)
+{
+ struct dprtc_time *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_TIME,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_time *)cmd.params;
+ cmd_params->time = cpu_to_le64(time);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_set_alarm() - Defines and sets alarm.
+ *
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRTC object
+ * @time: In nanoseconds, the time when the alarm
+ * should go off - must be a multiple of
+ * 1 microsecond
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_set_alarm(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token, uint64_t time)
+{
+ struct dprtc_time *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_ALARM,
+ cmd_flags,
+ token);
+ cmd_params = (struct dprtc_time *)cmd.params;
+ cmd_params->time = cpu_to_le64(time);
+
+ return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dprtc_get_api_version() - Get Data Path Real Time Counter API version
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver: Major version of data path real time counter API
+ * @minor_ver: Minor version of data path real time counter API
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprtc_get_api_version(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 *major_ver,
+ u16 *minor_ver)
+{
+ struct dprtc_rsp_get_api_version *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_API_VERSION,
+ cmd_flags,
+ 0);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dprtc_rsp_get_api_version *)cmd.params;
+ *major_ver = le16_to_cpu(rsp_params->major);
+ *minor_ver = le16_to_cpu(rsp_params->minor);
+
+ return 0;
+}
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc.h b/drivers/staging/fsl-dpaa2/rtc/dprtc.h
new file mode 100644
index 000000000000..08f7c7bebbca
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/dprtc.h
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#ifndef __FSL_DPRTC_H
+#define __FSL_DPRTC_H
+
+/* Data Path Real Time Counter API
+ * Contains initialization APIs and runtime control APIs for RTC
+ */
+
+struct fsl_mc_io;
+
+/**
+ * Number of irq's
+ */
+#define DPRTC_MAX_IRQ_NUM 1
+#define DPRTC_IRQ_INDEX 0
+
+/**
+ * Interrupt event masks:
+ */
+
+/**
+ * Interrupt event mask indicating alarm event had occurred
+ */
+#define DPRTC_EVENT_ALARM 0x40000000
+/**
+ * Interrupt event mask indicating periodic pulse event had occurred
+ */
+#define DPRTC_EVENT_PPS 0x08000000
+
+int dprtc_open(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ int dprtc_id,
+ u16 *token);
+
+int dprtc_close(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token);
+
+/**
+ * struct dprtc_cfg - Structure representing DPRTC configuration
+ * @options: place holder
+ */
+struct dprtc_cfg {
+ u32 options;
+};
+
+int dprtc_create(struct fsl_mc_io *mc_io,
+ u16 dprc_token,
+ u32 cmd_flags,
+ const struct dprtc_cfg *cfg,
+ u32 *obj_id);
+
+int dprtc_destroy(struct fsl_mc_io *mc_io,
+ u16 dprc_token,
+ u32 cmd_flags,
+ u32 object_id);
+
+int dprtc_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token);
+
+int dprtc_disable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token);
+
+int dprtc_is_enabled(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ int *en);
+
+int dprtc_reset(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token);
+
+int dprtc_set_clock_offset(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ int64_t offset);
+
+int dprtc_set_freq_compensation(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u32 freq_compensation);
+
+int dprtc_get_freq_compensation(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u32 *freq_compensation);
+
+int dprtc_get_time(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ uint64_t *time);
+
+int dprtc_set_time(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ uint64_t time);
+
+int dprtc_set_alarm(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ uint64_t time);
+
+int dprtc_set_irq_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u8 en);
+
+int dprtc_get_irq_enable(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u8 *en);
+
+int dprtc_set_irq_mask(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 mask);
+
+int dprtc_get_irq_mask(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 *mask);
+
+int dprtc_get_irq_status(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 *status);
+
+int dprtc_clear_irq_status(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u8 irq_index,
+ u32 status);
+
+/**
+ * struct dprtc_attr - Structure representing DPRTC attributes
+ * @id: DPRTC object ID
+ */
+struct dprtc_attr {
+ int id;
+};
+
+int dprtc_get_attributes(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ struct dprtc_attr *attr);
+
+int dprtc_get_api_version(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 *major_ver,
+ u16 *minor_ver);
+
+#endif /* __FSL_DPRTC_H */
diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.c b/drivers/staging/fsl-dpaa2/rtc/rtc.c
new file mode 100644
index 000000000000..0d52cb85441f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/rtc.c
@@ -0,0 +1,229 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/fsl/mc.h>
+
+#include "rtc.h"
+
+struct ptp_dpaa2_priv {
+ struct fsl_mc_device *rtc_mc_dev;
+ struct ptp_clock *clock;
+ struct ptp_clock_info caps;
+ u32 freq_comp;
+};
+
+/* PTP clock operations */
+static int ptp_dpaa2_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
+{
+ struct ptp_dpaa2_priv *ptp_dpaa2 =
+ container_of(ptp, struct ptp_dpaa2_priv, caps);
+ struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+ struct device *dev = &mc_dev->dev;
+ u64 adj;
+ u32 diff, tmr_add;
+ int neg_adj = 0;
+ int err = 0;
+
+ if (ppb < 0) {
+ neg_adj = 1;
+ ppb = -ppb;
+ }
+
+ tmr_add = ptp_dpaa2->freq_comp;
+ adj = tmr_add;
+ adj *= ppb;
+ diff = div_u64(adj, 1000000000ULL);
+
+ tmr_add = neg_adj ? tmr_add - diff : tmr_add + diff;
+
+ err = dprtc_set_freq_compensation(mc_dev->mc_io, 0,
+ mc_dev->mc_handle, tmr_add);
+ if (err)
+ dev_err(dev, "dprtc_set_freq_compensation err %d\n", err);
+ return 0;
+}
+
+static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+ struct ptp_dpaa2_priv *ptp_dpaa2 =
+ container_of(ptp, struct ptp_dpaa2_priv, caps);
+ struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+ struct device *dev = &mc_dev->dev;
+ s64 now;
+ int err = 0;
+
+ err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &now);
+ if (err) {
+ dev_err(dev, "dprtc_get_time err %d\n", err);
+ return 0;
+ }
+
+ now += delta;
+
+ err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, now);
+ if (err) {
+ dev_err(dev, "dprtc_set_time err %d\n", err);
+ return 0;
+ }
+ return 0;
+}
+
+static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
+{
+ struct ptp_dpaa2_priv *ptp_dpaa2 =
+ container_of(ptp, struct ptp_dpaa2_priv, caps);
+ struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+ struct device *dev = &mc_dev->dev;
+ u64 ns;
+ u32 remainder;
+ int err = 0;
+
+ err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &ns);
+ if (err) {
+ dev_err(dev, "dprtc_get_time err %d\n", err);
+ return 0;
+ }
+
+ ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
+ ts->tv_nsec = remainder;
+ return 0;
+}
+
+static int ptp_dpaa2_settime(struct ptp_clock_info *ptp,
+ const struct timespec64 *ts)
+{
+ struct ptp_dpaa2_priv *ptp_dpaa2 =
+ container_of(ptp, struct ptp_dpaa2_priv, caps);
+ struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+ struct device *dev = &mc_dev->dev;
+ u64 ns;
+ int err = 0;
+
+ ns = ts->tv_sec * 1000000000ULL;
+ ns += ts->tv_nsec;
+
+ err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, ns);
+ if (err)
+ dev_err(dev, "dprtc_set_time err %d\n", err);
+ return 0;
+}
+
+static struct ptp_clock_info ptp_dpaa2_caps = {
+ .owner = THIS_MODULE,
+ .name = "DPAA2 PTP Clock",
+ .max_adj = 512000,
+ .n_alarm = 2,
+ .n_ext_ts = 2,
+ .n_per_out = 3,
+ .n_pins = 0,
+ .pps = 1,
+ .adjfreq = ptp_dpaa2_adjfreq,
+ .adjtime = ptp_dpaa2_adjtime,
+ .gettime64 = ptp_dpaa2_gettime,
+ .settime64 = ptp_dpaa2_settime,
+};
+
+static int rtc_probe(struct fsl_mc_device *mc_dev)
+{
+ struct device *dev = &mc_dev->dev;
+ struct ptp_dpaa2_priv *ptp_dpaa2;
+ u32 tmr_add = 0;
+ int err;
+
+ ptp_dpaa2 = kzalloc(sizeof(*ptp_dpaa2), GFP_KERNEL);
+ if (!ptp_dpaa2)
+ return -ENOMEM;
+
+ err = fsl_mc_portal_allocate(mc_dev, 0, &mc_dev->mc_io);
+ if (err) {
+ dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
+ goto err_exit;
+ }
+
+ err = dprtc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
+ &mc_dev->mc_handle);
+ if (err) {
+ dev_err(dev, "dprtc_open err %d\n", err);
+ goto err_free_mcp;
+ }
+
+ ptp_dpaa2->rtc_mc_dev = mc_dev;
+
+ err = dprtc_get_freq_compensation(mc_dev->mc_io, 0,
+ mc_dev->mc_handle, &tmr_add);
+ if (err) {
+ dev_err(dev, "dprtc_get_freq_compensation err %d\n", err);
+ goto err_close;
+ }
+
+ ptp_dpaa2->freq_comp = tmr_add;
+ ptp_dpaa2->caps = ptp_dpaa2_caps;
+
+ ptp_dpaa2->clock = ptp_clock_register(&ptp_dpaa2->caps, dev);
+ if (IS_ERR(ptp_dpaa2->clock)) {
+ err = PTR_ERR(ptp_dpaa2->clock);
+ goto err_close;
+ }
+
+ dpaa2_phc_index = ptp_clock_index(ptp_dpaa2->clock);
+
+ dev_set_drvdata(dev, ptp_dpaa2);
+
+ return 0;
+
+err_close:
+ dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
+err_free_mcp:
+ fsl_mc_portal_free(mc_dev->mc_io);
+err_exit:
+ kfree(ptp_dpaa2);
+ dev_set_drvdata(dev, NULL);
+ return err;
+}
+
+static int rtc_remove(struct fsl_mc_device *mc_dev)
+{
+ struct ptp_dpaa2_priv *ptp_dpaa2;
+ struct device *dev = &mc_dev->dev;
+
+ ptp_dpaa2 = dev_get_drvdata(dev);
+ ptp_clock_unregister(ptp_dpaa2->clock);
+
+ dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
+ fsl_mc_portal_free(mc_dev->mc_io);
+
+ kfree(ptp_dpaa2);
+ dev_set_drvdata(dev, NULL);
+
+ return 0;
+}
+
+static const struct fsl_mc_device_id rtc_match_id_table[] = {
+ {
+ .vendor = FSL_MC_VENDOR_FREESCALE,
+ .obj_type = "dprtc",
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(fslmc, rtc_match_id_table);
+
+static struct fsl_mc_driver rtc_drv = {
+ .driver = {
+ .name = KBUILD_MODNAME,
+ .owner = THIS_MODULE,
+ },
+ .probe = rtc_probe,
+ .remove = rtc_remove,
+ .match_id_table = rtc_match_id_table,
+};
+
+module_fsl_mc_driver(rtc_drv);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("DPAA2 PTP Clock Driver");
diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.h b/drivers/staging/fsl-dpaa2/rtc/rtc.h
new file mode 100644
index 000000000000..ff2e177395d4
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/rtc.h
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __RTC_H
+#define __RTC_H
+
+#include "dprtc.h"
+#include "dprtc-cmd.h"
+
+extern int dpaa2_phc_index;
+
+#endif
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
index 182b38412a82..11a90a90d827 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -13,6 +13,7 @@
#include <linux/msi.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
+#include <linux/io.h>
#include <linux/fsl/mc.h>
#include "../../include/dpaa2-io.h"
@@ -100,7 +101,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
if (err) {
dev_dbg(dev, "MC portal allocation failed\n");
err = -EPROBE_DEFER;
- goto err_mcportal;
+ goto err_priv_alloc;
}
err = dpio_open(dpio_dev->mc_io, 0, dpio_dev->obj_desc.id,
@@ -146,10 +147,22 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
* Set the CENA regs to be the cache inhibited area of the portal to
* avoid coherency issues if a user migrates to another core.
*/
- desc.regs_cena = ioremap_wc(dpio_dev->regions[1].start,
- resource_size(&dpio_dev->regions[1]));
- desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
- resource_size(&dpio_dev->regions[1]));
+ desc.regs_cena = devm_memremap(dev, dpio_dev->regions[1].start,
+ resource_size(&dpio_dev->regions[1]),
+ MEMREMAP_WC);
+ if (IS_ERR(desc.regs_cena)) {
+ dev_err(dev, "devm_memremap failed\n");
+ err = PTR_ERR(desc.regs_cena);
+ goto err_allocate_irqs;
+ }
+
+ desc.regs_cinh = devm_ioremap(dev, dpio_dev->regions[1].start,
+ resource_size(&dpio_dev->regions[1]));
+ if (!desc.regs_cinh) {
+ err = -ENOMEM;
+ dev_err(dev, "devm_ioremap failed\n");
+ goto err_allocate_irqs;
+ }
err = fsl_mc_allocate_irqs(dpio_dev);
if (err) {
@@ -164,6 +177,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
priv->io = dpaa2_io_create(&desc);
if (!priv->io) {
dev_err(dev, "dpaa2_io_create failed\n");
+ err = -ENOMEM;
goto err_dpaa2_io_create;
}
@@ -185,8 +199,6 @@ err_get_attr:
dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
err_open:
fsl_mc_portal_free(dpio_dev->mc_io);
-err_mcportal:
- dev_set_drvdata(dev, NULL);
err_priv_alloc:
return err;
}
@@ -230,8 +242,6 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
fsl_mc_portal_free(dpio_dev->mc_io);
- dev_set_drvdata(dev, NULL);
-
return 0;
err_open:
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
index 4488a445b709..69db3c818742 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
@@ -15,7 +15,7 @@ struct qbman_swp;
/* qbman software portal descriptor structure */
struct qbman_swp_desc {
void *cena_bar; /* Cache-enabled portal base address */
- void *cinh_bar; /* Cache-inhibited portal base address */
+ void __iomem *cinh_bar; /* Cache-inhibited portal base address */
u32 qman_version;
};
@@ -102,7 +102,7 @@ struct qbman_release_desc {
/* portal data structure */
struct qbman_swp {
const struct qbman_swp_desc *desc;
- void __iomem *addr_cena;
+ void *addr_cena;
void __iomem *addr_cinh;
/* Management commands */
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/drivers/staging/fsl-mc/include/dpaa2-io.h
index f71227d3df8d..ab51e40d11db 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -52,7 +52,7 @@ struct dpaa2_io_desc {
int has_8prio;
int cpu;
void *regs_cena;
- void *regs_cinh;
+ void __iomem *regs_cinh;
int dpio_id;
u32 qman_version;
};
diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
index 4200391b1a97..ae39e59daf70 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#include <linux/kernel.h>
#include "gdm_endian.h"
diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h
index e58d29f868ba..f373dc3a19bf 100644
--- a/drivers/staging/gdm724x/gdm_endian.h
+++ b/drivers/staging/gdm724x/gdm_endian.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef __GDM_ENDIAN_H__
#define __GDM_ENDIAN_H__
diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index 4f3c518304f2..3c2aab7a921e 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -408,7 +398,7 @@ static s32 gdm_lte_tx_nic_type(struct net_device *dev, struct sk_buff *skb)
return nic_type;
}
-static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t gdm_lte_tx(struct sk_buff *skb, struct net_device *dev)
{
struct nic *nic = netdev_priv(dev);
u32 nic_type;
diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h
index bad0855e4721..f2143a6e0e99 100644
--- a/drivers/staging/gdm724x/gdm_lte.h
+++ b/drivers/staging/gdm724x/gdm_lte.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _GDM_LTE_H_
#define _GDM_LTE_H_
diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
index 63921bad519e..e2a050ba6fbb 100644
--- a/drivers/staging/gdm724x/gdm_mux.c
+++ b/drivers/staging/gdm724x/gdm_mux.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h
index 0871b8feec55..51c22e3d8aeb 100644
--- a/drivers/staging/gdm724x/gdm_mux.h
+++ b/drivers/staging/gdm724x/gdm_mux.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _GDM_MUX_H_
#define _GDM_MUX_H_
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 3cdebb81ba63..bf554f7c56ca 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h
index 195c5902989f..afec97ced476 100644
--- a/drivers/staging/gdm724x/gdm_tty.h
+++ b/drivers/staging/gdm724x/gdm_tty.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _GDM_TTY_H_
#define _GDM_TTY_H_
diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
index c95bad4a8615..0218782d1a08 100644
--- a/drivers/staging/gdm724x/gdm_usb.c
+++ b/drivers/staging/gdm724x/gdm_usb.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/gdm724x/gdm_usb.h b/drivers/staging/gdm724x/gdm_usb.h
index 701038685e23..db689b091c4f 100644
--- a/drivers/staging/gdm724x/gdm_usb.h
+++ b/drivers/staging/gdm724x/gdm_usb.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _GDM_USB_H_
#define _GDM_USB_H_
diff --git a/drivers/staging/gdm724x/hci.h b/drivers/staging/gdm724x/hci.h
index 9a591b0db516..b30945daf3a5 100644
--- a/drivers/staging/gdm724x/hci.h
+++ b/drivers/staging/gdm724x/hci.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _HCI_H_
#define _HCI_H_
diff --git a/drivers/staging/gdm724x/hci_packet.h b/drivers/staging/gdm724x/hci_packet.h
index 22ce8b9477b6..83fbd2515467 100644
--- a/drivers/staging/gdm724x/hci_packet.h
+++ b/drivers/staging/gdm724x/hci_packet.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _HCI_PACKET_H_
#define _HCI_PACKET_H_
diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c
index abe242505882..92440c3f055b 100644
--- a/drivers/staging/gdm724x/netlink_k.c
+++ b/drivers/staging/gdm724x/netlink_k.c
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/staging/gdm724x/netlink_k.h b/drivers/staging/gdm724x/netlink_k.h
index 5ebd73157f5a..c9e1d3b2d54f 100644
--- a/drivers/staging/gdm724x/netlink_k.h
+++ b/drivers/staging/gdm724x/netlink_k.h
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
#ifndef _NETLINK_K_H
#define _NETLINK_K_H
diff --git a/drivers/staging/goldfish/Kconfig b/drivers/staging/goldfish/Kconfig
index 4e094602437c..9165385df9de 100644
--- a/drivers/staging/goldfish/Kconfig
+++ b/drivers/staging/goldfish/Kconfig
@@ -1,13 +1,6 @@
config GOLDFISH_AUDIO
tristate "Goldfish AVD Audio Device"
depends on GOLDFISH
- ---help---
+ help
Emulated audio channel for the Goldfish Android Virtual Device
-config MTD_GOLDFISH_NAND
- tristate "Goldfish NAND device"
- depends on GOLDFISH
- depends on MTD
- help
- Drives the emulated NAND flash device on the Google Goldfish
- Android virtual device.
diff --git a/drivers/staging/goldfish/Makefile b/drivers/staging/goldfish/Makefile
index dec34ad58162..054eeb82151e 100644
--- a/drivers/staging/goldfish/Makefile
+++ b/drivers/staging/goldfish/Makefile
@@ -3,4 +3,3 @@
#
obj-$(CONFIG_GOLDFISH_AUDIO) += goldfish_audio.o
-obj-$(CONFIG_MTD_GOLDFISH_NAND) += goldfish_nand.o
diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c
deleted file mode 100644
index f5e002ecba75..000000000000
--- a/drivers/staging/goldfish/goldfish_nand.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * drivers/mtd/devices/goldfish_nand.c
- *
- * Copyright (C) 2007 Google, Inc.
- * Copyright (C) 2012 Intel, Inc.
- * Copyright (C) 2013 Intel, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/io.h>
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/vmalloc.h>
-#include <linux/mtd/mtd.h>
-#include <linux/platform_device.h>
-#include <linux/mutex.h>
-#include <linux/goldfish.h>
-#include <asm/div64.h>
-#include <linux/dma-mapping.h>
-
-#include "goldfish_nand_reg.h"
-
-struct goldfish_nand {
- /* lock protects access to the device registers */
- struct mutex lock;
- unsigned char __iomem *base;
- struct cmd_params *cmd_params;
- size_t mtd_count;
- struct mtd_info mtd[0];
-};
-
-static u32 goldfish_nand_cmd_with_params(struct mtd_info *mtd,
- enum nand_cmd cmd, u64 addr, u32 len,
- void *ptr, u32 *rv)
-{
- u32 cmdp;
- struct goldfish_nand *nand = mtd->priv;
- struct cmd_params *cps = nand->cmd_params;
- unsigned char __iomem *base = nand->base;
-
- if (!cps)
- return -1;
-
- switch (cmd) {
- case NAND_CMD_ERASE:
- cmdp = NAND_CMD_ERASE_WITH_PARAMS;
- break;
- case NAND_CMD_READ:
- cmdp = NAND_CMD_READ_WITH_PARAMS;
- break;
- case NAND_CMD_WRITE:
- cmdp = NAND_CMD_WRITE_WITH_PARAMS;
- break;
- default:
- return -1;
- }
- cps->dev = mtd - nand->mtd;
- cps->addr_high = (u32)(addr >> 32);
- cps->addr_low = (u32)addr;
- cps->transfer_size = len;
- cps->data = (unsigned long)ptr;
- writel(cmdp, base + NAND_COMMAND);
- *rv = cps->result;
- return 0;
-}
-
-static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
- u64 addr, u32 len, void *ptr)
-{
- struct goldfish_nand *nand = mtd->priv;
- u32 rv;
- unsigned char __iomem *base = nand->base;
-
- mutex_lock(&nand->lock);
- if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) {
- writel(mtd - nand->mtd, base + NAND_DEV);
- writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
- writel((u32)addr, base + NAND_ADDR_LOW);
- writel(len, base + NAND_TRANSFER_SIZE);
- gf_write_ptr(ptr, base + NAND_DATA, base + NAND_DATA_HIGH);
- writel(cmd, base + NAND_COMMAND);
- rv = readl(base + NAND_RESULT);
- }
- mutex_unlock(&nand->lock);
- return rv;
-}
-
-static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr)
-{
- loff_t ofs = instr->addr;
- u32 len = instr->len;
- s32 rem;
-
- if (ofs + len > mtd->size)
- goto invalid_arg;
- ofs = div_s64_rem(ofs, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- ofs *= (mtd->writesize + mtd->oobsize);
-
- if (len % mtd->writesize)
- goto invalid_arg;
- len = len / mtd->writesize * (mtd->writesize + mtd->oobsize);
-
- if (goldfish_nand_cmd(mtd, NAND_CMD_ERASE, ofs, len, NULL) != len) {
- pr_err("%s: erase failed, start %llx, len %x, dev_size %llx, erase_size %x\n",
- __func__, ofs, len, mtd->size, mtd->erasesize);
- return -EIO;
- }
-
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid erase, start %llx, len %x, dev_size %llx, erase_size %x\n",
- __func__, ofs, len, mtd->size, mtd->erasesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs,
- struct mtd_oob_ops *ops)
-{
- s32 rem;
-
- if (ofs + ops->len > mtd->size)
- goto invalid_arg;
- if (ops->datbuf && ops->len && ops->len != mtd->writesize)
- goto invalid_arg;
- if (ops->ooblen + ops->ooboffs > mtd->oobsize)
- goto invalid_arg;
-
- ofs = div_s64_rem(ofs, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- ofs *= (mtd->writesize + mtd->oobsize);
-
- if (ops->datbuf)
- ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs,
- ops->len, ops->datbuf);
- ofs += mtd->writesize + ops->ooboffs;
- if (ops->oobbuf)
- ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs,
- ops->ooblen, ops->oobbuf);
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid read, start %llx, len %zx, ooblen %zx, dev_size %llx, write_size %x\n",
- __func__, ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs,
- struct mtd_oob_ops *ops)
-{
- s32 rem;
-
- if (ofs + ops->len > mtd->size)
- goto invalid_arg;
- if (ops->len && ops->len != mtd->writesize)
- goto invalid_arg;
- if (ops->ooblen + ops->ooboffs > mtd->oobsize)
- goto invalid_arg;
-
- ofs = div_s64_rem(ofs, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- ofs *= (mtd->writesize + mtd->oobsize);
-
- if (ops->datbuf)
- ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs,
- ops->len, ops->datbuf);
- ofs += mtd->writesize + ops->ooboffs;
- if (ops->oobbuf)
- ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs,
- ops->ooblen, ops->oobbuf);
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid write, start %llx, len %zx, ooblen %zx, dev_size %llx, write_size %x\n",
- __func__, ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf)
-{
- s32 rem;
-
- if (from + len > mtd->size)
- goto invalid_arg;
-
- from = div_s64_rem(from, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- from *= (mtd->writesize + mtd->oobsize);
-
- *retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, from, len, buf);
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid read, start %llx, len %zx, dev_size %llx, write_size %x\n",
- __func__, from, len, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf)
-{
- s32 rem;
-
- if (to + len > mtd->size)
- goto invalid_arg;
-
- to = div_s64_rem(to, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- to *= (mtd->writesize + mtd->oobsize);
-
- *retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, to, len, (void *)buf);
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid write, start %llx, len %zx, dev_size %llx, write_size %x\n",
- __func__, to, len, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs)
-{
- s32 rem;
-
- if (ofs >= mtd->size)
- goto invalid_arg;
-
- ofs = div_s64_rem(ofs, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- ofs *= mtd->erasesize / mtd->writesize;
- ofs *= (mtd->writesize + mtd->oobsize);
-
- return goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_GET, ofs, 0, NULL);
-
-invalid_arg:
- pr_err("%s: invalid arg, ofs %llx, dev_size %llx, write_size %x\n",
- __func__, ofs, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
-{
- s32 rem;
-
- if (ofs >= mtd->size)
- goto invalid_arg;
-
- ofs = div_s64_rem(ofs, mtd->writesize, &rem);
- if (rem)
- goto invalid_arg;
- ofs *= mtd->erasesize / mtd->writesize;
- ofs *= (mtd->writesize + mtd->oobsize);
-
- if (goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_SET, ofs, 0, NULL) != 1)
- return -EIO;
- return 0;
-
-invalid_arg:
- pr_err("%s: invalid arg, ofs %llx, dev_size %llx, write_size %x\n",
- __func__, ofs, mtd->size, mtd->writesize);
- return -EINVAL;
-}
-
-static int nand_setup_cmd_params(struct platform_device *pdev,
- struct goldfish_nand *nand)
-{
- dma_addr_t dma_handle;
- unsigned char __iomem *base = nand->base;
-
- nand->cmd_params = dmam_alloc_coherent(&pdev->dev,
- sizeof(struct cmd_params),
- &dma_handle, GFP_KERNEL);
- if (!nand->cmd_params) {
- dev_err(&pdev->dev, "allocate buffer failed\n");
- return -ENOMEM;
- }
- writel((u32)((u64)dma_handle >> 32), base + NAND_CMD_PARAMS_ADDR_HIGH);
- writel((u32)dma_handle, base + NAND_CMD_PARAMS_ADDR_LOW);
- return 0;
-}
-
-static int goldfish_nand_init_device(struct platform_device *pdev,
- struct goldfish_nand *nand, int id)
-{
- u32 name_len;
- u32 result;
- u32 flags;
- unsigned char __iomem *base = nand->base;
- struct mtd_info *mtd = &nand->mtd[id];
- char *name;
-
- mutex_lock(&nand->lock);
- writel(id, base + NAND_DEV);
- flags = readl(base + NAND_DEV_FLAGS);
- name_len = readl(base + NAND_DEV_NAME_LEN);
- mtd->writesize = readl(base + NAND_DEV_PAGE_SIZE);
- mtd->size = readl(base + NAND_DEV_SIZE_LOW);
- mtd->size |= (u64)readl(base + NAND_DEV_SIZE_HIGH) << 32;
- mtd->oobsize = readl(base + NAND_DEV_EXTRA_SIZE);
- mtd->oobavail = mtd->oobsize;
- mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) /
- (mtd->writesize + mtd->oobsize) * mtd->writesize;
- mtd->size = div_s64(mtd->size, mtd->writesize + mtd->oobsize);
- mtd->size *= mtd->writesize;
- dev_dbg(&pdev->dev,
- "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n",
- id, mtd->size, mtd->writesize,
- mtd->oobsize, mtd->erasesize);
- mutex_unlock(&nand->lock);
-
- mtd->priv = nand;
-
- name = devm_kzalloc(&pdev->dev, name_len + 1, GFP_KERNEL);
- if (!name)
- return -ENOMEM;
- mtd->name = name;
-
- result = goldfish_nand_cmd(mtd, NAND_CMD_GET_DEV_NAME, 0, name_len,
- name);
- if (result != name_len) {
- dev_err(&pdev->dev,
- "%s: failed to get dev name %d != %d\n",
- __func__, result, name_len);
- return -ENODEV;
- }
- ((char *)mtd->name)[name_len] = '\0';
-
- /* Setup the MTD structure */
- mtd->type = MTD_NANDFLASH;
- mtd->flags = MTD_CAP_NANDFLASH;
- if (flags & NAND_DEV_FLAG_READ_ONLY)
- mtd->flags &= ~MTD_WRITEABLE;
- if (flags & NAND_DEV_FLAG_CMD_PARAMS_CAP)
- nand_setup_cmd_params(pdev, nand);
-
- mtd->owner = THIS_MODULE;
- mtd->_erase = goldfish_nand_erase;
- mtd->_read = goldfish_nand_read;
- mtd->_write = goldfish_nand_write;
- mtd->_read_oob = goldfish_nand_read_oob;
- mtd->_write_oob = goldfish_nand_write_oob;
- mtd->_block_isbad = goldfish_nand_block_isbad;
- mtd->_block_markbad = goldfish_nand_block_markbad;
-
- if (mtd_device_register(mtd, NULL, 0))
- return -EIO;
-
- return 0;
-}
-
-static int goldfish_nand_probe(struct platform_device *pdev)
-{
- u32 num_dev;
- int i;
- int err;
- u32 num_dev_working;
- u32 version;
- struct resource *r;
- struct goldfish_nand *nand;
- unsigned char __iomem *base;
-
- r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!r)
- return -ENODEV;
-
- base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
- if (!base)
- return -ENOMEM;
-
- version = readl(base + NAND_VERSION);
- if (version != NAND_VERSION_CURRENT) {
- dev_err(&pdev->dev,
- "goldfish_nand_init: version mismatch, got %d, expected %d\n",
- version, NAND_VERSION_CURRENT);
- return -ENODEV;
- }
- num_dev = readl(base + NAND_NUM_DEV);
- if (num_dev == 0)
- return -ENODEV;
-
- nand = devm_kzalloc(&pdev->dev, sizeof(*nand) +
- sizeof(struct mtd_info) * num_dev, GFP_KERNEL);
- if (!nand)
- return -ENOMEM;
-
- mutex_init(&nand->lock);
- nand->base = base;
- nand->mtd_count = num_dev;
- platform_set_drvdata(pdev, nand);
-
- num_dev_working = 0;
- for (i = 0; i < num_dev; i++) {
- err = goldfish_nand_init_device(pdev, nand, i);
- if (err == 0)
- num_dev_working++;
- }
- if (num_dev_working == 0)
- return -ENODEV;
- return 0;
-}
-
-static int goldfish_nand_remove(struct platform_device *pdev)
-{
- struct goldfish_nand *nand = platform_get_drvdata(pdev);
- int i;
-
- for (i = 0; i < nand->mtd_count; i++) {
- if (nand->mtd[i].name)
- mtd_device_unregister(&nand->mtd[i]);
- }
- return 0;
-}
-
-static struct platform_driver goldfish_nand_driver = {
- .probe = goldfish_nand_probe,
- .remove = goldfish_nand_remove,
- .driver = {
- .name = "goldfish_nand"
- }
-};
-
-module_platform_driver(goldfish_nand_driver);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/goldfish/goldfish_nand_reg.h b/drivers/staging/goldfish/goldfish_nand_reg.h
deleted file mode 100644
index 43aeba3a4c8f..000000000000
--- a/drivers/staging/goldfish/goldfish_nand_reg.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * drivers/mtd/devices/goldfish_nand_reg.h
- *
- * Copyright (C) 2007 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef GOLDFISH_NAND_REG_H
-#define GOLDFISH_NAND_REG_H
-
-enum nand_cmd {
- /* Write device name for NAND_DEV to NAND_DATA (vaddr) */
- NAND_CMD_GET_DEV_NAME,
- NAND_CMD_READ,
- NAND_CMD_WRITE,
- NAND_CMD_ERASE,
- /* NAND_RESULT is 1 if block is bad, 0 if it is not */
- NAND_CMD_BLOCK_BAD_GET,
- NAND_CMD_BLOCK_BAD_SET,
- NAND_CMD_READ_WITH_PARAMS,
- NAND_CMD_WRITE_WITH_PARAMS,
- NAND_CMD_ERASE_WITH_PARAMS
-};
-
-enum nand_dev_flags {
- NAND_DEV_FLAG_READ_ONLY = 0x00000001,
- NAND_DEV_FLAG_CMD_PARAMS_CAP = 0x00000002,
-};
-
-#define NAND_VERSION_CURRENT (1)
-
-enum nand_reg {
- /* Global */
- NAND_VERSION = 0x000,
- NAND_NUM_DEV = 0x004,
- NAND_DEV = 0x008,
-
- /* Dev info */
- NAND_DEV_FLAGS = 0x010,
- NAND_DEV_NAME_LEN = 0x014,
- NAND_DEV_PAGE_SIZE = 0x018,
- NAND_DEV_EXTRA_SIZE = 0x01c,
- NAND_DEV_ERASE_SIZE = 0x020,
- NAND_DEV_SIZE_LOW = 0x028,
- NAND_DEV_SIZE_HIGH = 0x02c,
-
- /* Command */
- NAND_RESULT = 0x040,
- NAND_COMMAND = 0x044,
- NAND_DATA = 0x048,
- NAND_DATA_HIGH = 0x100,
- NAND_TRANSFER_SIZE = 0x04c,
- NAND_ADDR_LOW = 0x050,
- NAND_ADDR_HIGH = 0x054,
- NAND_CMD_PARAMS_ADDR_LOW = 0x058,
- NAND_CMD_PARAMS_ADDR_HIGH = 0x05c,
-};
-
-struct cmd_params {
- u32 dev;
- u32 addr_low;
- u32 addr_high;
- u32 transfer_size;
- unsigned long data;
- u32 result;
-};
-#endif
diff --git a/drivers/staging/greybus/TODO b/drivers/staging/greybus/TODO
new file mode 100644
index 000000000000..3b90a5711998
--- /dev/null
+++ b/drivers/staging/greybus/TODO
@@ -0,0 +1,5 @@
+* Convert all uses of the old GPIO API from <linux/gpio.h> to the
+ GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
+ lines from device tree or ACPI.
+* Convert the GPIO driver to use the GPIO irqchip library
+ GPIOLIB_IRQCHIP instead of reimplementing the same.
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index 83254a72a7bb..4c36e88766e7 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -315,8 +315,7 @@ static ssize_t state_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct arche_platform_drvdata *arche_pdata = platform_get_drvdata(pdev);
+ struct arche_platform_drvdata *arche_pdata = dev_get_drvdata(dev);
int ret = 0;
mutex_lock(&arche_pdata->platform_state_mutex);
@@ -448,7 +447,7 @@ static int arche_platform_probe(struct platform_device *pdev)
arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
"svc,reset-gpio",
0);
- if (arche_pdata->svc_reset_gpio < 0) {
+ if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
dev_err(dev, "failed to get reset-gpio\n");
return arche_pdata->svc_reset_gpio;
}
@@ -468,7 +467,7 @@ static int arche_platform_probe(struct platform_device *pdev)
arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
"svc,sysboot-gpio",
0);
- if (arche_pdata->svc_sysboot_gpio < 0) {
+ if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
dev_err(dev, "failed to get sysboot gpio\n");
return arche_pdata->svc_sysboot_gpio;
}
@@ -487,7 +486,7 @@ static int arche_platform_probe(struct platform_device *pdev)
arche_pdata->svc_refclk_req = of_get_named_gpio(np,
"svc,refclk-req-gpio",
0);
- if (arche_pdata->svc_refclk_req < 0) {
+ if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
dev_err(dev, "failed to get svc clock-req gpio\n");
return arche_pdata->svc_refclk_req;
}
diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h
index a1d5440552d4..4efd8b3ebe07 100644
--- a/drivers/staging/greybus/audio_codec.h
+++ b/drivers/staging/greybus/audio_codec.h
@@ -23,7 +23,10 @@ enum {
NUM_CODEC_DAIS,
};
-/* device_type should be same as defined in audio.h (Android media layer) */
+/*
+ * device_type should be same as defined in audio.h
+ * (Android media layer)
+ */
enum {
GBAUDIO_DEVICE_NONE = 0x0,
/* reserved bits */
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index de4b1b2b12f3..15e57f701630 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -996,7 +996,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
ret = gbaudio_validate_kcontrol_count(w);
if (ret) {
- dev_err(module->dev, "Inavlid kcontrol count=%d for %s\n",
+ dev_err(module->dev, "Invalid kcontrol count=%d for %s\n",
w->ncontrols, w->name);
return ret;
}
diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c
index a874fed761a1..a2bb7e1a3db3 100644
--- a/drivers/staging/greybus/svc.c
+++ b/drivers/staging/greybus/svc.c
@@ -1137,7 +1137,6 @@ static int gb_svc_intf_reset_recv(struct gb_operation *op)
struct gb_svc *svc = gb_connection_get_data(op->connection);
struct gb_message *request = op->request;
struct gb_svc_intf_reset_request *reset;
- u8 intf_id;
if (request->payload_size < sizeof(*reset)) {
dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n",
@@ -1146,8 +1145,6 @@ static int gb_svc_intf_reset_recv(struct gb_operation *op)
}
reset = request->payload;
- intf_id = reset->intf_id;
-
/* FIXME Reset the interface here */
return 0;
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index bd9445956511..aee2335a25a1 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -11,7 +11,6 @@ source "drivers/staging/iio/cdc/Kconfig"
source "drivers/staging/iio/frequency/Kconfig"
source "drivers/staging/iio/gyro/Kconfig"
source "drivers/staging/iio/impedance-analyzer/Kconfig"
-source "drivers/staging/iio/light/Kconfig"
source "drivers/staging/iio/meter/Kconfig"
source "drivers/staging/iio/resolver/Kconfig"
diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile
index e99a375c07b9..c28d657497de 100644
--- a/drivers/staging/iio/Makefile
+++ b/drivers/staging/iio/Makefile
@@ -10,6 +10,5 @@ obj-y += cdc/
obj-y += frequency/
obj-y += gyro/
obj-y += impedance-analyzer/
-obj-y += light/
obj-y += meter/
obj-y += resolver/
diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO
index 4922402e2e98..1b8ebf2c1b69 100644
--- a/drivers/staging/iio/TODO
+++ b/drivers/staging/iio/TODO
@@ -1,4 +1,11 @@
-2016 10/09
+2018-04-15
+
+All affected drivers:
+Convert all uses of the old GPIO API from <linux/gpio.h> to the
+GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
+lines from device tree, ACPI or board files, board files should
+use <linux/gpio/machine.h>.
+
ADI Drivers:
CC the device-drivers-devel@blackfin.uclinux.org mailing list when
diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig
index c6b0f5eae7ab..befbbfe911c2 100644
--- a/drivers/staging/iio/accel/Kconfig
+++ b/drivers/staging/iio/accel/Kconfig
@@ -3,18 +3,6 @@
#
menu "Accelerometers"
-config ADIS16201
- tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer"
- depends on SPI
- select IIO_ADIS_LIB
- select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
- help
- Say Y here to build support for Analog Devices adis16201 dual-axis
- digital inclinometer and accelerometer.
-
- To compile this driver as a module, say M here: the module will
- be called adis16201.
-
config ADIS16203
tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer"
depends on SPI
@@ -27,18 +15,6 @@ config ADIS16203
To compile this driver as a module, say M here: the module will be
called adis16203.
-config ADIS16209
- tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer"
- depends on SPI
- select IIO_ADIS_LIB
- select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
- help
- Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer
- and accelerometer.
-
- To compile this driver as a module, say M here: the module will be
- called adis16209.
-
config ADIS16240
tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder"
depends on SPI
diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile
index 5d8ad21a0dae..773212e0c859 100644
--- a/drivers/staging/iio/accel/Makefile
+++ b/drivers/staging/iio/accel/Makefile
@@ -2,7 +2,5 @@
# Makefile for industrial I/O accelerometer drivers
#
-obj-$(CONFIG_ADIS16201) += adis16201.o
obj-$(CONFIG_ADIS16203) += adis16203.o
-obj-$(CONFIG_ADIS16209) += adis16209.o
obj-$(CONFIG_ADIS16240) += adis16240.o
diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c
deleted file mode 100644
index 0fae8aaf1cf4..000000000000
--- a/drivers/staging/iio/accel/adis16201.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/spi/spi.h>
-#include <linux/sysfs.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/imu/adis.h>
-
-#define ADIS16201_STARTUP_DELAY 220 /* ms */
-
-/* Flash memory write count */
-#define ADIS16201_FLASH_CNT 0x00
-
-/* Output, power supply */
-#define ADIS16201_SUPPLY_OUT 0x02
-
-/* Output, x-axis accelerometer */
-#define ADIS16201_XACCL_OUT 0x04
-
-/* Output, y-axis accelerometer */
-#define ADIS16201_YACCL_OUT 0x06
-
-/* Output, auxiliary ADC input */
-#define ADIS16201_AUX_ADC 0x08
-
-/* Output, temperature */
-#define ADIS16201_TEMP_OUT 0x0A
-
-/* Output, x-axis inclination */
-#define ADIS16201_XINCL_OUT 0x0C
-
-/* Output, y-axis inclination */
-#define ADIS16201_YINCL_OUT 0x0E
-
-/* Calibration, x-axis acceleration offset */
-#define ADIS16201_XACCL_OFFS 0x10
-
-/* Calibration, y-axis acceleration offset */
-#define ADIS16201_YACCL_OFFS 0x12
-
-/* x-axis acceleration scale factor */
-#define ADIS16201_XACCL_SCALE 0x14
-
-/* y-axis acceleration scale factor */
-#define ADIS16201_YACCL_SCALE 0x16
-
-/* Calibration, x-axis inclination offset */
-#define ADIS16201_XINCL_OFFS 0x18
-
-/* Calibration, y-axis inclination offset */
-#define ADIS16201_YINCL_OFFS 0x1A
-
-/* x-axis inclination scale factor */
-#define ADIS16201_XINCL_SCALE 0x1C
-
-/* y-axis inclination scale factor */
-#define ADIS16201_YINCL_SCALE 0x1E
-
-/* Alarm 1 amplitude threshold */
-#define ADIS16201_ALM_MAG1 0x20
-
-/* Alarm 2 amplitude threshold */
-#define ADIS16201_ALM_MAG2 0x22
-
-/* Alarm 1, sample period */
-#define ADIS16201_ALM_SMPL1 0x24
-
-/* Alarm 2, sample period */
-#define ADIS16201_ALM_SMPL2 0x26
-
-/* Alarm control */
-#define ADIS16201_ALM_CTRL 0x28
-
-/* Auxiliary DAC data */
-#define ADIS16201_AUX_DAC 0x30
-
-/* General-purpose digital input/output control */
-#define ADIS16201_GPIO_CTRL 0x32
-
-/* Miscellaneous control */
-#define ADIS16201_MSC_CTRL 0x34
-
-/* Internal sample period (rate) control */
-#define ADIS16201_SMPL_PRD 0x36
-
-/* Operation, filter configuration */
-#define ADIS16201_AVG_CNT 0x38
-
-/* Operation, sleep mode control */
-#define ADIS16201_SLP_CNT 0x3A
-
-/* Diagnostics, system status register */
-#define ADIS16201_DIAG_STAT 0x3C
-
-/* Operation, system command register */
-#define ADIS16201_GLOB_CMD 0x3E
-
-/* MSC_CTRL */
-
-/* Self-test enable */
-#define ADIS16201_MSC_CTRL_SELF_TEST_EN BIT(8)
-
-/* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2)
-
-/* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16201_MSC_CTRL_ACTIVE_HIGH BIT(1)
-
-/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
-#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1 BIT(0)
-
-/* DIAG_STAT */
-
-/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16201_DIAG_STAT_ALARM2 BIT(9)
-
-/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16201_DIAG_STAT_ALARM1 BIT(8)
-
-/* SPI communications failure */
-#define ADIS16201_DIAG_STAT_SPI_FAIL_BIT 3
-
-/* Flash update failure */
-#define ADIS16201_DIAG_STAT_FLASH_UPT_BIT 2
-
-/* Power supply above 3.625 V */
-#define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1
-
-/* Power supply below 3.15 V */
-#define ADIS16201_DIAG_STAT_POWER_LOW_BIT 0
-
-/* GLOB_CMD */
-
-#define ADIS16201_GLOB_CMD_SW_RESET BIT(7)
-#define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1)
-
-#define ADIS16201_ERROR_ACTIVE BIT(14)
-
-enum adis16201_scan {
- ADIS16201_SCAN_ACC_X,
- ADIS16201_SCAN_ACC_Y,
- ADIS16201_SCAN_INCLI_X,
- ADIS16201_SCAN_INCLI_Y,
- ADIS16201_SCAN_SUPPLY,
- ADIS16201_SCAN_AUX_ADC,
- ADIS16201_SCAN_TEMP,
-};
-
-static const u8 adis16201_addresses[] = {
- [ADIS16201_SCAN_ACC_X] = ADIS16201_XACCL_OFFS,
- [ADIS16201_SCAN_ACC_Y] = ADIS16201_YACCL_OFFS,
- [ADIS16201_SCAN_INCLI_X] = ADIS16201_XINCL_OFFS,
- [ADIS16201_SCAN_INCLI_Y] = ADIS16201_YINCL_OFFS,
-};
-
-static int adis16201_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val, int *val2,
- long mask)
-{
- struct adis *st = iio_priv(indio_dev);
- int ret;
- int bits;
- u8 addr;
- s16 val16;
-
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- return adis_single_conversion(indio_dev, chan,
- ADIS16201_ERROR_ACTIVE, val);
- case IIO_CHAN_INFO_SCALE:
- switch (chan->type) {
- case IIO_VOLTAGE:
- if (chan->channel == 0) {
- *val = 1;
- *val2 = 220000; /* 1.22 mV */
- } else {
- *val = 0;
- *val2 = 610000; /* 0.610 mV */
- }
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_TEMP:
- *val = -470; /* 0.47 C */
- *val2 = 0;
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_ACCEL:
- *val = 0;
- *val2 = IIO_G_TO_M_S_2(462400); /* 0.4624 mg */
- return IIO_VAL_INT_PLUS_NANO;
- case IIO_INCLI:
- *val = 0;
- *val2 = 100000; /* 0.1 degree */
- return IIO_VAL_INT_PLUS_MICRO;
- default:
- return -EINVAL;
- }
- break;
- case IIO_CHAN_INFO_OFFSET:
- *val = 25000 / -470 - 1278; /* 25 C = 1278 */
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBBIAS:
- switch (chan->type) {
- case IIO_ACCEL:
- bits = 12;
- break;
- case IIO_INCLI:
- bits = 9;
- break;
- default:
- return -EINVAL;
- }
- addr = adis16201_addresses[chan->scan_index];
- ret = adis_read_reg_16(st, addr, &val16);
- if (ret)
- return ret;
- val16 &= (1 << bits) - 1;
- val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
- *val = val16;
- return IIO_VAL_INT;
- }
-
- return -EINVAL;
-}
-
-static int adis16201_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct adis *st = iio_priv(indio_dev);
- int bits;
- s16 val16;
- u8 addr;
-
- switch (mask) {
- case IIO_CHAN_INFO_CALIBBIAS:
- switch (chan->type) {
- case IIO_ACCEL:
- bits = 12;
- break;
- case IIO_INCLI:
- bits = 9;
- break;
- default:
- return -EINVAL;
- }
- val16 = val & ((1 << bits) - 1);
- addr = adis16201_addresses[chan->scan_index];
- return adis_write_reg_16(st, addr, val16);
- }
-
- return -EINVAL;
-}
-
-static const struct iio_chan_spec adis16201_channels[] = {
- ADIS_SUPPLY_CHAN(ADIS16201_SUPPLY_OUT, ADIS16201_SCAN_SUPPLY, 0, 12),
- ADIS_TEMP_CHAN(ADIS16201_TEMP_OUT, ADIS16201_SCAN_TEMP, 0, 12),
- ADIS_ACCEL_CHAN(X, ADIS16201_XACCL_OUT, ADIS16201_SCAN_ACC_X,
- BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
- ADIS_ACCEL_CHAN(Y, ADIS16201_YACCL_OUT, ADIS16201_SCAN_ACC_Y,
- BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
- ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC, ADIS16201_SCAN_AUX_ADC, 0, 12),
- ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT, ADIS16201_SCAN_INCLI_X,
- BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
- ADIS_INCLI_CHAN(X, ADIS16201_YINCL_OUT, ADIS16201_SCAN_INCLI_Y,
- BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
- IIO_CHAN_SOFT_TIMESTAMP(7)
-};
-
-static const struct iio_info adis16201_info = {
- .read_raw = adis16201_read_raw,
- .write_raw = adis16201_write_raw,
- .update_scan_mode = adis_update_scan_mode,
-};
-
-static const char * const adis16201_status_error_msgs[] = {
- [ADIS16201_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure",
- [ADIS16201_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed",
- [ADIS16201_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V",
- [ADIS16201_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V",
-};
-
-static const struct adis_data adis16201_data = {
- .read_delay = 20,
- .msc_ctrl_reg = ADIS16201_MSC_CTRL,
- .glob_cmd_reg = ADIS16201_GLOB_CMD,
- .diag_stat_reg = ADIS16201_DIAG_STAT,
-
- .self_test_mask = ADIS16201_MSC_CTRL_SELF_TEST_EN,
- .self_test_no_autoclear = true,
- .startup_delay = ADIS16201_STARTUP_DELAY,
-
- .status_error_msgs = adis16201_status_error_msgs,
- .status_error_mask = BIT(ADIS16201_DIAG_STAT_SPI_FAIL_BIT) |
- BIT(ADIS16201_DIAG_STAT_FLASH_UPT_BIT) |
- BIT(ADIS16201_DIAG_STAT_POWER_HIGH_BIT) |
- BIT(ADIS16201_DIAG_STAT_POWER_LOW_BIT),
-};
-
-static int adis16201_probe(struct spi_device *spi)
-{
- int ret;
- struct adis *st;
- struct iio_dev *indio_dev;
-
- /* setup the industrialio driver allocated elements */
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev)
- return -ENOMEM;
-
- st = iio_priv(indio_dev);
- /* this is only used for removal purposes */
- spi_set_drvdata(spi, indio_dev);
-
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &adis16201_info;
-
- indio_dev->channels = adis16201_channels;
- indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- ret = adis_init(st, indio_dev, spi, &adis16201_data);
- if (ret)
- return ret;
-
- ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
- if (ret)
- return ret;
-
- /* Get the device into a sane initial state */
- ret = adis_initial_startup(st);
- if (ret)
- goto error_cleanup_buffer_trigger;
-
- ret = iio_device_register(indio_dev);
- if (ret < 0)
- goto error_cleanup_buffer_trigger;
-
- return 0;
-
-error_cleanup_buffer_trigger:
- adis_cleanup_buffer_and_trigger(st, indio_dev);
- return ret;
-}
-
-static int adis16201_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct adis *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- adis_cleanup_buffer_and_trigger(st, indio_dev);
-
- return 0;
-}
-
-static struct spi_driver adis16201_driver = {
- .driver = {
- .name = "adis16201",
- },
- .probe = adis16201_probe,
- .remove = adis16201_remove,
-};
-module_spi_driver(adis16201_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:adis16201");
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index 3eb6f8f312dd..a34c2a1d5373 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -18,8 +18,7 @@
static int ad7606_par16_read_block(struct device *dev,
int count, void *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad7606_state *st = iio_priv(indio_dev);
insw((unsigned long)st->base_address, buf, count);
@@ -34,8 +33,7 @@ static const struct ad7606_bus_ops ad7606_par16_bops = {
static int ad7606_par8_read_block(struct device *dev,
int count, void *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad7606_state *st = iio_priv(indio_dev);
insb((unsigned long)st->base_address, buf, count * 2);
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index a7797af579b9..16d72072c076 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -128,7 +128,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
};
#define AD7780_CHANNEL(bits, wordsize) \
- AD_SD_CHANNEL(1, 0, 0, bits, 32, wordsize - bits)
+ AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)
static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
[ID_AD7170] = {
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 4882dbc81c53..f53612a6461d 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -6,15 +6,15 @@
* Licensed under the GPL-2.
*/
-#include <linux/interrupt.h>
+#include <linux/delay.h>
#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
#include <linux/i2c.h>
-#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/stat.h>
+#include <linux/sysfs.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -220,8 +220,8 @@ static int ad7746_select_channel(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan)
{
struct ad7746_chip_info *chip = iio_priv(indio_dev);
- int ret, delay, idx;
u8 vt_setup, cap_setup;
+ int ret, delay, idx;
switch (chan->type) {
case IIO_CAPACITANCE:
@@ -289,8 +289,8 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
- bool doit;
int ret, timeout = 10;
+ bool doit;
ret = strtobool(buf, &doit);
if (ret < 0)
@@ -410,8 +410,7 @@ static struct attribute *ad7746_attributes[] = {
&iio_dev_attr_in_capacitance1_calibbias_calibration.dev_attr.attr,
&iio_dev_attr_in_voltage0_calibscale_calibration.dev_attr.attr,
&iio_const_attr_in_voltage_sampling_frequency_available.dev_attr.attr,
- &iio_const_attr_in_capacitance_sampling_frequency_available.
- dev_attr.attr,
+ &iio_const_attr_in_capacitance_sampling_frequency_available.dev_attr.attr,
NULL,
};
@@ -451,26 +450,26 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
goto out;
}
- ret = i2c_smbus_write_word_data(chip->client, reg, swab16(val));
+ ret = i2c_smbus_write_word_swapped(chip->client, reg, val);
if (ret < 0)
goto out;
ret = 0;
break;
case IIO_CHAN_INFO_CALIBBIAS:
- if ((val < 0) | (val > 0xFFFF)) {
+ if (val < 0 || val > 0xFFFF) {
ret = -EINVAL;
goto out;
}
- ret = i2c_smbus_write_word_data(chip->client,
- AD7746_REG_CAP_OFFH, swab16(val));
+ ret = i2c_smbus_write_word_swapped(chip->client,
+ AD7746_REG_CAP_OFFH, val);
if (ret < 0)
goto out;
ret = 0;
break;
case IIO_CHAN_INFO_OFFSET:
- if ((val < 0) | (val > 43008000)) { /* 21pF */
+ if (val < 0 || val > 43008000) { /* 21pF */
ret = -EINVAL;
goto out;
}
@@ -556,7 +555,8 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
/* Now read the actual register */
ret = i2c_smbus_read_i2c_block_data(chip->client,
- chan->address >> 8, 3, &chip->data.d8[1]);
+ chan->address >> 8, 3,
+ &chip->data.d8[1]);
if (ret < 0)
goto out;
@@ -594,27 +594,27 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
goto out;
}
- ret = i2c_smbus_read_word_data(chip->client, reg);
+ ret = i2c_smbus_read_word_swapped(chip->client, reg);
if (ret < 0)
goto out;
/* 1 + gain_val / 2^16 */
*val = 1;
- *val2 = (15625 * swab16(ret)) / 1024;
+ *val2 = (15625 * ret) / 1024;
ret = IIO_VAL_INT_PLUS_MICRO;
break;
case IIO_CHAN_INFO_CALIBBIAS:
- ret = i2c_smbus_read_word_data(chip->client,
- AD7746_REG_CAP_OFFH);
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ AD7746_REG_CAP_OFFH);
if (ret < 0)
goto out;
- *val = swab16(ret);
+ *val = ret;
ret = IIO_VAL_INT;
break;
case IIO_CHAN_INFO_OFFSET:
*val = AD7746_CAPDAC_DACP(chip->capdac[chan->channel]
- [chan->differential]) * 338646;
+ [chan->differential]) * 338646;
ret = IIO_VAL_INT;
break;
@@ -680,8 +680,8 @@ static int ad7746_probe(struct i2c_client *client,
struct ad7746_platform_data *pdata = client->dev.platform_data;
struct ad7746_chip_info *chip;
struct iio_dev *indio_dev;
- int ret = 0;
unsigned char regval = 0;
+ int ret = 0;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
if (!indio_dev)
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
deleted file mode 100644
index aacb0ae58c0e..000000000000
--- a/drivers/staging/iio/light/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Light sensors
-#
-menu "Light sensors"
-
-config TSL2x7x
- tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors"
- depends on I2C
- help
- Support for: tsl2571, tsl2671, tmd2671, tsl2771, tmd2771, tsl2572, tsl2672,
- tmd2672, tsl2772, tmd2772 devices.
- Provides iio_events and direct access via sysfs.
-
-endmenu
diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile
deleted file mode 100644
index ab8dc3a3d10b..000000000000
--- a/drivers/staging/iio/light/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for industrial I/O Light sensors
-#
-
-obj-$(CONFIG_TSL2x7x) += tsl2x7x.o
diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
deleted file mode 100644
index 82681300e106..000000000000
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ /dev/null
@@ -1,1889 +0,0 @@
-/*
- * Device driver for monitoring ambient light intensity in (lux)
- * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
- *
- * Copyright (c) 2012, TAOS Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- */
-
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/i2c.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/iio/events.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include "tsl2x7x.h"
-
-/* Cal defs*/
-#define PROX_STAT_CAL 0
-#define PROX_STAT_SAMP 1
-#define MAX_SAMPLES_CAL 200
-
-/* TSL2X7X Device ID */
-#define TRITON_ID 0x00
-#define SWORDFISH_ID 0x30
-#define HALIBUT_ID 0x20
-
-/* Lux calculation constants */
-#define TSL2X7X_LUX_CALC_OVER_FLOW 65535
-
-/* TAOS Register definitions - note:
- * depending on device, some of these register are not used and the
- * register address is benign.
- */
-/* 2X7X register offsets */
-#define TSL2X7X_MAX_CONFIG_REG 16
-
-/* Device Registers and Masks */
-#define TSL2X7X_CNTRL 0x00
-#define TSL2X7X_ALS_TIME 0X01
-#define TSL2X7X_PRX_TIME 0x02
-#define TSL2X7X_WAIT_TIME 0x03
-#define TSL2X7X_ALS_MINTHRESHLO 0X04
-#define TSL2X7X_ALS_MINTHRESHHI 0X05
-#define TSL2X7X_ALS_MAXTHRESHLO 0X06
-#define TSL2X7X_ALS_MAXTHRESHHI 0X07
-#define TSL2X7X_PRX_MINTHRESHLO 0X08
-#define TSL2X7X_PRX_MINTHRESHHI 0X09
-#define TSL2X7X_PRX_MAXTHRESHLO 0X0A
-#define TSL2X7X_PRX_MAXTHRESHHI 0X0B
-#define TSL2X7X_PERSISTENCE 0x0C
-#define TSL2X7X_PRX_CONFIG 0x0D
-#define TSL2X7X_PRX_COUNT 0x0E
-#define TSL2X7X_GAIN 0x0F
-#define TSL2X7X_NOTUSED 0x10
-#define TSL2X7X_REVID 0x11
-#define TSL2X7X_CHIPID 0x12
-#define TSL2X7X_STATUS 0x13
-#define TSL2X7X_ALS_CHAN0LO 0x14
-#define TSL2X7X_ALS_CHAN0HI 0x15
-#define TSL2X7X_ALS_CHAN1LO 0x16
-#define TSL2X7X_ALS_CHAN1HI 0x17
-#define TSL2X7X_PRX_LO 0x18
-#define TSL2X7X_PRX_HI 0x19
-
-/* tsl2X7X cmd reg masks */
-#define TSL2X7X_CMD_REG 0x80
-#define TSL2X7X_CMD_SPL_FN 0x60
-
-#define TSL2X7X_CMD_PROX_INT_CLR 0X05
-#define TSL2X7X_CMD_ALS_INT_CLR 0x06
-#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07
-
-/* tsl2X7X cntrl reg masks */
-#define TSL2X7X_CNTL_ADC_ENBL 0x02
-#define TSL2X7X_CNTL_PWR_ON 0x01
-
-/* tsl2X7X status reg masks */
-#define TSL2X7X_STA_ADC_VALID 0x01
-#define TSL2X7X_STA_PRX_VALID 0x02
-#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID | \
- TSL2X7X_STA_PRX_VALID)
-#define TSL2X7X_STA_ALS_INTR 0x10
-#define TSL2X7X_STA_PRX_INTR 0x20
-
-/* tsl2X7X cntrl reg masks */
-#define TSL2X7X_CNTL_REG_CLEAR 0x00
-#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20
-#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10
-#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08
-#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04
-#define TSL2X7X_CNTL_PWRON 0x01
-#define TSL2X7X_CNTL_ALSPON_ENBL 0x03
-#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13
-#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F
-#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F
-
-/*Prox diode to use */
-#define TSL2X7X_DIODE0 0x01
-#define TSL2X7X_DIODE1 0x02
-#define TSL2X7X_DIODE_BOTH 0x03
-
-/* LED Power */
-#define TSL2X7X_100_mA 0x00
-#define TSL2X7X_50_mA 0x01
-#define TSL2X7X_25_mA 0x02
-#define TSL2X7X_13_mA 0x03
-#define TSL2X7X_MAX_TIMER_CNT 0xFF
-
-#define TSL2X7X_MIN_ITIME 3
-
-/* TAOS txx2x7x Device family members */
-enum {
- tsl2571,
- tsl2671,
- tmd2671,
- tsl2771,
- tmd2771,
- tsl2572,
- tsl2672,
- tmd2672,
- tsl2772,
- tmd2772
-};
-
-enum {
- TSL2X7X_CHIP_UNKNOWN = 0,
- TSL2X7X_CHIP_WORKING = 1,
- TSL2X7X_CHIP_SUSPENDED = 2
-};
-
-/* Per-device data */
-struct tsl2x7x_als_info {
- u16 als_ch0;
- u16 als_ch1;
- u16 lux;
-};
-
-struct tsl2x7x_prox_stat {
- int min;
- int max;
- int mean;
- unsigned long stddev;
-};
-
-struct tsl2x7x_chip_info {
- int chan_table_elements;
- struct iio_chan_spec channel[4];
- const struct iio_info *info;
-};
-
-struct tsl2X7X_chip {
- kernel_ulong_t id;
- struct mutex prox_mutex;
- struct mutex als_mutex;
- struct i2c_client *client;
- u16 prox_data;
- struct tsl2x7x_als_info als_cur_info;
- struct tsl2x7x_settings settings;
- struct tsl2X7X_platform_data *pdata;
- int als_time_scale;
- int als_saturation;
- int tsl2x7x_chip_status;
- u8 tsl2x7x_config[TSL2X7X_MAX_CONFIG_REG];
- const struct tsl2x7x_chip_info *chip_info;
- const struct iio_info *info;
- s64 event_timestamp;
- /*
- * This structure is intentionally large to accommodate
- * updates via sysfs.
- * Sized to 9 = max 8 segments + 1 termination segment
- */
- struct tsl2x7x_lux tsl2x7x_device_lux[TSL2X7X_MAX_LUX_TABLE_SIZE];
-};
-
-/* Different devices require different coefficents */
-static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
- { 14461, 611, 1211 },
- { 18540, 352, 623 },
- { 0, 0, 0 },
-};
-
-static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
- { 11635, 115, 256 },
- { 15536, 87, 179 },
- { 0, 0, 0 },
-};
-
-static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
- { 14013, 466, 917 },
- { 18222, 310, 552 },
- { 0, 0, 0 },
-};
-
-static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
- { 13218, 130, 262 },
- { 17592, 92, 169 },
- { 0, 0, 0 },
-};
-
-static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
- [tsl2571] = tsl2x71_lux_table,
- [tsl2671] = tsl2x71_lux_table,
- [tmd2671] = tmd2x71_lux_table,
- [tsl2771] = tsl2x71_lux_table,
- [tmd2771] = tmd2x71_lux_table,
- [tsl2572] = tsl2x72_lux_table,
- [tsl2672] = tsl2x72_lux_table,
- [tmd2672] = tmd2x72_lux_table,
- [tsl2772] = tsl2x72_lux_table,
- [tmd2772] = tmd2x72_lux_table,
-};
-
-static const struct tsl2x7x_settings tsl2x7x_default_settings = {
- .als_time = 219, /* 101 ms */
- .als_gain = 0,
- .prx_time = 254, /* 5.4 ms */
- .prox_gain = 0,
- .wait_time = 245,
- .prox_config = 0,
- .als_gain_trim = 1000,
- .als_cal_target = 150,
- .als_thresh_low = 200,
- .als_thresh_high = 256,
- .persistence = 255,
- .interrupts_en = 0,
- .prox_thres_low = 0,
- .prox_thres_high = 512,
- .prox_max_samples_cal = 30,
- .prox_pulse_count = 8,
- .prox_diode = TSL2X7X_DIODE1,
- .prox_power = TSL2X7X_100_mA
-};
-
-static const s16 tsl2x7x_als_gain[] = {
- 1,
- 8,
- 16,
- 120
-};
-
-static const s16 tsl2x7x_prx_gain[] = {
- 1,
- 2,
- 4,
- 8
-};
-
-/* Channel variations */
-enum {
- ALS,
- PRX,
- ALSPRX,
- PRX2,
- ALSPRX2,
-};
-
-static const u8 device_channel_config[] = {
- ALS,
- PRX,
- PRX,
- ALSPRX,
- ALSPRX,
- ALS,
- PRX2,
- PRX2,
- ALSPRX2,
- ALSPRX2
-};
-
-static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
-{
- int ret;
-
- ret = i2c_smbus_write_byte(chip->client,
- TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
- if (ret < 0)
- dev_err(&chip->client->dev,
- "%s: failed to clear interrupt status %x: %d\n",
- __func__, reg, ret);
-
- return ret;
-}
-
-static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
-{
- int ret;
-
- ret = i2c_smbus_read_byte_data(chip->client,
- TSL2X7X_CMD_REG | TSL2X7X_STATUS);
- if (ret < 0)
- dev_err(&chip->client->dev,
- "%s: failed to read STATUS register: %d\n", __func__,
- ret);
-
- return ret;
-}
-
-static int tsl2x7x_write_control_reg(struct tsl2X7X_chip *chip, u8 data)
-{
- int ret;
-
- ret = i2c_smbus_write_byte_data(chip->client,
- TSL2X7X_CMD_REG | TSL2X7X_CNTRL, data);
- if (ret < 0) {
- dev_err(&chip->client->dev,
- "%s: failed to write to control register %x: %d\n",
- __func__, data, ret);
- }
-
- return ret;
-}
-
-/**
- * tsl2x7x_get_lux() - Reads and calculates current lux value.
- * @indio_dev: pointer to IIO device
- *
- * The raw ch0 and ch1 values of the ambient light sensed in the last
- * integration cycle are read from the device.
- * Time scale factor array values are adjusted based on the integration time.
- * The raw values are multiplied by a scale factor, and device gain is obtained
- * using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
- * is then scanned to find the first ratio value that is just above the ratio
- * we just calculated. The ch0 and ch1 multiplier constants in the array are
- * then used along with the time scale factor array values, to calculate the
- * lux.
- */
-static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
-{
- u16 ch0, ch1; /* separated ch0/ch1 data from device */
- u32 lux; /* raw lux calculated from device data */
- u64 lux64;
- u32 ratio;
- u8 buf[4];
- struct tsl2x7x_lux *p;
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int i, ret;
- u32 ch0lux = 0;
- u32 ch1lux = 0;
-
- mutex_lock(&chip->als_mutex);
-
- if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
- /* device is not enabled */
- dev_err(&chip->client->dev, "%s: device is not enabled\n",
- __func__);
- ret = -EBUSY;
- goto out_unlock;
- }
-
- ret = tsl2x7x_read_status(chip);
- if (ret < 0)
- goto out_unlock;
-
- /* is data new & valid */
- if (!(ret & TSL2X7X_STA_ADC_VALID)) {
- dev_err(&chip->client->dev,
- "%s: data not valid yet\n", __func__);
- ret = chip->als_cur_info.lux; /* return LAST VALUE */
- goto out_unlock;
- }
-
- for (i = 0; i < 4; i++) {
- int reg = TSL2X7X_CMD_REG | (TSL2X7X_ALS_CHAN0LO + i);
-
- ret = i2c_smbus_read_byte_data(chip->client, reg);
- if (ret < 0) {
- dev_err(&chip->client->dev,
- "failed to read. err=%x\n", ret);
- goto out_unlock;
- }
-
- buf[i] = ret;
- }
-
- ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_ALS_INT_CLR);
- if (ret < 0)
- goto out_unlock;
-
- /* extract ALS/lux data */
- ch0 = le16_to_cpup((const __le16 *)&buf[0]);
- ch1 = le16_to_cpup((const __le16 *)&buf[2]);
-
- chip->als_cur_info.als_ch0 = ch0;
- chip->als_cur_info.als_ch1 = ch1;
-
- if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
- lux = TSL2X7X_LUX_CALC_OVER_FLOW;
- goto return_max;
- }
-
- if (!ch0) {
- /* have no data, so return LAST VALUE */
- ret = chip->als_cur_info.lux;
- goto out_unlock;
- }
- /* calculate ratio */
- ratio = (ch1 << 15) / ch0;
- /* convert to unscaled lux using the pointer to the table */
- p = (struct tsl2x7x_lux *)chip->tsl2x7x_device_lux;
- while (p->ratio != 0 && p->ratio < ratio)
- p++;
-
- if (p->ratio == 0) {
- lux = 0;
- } else {
- lux = DIV_ROUND_UP(ch0 * p->ch0,
- tsl2x7x_als_gain[chip->settings.als_gain]) -
- DIV_ROUND_UP(ch1 * p->ch1,
- tsl2x7x_als_gain[chip->settings.als_gain]);
- }
-
- /* note: lux is 31 bit max at this point */
- if (ch1lux > ch0lux) {
- dev_dbg(&chip->client->dev, "ch1lux > ch0lux-return last value\n");
- ret = chip->als_cur_info.lux;
- goto out_unlock;
- }
-
- /* adjust for active time scale */
- if (chip->als_time_scale == 0)
- lux = 0;
- else
- lux = (lux + (chip->als_time_scale >> 1)) /
- chip->als_time_scale;
-
- /* adjust for active gain scale
- * The tsl2x7x_device_lux tables have a factor of 256 built-in.
- * User-specified gain provides a multiplier.
- * Apply user-specified gain before shifting right to retain precision.
- * Use 64 bits to avoid overflow on multiplication.
- * Then go back to 32 bits before division to avoid using div_u64().
- */
-
- lux64 = lux;
- lux64 = lux64 * chip->settings.als_gain_trim;
- lux64 >>= 8;
- lux = lux64;
- lux = (lux + 500) / 1000;
-
- if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */
- lux = TSL2X7X_LUX_CALC_OVER_FLOW;
-
- /* Update the structure with the latest lux. */
-return_max:
- chip->als_cur_info.lux = lux;
- ret = lux;
-
-out_unlock:
- mutex_unlock(&chip->als_mutex);
-
- return ret;
-}
-
-/**
- * tsl2x7x_get_prox() - Reads proximity data registers and updates
- * chip->prox_data.
- *
- * @indio_dev: pointer to IIO device
- */
-static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
-{
- int i;
- int ret;
- u8 chdata[2];
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-
- mutex_lock(&chip->prox_mutex);
-
- ret = tsl2x7x_read_status(chip);
- if (ret < 0)
- goto prox_poll_err;
-
- switch (chip->id) {
- case tsl2571:
- case tsl2671:
- case tmd2671:
- case tsl2771:
- case tmd2771:
- if (!(ret & TSL2X7X_STA_ADC_VALID)) {
- ret = -EINVAL;
- goto prox_poll_err;
- }
- break;
- case tsl2572:
- case tsl2672:
- case tmd2672:
- case tsl2772:
- case tmd2772:
- if (!(ret & TSL2X7X_STA_PRX_VALID)) {
- ret = -EINVAL;
- goto prox_poll_err;
- }
- break;
- }
-
- for (i = 0; i < 2; i++) {
- int reg = TSL2X7X_CMD_REG | (TSL2X7X_PRX_LO + i);
-
- ret = i2c_smbus_read_byte_data(chip->client, reg);
- if (ret < 0)
- goto prox_poll_err;
-
- chdata[i] = ret;
- }
-
- chip->prox_data = le16_to_cpup((const __le16 *)&chdata[0]);
- ret = chip->prox_data;
-
-prox_poll_err:
- mutex_unlock(&chip->prox_mutex);
-
- return ret;
-}
-
-/**
- * tsl2x7x_defaults() - Populates the device nominal operating parameters
- * with those provided by a 'platform' data struct or
- * with prefined defaults.
- *
- * @chip: pointer to device structure.
- */
-static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
-{
- /* If Operational settings defined elsewhere.. */
- if (chip->pdata && chip->pdata->platform_default_settings)
- memcpy(&chip->settings, chip->pdata->platform_default_settings,
- sizeof(tsl2x7x_default_settings));
- else
- memcpy(&chip->settings, &tsl2x7x_default_settings,
- sizeof(tsl2x7x_default_settings));
-
- /* Load up the proper lux table. */
- if (chip->pdata && chip->pdata->platform_lux_table[0].ratio != 0)
- memcpy(chip->tsl2x7x_device_lux,
- chip->pdata->platform_lux_table,
- sizeof(chip->pdata->platform_lux_table));
- else
- memcpy(chip->tsl2x7x_device_lux,
- tsl2x7x_default_lux_table_group[chip->id],
- TSL2X7X_DEFAULT_TABLE_BYTES);
-}
-
-/**
- * tsl2x7x_als_calibrate() - Obtain single reading and calculate
- * the als_gain_trim.
- *
- * @indio_dev: pointer to IIO device
- */
-static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret, lux_val;
-
- ret = i2c_smbus_read_byte_data(chip->client,
- TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
- if (ret < 0) {
- dev_err(&chip->client->dev,
- "%s: failed to read from the CNTRL register\n",
- __func__);
- return ret;
- }
-
- if ((ret & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
- != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
- dev_err(&chip->client->dev,
- "%s: Device is not powered on and/or ADC is not enabled\n",
- __func__);
- return -EINVAL;
- } else if ((ret & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
- dev_err(&chip->client->dev,
- "%s: The two ADC channels have not completed an integration cycle\n",
- __func__);
- return -ENODATA;
- }
-
- lux_val = tsl2x7x_get_lux(indio_dev);
- if (lux_val < 0) {
- dev_err(&chip->client->dev,
- "%s: failed to get lux\n", __func__);
- return lux_val;
- }
-
- ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) /
- lux_val;
- if (ret < 250 || ret > 4000)
- return -ERANGE;
-
- chip->settings.als_gain_trim = ret;
- dev_info(&chip->client->dev,
- "%s als_calibrate completed\n", chip->client->name);
-
- return ret;
-}
-
-static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
-{
- int i;
- int ret = 0;
- u8 *dev_reg;
- int als_count;
- int als_time;
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- u8 reg_val = 0;
-
- /* Non calculated parameters */
- chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
- chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
- chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
-
- chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
- (chip->settings.als_thresh_low) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] =
- (chip->settings.als_thresh_low >> 8) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] =
- (chip->settings.als_thresh_high) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] =
- (chip->settings.als_thresh_high >> 8) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = chip->settings.persistence;
-
- chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
- chip->settings.prox_pulse_count;
- chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
- (chip->settings.prox_thres_low) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
- (chip->settings.prox_thres_low >> 8) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
- (chip->settings.prox_thres_high) & 0xFF;
- chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
- (chip->settings.prox_thres_high >> 8) & 0xFF;
-
- /* and make sure we're not already on */
- if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
- /* if forcing a register update - turn off, then on */
- dev_info(&chip->client->dev, "device is already enabled\n");
- return -EINVAL;
- }
-
- /* determine als integration register */
- als_count = (chip->settings.als_time * 100 + 135) / 270;
- if (!als_count)
- als_count = 1; /* ensure at least one cycle */
-
- /* convert back to time (encompasses overrides) */
- als_time = (als_count * 27 + 5) / 10;
- chip->tsl2x7x_config[TSL2X7X_ALS_TIME] = 256 - als_count;
-
- /* Set the gain based on tsl2x7x_settings struct */
- chip->tsl2x7x_config[TSL2X7X_GAIN] =
- (chip->settings.als_gain & 0xFF) |
- ((chip->settings.prox_gain & 0xFF) << 2) |
- (chip->settings.prox_diode << 4) |
- (chip->settings.prox_power << 6);
-
- /* set chip struct re scaling and saturation */
- chip->als_saturation = als_count * 922; /* 90% of full scale */
- chip->als_time_scale = (als_time + 25) / 50;
-
- /*
- * TSL2X7X Specific power-on / adc enable sequence
- * Power on the device 1st.
- */
- ret = tsl2x7x_write_control_reg(chip, TSL2X7X_CNTL_PWR_ON);
- if (ret < 0)
- return ret;
-
- /*
- * Use the following shadow copy for our delay before enabling ADC.
- * Write all the registers.
- */
- for (i = 0, dev_reg = chip->tsl2x7x_config;
- i < TSL2X7X_MAX_CONFIG_REG; i++) {
- ret = i2c_smbus_write_byte_data(chip->client,
- TSL2X7X_CMD_REG + i,
- *dev_reg++);
- if (ret < 0) {
- dev_err(&chip->client->dev,
- "failed on write to reg %d.\n", i);
- return ret;
- }
- }
-
- /* Power-on settling time */
- usleep_range(3000, 3500);
-
- /*
- * NOW enable the ADC
- * initialize the desired mode of operation
- */
- ret = tsl2x7x_write_control_reg(chip,
- TSL2X7X_CNTL_PWR_ON |
- TSL2X7X_CNTL_ADC_ENBL |
- TSL2X7X_CNTL_PROX_DET_ENBL);
- if (ret < 0)
- return ret;
-
- chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
-
- if (chip->settings.interrupts_en != 0) {
- dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n");
-
- reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL;
- if (chip->settings.interrupts_en == 0x20 ||
- chip->settings.interrupts_en == 0x30)
- reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL;
-
- reg_val |= chip->settings.interrupts_en;
- ret = tsl2x7x_write_control_reg(chip, reg_val);
- if (ret < 0)
- return ret;
-
- ret = tsl2x7x_clear_interrupts(chip,
- TSL2X7X_CMD_PROXALS_INT_CLR);
- if (ret < 0)
- return ret;
- }
-
- return ret;
-}
-
-static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-
- /* turn device off */
- chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
- return tsl2x7x_write_control_reg(chip, 0x00);
-}
-
-/**
- * tsl2x7x_invoke_change
- * @indio_dev: pointer to IIO device
- *
- * Obtain and lock both ALS and PROX resources,
- * determine and save device state (On/Off),
- * cycle device to implement updated parameter,
- * put device back into proper state, and unlock
- * resource.
- */
-static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int device_status = chip->tsl2x7x_chip_status;
- int ret;
-
- mutex_lock(&chip->als_mutex);
- mutex_lock(&chip->prox_mutex);
-
- if (device_status == TSL2X7X_CHIP_WORKING) {
- ret = tsl2x7x_chip_off(indio_dev);
- if (ret < 0)
- goto unlock;
- }
-
- ret = tsl2x7x_chip_on(indio_dev);
-
-unlock:
- mutex_unlock(&chip->prox_mutex);
- mutex_unlock(&chip->als_mutex);
-
- return ret;
-}
-
-static void tsl2x7x_prox_calculate(int *data, int length,
- struct tsl2x7x_prox_stat *stat)
-{
- int i;
- int sample_sum;
- int tmp;
-
- if (!length)
- length = 1;
-
- sample_sum = 0;
- stat->min = INT_MAX;
- stat->max = INT_MIN;
- for (i = 0; i < length; i++) {
- sample_sum += data[i];
- stat->min = min(stat->min, data[i]);
- stat->max = max(stat->max, data[i]);
- }
-
- stat->mean = sample_sum / length;
- sample_sum = 0;
- for (i = 0; i < length; i++) {
- tmp = data[i] - stat->mean;
- sample_sum += tmp * tmp;
- }
- stat->stddev = int_sqrt((long)sample_sum / length);
-}
-
-/**
- * tsl2x7x_prox_cal() - Calculates std. and sets thresholds.
- * @indio_dev: pointer to IIO device
- *
- * Calculates a standard deviation based on the samples,
- * and sets the threshold accordingly.
- */
-static int tsl2x7x_prox_cal(struct iio_dev *indio_dev)
-{
- int prox_history[MAX_SAMPLES_CAL + 1];
- int i, ret;
- struct tsl2x7x_prox_stat prox_stat_data[2];
- struct tsl2x7x_prox_stat *cal;
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- u8 tmp_irq_settings;
- u8 current_state = chip->tsl2x7x_chip_status;
-
- if (chip->settings.prox_max_samples_cal > MAX_SAMPLES_CAL) {
- dev_err(&chip->client->dev,
- "max prox samples cal is too big: %d\n",
- chip->settings.prox_max_samples_cal);
- chip->settings.prox_max_samples_cal = MAX_SAMPLES_CAL;
- }
-
- /* have to stop to change settings */
- ret = tsl2x7x_chip_off(indio_dev);
- if (ret < 0)
- return ret;
-
- /* Enable proximity detection save just in case prox not wanted yet*/
- tmp_irq_settings = chip->settings.interrupts_en;
- chip->settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL;
-
- /*turn on device if not already on*/
- ret = tsl2x7x_chip_on(indio_dev);
- if (ret < 0)
- return ret;
-
- /*gather the samples*/
- for (i = 0; i < chip->settings.prox_max_samples_cal; i++) {
- usleep_range(15000, 17500);
- ret = tsl2x7x_get_prox(indio_dev);
- if (ret < 0)
- return ret;
- prox_history[i] = chip->prox_data;
- dev_info(&chip->client->dev, "2 i=%d prox data= %d\n",
- i, chip->prox_data);
- }
-
- ret = tsl2x7x_chip_off(indio_dev);
- if (ret < 0)
- return ret;
- cal = &prox_stat_data[PROX_STAT_CAL];
- tsl2x7x_prox_calculate(prox_history,
- chip->settings.prox_max_samples_cal, cal);
- chip->settings.prox_thres_high = (cal->max << 1) - cal->mean;
-
- dev_info(&chip->client->dev, " cal min=%d mean=%d max=%d\n",
- cal->min, cal->mean, cal->max);
- dev_info(&chip->client->dev,
- "%s proximity threshold set to %d\n",
- chip->client->name, chip->settings.prox_thres_high);
-
- /* back to the way they were */
- chip->settings.interrupts_en = tmp_irq_settings;
- if (current_state == TSL2X7X_CHIP_WORKING) {
- ret = tsl2x7x_chip_on(indio_dev);
- if (ret < 0)
- return ret;
- }
-
- return 0;
-}
-
-static ssize_t
-in_illuminance0_calibscale_available_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-
- switch (chip->id) {
- case tsl2571:
- case tsl2671:
- case tmd2671:
- case tsl2771:
- case tmd2771:
- return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 128");
- }
-
- return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
-}
-
-static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
-
-static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
- ".00272 - .696");
-
-static ssize_t in_illuminance0_target_input_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-
- return snprintf(buf, PAGE_SIZE, "%d\n", chip->settings.als_cal_target);
-}
-
-static ssize_t in_illuminance0_target_input_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- unsigned long value;
- int ret;
-
- if (kstrtoul(buf, 0, &value))
- return -EINVAL;
-
- if (value)
- chip->settings.als_cal_target = value;
-
- ret = tsl2x7x_invoke_change(indio_dev);
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-static ssize_t in_illuminance0_calibrate_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- bool value;
- int ret;
-
- if (strtobool(buf, &value))
- return -EINVAL;
-
- if (value) {
- ret = tsl2x7x_als_calibrate(indio_dev);
- if (ret < 0)
- return ret;
- }
-
- ret = tsl2x7x_invoke_change(indio_dev);
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-static ssize_t in_illuminance0_lux_table_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
- int i = 0;
- int offset = 0;
-
- while (i < TSL2X7X_MAX_LUX_TABLE_SIZE) {
- offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,",
- chip->tsl2x7x_device_lux[i].ratio,
- chip->tsl2x7x_device_lux[i].ch0,
- chip->tsl2x7x_device_lux[i].ch1);
- if (chip->tsl2x7x_device_lux[i].ratio == 0) {
- /*
- * We just printed the first "0" entry.
- * Now get rid of the extra "," and break.
- */
- offset--;
- break;
- }
- i++;
- }
-
- offset += snprintf(buf + offset, PAGE_SIZE, "\n");
- return offset;
-}
-
-static ssize_t in_illuminance0_lux_table_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int value[ARRAY_SIZE(chip->tsl2x7x_device_lux) * 3 + 1];
- int n, ret;
-
- get_options(buf, ARRAY_SIZE(value), value);
-
- /* We now have an array of ints starting at value[1], and
- * enumerated by value[0].
- * We expect each group of three ints is one table entry,
- * and the last table entry is all 0.
- */
- n = value[0];
- if ((n % 3) || n < 6 ||
- n > ((ARRAY_SIZE(chip->tsl2x7x_device_lux) - 1) * 3)) {
- dev_info(dev, "LUX TABLE INPUT ERROR 1 Value[0]=%d\n", n);
- return -EINVAL;
- }
-
- if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) {
- dev_info(dev, "LUX TABLE INPUT ERROR 2 Value[0]=%d\n", n);
- return -EINVAL;
- }
-
- if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
- ret = tsl2x7x_chip_off(indio_dev);
- if (ret < 0)
- return ret;
- }
-
- /* Zero out the table */
- memset(chip->tsl2x7x_device_lux, 0, sizeof(chip->tsl2x7x_device_lux));
- memcpy(chip->tsl2x7x_device_lux, &value[1], (value[0] * 4));
-
- ret = tsl2x7x_invoke_change(indio_dev);
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-static ssize_t in_proximity0_calibrate_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- bool value;
- int ret;
-
- if (strtobool(buf, &value))
- return -EINVAL;
-
- if (value) {
- ret = tsl2x7x_prox_cal(indio_dev);
- if (ret < 0)
- return ret;
- }
-
- ret = tsl2x7x_invoke_change(indio_dev);
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret;
-
- if (chan->type == IIO_INTENSITY)
- ret = !!(chip->settings.interrupts_en & 0x10);
- else
- ret = !!(chip->settings.interrupts_en & 0x20);
-
- return ret;
-}
-
-static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir,
- int val)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret;
-
- if (chan->type == IIO_INTENSITY) {
- if (val)
- chip->settings.interrupts_en |= 0x10;
- else
- chip->settings.interrupts_en &= 0x20;
- } else {
- if (val)
- chip->settings.interrupts_en |= 0x20;
- else
- chip->settings.interrupts_en &= 0x10;
- }
-
- ret = tsl2x7x_invoke_change(indio_dev);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir,
- enum iio_event_info info,
- int val, int val2)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret = -EINVAL, y, z, filter_delay;
- u8 time;
-
- switch (info) {
- case IIO_EV_INFO_VALUE:
- if (chan->type == IIO_INTENSITY) {
- switch (dir) {
- case IIO_EV_DIR_RISING:
- chip->settings.als_thresh_high = val;
- ret = 0;
- break;
- case IIO_EV_DIR_FALLING:
- chip->settings.als_thresh_low = val;
- ret = 0;
- break;
- default:
- break;
- }
- } else {
- switch (dir) {
- case IIO_EV_DIR_RISING:
- chip->settings.prox_thres_high = val;
- ret = 0;
- break;
- case IIO_EV_DIR_FALLING:
- chip->settings.prox_thres_low = val;
- ret = 0;
- break;
- default:
- break;
- }
- }
- break;
- case IIO_EV_INFO_PERIOD:
- if (chan->type == IIO_INTENSITY)
- time = chip->settings.als_time;
- else
- time = chip->settings.prx_time;
-
- y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
- z = y * TSL2X7X_MIN_ITIME;
-
- filter_delay = DIV_ROUND_UP((val * 1000) + val2, z);
-
- if (chan->type == IIO_INTENSITY) {
- chip->settings.persistence &= 0xF0;
- chip->settings.persistence |=
- (filter_delay & 0x0F);
- dev_info(&chip->client->dev, "%s: ALS persistence = %d",
- __func__, filter_delay);
- } else {
- chip->settings.persistence &= 0x0F;
- chip->settings.persistence |=
- ((filter_delay << 4) & 0xF0);
- dev_info(&chip->client->dev,
- "%s: Proximity persistence = %d",
- __func__, filter_delay);
- }
- ret = 0;
- break;
- default:
- break;
- }
-
- if (ret < 0)
- return ret;
-
- return tsl2x7x_invoke_change(indio_dev);
-}
-
-static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir,
- enum iio_event_info info,
- int *val, int *val2)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret = -EINVAL, filter_delay, mult;
- u8 time;
-
- switch (info) {
- case IIO_EV_INFO_VALUE:
- if (chan->type == IIO_INTENSITY) {
- switch (dir) {
- case IIO_EV_DIR_RISING:
- *val = chip->settings.als_thresh_high;
- ret = IIO_VAL_INT;
- break;
- case IIO_EV_DIR_FALLING:
- *val = chip->settings.als_thresh_low;
- ret = IIO_VAL_INT;
- break;
- default:
- break;
- }
- } else {
- switch (dir) {
- case IIO_EV_DIR_RISING:
- *val = chip->settings.prox_thres_high;
- ret = IIO_VAL_INT;
- break;
- case IIO_EV_DIR_FALLING:
- *val = chip->settings.prox_thres_low;
- ret = IIO_VAL_INT;
- break;
- default:
- break;
- }
- }
- break;
- case IIO_EV_INFO_PERIOD:
- if (chan->type == IIO_INTENSITY) {
- time = chip->settings.als_time;
- mult = chip->settings.persistence & 0x0F;
- } else {
- time = chip->settings.prx_time;
- mult = (chip->settings.persistence & 0xF0) >> 4;
- }
-
- /* Determine integration time */
- *val = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
- *val2 = *val * TSL2X7X_MIN_ITIME;
- filter_delay = *val2 * mult;
- *val = filter_delay / 1000;
- *val2 = filter_delay % 1000;
- ret = IIO_VAL_INT_PLUS_MICRO;
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask)
-{
- int ret = -EINVAL;
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-
- switch (mask) {
- case IIO_CHAN_INFO_PROCESSED:
- switch (chan->type) {
- case IIO_LIGHT:
- tsl2x7x_get_lux(indio_dev);
- *val = chip->als_cur_info.lux;
- ret = IIO_VAL_INT;
- break;
- default:
- return -EINVAL;
- }
- break;
- case IIO_CHAN_INFO_RAW:
- switch (chan->type) {
- case IIO_INTENSITY:
- tsl2x7x_get_lux(indio_dev);
- if (chan->channel == 0)
- *val = chip->als_cur_info.als_ch0;
- else
- *val = chip->als_cur_info.als_ch1;
- ret = IIO_VAL_INT;
- break;
- case IIO_PROXIMITY:
- tsl2x7x_get_prox(indio_dev);
- *val = chip->prox_data;
- ret = IIO_VAL_INT;
- break;
- default:
- return -EINVAL;
- }
- break;
- case IIO_CHAN_INFO_CALIBSCALE:
- if (chan->type == IIO_LIGHT)
- *val = tsl2x7x_als_gain[chip->settings.als_gain];
- else
- *val = tsl2x7x_prx_gain[chip->settings.prox_gain];
- ret = IIO_VAL_INT;
- break;
- case IIO_CHAN_INFO_CALIBBIAS:
- *val = chip->settings.als_gain_trim;
- ret = IIO_VAL_INT;
- break;
- case IIO_CHAN_INFO_INT_TIME:
- *val = (TSL2X7X_MAX_TIMER_CNT - chip->settings.als_time) + 1;
- *val2 = ((*val * TSL2X7X_MIN_ITIME) % 1000) / 1000;
- ret = IIO_VAL_INT_PLUS_MICRO;
- break;
- default:
- ret = -EINVAL;
- }
-
- return ret;
-}
-
-static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-
- switch (mask) {
- case IIO_CHAN_INFO_CALIBSCALE:
- if (chan->type == IIO_INTENSITY) {
- switch (val) {
- case 1:
- chip->settings.als_gain = 0;
- break;
- case 8:
- chip->settings.als_gain = 1;
- break;
- case 16:
- chip->settings.als_gain = 2;
- break;
- case 120:
- switch (chip->id) {
- case tsl2572:
- case tsl2672:
- case tmd2672:
- case tsl2772:
- case tmd2772:
- return -EINVAL;
- }
- chip->settings.als_gain = 3;
- break;
- case 128:
- switch (chip->id) {
- case tsl2571:
- case tsl2671:
- case tmd2671:
- case tsl2771:
- case tmd2771:
- return -EINVAL;
- }
- chip->settings.als_gain = 3;
- break;
- default:
- return -EINVAL;
- }
- } else {
- switch (val) {
- case 1:
- chip->settings.prox_gain = 0;
- break;
- case 2:
- chip->settings.prox_gain = 1;
- break;
- case 4:
- chip->settings.prox_gain = 2;
- break;
- case 8:
- chip->settings.prox_gain = 3;
- break;
- default:
- return -EINVAL;
- }
- }
- break;
- case IIO_CHAN_INFO_CALIBBIAS:
- chip->settings.als_gain_trim = val;
- break;
- case IIO_CHAN_INFO_INT_TIME:
- chip->settings.als_time =
- TSL2X7X_MAX_TIMER_CNT - (val2 / TSL2X7X_MIN_ITIME);
-
- dev_info(&chip->client->dev, "%s: als time = %d",
- __func__, chip->settings.als_time);
- break;
- default:
- return -EINVAL;
- }
-
- return tsl2x7x_invoke_change(indio_dev);
-}
-
-static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
-
-static DEVICE_ATTR_RW(in_illuminance0_target_input);
-
-static DEVICE_ATTR_WO(in_illuminance0_calibrate);
-
-static DEVICE_ATTR_WO(in_proximity0_calibrate);
-
-static DEVICE_ATTR_RW(in_illuminance0_lux_table);
-
-/* Use the default register values to identify the Taos device */
-static int tsl2x7x_device_id(int *id, int target)
-{
- switch (target) {
- case tsl2571:
- case tsl2671:
- case tsl2771:
- return (*id & 0xf0) == TRITON_ID;
- case tmd2671:
- case tmd2771:
- return (*id & 0xf0) == HALIBUT_ID;
- case tsl2572:
- case tsl2672:
- case tmd2672:
- case tsl2772:
- case tmd2772:
- return (*id & 0xf0) == SWORDFISH_ID;
- }
-
- return -EINVAL;
-}
-
-static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
-{
- struct iio_dev *indio_dev = private;
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- s64 timestamp = iio_get_time_ns(indio_dev);
- int ret;
-
- ret = tsl2x7x_read_status(chip);
- if (ret < 0)
- return ret;
-
- /* What type of interrupt do we need to process */
- if (ret & TSL2X7X_STA_PRX_INTR) {
- tsl2x7x_get_prox(indio_dev); /* freshen data for ABI */
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_EITHER),
- timestamp);
- }
-
- if (ret & TSL2X7X_STA_ALS_INTR) {
- tsl2x7x_get_lux(indio_dev); /* freshen data for ABI */
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_EITHER),
- timestamp);
- }
-
- ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
- if (ret < 0)
- return ret;
-
- return IRQ_HANDLED;
-}
-
-static struct attribute *tsl2x7x_ALS_device_attrs[] = {
- &dev_attr_in_illuminance0_calibscale_available.attr,
- &iio_const_attr_in_illuminance0_integration_time_available
- .dev_attr.attr,
- &dev_attr_in_illuminance0_target_input.attr,
- &dev_attr_in_illuminance0_calibrate.attr,
- &dev_attr_in_illuminance0_lux_table.attr,
- NULL
-};
-
-static struct attribute *tsl2x7x_PRX_device_attrs[] = {
- &dev_attr_in_proximity0_calibrate.attr,
- NULL
-};
-
-static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
- &dev_attr_in_illuminance0_calibscale_available.attr,
- &iio_const_attr_in_illuminance0_integration_time_available
- .dev_attr.attr,
- &dev_attr_in_illuminance0_target_input.attr,
- &dev_attr_in_illuminance0_calibrate.attr,
- &dev_attr_in_illuminance0_lux_table.attr,
- NULL
-};
-
-static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
- &dev_attr_in_proximity0_calibrate.attr,
- &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
- NULL
-};
-
-static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
- &dev_attr_in_illuminance0_calibscale_available.attr,
- &iio_const_attr_in_illuminance0_integration_time_available
- .dev_attr.attr,
- &dev_attr_in_illuminance0_target_input.attr,
- &dev_attr_in_illuminance0_calibrate.attr,
- &dev_attr_in_illuminance0_lux_table.attr,
- &dev_attr_in_proximity0_calibrate.attr,
- &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
- [ALS] = {
- .attrs = tsl2x7x_ALS_device_attrs,
- },
- [PRX] = {
- .attrs = tsl2x7x_PRX_device_attrs,
- },
- [ALSPRX] = {
- .attrs = tsl2x7x_ALSPRX_device_attrs,
- },
- [PRX2] = {
- .attrs = tsl2x7x_PRX2_device_attrs,
- },
- [ALSPRX2] = {
- .attrs = tsl2x7x_ALSPRX2_device_attrs,
- },
-};
-
-static const struct iio_info tsl2X7X_device_info[] = {
- [ALS] = {
- .attrs = &tsl2X7X_device_attr_group_tbl[ALS],
- .read_raw = &tsl2x7x_read_raw,
- .write_raw = &tsl2x7x_write_raw,
- .read_event_value = &tsl2x7x_read_event_value,
- .write_event_value = &tsl2x7x_write_event_value,
- .read_event_config = &tsl2x7x_read_interrupt_config,
- .write_event_config = &tsl2x7x_write_interrupt_config,
- },
- [PRX] = {
- .attrs = &tsl2X7X_device_attr_group_tbl[PRX],
- .read_raw = &tsl2x7x_read_raw,
- .write_raw = &tsl2x7x_write_raw,
- .read_event_value = &tsl2x7x_read_event_value,
- .write_event_value = &tsl2x7x_write_event_value,
- .read_event_config = &tsl2x7x_read_interrupt_config,
- .write_event_config = &tsl2x7x_write_interrupt_config,
- },
- [ALSPRX] = {
- .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
- .read_raw = &tsl2x7x_read_raw,
- .write_raw = &tsl2x7x_write_raw,
- .read_event_value = &tsl2x7x_read_event_value,
- .write_event_value = &tsl2x7x_write_event_value,
- .read_event_config = &tsl2x7x_read_interrupt_config,
- .write_event_config = &tsl2x7x_write_interrupt_config,
- },
- [PRX2] = {
- .attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
- .read_raw = &tsl2x7x_read_raw,
- .write_raw = &tsl2x7x_write_raw,
- .read_event_value = &tsl2x7x_read_event_value,
- .write_event_value = &tsl2x7x_write_event_value,
- .read_event_config = &tsl2x7x_read_interrupt_config,
- .write_event_config = &tsl2x7x_write_interrupt_config,
- },
- [ALSPRX2] = {
- .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
- .read_raw = &tsl2x7x_read_raw,
- .write_raw = &tsl2x7x_write_raw,
- .read_event_value = &tsl2x7x_read_event_value,
- .write_event_value = &tsl2x7x_write_event_value,
- .read_event_config = &tsl2x7x_read_interrupt_config,
- .write_event_config = &tsl2x7x_write_interrupt_config,
- },
-};
-
-static const struct iio_event_spec tsl2x7x_events[] = {
- {
- .type = IIO_EV_TYPE_THRESH,
- .dir = IIO_EV_DIR_RISING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_THRESH,
- .dir = IIO_EV_DIR_FALLING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_THRESH,
- .dir = IIO_EV_DIR_EITHER,
- .mask_separate = BIT(IIO_EV_INFO_PERIOD),
- },
-};
-
-static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
- [ALS] = {
- .channel = {
- {
- .type = IIO_LIGHT,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_CALIBSCALE) |
- BIT(IIO_CHAN_INFO_CALIBBIAS),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 1,
- },
- },
- .chan_table_elements = 3,
- .info = &tsl2X7X_device_info[ALS],
- },
- [PRX] = {
- .channel = {
- {
- .type = IIO_PROXIMITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- },
- },
- .chan_table_elements = 1,
- .info = &tsl2X7X_device_info[PRX],
- },
- [ALSPRX] = {
- .channel = {
- {
- .type = IIO_LIGHT,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_CALIBSCALE) |
- BIT(IIO_CHAN_INFO_CALIBBIAS),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 1,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
- }, {
- .type = IIO_PROXIMITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- },
- },
- .chan_table_elements = 4,
- .info = &tsl2X7X_device_info[ALSPRX],
- },
- [PRX2] = {
- .channel = {
- {
- .type = IIO_PROXIMITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_CALIBSCALE),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- },
- },
- .chan_table_elements = 1,
- .info = &tsl2X7X_device_info[PRX2],
- },
- [ALSPRX2] = {
- .channel = {
- {
- .type = IIO_LIGHT,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_CALIBSCALE) |
- BIT(IIO_CHAN_INFO_CALIBBIAS),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- }, {
- .type = IIO_INTENSITY,
- .indexed = 1,
- .channel = 1,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
- }, {
- .type = IIO_PROXIMITY,
- .indexed = 1,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_CALIBSCALE),
- .event_spec = tsl2x7x_events,
- .num_event_specs = ARRAY_SIZE(tsl2x7x_events),
- },
- },
- .chan_table_elements = 4,
- .info = &tsl2X7X_device_info[ALSPRX2],
- },
-};
-
-static int tsl2x7x_probe(struct i2c_client *clientp,
- const struct i2c_device_id *id)
-{
- int ret;
- struct iio_dev *indio_dev;
- struct tsl2X7X_chip *chip;
-
- indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
- if (!indio_dev)
- return -ENOMEM;
-
- chip = iio_priv(indio_dev);
- chip->client = clientp;
- i2c_set_clientdata(clientp, indio_dev);
-
- ret = i2c_smbus_read_byte_data(chip->client,
- TSL2X7X_CMD_REG | TSL2X7X_CHIPID);
- if (ret < 0)
- return ret;
-
- if ((!tsl2x7x_device_id(&ret, id->driver_data)) ||
- (tsl2x7x_device_id(&ret, id->driver_data) == -EINVAL)) {
- dev_info(&chip->client->dev,
- "%s: i2c device found does not match expected id\n",
- __func__);
- return -EINVAL;
- }
-
- ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
- if (ret < 0) {
- dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n",
- ret);
- return ret;
- }
-
- /*
- * ALS and PROX functions can be invoked via user space poll
- * or H/W interrupt. If busy return last sample.
- */
- mutex_init(&chip->als_mutex);
- mutex_init(&chip->prox_mutex);
-
- chip->tsl2x7x_chip_status = TSL2X7X_CHIP_UNKNOWN;
- chip->pdata = dev_get_platdata(&clientp->dev);
- chip->id = id->driver_data;
- chip->chip_info =
- &tsl2x7x_chip_info_tbl[device_channel_config[id->driver_data]];
-
- indio_dev->info = chip->chip_info->info;
- indio_dev->dev.parent = &clientp->dev;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->name = chip->client->name;
- indio_dev->channels = chip->chip_info->channel;
- indio_dev->num_channels = chip->chip_info->chan_table_elements;
-
- if (clientp->irq) {
- ret = devm_request_threaded_irq(&clientp->dev, clientp->irq,
- NULL,
- &tsl2x7x_event_handler,
- IRQF_TRIGGER_RISING |
- IRQF_ONESHOT,
- "TSL2X7X_event",
- indio_dev);
- if (ret) {
- dev_err(&clientp->dev,
- "%s: irq request failed", __func__);
- return ret;
- }
- }
-
- /* Load up the defaults */
- tsl2x7x_defaults(chip);
- /* Make sure the chip is on */
- tsl2x7x_chip_on(indio_dev);
-
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&clientp->dev,
- "%s: iio registration failed\n", __func__);
- return ret;
- }
-
- dev_info(&clientp->dev, "%s Light sensor found.\n", id->name);
-
- return 0;
-}
-
-static int tsl2x7x_suspend(struct device *dev)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret = 0;
-
- if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
- ret = tsl2x7x_chip_off(indio_dev);
- chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
- }
-
- return ret;
-}
-
-static int tsl2x7x_resume(struct device *dev)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct tsl2X7X_chip *chip = iio_priv(indio_dev);
- int ret = 0;
-
- if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
- ret = tsl2x7x_chip_on(indio_dev);
-
- return ret;
-}
-
-static int tsl2x7x_remove(struct i2c_client *client)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
-
- tsl2x7x_chip_off(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- return 0;
-}
-
-static const struct i2c_device_id tsl2x7x_idtable[] = {
- { "tsl2571", tsl2571 },
- { "tsl2671", tsl2671 },
- { "tmd2671", tmd2671 },
- { "tsl2771", tsl2771 },
- { "tmd2771", tmd2771 },
- { "tsl2572", tsl2572 },
- { "tsl2672", tsl2672 },
- { "tmd2672", tmd2672 },
- { "tsl2772", tsl2772 },
- { "tmd2772", tmd2772 },
- {}
-};
-
-MODULE_DEVICE_TABLE(i2c, tsl2x7x_idtable);
-
-static const struct of_device_id tsl2x7x_of_match[] = {
- { .compatible = "amstaos,tsl2571" },
- { .compatible = "amstaos,tsl2671" },
- { .compatible = "amstaos,tmd2671" },
- { .compatible = "amstaos,tsl2771" },
- { .compatible = "amstaos,tmd2771" },
- { .compatible = "amstaos,tsl2572" },
- { .compatible = "amstaos,tsl2672" },
- { .compatible = "amstaos,tmd2672" },
- { .compatible = "amstaos,tsl2772" },
- { .compatible = "amstaos,tmd2772" },
- {}
-};
-MODULE_DEVICE_TABLE(of, tsl2x7x_of_match);
-
-static const struct dev_pm_ops tsl2x7x_pm_ops = {
- .suspend = tsl2x7x_suspend,
- .resume = tsl2x7x_resume,
-};
-
-/* Driver definition */
-static struct i2c_driver tsl2x7x_driver = {
- .driver = {
- .name = "tsl2x7x",
- .of_match_table = tsl2x7x_of_match,
- .pm = &tsl2x7x_pm_ops,
- },
- .id_table = tsl2x7x_idtable,
- .probe = tsl2x7x_probe,
- .remove = tsl2x7x_remove,
-};
-
-module_i2c_driver(tsl2x7x_driver);
-
-MODULE_AUTHOR("J. August Brenner<jbrenner@taosinc.com>");
-MODULE_DESCRIPTION("TAOS tsl2x7x ambient and proximity light sensor driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
deleted file mode 100644
index 28b0e7fdc9b8..000000000000
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Device driver for monitoring ambient light intensity (lux)
- * and proximity (prox) within the TAOS TSL2X7X family of devices.
- *
- * Copyright (c) 2012, TAOS Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef __TSL2X7X_H
-#define __TSL2X7X_H
-
-struct tsl2x7x_lux {
- unsigned int ratio;
- unsigned int ch0;
- unsigned int ch1;
-};
-
-/* Max number of segments allowable in LUX table */
-#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
-/* The default LUX tables all have 3 elements. */
-#define TSL2X7X_DEF_LUX_TABLE_SZ 3
-#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
- TSL2X7X_DEF_LUX_TABLE_SZ)
-
-/**
- * struct tsl2x7x_default_settings - power on defaults unless
- * overridden by platform data.
- * @als_time: ALS Integration time - multiple of 50mS
- * @als_gain: Index into the ALS gain table.
- * @als_gain_trim: default gain trim to account for
- * aperture effects.
- * @wait_time: Time between PRX and ALS cycles
- * in 2.7 periods
- * @prx_time: 5.2ms prox integration time -
- * decrease in 2.7ms periods
- * @prx_gain: Proximity gain index
- * @prox_config: Prox configuration filters.
- * @als_cal_target: Known external ALS reading for
- * calibration.
- * @interrupts_en: Enable/Disable - 0x00 = none, 0x10 = als,
- * 0x20 = prx, 0x30 = bth
- * @persistence: H/W Filters, Number of 'out of limits'
- * ADC readings PRX/ALS.
- * @als_thresh_low: CH0 'low' count to trigger interrupt.
- * @als_thresh_high: CH0 'high' count to trigger interrupt.
- * @prox_thres_low: Low threshold proximity detection.
- * @prox_thres_high: High threshold proximity detection
- * @prox_pulse_count: Number if proximity emitter pulses
- * @prox_max_samples_cal: Used for prox cal.
- */
-struct tsl2x7x_settings {
- int als_time;
- int als_gain;
- int als_gain_trim;
- int wait_time;
- int prx_time;
- int prox_gain;
- int prox_config;
- int als_cal_target;
- u8 interrupts_en;
- u8 persistence;
- int als_thresh_low;
- int als_thresh_high;
- int prox_thres_low;
- int prox_thres_high;
- int prox_pulse_count;
- int prox_max_samples_cal;
- int prox_diode;
- int prox_power;
-};
-
-/**
- * struct tsl2X7X_platform_data - Platform callback, glass and defaults
- * @platform_power: Suspend/resume platform callback
- * @power_on: Power on callback
- * @power_off: Power off callback
- * @platform_lux_table: Device specific glass coefficents
- * @platform_default_settings: Device specific power on defaults
- *
- */
-struct tsl2X7X_platform_data {
- struct tsl2x7x_lux platform_lux_table[TSL2X7X_MAX_LUX_TABLE_SIZE];
- struct tsl2x7x_settings *platform_default_settings;
-};
-
-#endif /* __TSL2X7X_H */
diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
index 64cd3704ec6e..e01eb8abcdce 100644
--- a/drivers/staging/iio/meter/Kconfig
+++ b/drivers/staging/iio/meter/Kconfig
@@ -3,48 +3,6 @@
#
menu "Active energy metering IC"
-config ADE7753
- tristate "Analog Devices ADE7753/6 Single-Phase Multifunction Metering IC Driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices ADE7753 Single-Phase Multifunction
- Metering IC with di/dt Sensor Interface.
-
- To compile this driver as a module, choose M here: the
- module will be called ade7753.
-
-config ADE7754
- tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices ADE7754 Polyphase
- Multifunction Energy Metering IC Driver.
-
- To compile this driver as a module, choose M here: the
- module will be called ade7754.
-
-config ADE7758
- tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
- depends on SPI
- select IIO_TRIGGER if IIO_BUFFER
- select IIO_KFIFO_BUF if IIO_BUFFER
- help
- Say yes here to build support for Analog Devices ADE7758 Polyphase
- Multifunction Energy Metering IC with Per Phase Information Driver.
-
- To compile this driver as a module, choose M here: the
- module will be called ade7758.
-
-config ADE7759
- tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices ADE7758 Active Energy
- Metering IC with di/dt Sensor Interface.
-
- To compile this driver as a module, choose M here: the
- module will be called ade7759.
-
config ADE7854
tristate "Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver"
depends on SPI || I2C
diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
index 19e7982f5563..ed4547e38f3a 100644
--- a/drivers/staging/iio/meter/Makefile
+++ b/drivers/staging/iio/meter/Makefile
@@ -3,14 +3,6 @@
# Makefile for metering ic drivers
#
-obj-$(CONFIG_ADE7753) += ade7753.o
-obj-$(CONFIG_ADE7754) += ade7754.o
-
-ade7758-y := ade7758_core.o
-ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o
-obj-$(CONFIG_ADE7758) += ade7758.o
-
-obj-$(CONFIG_ADE7759) += ade7759.o
obj-$(CONFIG_ADE7854) += ade7854.o
obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
obj-$(CONFIG_ADE7854_SPI) += ade7854-spi.o
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
deleted file mode 100644
index 275e8dfff836..000000000000
--- a/drivers/staging/iio/meter/ade7753.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * ADE7753 Single-Phase Multifunction Metering IC with di/dt Sensor Interface
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/spi/spi.h>
-#include "meter.h"
-
-#define ADE7753_WAVEFORM 0x01
-#define ADE7753_AENERGY 0x02
-#define ADE7753_RAENERGY 0x03
-#define ADE7753_LAENERGY 0x04
-#define ADE7753_VAENERGY 0x05
-#define ADE7753_RVAENERGY 0x06
-#define ADE7753_LVAENERGY 0x07
-#define ADE7753_LVARENERGY 0x08
-#define ADE7753_MODE 0x09
-#define ADE7753_IRQEN 0x0A
-#define ADE7753_STATUS 0x0B
-#define ADE7753_RSTSTATUS 0x0C
-#define ADE7753_CH1OS 0x0D
-#define ADE7753_CH2OS 0x0E
-#define ADE7753_GAIN 0x0F
-#define ADE7753_PHCAL 0x10
-#define ADE7753_APOS 0x11
-#define ADE7753_WGAIN 0x12
-#define ADE7753_WDIV 0x13
-#define ADE7753_CFNUM 0x14
-#define ADE7753_CFDEN 0x15
-#define ADE7753_IRMS 0x16
-#define ADE7753_VRMS 0x17
-#define ADE7753_IRMSOS 0x18
-#define ADE7753_VRMSOS 0x19
-#define ADE7753_VAGAIN 0x1A
-#define ADE7753_VADIV 0x1B
-#define ADE7753_LINECYC 0x1C
-#define ADE7753_ZXTOUT 0x1D
-#define ADE7753_SAGCYC 0x1E
-#define ADE7753_SAGLVL 0x1F
-#define ADE7753_IPKLVL 0x20
-#define ADE7753_VPKLVL 0x21
-#define ADE7753_IPEAK 0x22
-#define ADE7753_RSTIPEAK 0x23
-#define ADE7753_VPEAK 0x24
-#define ADE7753_RSTVPEAK 0x25
-#define ADE7753_TEMP 0x26
-#define ADE7753_PERIOD 0x27
-#define ADE7753_TMODE 0x3D
-#define ADE7753_CHKSUM 0x3E
-#define ADE7753_DIEREV 0x3F
-
-#define ADE7753_READ_REG(a) a
-#define ADE7753_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7753_MAX_TX 4
-#define ADE7753_MAX_RX 4
-#define ADE7753_STARTUP_DELAY 1000
-
-#define ADE7753_SPI_SLOW (u32)(300 * 1000)
-#define ADE7753_SPI_BURST (u32)(1000 * 1000)
-#define ADE7753_SPI_FAST (u32)(2000 * 1000)
-
-/**
- * struct ade7753_state - device instance specific data
- * @us: actual spi_device
- * @tx: transmit buffer
- * @rx: receive buffer
- * @buf_lock: mutex to protect tx, rx and write frequency
- **/
-struct ade7753_state {
- struct spi_device *us;
- struct mutex buf_lock;
- u8 tx[ADE7753_MAX_TX] ____cacheline_aligned;
- u8 rx[ADE7753_MAX_RX];
-};
-
-static int ade7753_spi_write_reg_8(struct device *dev,
- u8 reg_address,
- u8 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7753_WRITE_REG(reg_address);
- st->tx[1] = val;
-
- ret = spi_write(st->us, st->tx, 2);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int __ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
- u16 value)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
-
- st->tx[0] = ADE7753_WRITE_REG(reg_address);
- st->tx[1] = (value >> 8) & 0xFF;
- st->tx[2] = value & 0xFF;
-
- return spi_write(st->us, st->tx, 3);
-}
-
-static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
- u16 value)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- ret = __ade7753_spi_write_reg_16(dev, reg_address, value);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7753_spi_read_reg_8(struct device *dev,
- u8 reg_address,
- u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
- ssize_t ret;
-
- ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
- reg_address);
- return ret;
- }
- *val = ret;
-
- return 0;
-}
-
-static int ade7753_spi_read_reg_16(struct device *dev,
- u8 reg_address,
- u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
- ssize_t ret;
-
- ret = spi_w8r16be(st->us, ADE7753_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
- reg_address);
- return ret;
- }
-
- *val = ret;
-
- return 0;
-}
-
-static int ade7753_spi_read_reg_24(struct device *dev,
- u8 reg_address,
- u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 1,
- }, {
- .rx_buf = st->tx,
- .bits_per_word = 8,
- .len = 3,
- }
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7753_READ_REG(reg_address);
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static ssize_t ade7753_read_8bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u8 val;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7753_spi_read_reg_8(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_read_16bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u16 val;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7753_spi_read_reg_16(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_read_24bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u32 val;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7753_spi_read_reg_24(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_write_8bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u8 val;
-
- ret = kstrtou8(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7753_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static ssize_t ade7753_write_16bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u16 val;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7753_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static int ade7753_reset(struct device *dev)
-{
- u16 val;
- int ret;
-
- ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
- if (ret)
- return ret;
-
- val |= BIT(6); /* Software Chip Reset */
-
- return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, ADE7753_AENERGY);
-static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
-static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
-static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
-static IIO_DEV_ATTR_CFDEN(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_CFDEN);
-static IIO_DEV_ATTR_CFNUM(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_CFNUM);
-static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_PHCAL);
-static IIO_DEV_ATTR_APOS(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_APOS);
-static IIO_DEV_ATTR_SAGCYC(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_LINECYC);
-static IIO_DEV_ATTR_WDIV(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_WDIV);
-static IIO_DEV_ATTR_IRMS(0644,
- ade7753_read_24bit,
- NULL,
- ADE7753_IRMS);
-static IIO_DEV_ATTR_VRMS(0444,
- ade7753_read_24bit,
- NULL,
- ADE7753_VRMS);
-static IIO_DEV_ATTR_IRMSOS(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_IRMSOS);
-static IIO_DEV_ATTR_VRMSOS(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_VRMSOS);
-static IIO_DEV_ATTR_WGAIN(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_WGAIN);
-static IIO_DEV_ATTR_VAGAIN(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_VAGAIN);
-static IIO_DEV_ATTR_PGA_GAIN(0644,
- ade7753_read_16bit,
- ade7753_write_16bit,
- ADE7753_GAIN);
-static IIO_DEV_ATTR_IPKLVL(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_IPKLVL);
-static IIO_DEV_ATTR_VPKLVL(0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_VPKLVL);
-static IIO_DEV_ATTR_IPEAK(0444,
- ade7753_read_24bit,
- NULL,
- ADE7753_IPEAK);
-static IIO_DEV_ATTR_VPEAK(0444,
- ade7753_read_24bit,
- NULL,
- ADE7753_VPEAK);
-static IIO_DEV_ATTR_VPERIOD(0444,
- ade7753_read_16bit,
- NULL,
- ADE7753_PERIOD);
-
-static IIO_DEVICE_ATTR(choff_1, 0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_CH1OS);
-
-static IIO_DEVICE_ATTR(choff_2, 0644,
- ade7753_read_8bit,
- ade7753_write_8bit,
- ADE7753_CH2OS);
-
-static int ade7753_set_irq(struct device *dev, bool enable)
-{
- int ret;
- u8 irqen;
-
- ret = ade7753_spi_read_reg_8(dev, ADE7753_IRQEN, &irqen);
- if (ret)
- goto error_ret;
-
- if (enable)
- irqen |= BIT(3); /* Enables an interrupt when a data is
- * present in the waveform register
- */
- else
- irqen &= ~BIT(3);
-
- ret = ade7753_spi_write_reg_8(dev, ADE7753_IRQEN, irqen);
-
-error_ret:
- return ret;
-}
-
-/* Power down the device */
-static int ade7753_stop_device(struct device *dev)
-{
- u16 val;
- int ret;
-
- ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
- if (ret)
- return ret;
-
- val |= BIT(4); /* AD converters can be turned off */
-
- return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
-}
-
-static int ade7753_initial_setup(struct iio_dev *indio_dev)
-{
- int ret;
- struct device *dev = &indio_dev->dev;
- struct ade7753_state *st = iio_priv(indio_dev);
-
- /* use low spi speed for init */
- st->us->mode = SPI_MODE_3;
- spi_setup(st->us);
-
- /* Disable IRQ */
- ret = ade7753_set_irq(dev, false);
- if (ret) {
- dev_err(dev, "disable irq failed");
- goto err_ret;
- }
-
- ade7753_reset(dev);
- usleep_range(ADE7753_STARTUP_DELAY, ADE7753_STARTUP_DELAY + 100);
-
-err_ret:
- return ret;
-}
-
-static ssize_t ade7753_read_frequency(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u16 t;
- int sps;
-
- ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &t);
- if (ret)
- return ret;
-
- t = (t >> 11) & 0x3;
- sps = 27900 / (1 + t);
-
- return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7753_write_frequency(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7753_state *st = iio_priv(indio_dev);
- u16 val;
- int ret;
- u16 reg, t;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- return ret;
- if (!val)
- return -EINVAL;
-
- mutex_lock(&st->buf_lock);
-
- t = 27900 / val;
- if (t > 0)
- t--;
-
- if (t > 1)
- st->us->max_speed_hz = ADE7753_SPI_SLOW;
- else
- st->us->max_speed_hz = ADE7753_SPI_FAST;
-
- ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &reg);
- if (ret)
- goto out;
-
- reg &= ~(3 << 11);
- reg |= t << 11;
-
- ret = __ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
-
-out:
- mutex_unlock(&st->buf_lock);
-
- return ret ? ret : len;
-}
-
-static IIO_DEV_ATTR_TEMP_RAW(ade7753_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "-25 C");
-static IIO_CONST_ATTR(in_temp_scale, "0.67 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
- ade7753_read_frequency,
- ade7753_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
-
-static struct attribute *ade7753_attributes[] = {
- &iio_dev_attr_in_temp_raw.dev_attr.attr,
- &iio_const_attr_in_temp_offset.dev_attr.attr,
- &iio_const_attr_in_temp_scale.dev_attr.attr,
- &iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_phcal.dev_attr.attr,
- &iio_dev_attr_cfden.dev_attr.attr,
- &iio_dev_attr_aenergy.dev_attr.attr,
- &iio_dev_attr_laenergy.dev_attr.attr,
- &iio_dev_attr_vaenergy.dev_attr.attr,
- &iio_dev_attr_lvaenergy.dev_attr.attr,
- &iio_dev_attr_cfnum.dev_attr.attr,
- &iio_dev_attr_apos.dev_attr.attr,
- &iio_dev_attr_sagcyc.dev_attr.attr,
- &iio_dev_attr_saglvl.dev_attr.attr,
- &iio_dev_attr_linecyc.dev_attr.attr,
- &iio_dev_attr_chksum.dev_attr.attr,
- &iio_dev_attr_pga_gain.dev_attr.attr,
- &iio_dev_attr_wgain.dev_attr.attr,
- &iio_dev_attr_choff_1.dev_attr.attr,
- &iio_dev_attr_choff_2.dev_attr.attr,
- &iio_dev_attr_wdiv.dev_attr.attr,
- &iio_dev_attr_irms.dev_attr.attr,
- &iio_dev_attr_vrms.dev_attr.attr,
- &iio_dev_attr_irmsos.dev_attr.attr,
- &iio_dev_attr_vrmsos.dev_attr.attr,
- &iio_dev_attr_vagain.dev_attr.attr,
- &iio_dev_attr_ipklvl.dev_attr.attr,
- &iio_dev_attr_vpklvl.dev_attr.attr,
- &iio_dev_attr_ipeak.dev_attr.attr,
- &iio_dev_attr_vpeak.dev_attr.attr,
- &iio_dev_attr_vperiod.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ade7753_attribute_group = {
- .attrs = ade7753_attributes,
-};
-
-static const struct iio_info ade7753_info = {
- .attrs = &ade7753_attribute_group,
-};
-
-static int ade7753_probe(struct spi_device *spi)
-{
- int ret;
- struct ade7753_state *st;
- struct iio_dev *indio_dev;
-
- /* setup the industrialio driver allocated elements */
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev)
- return -ENOMEM;
- /* this is only used for removal purposes */
- spi_set_drvdata(spi, indio_dev);
-
- st = iio_priv(indio_dev);
- st->us = spi;
- mutex_init(&st->buf_lock);
-
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ade7753_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- /* Get the device into a sane initial state */
- ret = ade7753_initial_setup(indio_dev);
- if (ret)
- return ret;
-
- return iio_device_register(indio_dev);
-}
-
-static int ade7753_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
- iio_device_unregister(indio_dev);
- ade7753_stop_device(&indio_dev->dev);
-
- return 0;
-}
-
-static struct spi_driver ade7753_driver = {
- .driver = {
- .name = "ade7753",
- },
- .probe = ade7753_probe,
- .remove = ade7753_remove,
-};
-module_spi_driver(ade7753_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7753/6 Single-Phase Multifunction Meter");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ade7753");
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
deleted file mode 100644
index 9aa067736715..000000000000
--- a/drivers/staging/iio/meter/ade7754.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * ADE7754 Polyphase Multifunction Energy Metering IC Driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include "meter.h"
-
-#define ADE7754_AENERGY 0x01
-#define ADE7754_RAENERGY 0x02
-#define ADE7754_LAENERGY 0x03
-#define ADE7754_VAENERGY 0x04
-#define ADE7754_RVAENERGY 0x05
-#define ADE7754_LVAENERGY 0x06
-#define ADE7754_PERIOD 0x07
-#define ADE7754_TEMP 0x08
-#define ADE7754_WFORM 0x09
-#define ADE7754_OPMODE 0x0A
-#define ADE7754_MMODE 0x0B
-#define ADE7754_WAVMODE 0x0C
-#define ADE7754_WATMODE 0x0D
-#define ADE7754_VAMODE 0x0E
-#define ADE7754_IRQEN 0x0F
-#define ADE7754_STATUS 0x10
-#define ADE7754_RSTATUS 0x11
-#define ADE7754_ZXTOUT 0x12
-#define ADE7754_LINCYC 0x13
-#define ADE7754_SAGCYC 0x14
-#define ADE7754_SAGLVL 0x15
-#define ADE7754_VPEAK 0x16
-#define ADE7754_IPEAK 0x17
-#define ADE7754_GAIN 0x18
-#define ADE7754_AWG 0x19
-#define ADE7754_BWG 0x1A
-#define ADE7754_CWG 0x1B
-#define ADE7754_AVAG 0x1C
-#define ADE7754_BVAG 0x1D
-#define ADE7754_CVAG 0x1E
-#define ADE7754_APHCAL 0x1F
-#define ADE7754_BPHCAL 0x20
-#define ADE7754_CPHCAL 0x21
-#define ADE7754_AAPOS 0x22
-#define ADE7754_BAPOS 0x23
-#define ADE7754_CAPOS 0x24
-#define ADE7754_CFNUM 0x25
-#define ADE7754_CFDEN 0x26
-#define ADE7754_WDIV 0x27
-#define ADE7754_VADIV 0x28
-#define ADE7754_AIRMS 0x29
-#define ADE7754_BIRMS 0x2A
-#define ADE7754_CIRMS 0x2B
-#define ADE7754_AVRMS 0x2C
-#define ADE7754_BVRMS 0x2D
-#define ADE7754_CVRMS 0x2E
-#define ADE7754_AIRMSOS 0x2F
-#define ADE7754_BIRMSOS 0x30
-#define ADE7754_CIRMSOS 0x31
-#define ADE7754_AVRMSOS 0x32
-#define ADE7754_BVRMSOS 0x33
-#define ADE7754_CVRMSOS 0x34
-#define ADE7754_AAPGAIN 0x35
-#define ADE7754_BAPGAIN 0x36
-#define ADE7754_CAPGAIN 0x37
-#define ADE7754_AVGAIN 0x38
-#define ADE7754_BVGAIN 0x39
-#define ADE7754_CVGAIN 0x3A
-#define ADE7754_CHKSUM 0x3E
-#define ADE7754_VERSION 0x3F
-
-#define ADE7754_READ_REG(a) a
-#define ADE7754_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7754_MAX_TX 4
-#define ADE7754_MAX_RX 4
-#define ADE7754_STARTUP_DELAY 1000
-
-#define ADE7754_SPI_SLOW (u32)(300 * 1000)
-#define ADE7754_SPI_BURST (u32)(1000 * 1000)
-#define ADE7754_SPI_FAST (u32)(2000 * 1000)
-
-/**
- * struct ade7754_state - device instance specific data
- * @us: actual spi_device
- * @buf_lock: mutex to protect tx, rx and write frequency
- * @tx: transmit buffer
- * @rx: receive buffer
- **/
-struct ade7754_state {
- struct spi_device *us;
- struct mutex buf_lock;
- u8 tx[ADE7754_MAX_TX] ____cacheline_aligned;
- u8 rx[ADE7754_MAX_RX];
-};
-
-/* Unlocked version of ade7754_spi_write_reg_8 function */
-static int __ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
-
- st->tx[0] = ADE7754_WRITE_REG(reg_address);
- st->tx[1] = val;
- return spi_write(st->us, st->tx, 2);
-}
-
-static int ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- ret = __ade7754_spi_write_reg_8(dev, reg_address, val);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7754_spi_write_reg_16(struct device *dev,
- u8 reg_address, u16 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7754_WRITE_REG(reg_address);
- st->tx[1] = (val >> 8) & 0xFF;
- st->tx[2] = val & 0xFF;
- ret = spi_write(st->us, st->tx, 3);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7754_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
- int ret;
-
- ret = spi_w8r8(st->us, ADE7754_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
- reg_address);
- return ret;
- }
- *val = ret;
-
- return 0;
-}
-
-static int ade7754_spi_read_reg_16(struct device *dev,
- u8 reg_address, u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
- int ret;
-
- ret = spi_w8r16be(st->us, ADE7754_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
- reg_address);
- return ret;
- }
-
- *val = ret;
-
- return 0;
-}
-
-static int ade7754_spi_read_reg_24(struct device *dev,
- u8 reg_address, u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 4,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7754_READ_REG(reg_address);
- st->tx[1] = 0;
- st->tx[2] = 0;
- st->tx[3] = 0;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static ssize_t ade7754_read_8bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u8 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7754_spi_read_reg_8(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7754_read_16bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u16 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7754_spi_read_reg_16(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7754_read_24bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u32 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7754_spi_read_reg_24(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val & 0xFFFFFF);
-}
-
-static ssize_t ade7754_write_8bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u8 val;
-
- ret = kstrtou8(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7754_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static ssize_t ade7754_write_16bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u16 val;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7754_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static int ade7754_reset(struct device *dev)
-{
- int ret;
- u8 val;
-
- ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
- if (ret < 0)
- return ret;
-
- val |= BIT(6); /* Software Chip Reset */
- return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7754_read_24bit, ADE7754_AENERGY);
-static IIO_DEV_ATTR_LAENERGY(ade7754_read_24bit, ADE7754_LAENERGY);
-static IIO_DEV_ATTR_VAENERGY(ade7754_read_24bit, ADE7754_VAENERGY);
-static IIO_DEV_ATTR_LVAENERGY(ade7754_read_24bit, ADE7754_LVAENERGY);
-static IIO_DEV_ATTR_VPEAK(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_VPEAK);
-static IIO_DEV_ATTR_IPEAK(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_VPEAK);
-static IIO_DEV_ATTR_APHCAL(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_APHCAL);
-static IIO_DEV_ATTR_BPHCAL(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_BPHCAL);
-static IIO_DEV_ATTR_CPHCAL(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_CPHCAL);
-static IIO_DEV_ATTR_AAPOS(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_AAPOS);
-static IIO_DEV_ATTR_BAPOS(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_BAPOS);
-static IIO_DEV_ATTR_CAPOS(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CAPOS);
-static IIO_DEV_ATTR_WDIV(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_WDIV);
-static IIO_DEV_ATTR_VADIV(0644,
- ade7754_read_8bit,
- ade7754_write_8bit,
- ADE7754_VADIV);
-static IIO_DEV_ATTR_CFNUM(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CFNUM);
-static IIO_DEV_ATTR_CFDEN(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CFDEN);
-static IIO_DEV_ATTR_ACTIVE_POWER_A_GAIN(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_AAPGAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_B_GAIN(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_BAPGAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_C_GAIN(0644,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CAPGAIN);
-static IIO_DEV_ATTR_AIRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_AIRMS);
-static IIO_DEV_ATTR_BIRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_BIRMS);
-static IIO_DEV_ATTR_CIRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_CIRMS);
-static IIO_DEV_ATTR_AVRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_AVRMS);
-static IIO_DEV_ATTR_BVRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_BVRMS);
-static IIO_DEV_ATTR_CVRMS(0444,
- ade7754_read_24bit,
- NULL,
- ADE7754_CVRMS);
-static IIO_DEV_ATTR_AIRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_AIRMSOS);
-static IIO_DEV_ATTR_BIRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_BIRMSOS);
-static IIO_DEV_ATTR_CIRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CIRMSOS);
-static IIO_DEV_ATTR_AVRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_AVRMSOS);
-static IIO_DEV_ATTR_BVRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_BVRMSOS);
-static IIO_DEV_ATTR_CVRMSOS(0444,
- ade7754_read_16bit,
- ade7754_write_16bit,
- ADE7754_CVRMSOS);
-
-static int ade7754_set_irq(struct device *dev, bool enable)
-{
- int ret;
- u16 irqen;
-
- ret = ade7754_spi_read_reg_16(dev, ADE7754_IRQEN, &irqen);
- if (ret)
- return ret;
-
- if (enable)
- irqen |= BIT(14); /* Enables an interrupt when a data is
- * present in the waveform register
- */
- else
- irqen &= ~BIT(14);
-
- return ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen);
-}
-
-/* Power down the device */
-static int ade7754_stop_device(struct device *dev)
-{
- int ret;
- u8 val;
-
- ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
- if (ret < 0) {
- dev_err(dev, "unable to power down the device, error: %d",
- ret);
- return ret;
- }
-
- val |= 7 << 3; /* ADE7754 powered down */
- return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
-}
-
-static int ade7754_initial_setup(struct iio_dev *indio_dev)
-{
- int ret;
- struct ade7754_state *st = iio_priv(indio_dev);
- struct device *dev = &indio_dev->dev;
-
- /* use low spi speed for init */
- st->us->mode = SPI_MODE_3;
- spi_setup(st->us);
-
- /* Disable IRQ */
- ret = ade7754_set_irq(dev, false);
- if (ret) {
- dev_err(dev, "disable irq failed");
- goto err_ret;
- }
-
- ade7754_reset(dev);
- usleep_range(ADE7754_STARTUP_DELAY, ADE7754_STARTUP_DELAY + 100);
-
-err_ret:
- return ret;
-}
-
-static ssize_t ade7754_read_frequency(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u8 t;
- int sps;
-
- ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &t);
- if (ret)
- return ret;
-
- t = (t >> 3) & 0x3;
- sps = 26000 / (1 + t);
-
- return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7754_write_frequency(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7754_state *st = iio_priv(indio_dev);
- u16 val;
- int ret;
- u8 reg, t;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- return ret;
- if (!val)
- return -EINVAL;
-
- mutex_lock(&st->buf_lock);
-
- t = 26000 / val;
- if (t > 0)
- t--;
-
- if (t > 1)
- st->us->max_speed_hz = ADE7754_SPI_SLOW;
- else
- st->us->max_speed_hz = ADE7754_SPI_FAST;
-
- ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &reg);
- if (ret)
- goto out;
-
- reg &= ~(3 << 3);
- reg |= t << 3;
-
- ret = __ade7754_spi_write_reg_8(dev, ADE7754_WAVMODE, reg);
-
-out:
- mutex_unlock(&st->buf_lock);
-
- return ret ? ret : len;
-}
-static IIO_DEV_ATTR_TEMP_RAW(ade7754_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "129 C");
-static IIO_CONST_ATTR(in_temp_scale, "4 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
- ade7754_read_frequency,
- ade7754_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000");
-
-static struct attribute *ade7754_attributes[] = {
- &iio_dev_attr_in_temp_raw.dev_attr.attr,
- &iio_const_attr_in_temp_offset.dev_attr.attr,
- &iio_const_attr_in_temp_scale.dev_attr.attr,
- &iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_aenergy.dev_attr.attr,
- &iio_dev_attr_laenergy.dev_attr.attr,
- &iio_dev_attr_vaenergy.dev_attr.attr,
- &iio_dev_attr_lvaenergy.dev_attr.attr,
- &iio_dev_attr_vpeak.dev_attr.attr,
- &iio_dev_attr_ipeak.dev_attr.attr,
- &iio_dev_attr_aphcal.dev_attr.attr,
- &iio_dev_attr_bphcal.dev_attr.attr,
- &iio_dev_attr_cphcal.dev_attr.attr,
- &iio_dev_attr_aapos.dev_attr.attr,
- &iio_dev_attr_bapos.dev_attr.attr,
- &iio_dev_attr_capos.dev_attr.attr,
- &iio_dev_attr_wdiv.dev_attr.attr,
- &iio_dev_attr_vadiv.dev_attr.attr,
- &iio_dev_attr_cfnum.dev_attr.attr,
- &iio_dev_attr_cfden.dev_attr.attr,
- &iio_dev_attr_active_power_a_gain.dev_attr.attr,
- &iio_dev_attr_active_power_b_gain.dev_attr.attr,
- &iio_dev_attr_active_power_c_gain.dev_attr.attr,
- &iio_dev_attr_airms.dev_attr.attr,
- &iio_dev_attr_birms.dev_attr.attr,
- &iio_dev_attr_cirms.dev_attr.attr,
- &iio_dev_attr_avrms.dev_attr.attr,
- &iio_dev_attr_bvrms.dev_attr.attr,
- &iio_dev_attr_cvrms.dev_attr.attr,
- &iio_dev_attr_airmsos.dev_attr.attr,
- &iio_dev_attr_birmsos.dev_attr.attr,
- &iio_dev_attr_cirmsos.dev_attr.attr,
- &iio_dev_attr_avrmsos.dev_attr.attr,
- &iio_dev_attr_bvrmsos.dev_attr.attr,
- &iio_dev_attr_cvrmsos.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ade7754_attribute_group = {
- .attrs = ade7754_attributes,
-};
-
-static const struct iio_info ade7754_info = {
- .attrs = &ade7754_attribute_group,
-};
-
-static int ade7754_probe(struct spi_device *spi)
-{
- int ret;
- struct ade7754_state *st;
- struct iio_dev *indio_dev;
-
- /* setup the industrialio driver allocated elements */
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev)
- return -ENOMEM;
- /* this is only used for removal purposes */
- spi_set_drvdata(spi, indio_dev);
-
- st = iio_priv(indio_dev);
- st->us = spi;
- mutex_init(&st->buf_lock);
-
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ade7754_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- /* Get the device into a sane initial state */
- ret = ade7754_initial_setup(indio_dev);
- if (ret)
- goto powerdown_on_error;
- ret = iio_device_register(indio_dev);
- if (ret)
- goto powerdown_on_error;
- return ret;
-
-powerdown_on_error:
- ade7754_stop_device(&indio_dev->dev);
- return ret;
-}
-
-static int ade7754_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
- iio_device_unregister(indio_dev);
- ade7754_stop_device(&indio_dev->dev);
-
- return 0;
-}
-
-static struct spi_driver ade7754_driver = {
- .driver = {
- .name = "ade7754",
- },
- .probe = ade7754_probe,
- .remove = ade7754_remove,
-};
-module_spi_driver(ade7754_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ad7754");
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
deleted file mode 100644
index 2de81b53e786..000000000000
--- a/drivers/staging/iio/meter/ade7758.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#ifndef _ADE7758_H
-#define _ADE7758_H
-
-#define ADE7758_AWATTHR 0x01
-#define ADE7758_BWATTHR 0x02
-#define ADE7758_CWATTHR 0x03
-#define ADE7758_AVARHR 0x04
-#define ADE7758_BVARHR 0x05
-#define ADE7758_CVARHR 0x06
-#define ADE7758_AVAHR 0x07
-#define ADE7758_BVAHR 0x08
-#define ADE7758_CVAHR 0x09
-#define ADE7758_AIRMS 0x0A
-#define ADE7758_BIRMS 0x0B
-#define ADE7758_CIRMS 0x0C
-#define ADE7758_AVRMS 0x0D
-#define ADE7758_BVRMS 0x0E
-#define ADE7758_CVRMS 0x0F
-#define ADE7758_FREQ 0x10
-#define ADE7758_TEMP 0x11
-#define ADE7758_WFORM 0x12
-#define ADE7758_OPMODE 0x13
-#define ADE7758_MMODE 0x14
-#define ADE7758_WAVMODE 0x15
-#define ADE7758_COMPMODE 0x16
-#define ADE7758_LCYCMODE 0x17
-#define ADE7758_MASK 0x18
-#define ADE7758_STATUS 0x19
-#define ADE7758_RSTATUS 0x1A
-#define ADE7758_ZXTOUT 0x1B
-#define ADE7758_LINECYC 0x1C
-#define ADE7758_SAGCYC 0x1D
-#define ADE7758_SAGLVL 0x1E
-#define ADE7758_VPINTLVL 0x1F
-#define ADE7758_IPINTLVL 0x20
-#define ADE7758_VPEAK 0x21
-#define ADE7758_IPEAK 0x22
-#define ADE7758_GAIN 0x23
-#define ADE7758_AVRMSGAIN 0x24
-#define ADE7758_BVRMSGAIN 0x25
-#define ADE7758_CVRMSGAIN 0x26
-#define ADE7758_AIGAIN 0x27
-#define ADE7758_BIGAIN 0x28
-#define ADE7758_CIGAIN 0x29
-#define ADE7758_AWG 0x2A
-#define ADE7758_BWG 0x2B
-#define ADE7758_CWG 0x2C
-#define ADE7758_AVARG 0x2D
-#define ADE7758_BVARG 0x2E
-#define ADE7758_CVARG 0x2F
-#define ADE7758_AVAG 0x30
-#define ADE7758_BVAG 0x31
-#define ADE7758_CVAG 0x32
-#define ADE7758_AVRMSOS 0x33
-#define ADE7758_BVRMSOS 0x34
-#define ADE7758_CVRMSOS 0x35
-#define ADE7758_AIRMSOS 0x36
-#define ADE7758_BIRMSOS 0x37
-#define ADE7758_CIRMSOS 0x38
-#define ADE7758_AWAITOS 0x39
-#define ADE7758_BWAITOS 0x3A
-#define ADE7758_CWAITOS 0x3B
-#define ADE7758_AVAROS 0x3C
-#define ADE7758_BVAROS 0x3D
-#define ADE7758_CVAROS 0x3E
-#define ADE7758_APHCAL 0x3F
-#define ADE7758_BPHCAL 0x40
-#define ADE7758_CPHCAL 0x41
-#define ADE7758_WDIV 0x42
-#define ADE7758_VADIV 0x44
-#define ADE7758_VARDIV 0x43
-#define ADE7758_APCFNUM 0x45
-#define ADE7758_APCFDEN 0x46
-#define ADE7758_VARCFNUM 0x47
-#define ADE7758_VARCFDEN 0x48
-#define ADE7758_CHKSUM 0x7E
-#define ADE7758_VERSION 0x7F
-
-#define ADE7758_READ_REG(a) a
-#define ADE7758_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7758_MAX_TX 8
-#define ADE7758_MAX_RX 4
-#define ADE7758_STARTUP_DELAY 1000
-
-#define AD7758_NUM_WAVSEL 5
-#define AD7758_NUM_PHSEL 3
-#define AD7758_NUM_WAVESRC (AD7758_NUM_WAVSEL * AD7758_NUM_PHSEL)
-
-#define AD7758_PHASE_A 0
-#define AD7758_PHASE_B 1
-#define AD7758_PHASE_C 2
-#define AD7758_CURRENT 0
-#define AD7758_VOLTAGE 1
-#define AD7758_ACT_PWR 2
-#define AD7758_REACT_PWR 3
-#define AD7758_APP_PWR 4
-#define AD7758_WT(p, w) (((w) << 2) | (p))
-
-/**
- * struct ade7758_state - device instance specific data
- * @us: actual spi_device
- * @trig: data ready trigger registered with iio
- * @tx: transmit buffer
- * @rx: receive buffer
- * @buf_lock: mutex to protect tx, rx, read and write frequency
- **/
-struct ade7758_state {
- struct spi_device *us;
- struct iio_trigger *trig;
- u8 *tx;
- u8 *rx;
- struct mutex buf_lock;
- struct spi_transfer ring_xfer[4];
- struct spi_message ring_msg;
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
- unsigned char rx_buf[8] ____cacheline_aligned;
- unsigned char tx_buf[8];
-
-};
-
-#ifdef CONFIG_IIO_BUFFER
-/* At the moment triggers are only used for ring buffer
- * filling. This may change!
- */
-
-void ade7758_remove_trigger(struct iio_dev *indio_dev);
-int ade7758_probe_trigger(struct iio_dev *indio_dev);
-
-ssize_t ade7758_read_data_from_ring(struct device *dev,
- struct device_attribute *attr, char *buf);
-
-int ade7758_configure_ring(struct iio_dev *indio_dev);
-void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
-
-int ade7758_set_irq(struct device *dev, bool enable);
-
-int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val);
-int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline void ade7758_remove_trigger(struct iio_dev *indio_dev)
-{
-}
-
-static inline int ade7758_probe_trigger(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
-static int ade7758_configure_ring(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
-static inline void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
-{
-}
-
-static inline int ade7758_initialize_ring(struct iio_ring_buffer *ring)
-{
- return 0;
-}
-
-static inline void ade7758_uninitialize_ring(struct iio_dev *indio_dev)
-{
-}
-
-#endif /* CONFIG_IIO_BUFFER */
-
-#endif
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
deleted file mode 100644
index 4e0dbf5c5705..000000000000
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ /dev/null
@@ -1,955 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
-#include "meter.h"
-#include "ade7758.h"
-
-static int __ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
-
- st->tx[0] = ADE7758_WRITE_REG(reg_address);
- st->tx[1] = val;
-
- return spi_write(st->us, st->tx, 2);
-}
-
-int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- ret = __ade7758_spi_write_reg_8(dev, reg_address, val);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7758_spi_write_reg_16(struct device *dev, u8 reg_address,
- u16 value)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 3,
- }
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7758_WRITE_REG(reg_address);
- st->tx[1] = (value >> 8) & 0xFF;
- st->tx[2] = value & 0xFF;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7758_spi_write_reg_24(struct device *dev, u8 reg_address,
- u32 value)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 4,
- }
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7758_WRITE_REG(reg_address);
- st->tx[1] = (value >> 16) & 0xFF;
- st->tx[2] = (value >> 8) & 0xFF;
- st->tx[3] = value & 0xFF;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int __ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 1,
- .delay_usecs = 4,
- },
- {
- .tx_buf = &st->tx[1],
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 1,
- },
- };
-
- st->tx[0] = ADE7758_READ_REG(reg_address);
- st->tx[1] = 0;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = st->rx[0];
-
-error_ret:
- return ret;
-}
-
-int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&st->buf_lock);
- ret = __ade7758_spi_read_reg_8(dev, reg_address, val);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7758_spi_read_reg_16(struct device *dev, u8 reg_address,
- u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 1,
- .delay_usecs = 4,
- },
- {
- .tx_buf = &st->tx[1],
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 2,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7758_READ_REG(reg_address);
- st->tx[1] = 0;
- st->tx[2] = 0;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
-
- *val = (st->rx[0] << 8) | st->rx[1];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7758_spi_read_reg_24(struct device *dev, u8 reg_address,
- u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 1,
- .delay_usecs = 4,
- },
- {
- .tx_buf = &st->tx[1],
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 3,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7758_READ_REG(reg_address);
- st->tx[1] = 0;
- st->tx[2] = 0;
- st->tx[3] = 0;
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static ssize_t ade7758_read_8bit(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- int ret;
- u8 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7758_spi_read_reg_8(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7758_read_16bit(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- int ret;
- u16 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7758_spi_read_reg_16(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7758_read_24bit(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- int ret;
- u32 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7758_spi_read_reg_24(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val & 0xFFFFFF);
-}
-
-static ssize_t ade7758_write_8bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u8 val;
-
- ret = kstrtou8(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7758_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static ssize_t ade7758_write_16bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u16 val;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7758_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static int ade7758_reset(struct device *dev)
-{
- int ret;
- u8 val;
-
- ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
- if (ret < 0) {
- dev_err(dev, "Failed to read opmode reg\n");
- return ret;
- }
- val |= BIT(6); /* Software Chip Reset */
- ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
- if (ret < 0)
- dev_err(dev, "Failed to write opmode reg\n");
- return ret;
-}
-
-static IIO_DEV_ATTR_VPEAK(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_VPEAK);
-static IIO_DEV_ATTR_IPEAK(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_VPEAK);
-static IIO_DEV_ATTR_APHCAL(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_APHCAL);
-static IIO_DEV_ATTR_BPHCAL(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_BPHCAL);
-static IIO_DEV_ATTR_CPHCAL(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_CPHCAL);
-static IIO_DEV_ATTR_WDIV(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_WDIV);
-static IIO_DEV_ATTR_VADIV(0644,
- ade7758_read_8bit,
- ade7758_write_8bit,
- ADE7758_VADIV);
-static IIO_DEV_ATTR_AIRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_AIRMS);
-static IIO_DEV_ATTR_BIRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_BIRMS);
-static IIO_DEV_ATTR_CIRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_CIRMS);
-static IIO_DEV_ATTR_AVRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_AVRMS);
-static IIO_DEV_ATTR_BVRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_BVRMS);
-static IIO_DEV_ATTR_CVRMS(0444,
- ade7758_read_24bit,
- NULL,
- ADE7758_CVRMS);
-static IIO_DEV_ATTR_AIRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_AIRMSOS);
-static IIO_DEV_ATTR_BIRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_BIRMSOS);
-static IIO_DEV_ATTR_CIRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_CIRMSOS);
-static IIO_DEV_ATTR_AVRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_AVRMSOS);
-static IIO_DEV_ATTR_BVRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_BVRMSOS);
-static IIO_DEV_ATTR_CVRMSOS(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_CVRMSOS);
-static IIO_DEV_ATTR_AIGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_AIGAIN);
-static IIO_DEV_ATTR_BIGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_BIGAIN);
-static IIO_DEV_ATTR_CIGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_CIGAIN);
-static IIO_DEV_ATTR_AVRMSGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_AVRMSGAIN);
-static IIO_DEV_ATTR_BVRMSGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_BVRMSGAIN);
-static IIO_DEV_ATTR_CVRMSGAIN(0644,
- ade7758_read_16bit,
- ade7758_write_16bit,
- ADE7758_CVRMSGAIN);
-
-int ade7758_set_irq(struct device *dev, bool enable)
-{
- int ret;
- u32 irqen;
-
- ret = ade7758_spi_read_reg_24(dev, ADE7758_MASK, &irqen);
- if (ret)
- return ret;
-
- if (enable)
- irqen |= BIT(16); /* Enables an interrupt when a data is
- * present in the waveform register
- */
- else
- irqen &= ~BIT(16);
-
- ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen);
-
- return ret;
-}
-
-/* Power down the device */
-static int ade7758_stop_device(struct device *dev)
-{
- int ret;
- u8 val;
-
- ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
- if (ret < 0) {
- dev_err(dev, "Failed to read opmode reg\n");
- return ret;
- }
- val |= 7 << 3; /* ADE7758 powered down */
- ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
- if (ret < 0)
- dev_err(dev, "Failed to write opmode reg\n");
- return ret;
-}
-
-static int ade7758_initial_setup(struct iio_dev *indio_dev)
-{
- struct ade7758_state *st = iio_priv(indio_dev);
- struct device *dev = &indio_dev->dev;
- int ret;
-
- /* use low spi speed for init */
- st->us->mode = SPI_MODE_1;
- spi_setup(st->us);
-
- /* Disable IRQ */
- ret = ade7758_set_irq(dev, false);
- if (ret) {
- dev_err(dev, "disable irq failed");
- goto err_ret;
- }
-
- ade7758_reset(dev);
- usleep_range(ADE7758_STARTUP_DELAY, ADE7758_STARTUP_DELAY + 100);
-
-err_ret:
- return ret;
-}
-
-static int ade7758_read_samp_freq(struct device *dev, int *val)
-{
- int ret;
- u8 t;
-
- ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &t);
- if (ret)
- return ret;
-
- t = (t >> 5) & 0x3;
- *val = 26040 / (1 << t);
-
- return 0;
-}
-
-static int ade7758_write_samp_freq(struct device *dev, int val)
-{
- int ret;
- u8 reg, t;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7758_state *st = iio_priv(indio_dev);
-
- switch (val) {
- case 26040:
- t = 0;
- break;
- case 13020:
- t = 1;
- break;
- case 6510:
- t = 2;
- break;
- case 3255:
- t = 3;
- break;
- default:
- return -EINVAL;
- }
-
- mutex_lock(&st->buf_lock);
-
- ret = __ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
- if (ret)
- goto out;
-
- reg &= ~(5 << 3);
- reg |= t << 5;
-
- ret = __ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
-
-out:
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7758_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask)
-{
- int ret;
-
- switch (mask) {
- case IIO_CHAN_INFO_SAMP_FREQ:
-
- ret = ade7758_read_samp_freq(&indio_dev->dev, val);
-
- return ret;
- default:
- return -EINVAL;
- }
-
- return ret;
-}
-
-static int ade7758_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val, int val2, long mask)
-{
- int ret;
-
- switch (mask) {
- case IIO_CHAN_INFO_SAMP_FREQ:
- if (val2)
- return -EINVAL;
-
- ret = ade7758_write_samp_freq(&indio_dev->dev, val);
-
- return ret;
- default:
- return -EINVAL;
- }
-
- return ret;
-}
-
-static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "129 C");
-static IIO_CONST_ATTR(in_temp_scale, "4 C");
-
-static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit,
- ADE7758_AWATTHR);
-static IIO_DEV_ATTR_BWATTHR(ade7758_read_16bit,
- ADE7758_BWATTHR);
-static IIO_DEV_ATTR_CWATTHR(ade7758_read_16bit,
- ADE7758_CWATTHR);
-static IIO_DEV_ATTR_AVARHR(ade7758_read_16bit,
- ADE7758_AVARHR);
-static IIO_DEV_ATTR_BVARHR(ade7758_read_16bit,
- ADE7758_BVARHR);
-static IIO_DEV_ATTR_CVARHR(ade7758_read_16bit,
- ADE7758_CVARHR);
-static IIO_DEV_ATTR_AVAHR(ade7758_read_16bit,
- ADE7758_AVAHR);
-static IIO_DEV_ATTR_BVAHR(ade7758_read_16bit,
- ADE7758_BVAHR);
-static IIO_DEV_ATTR_CVAHR(ade7758_read_16bit,
- ADE7758_CVAHR);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
-
-static struct attribute *ade7758_attributes[] = {
- &iio_dev_attr_in_temp_raw.dev_attr.attr,
- &iio_const_attr_in_temp_offset.dev_attr.attr,
- &iio_const_attr_in_temp_scale.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_awatthr.dev_attr.attr,
- &iio_dev_attr_bwatthr.dev_attr.attr,
- &iio_dev_attr_cwatthr.dev_attr.attr,
- &iio_dev_attr_avarhr.dev_attr.attr,
- &iio_dev_attr_bvarhr.dev_attr.attr,
- &iio_dev_attr_cvarhr.dev_attr.attr,
- &iio_dev_attr_avahr.dev_attr.attr,
- &iio_dev_attr_bvahr.dev_attr.attr,
- &iio_dev_attr_cvahr.dev_attr.attr,
- &iio_dev_attr_vpeak.dev_attr.attr,
- &iio_dev_attr_ipeak.dev_attr.attr,
- &iio_dev_attr_aphcal.dev_attr.attr,
- &iio_dev_attr_bphcal.dev_attr.attr,
- &iio_dev_attr_cphcal.dev_attr.attr,
- &iio_dev_attr_wdiv.dev_attr.attr,
- &iio_dev_attr_vadiv.dev_attr.attr,
- &iio_dev_attr_airms.dev_attr.attr,
- &iio_dev_attr_birms.dev_attr.attr,
- &iio_dev_attr_cirms.dev_attr.attr,
- &iio_dev_attr_avrms.dev_attr.attr,
- &iio_dev_attr_bvrms.dev_attr.attr,
- &iio_dev_attr_cvrms.dev_attr.attr,
- &iio_dev_attr_aigain.dev_attr.attr,
- &iio_dev_attr_bigain.dev_attr.attr,
- &iio_dev_attr_cigain.dev_attr.attr,
- &iio_dev_attr_avrmsgain.dev_attr.attr,
- &iio_dev_attr_bvrmsgain.dev_attr.attr,
- &iio_dev_attr_cvrmsgain.dev_attr.attr,
- &iio_dev_attr_airmsos.dev_attr.attr,
- &iio_dev_attr_birmsos.dev_attr.attr,
- &iio_dev_attr_cirmsos.dev_attr.attr,
- &iio_dev_attr_avrmsos.dev_attr.attr,
- &iio_dev_attr_bvrmsos.dev_attr.attr,
- &iio_dev_attr_cvrmsos.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ade7758_attribute_group = {
- .attrs = ade7758_attributes,
-};
-
-static const struct iio_chan_spec ade7758_channels[] = {
- {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
- .scan_index = 0,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 0,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
- .scan_index = 1,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
- .extend_name = "apparent",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
- .scan_index = 2,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
- .extend_name = "active",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
- .scan_index = 3,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
- .extend_name = "reactive",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
- .scan_index = 4,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 1,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
- .scan_index = 5,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 1,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
- .scan_index = 6,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
- .extend_name = "apparent",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
- .scan_index = 7,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
- .extend_name = "active",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
- .scan_index = 8,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
- .extend_name = "reactive",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
- .scan_index = 9,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 2,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
- .scan_index = 10,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 2,
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
- .scan_index = 11,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
- .extend_name = "apparent",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
- .scan_index = 12,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
- .extend_name = "active",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
- .scan_index = 13,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- }, {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
- .extend_name = "reactive",
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
- .scan_index = 14,
- .scan_type = {
- .sign = 's',
- .realbits = 24,
- .storagebits = 32,
- },
- },
- IIO_CHAN_SOFT_TIMESTAMP(15),
-};
-
-static const struct iio_info ade7758_info = {
- .attrs = &ade7758_attribute_group,
- .read_raw = &ade7758_read_raw,
- .write_raw = &ade7758_write_raw,
-};
-
-static int ade7758_probe(struct spi_device *spi)
-{
- int ret;
- struct ade7758_state *st;
- struct iio_dev *indio_dev;
-
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev)
- return -ENOMEM;
-
- st = iio_priv(indio_dev);
- /* this is only used for removal purposes */
- spi_set_drvdata(spi, indio_dev);
-
- /* Allocate the comms buffers */
- st->rx = kcalloc(ADE7758_MAX_RX, sizeof(*st->rx), GFP_KERNEL);
- if (!st->rx)
- return -ENOMEM;
- st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
- if (!st->tx) {
- ret = -ENOMEM;
- goto error_free_rx;
- }
- st->us = spi;
- mutex_init(&st->buf_lock);
-
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ade7758_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = ade7758_channels;
- indio_dev->num_channels = ARRAY_SIZE(ade7758_channels);
-
- ret = ade7758_configure_ring(indio_dev);
- if (ret)
- goto error_free_tx;
-
- /* Get the device into a sane initial state */
- ret = ade7758_initial_setup(indio_dev);
- if (ret)
- goto error_unreg_ring_funcs;
-
- if (spi->irq) {
- ret = ade7758_probe_trigger(indio_dev);
- if (ret)
- goto error_unreg_ring_funcs;
- }
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_remove_trigger;
-
- return 0;
-
-error_remove_trigger:
- if (spi->irq)
- ade7758_remove_trigger(indio_dev);
-error_unreg_ring_funcs:
- ade7758_unconfigure_ring(indio_dev);
-error_free_tx:
- kfree(st->tx);
-error_free_rx:
- kfree(st->rx);
- return ret;
-}
-
-static int ade7758_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ade7758_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- ade7758_stop_device(&indio_dev->dev);
- ade7758_remove_trigger(indio_dev);
- ade7758_unconfigure_ring(indio_dev);
- kfree(st->tx);
- kfree(st->rx);
-
- return 0;
-}
-
-static const struct spi_device_id ade7758_id[] = {
- {"ade7758", 0},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ade7758_id);
-
-static struct spi_driver ade7758_driver = {
- .driver = {
- .name = "ade7758",
- },
- .probe = ade7758_probe,
- .remove = ade7758_remove,
- .id_table = ade7758_id,
-};
-module_spi_driver(ade7758_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
deleted file mode 100644
index 6d7444d6e880..000000000000
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-#include <linux/export.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <asm/unaligned.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/kfifo_buf.h>
-#include <linux/iio/trigger_consumer.h>
-#include "ade7758.h"
-
-/**
- * ade7758_spi_read_burst() - read data registers
- * @indio_dev: the IIO device
- **/
-static int ade7758_spi_read_burst(struct iio_dev *indio_dev)
-{
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
-
- ret = spi_sync(st->us, &st->ring_msg);
- if (ret)
- dev_err(&st->us->dev, "problem when reading WFORM value\n");
-
- return ret;
-}
-
-static int ade7758_write_waveform_type(struct device *dev, unsigned int type)
-{
- int ret;
- u8 reg;
-
- ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
- if (ret)
- goto out;
-
- reg &= ~0x1F;
- reg |= type & 0x1F;
-
- ret = ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
-out:
- return ret;
-}
-
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is too device
- * specific to be rolled into the core.
- */
-static irqreturn_t ade7758_trigger_handler(int irq, void *p)
-{
- struct iio_poll_func *pf = p;
- struct iio_dev *indio_dev = pf->indio_dev;
- struct ade7758_state *st = iio_priv(indio_dev);
- s64 dat64[2];
- u32 *dat32 = (u32 *)dat64;
-
- if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
- if (ade7758_spi_read_burst(indio_dev) >= 0)
- *dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
-
- iio_push_to_buffers_with_timestamp(indio_dev, dat64, pf->timestamp);
-
- iio_trigger_notify_done(indio_dev->trig);
-
- return IRQ_HANDLED;
-}
-
-/**
- * ade7758_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the number of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
- **/
-static int ade7758_ring_preenable(struct iio_dev *indio_dev)
-{
- unsigned int channel;
-
- if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
- return -EINVAL;
-
- channel = find_first_bit(indio_dev->active_scan_mask,
- indio_dev->masklength);
-
- ade7758_write_waveform_type(&indio_dev->dev,
- indio_dev->channels[channel].address);
-
- return 0;
-}
-
-static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = {
- .preenable = &ade7758_ring_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
- .validate_scan_mask = &iio_validate_scan_mask_onehot,
-};
-
-void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
-{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_kfifo_free(indio_dev->buffer);
-}
-
-int ade7758_configure_ring(struct iio_dev *indio_dev)
-{
- struct ade7758_state *st = iio_priv(indio_dev);
- struct iio_buffer *buffer;
- int ret = 0;
-
- buffer = iio_kfifo_allocate();
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- indio_dev->setup_ops = &ade7758_ring_setup_ops;
-
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &ade7758_trigger_handler,
- 0,
- indio_dev,
- "ade7759_consumer%d",
- indio_dev->id);
- if (!indio_dev->pollfunc) {
- ret = -ENOMEM;
- goto error_iio_kfifo_free;
- }
-
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
-
- st->tx_buf[0] = ADE7758_READ_REG(ADE7758_RSTATUS);
- st->tx_buf[1] = 0;
- st->tx_buf[2] = 0;
- st->tx_buf[3] = 0;
- st->tx_buf[4] = ADE7758_READ_REG(ADE7758_WFORM);
- st->tx_buf[5] = 0;
- st->tx_buf[6] = 0;
- st->tx_buf[7] = 0;
-
- /* build spi ring message */
- st->ring_xfer[0].tx_buf = &st->tx_buf[0];
- st->ring_xfer[0].len = 1;
- st->ring_xfer[0].bits_per_word = 8;
- st->ring_xfer[0].delay_usecs = 4;
- st->ring_xfer[1].rx_buf = &st->rx_buf[1];
- st->ring_xfer[1].len = 3;
- st->ring_xfer[1].bits_per_word = 8;
- st->ring_xfer[1].cs_change = 1;
-
- st->ring_xfer[2].tx_buf = &st->tx_buf[4];
- st->ring_xfer[2].len = 1;
- st->ring_xfer[2].bits_per_word = 8;
- st->ring_xfer[2].delay_usecs = 1;
- st->ring_xfer[3].rx_buf = &st->rx_buf[5];
- st->ring_xfer[3].len = 3;
- st->ring_xfer[3].bits_per_word = 8;
-
- spi_message_init(&st->ring_msg);
- spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
- spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
- spi_message_add_tail(&st->ring_xfer[2], &st->ring_msg);
- spi_message_add_tail(&st->ring_xfer[3], &st->ring_msg);
-
- return 0;
-
-error_iio_kfifo_free:
- iio_kfifo_free(indio_dev->buffer);
- return ret;
-}
diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
deleted file mode 100644
index 4f6b338cffeb..000000000000
--- a/drivers/staging/iio/meter/ade7758_trigger.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/export.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/trigger.h>
-#include "ade7758.h"
-
-/**
- * ade7758_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private)
-{
- disable_irq_nosync(irq);
- iio_trigger_poll(private);
-
- return IRQ_HANDLED;
-}
-
-/**
- * ade7758_data_rdy_trigger_set_state() set datardy interrupt state
- **/
-static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
- bool state)
-{
- struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
-
- dev_dbg(&indio_dev->dev, "(%d)\n", state);
- return ade7758_set_irq(&indio_dev->dev, state);
-}
-
-/**
- * ade7758_trig_try_reen() try renabling irq for data rdy trigger
- * @trig: the datardy trigger
- **/
-static int ade7758_trig_try_reen(struct iio_trigger *trig)
-{
- struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
- struct ade7758_state *st = iio_priv(indio_dev);
-
- enable_irq(st->us->irq);
- /* irq reenabled so success! */
- return 0;
-}
-
-static const struct iio_trigger_ops ade7758_trigger_ops = {
- .set_trigger_state = &ade7758_data_rdy_trigger_set_state,
- .try_reenable = &ade7758_trig_try_reen,
-};
-
-int ade7758_probe_trigger(struct iio_dev *indio_dev)
-{
- struct ade7758_state *st = iio_priv(indio_dev);
- int ret;
-
- st->trig = iio_trigger_alloc("%s-dev%d",
- spi_get_device_id(st->us)->name,
- indio_dev->id);
- if (!st->trig) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- ret = request_irq(st->us->irq,
- ade7758_data_rdy_trig_poll,
- IRQF_TRIGGER_LOW,
- spi_get_device_id(st->us)->name,
- st->trig);
- if (ret)
- goto error_free_trig;
-
- st->trig->dev.parent = &st->us->dev;
- st->trig->ops = &ade7758_trigger_ops;
- iio_trigger_set_drvdata(st->trig, indio_dev);
- ret = iio_trigger_register(st->trig);
-
- /* select default trigger */
- indio_dev->trig = iio_trigger_get(st->trig);
- if (ret)
- goto error_free_irq;
-
- return 0;
-
-error_free_irq:
- free_irq(st->us->irq, st->trig);
-error_free_trig:
- iio_trigger_free(st->trig);
-error_ret:
- return ret;
-}
-
-void ade7758_remove_trigger(struct iio_dev *indio_dev)
-{
- struct ade7758_state *st = iio_priv(indio_dev);
-
- iio_trigger_unregister(st->trig);
- free_irq(st->us->irq, st->trig);
- iio_trigger_free(st->trig);
-}
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
deleted file mode 100644
index c078b770fa53..000000000000
--- a/drivers/staging/iio/meter/ade7759.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * ADE7759 Active Energy Metering IC with di/dt Sensor Interface Driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include "meter.h"
-
-#define ADE7759_WAVEFORM 0x01
-#define ADE7759_AENERGY 0x02
-#define ADE7759_RSTENERGY 0x03
-#define ADE7759_STATUS 0x04
-#define ADE7759_RSTSTATUS 0x05
-#define ADE7759_MODE 0x06
-#define ADE7759_CFDEN 0x07
-#define ADE7759_CH1OS 0x08
-#define ADE7759_CH2OS 0x09
-#define ADE7759_GAIN 0x0A
-#define ADE7759_APGAIN 0x0B
-#define ADE7759_PHCAL 0x0C
-#define ADE7759_APOS 0x0D
-#define ADE7759_ZXTOUT 0x0E
-#define ADE7759_SAGCYC 0x0F
-#define ADE7759_IRQEN 0x10
-#define ADE7759_SAGLVL 0x11
-#define ADE7759_TEMP 0x12
-#define ADE7759_LINECYC 0x13
-#define ADE7759_LENERGY 0x14
-#define ADE7759_CFNUM 0x15
-#define ADE7759_CHKSUM 0x1E
-#define ADE7759_DIEREV 0x1F
-
-#define ADE7759_READ_REG(a) a
-#define ADE7759_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7759_MAX_TX 6
-#define ADE7759_MAX_RX 6
-#define ADE7759_STARTUP_DELAY 1000
-
-#define ADE7759_SPI_SLOW (u32)(300 * 1000)
-#define ADE7759_SPI_BURST (u32)(1000 * 1000)
-#define ADE7759_SPI_FAST (u32)(2000 * 1000)
-
-/**
- * struct ade7759_state - device instance specific data
- * @us: actual spi_device
- * @buf_lock: mutex to protect tx and rx and write frequency
- * @tx: transmit buffer
- * @rx: receive buffer
- **/
-struct ade7759_state {
- struct spi_device *us;
- struct mutex buf_lock;
- u8 tx[ADE7759_MAX_TX] ____cacheline_aligned;
- u8 rx[ADE7759_MAX_RX];
-};
-
-static int ade7759_spi_write_reg_8(struct device *dev,
- u8 reg_address,
- u8 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7759_WRITE_REG(reg_address);
- st->tx[1] = val;
-
- ret = spi_write(st->us, st->tx, 2);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-/*Unlocked version of ade7759_spi_write_reg_16 function */
-static int __ade7759_spi_write_reg_16(struct device *dev,
- u8 reg_address,
- u16 value)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
-
- st->tx[0] = ADE7759_WRITE_REG(reg_address);
- st->tx[1] = (value >> 8) & 0xFF;
- st->tx[2] = value & 0xFF;
- return spi_write(st->us, st->tx, 3);
-}
-
-static int ade7759_spi_write_reg_16(struct device *dev,
- u8 reg_address,
- u16 value)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- ret = __ade7759_spi_write_reg_16(dev, reg_address, value);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7759_spi_read_reg_8(struct device *dev,
- u8 reg_address,
- u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
- int ret;
-
- ret = spi_w8r8(st->us, ADE7759_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev,
- "problem when reading 8 bit register 0x%02X",
- reg_address);
- return ret;
- }
- *val = ret;
-
- return 0;
-}
-
-static int ade7759_spi_read_reg_16(struct device *dev,
- u8 reg_address,
- u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
- int ret;
-
- ret = spi_w8r16be(st->us, ADE7759_READ_REG(reg_address));
- if (ret < 0) {
- dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
- reg_address);
- return ret;
- }
-
- *val = ret;
-
- return 0;
-}
-
-static int ade7759_spi_read_reg_40(struct device *dev,
- u8 reg_address,
- u64 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 6,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7759_READ_REG(reg_address);
- memset(&st->tx[1], 0, 5);
-
- ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->us->dev,
- "problem when reading 40 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = ((u64)st->rx[1] << 32) | ((u64)st->rx[2] << 24) |
- (st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static ssize_t ade7759_read_8bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u8 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7759_spi_read_reg_8(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7759_read_16bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u16 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7759_spi_read_reg_16(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7759_read_40bit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u64 val = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = ade7759_spi_read_reg_40(dev, this_attr->address, &val);
- if (ret)
- return ret;
-
- return sprintf(buf, "%llu\n", val);
-}
-
-static ssize_t ade7759_write_8bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u8 val;
-
- ret = kstrtou8(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7759_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static ssize_t ade7759_write_16bit(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- u16 val;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- goto error_ret;
- ret = ade7759_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
- return ret ? ret : len;
-}
-
-static int ade7759_reset(struct device *dev)
-{
- int ret;
- u16 val;
-
- ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
- if (ret < 0)
- return ret;
-
- val |= BIT(6); /* Software Chip Reset */
- return ade7759_spi_write_reg_16(dev,
- ADE7759_MODE,
- val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7759_read_40bit, ADE7759_AENERGY);
-static IIO_DEV_ATTR_CFDEN(0644,
- ade7759_read_16bit,
- ade7759_write_16bit,
- ADE7759_CFDEN);
-static IIO_DEV_ATTR_CFNUM(0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_CFNUM);
-static IIO_DEV_ATTR_CHKSUM(ade7759_read_8bit, ADE7759_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(0644,
- ade7759_read_16bit,
- ade7759_write_16bit,
- ADE7759_PHCAL);
-static IIO_DEV_ATTR_APOS(0644,
- ade7759_read_16bit,
- ade7759_write_16bit,
- ADE7759_APOS);
-static IIO_DEV_ATTR_SAGCYC(0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_LINECYC);
-static IIO_DEV_ATTR_LENERGY(ade7759_read_40bit, ADE7759_LENERGY);
-static IIO_DEV_ATTR_PGA_GAIN(0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_GAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_GAIN(0644,
- ade7759_read_16bit,
- ade7759_write_16bit,
- ADE7759_APGAIN);
-
-static IIO_DEVICE_ATTR(choff_1, 0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_CH1OS);
-
-static IIO_DEVICE_ATTR(choff_2, 0644,
- ade7759_read_8bit,
- ade7759_write_8bit,
- ADE7759_CH2OS);
-
-static int ade7759_set_irq(struct device *dev, bool enable)
-{
- int ret;
- u8 irqen;
-
- ret = ade7759_spi_read_reg_8(dev, ADE7759_IRQEN, &irqen);
- if (ret)
- goto error_ret;
-
- if (enable)
- irqen |= BIT(3); /* Enables an interrupt when a data is
- * present in the waveform register
- */
- else
- irqen &= ~BIT(3);
-
- ret = ade7759_spi_write_reg_8(dev, ADE7759_IRQEN, irqen);
-
-error_ret:
- return ret;
-}
-
-/* Power down the device */
-static int ade7759_stop_device(struct device *dev)
-{
- int ret;
- u16 val;
-
- ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
- if (ret < 0) {
- dev_err(dev, "unable to power down the device, error: %d\n",
- ret);
- return ret;
- }
-
- val |= BIT(4); /* AD converters can be turned off */
-
- return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val);
-}
-
-static int ade7759_initial_setup(struct iio_dev *indio_dev)
-{
- int ret;
- struct ade7759_state *st = iio_priv(indio_dev);
- struct device *dev = &indio_dev->dev;
-
- /* use low spi speed for init */
- st->us->mode = SPI_MODE_3;
- spi_setup(st->us);
-
- /* Disable IRQ */
- ret = ade7759_set_irq(dev, false);
- if (ret) {
- dev_err(dev, "disable irq failed");
- goto err_ret;
- }
-
- ade7759_reset(dev);
- usleep_range(ADE7759_STARTUP_DELAY, ADE7759_STARTUP_DELAY + 100);
-
-err_ret:
- return ret;
-}
-
-static ssize_t ade7759_read_frequency(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- u16 t;
- int sps;
-
- ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &t);
- if (ret)
- return ret;
-
- t = (t >> 3) & 0x3;
- sps = 27900 / (1 + t);
-
- return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7759_write_frequency(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7759_state *st = iio_priv(indio_dev);
- u16 val;
- int ret;
- u16 reg, t;
-
- ret = kstrtou16(buf, 10, &val);
- if (ret)
- return ret;
- if (!val)
- return -EINVAL;
-
- mutex_lock(&st->buf_lock);
-
- t = 27900 / val;
- if (t > 0)
- t--;
-
- if (t > 1)
- st->us->max_speed_hz = ADE7759_SPI_SLOW;
- else
- st->us->max_speed_hz = ADE7759_SPI_FAST;
-
- ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &reg);
- if (ret)
- goto out;
-
- reg &= ~(3 << 13);
- reg |= t << 13;
-
- ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
-
-out:
- mutex_unlock(&st->buf_lock);
-
- return ret ? ret : len;
-}
-static IIO_DEV_ATTR_TEMP_RAW(ade7759_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "70 C");
-static IIO_CONST_ATTR(in_temp_scale, "1 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
- ade7759_read_frequency,
- ade7759_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
-
-static struct attribute *ade7759_attributes[] = {
- &iio_dev_attr_in_temp_raw.dev_attr.attr,
- &iio_const_attr_in_temp_offset.dev_attr.attr,
- &iio_const_attr_in_temp_scale.dev_attr.attr,
- &iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_phcal.dev_attr.attr,
- &iio_dev_attr_cfden.dev_attr.attr,
- &iio_dev_attr_aenergy.dev_attr.attr,
- &iio_dev_attr_cfnum.dev_attr.attr,
- &iio_dev_attr_apos.dev_attr.attr,
- &iio_dev_attr_sagcyc.dev_attr.attr,
- &iio_dev_attr_saglvl.dev_attr.attr,
- &iio_dev_attr_linecyc.dev_attr.attr,
- &iio_dev_attr_lenergy.dev_attr.attr,
- &iio_dev_attr_chksum.dev_attr.attr,
- &iio_dev_attr_pga_gain.dev_attr.attr,
- &iio_dev_attr_active_power_gain.dev_attr.attr,
- &iio_dev_attr_choff_1.dev_attr.attr,
- &iio_dev_attr_choff_2.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ade7759_attribute_group = {
- .attrs = ade7759_attributes,
-};
-
-static const struct iio_info ade7759_info = {
- .attrs = &ade7759_attribute_group,
-};
-
-static int ade7759_probe(struct spi_device *spi)
-{
- int ret;
- struct ade7759_state *st;
- struct iio_dev *indio_dev;
-
- /* setup the industrialio driver allocated elements */
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev)
- return -ENOMEM;
- /* this is only used for removal purposes */
- spi_set_drvdata(spi, indio_dev);
-
- st = iio_priv(indio_dev);
- st->us = spi;
- mutex_init(&st->buf_lock);
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ade7759_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- /* Get the device into a sane initial state */
- ret = ade7759_initial_setup(indio_dev);
- if (ret)
- return ret;
-
- return iio_device_register(indio_dev);
-}
-
-static int ade7759_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
- iio_device_unregister(indio_dev);
- ade7759_stop_device(&indio_dev->dev);
-
- return 0;
-}
-
-static struct spi_driver ade7759_driver = {
- .driver = {
- .name = "ade7759",
- },
- .probe = ade7759_probe,
- .remove = ade7759_remove,
-};
-module_spi_driver(ade7759_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7759 Active Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ad7759");
diff --git a/drivers/staging/iio/meter/ade7854-i2c.c b/drivers/staging/iio/meter/ade7854-i2c.c
index 317e4f0d8176..c3aa6ea9d036 100644
--- a/drivers/staging/iio/meter/ade7854-i2c.c
+++ b/drivers/staging/iio/meter/ade7854-i2c.c
@@ -15,91 +15,60 @@
#include <linux/iio/iio.h>
#include "ade7854.h"
-static int ade7854_i2c_write_reg_8(struct device *dev,
- u16 reg_address,
- u8 val)
+static int ade7854_i2c_write_reg(struct device *dev,
+ u16 reg_address,
+ u32 val,
+ int bits)
{
int ret;
+ int count;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
st->tx[0] = (reg_address >> 8) & 0xFF;
st->tx[1] = reg_address & 0xFF;
- st->tx[2] = val;
- ret = i2c_master_send(st->i2c, st->tx, 3);
+ switch (bits) {
+ case 8:
+ st->tx[2] = val & 0xFF;
+ count = 3;
+ break;
+ case 16:
+ st->tx[2] = (val >> 8) & 0xFF;
+ st->tx[3] = val & 0xFF;
+ count = 4;
+ break;
+ case 24:
+ st->tx[2] = (val >> 16) & 0xFF;
+ st->tx[3] = (val >> 8) & 0xFF;
+ st->tx[4] = val & 0xFF;
+ count = 5;
+ break;
+ case 32:
+ st->tx[2] = (val >> 24) & 0xFF;
+ st->tx[3] = (val >> 16) & 0xFF;
+ st->tx[4] = (val >> 8) & 0xFF;
+ st->tx[5] = val & 0xFF;
+ count = 6;
+ break;
+ default:
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+ ret = i2c_master_send(st->i2c, st->tx, count);
+
+unlock:
mutex_unlock(&st->buf_lock);
- return ret;
+ return ret < 0 ? ret : 0;
}
-static int ade7854_i2c_write_reg_16(struct device *dev,
- u16 reg_address,
- u16 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
- st->tx[2] = (val >> 8) & 0xFF;
- st->tx[3] = val & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 4);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_i2c_write_reg_24(struct device *dev,
- u16 reg_address,
- u32 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
- st->tx[2] = (val >> 16) & 0xFF;
- st->tx[3] = (val >> 8) & 0xFF;
- st->tx[4] = val & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 5);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_i2c_write_reg_32(struct device *dev,
- u16 reg_address,
- u32 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
- st->tx[2] = (val >> 24) & 0xFF;
- st->tx[3] = (val >> 16) & 0xFF;
- st->tx[4] = (val >> 8) & 0xFF;
- st->tx[5] = val & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 6);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_i2c_read_reg_8(struct device *dev,
- u16 reg_address,
- u8 *val)
+static int ade7854_i2c_read_reg(struct device *dev,
+ u16 reg_address,
+ u32 *val,
+ int bits)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
@@ -110,94 +79,33 @@ static int ade7854_i2c_read_reg_8(struct device *dev,
st->tx[1] = reg_address & 0xFF;
ret = i2c_master_send(st->i2c, st->tx, 2);
- if (ret)
- goto out;
-
- ret = i2c_master_recv(st->i2c, st->rx, 1);
- if (ret)
- goto out;
-
- *val = st->rx[0];
-out:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7854_i2c_read_reg_16(struct device *dev,
- u16 reg_address,
- u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 2);
- if (ret)
- goto out;
-
- ret = i2c_master_recv(st->i2c, st->rx, 2);
- if (ret)
- goto out;
-
- *val = (st->rx[0] << 8) | st->rx[1];
-out:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7854_i2c_read_reg_24(struct device *dev,
- u16 reg_address,
- u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 2);
- if (ret)
- goto out;
-
- ret = i2c_master_recv(st->i2c, st->rx, 3);
- if (ret)
- goto out;
-
- *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-out:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7854_i2c_read_reg_32(struct device *dev,
- u16 reg_address,
- u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = (reg_address >> 8) & 0xFF;
- st->tx[1] = reg_address & 0xFF;
-
- ret = i2c_master_send(st->i2c, st->tx, 2);
- if (ret)
- goto out;
-
- ret = i2c_master_recv(st->i2c, st->rx, 3);
- if (ret)
- goto out;
-
- *val = (st->rx[0] << 24) | (st->rx[1] << 16) |
- (st->rx[2] << 8) | st->rx[3];
-out:
+ if (ret < 0)
+ goto unlock;
+
+ ret = i2c_master_recv(st->i2c, st->rx, bits);
+ if (ret < 0)
+ goto unlock;
+
+ switch (bits) {
+ case 8:
+ *val = st->rx[0];
+ break;
+ case 16:
+ *val = (st->rx[0] << 8) | st->rx[1];
+ break;
+ case 24:
+ *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
+ break;
+ case 32:
+ *val = (st->rx[0] << 24) | (st->rx[1] << 16) |
+ (st->rx[2] << 8) | st->rx[3];
+ break;
+ default:
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+unlock:
mutex_unlock(&st->buf_lock);
return ret;
}
@@ -213,14 +121,8 @@ static int ade7854_i2c_probe(struct i2c_client *client,
return -ENOMEM;
st = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
- st->read_reg_8 = ade7854_i2c_read_reg_8;
- st->read_reg_16 = ade7854_i2c_read_reg_16;
- st->read_reg_24 = ade7854_i2c_read_reg_24;
- st->read_reg_32 = ade7854_i2c_read_reg_32;
- st->write_reg_8 = ade7854_i2c_write_reg_8;
- st->write_reg_16 = ade7854_i2c_write_reg_16;
- st->write_reg_24 = ade7854_i2c_write_reg_24;
- st->write_reg_32 = ade7854_i2c_write_reg_32;
+ st->read_reg = ade7854_i2c_read_reg;
+ st->write_reg = ade7854_i2c_write_reg;
st->i2c = client;
st->irq = client->irq;
diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c
index 4419b8f06197..fc9146757283 100644
--- a/drivers/staging/iio/meter/ade7854-spi.c
+++ b/drivers/staging/iio/meter/ade7854-spi.c
@@ -15,9 +15,10 @@
#include <linux/iio/iio.h>
#include "ade7854.h"
-static int ade7854_spi_write_reg_8(struct device *dev,
- u16 reg_address,
- u8 val)
+static int ade7854_spi_write_reg(struct device *dev,
+ u16 reg_address,
+ u32 val,
+ int bits)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -32,173 +33,44 @@ static int ade7854_spi_write_reg_8(struct device *dev,
st->tx[0] = ADE7854_WRITE_REG;
st->tx[1] = (reg_address >> 8) & 0xFF;
st->tx[2] = reg_address & 0xFF;
- st->tx[3] = val & 0xFF;
-
- ret = spi_sync_transfer(st->spi, &xfer, 1);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_spi_write_reg_16(struct device *dev,
- u16 reg_address,
- u16 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- struct spi_transfer xfer = {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 5,
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7854_WRITE_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
- st->tx[3] = (val >> 8) & 0xFF;
- st->tx[4] = val & 0xFF;
-
- ret = spi_sync_transfer(st->spi, &xfer, 1);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_spi_write_reg_24(struct device *dev,
- u16 reg_address,
- u32 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- struct spi_transfer xfer = {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 6,
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7854_WRITE_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
- st->tx[3] = (val >> 16) & 0xFF;
- st->tx[4] = (val >> 8) & 0xFF;
- st->tx[5] = val & 0xFF;
-
- ret = spi_sync_transfer(st->spi, &xfer, 1);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_spi_write_reg_32(struct device *dev,
- u16 reg_address,
- u32 val)
-{
- int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- struct spi_transfer xfer = {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 7,
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7854_WRITE_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
- st->tx[3] = (val >> 24) & 0xFF;
- st->tx[4] = (val >> 16) & 0xFF;
- st->tx[5] = (val >> 8) & 0xFF;
- st->tx[6] = val & 0xFF;
-
- ret = spi_sync_transfer(st->spi, &xfer, 1);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-static int ade7854_spi_read_reg_8(struct device *dev,
- u16 reg_address,
- u8 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 3,
- }, {
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 1,
- }
- };
-
- mutex_lock(&st->buf_lock);
-
- st->tx[0] = ADE7854_READ_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
-
- ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->spi->dev, "problem when reading 8 bit register 0x%02X",
- reg_address);
- goto error_ret;
+ switch (bits) {
+ case 8:
+ st->tx[3] = val & 0xFF;
+ break;
+ case 16:
+ xfer.len = 5;
+ st->tx[3] = (val >> 8) & 0xFF;
+ st->tx[4] = val & 0xFF;
+ break;
+ case 24:
+ xfer.len = 6;
+ st->tx[3] = (val >> 16) & 0xFF;
+ st->tx[4] = (val >> 8) & 0xFF;
+ st->tx[5] = val & 0xFF;
+ break;
+ case 32:
+ xfer.len = 7;
+ st->tx[3] = (val >> 24) & 0xFF;
+ st->tx[4] = (val >> 16) & 0xFF;
+ st->tx[5] = (val >> 8) & 0xFF;
+ st->tx[6] = val & 0xFF;
+ break;
+ default:
+ ret = -EINVAL;
+ goto unlock;
}
- *val = st->rx[0];
-error_ret:
+ ret = spi_sync_transfer(st->spi, &xfer, 1);
+unlock:
mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7854_spi_read_reg_16(struct device *dev,
- u16 reg_address,
- u16 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 3,
- }, {
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 2,
- }
- };
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7854_READ_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
-
- ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->spi->dev, "problem when reading 16 bit register 0x%02X",
- reg_address);
- goto error_ret;
- }
- *val = be16_to_cpup((const __be16 *)st->rx);
-
-error_ret:
- mutex_unlock(&st->buf_lock);
return ret;
}
-static int ade7854_spi_read_reg_24(struct device *dev,
- u16 reg_address,
- u32 *val)
+static int ade7854_spi_read_reg(struct device *dev,
+ u16 reg_address,
+ u32 *val,
+ int bits)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
@@ -211,7 +83,7 @@ static int ade7854_spi_read_reg_24(struct device *dev,
}, {
.rx_buf = st->rx,
.bits_per_word = 8,
- .len = 3,
+ .len = bits,
}
};
@@ -222,52 +94,28 @@ static int ade7854_spi_read_reg_24(struct device *dev,
st->tx[2] = reg_address & 0xFF;
ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->spi->dev, "problem when reading 24 bit register 0x%02X",
+ if (ret < 0) {
+ dev_err(&st->spi->dev, "problem when reading register 0x%02X",
reg_address);
- goto error_ret;
+ goto unlock;
}
- *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int ade7854_spi_read_reg_32(struct device *dev,
- u16 reg_address,
- u32 *val)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ade7854_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 3,
- }, {
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 4,
- }
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADE7854_READ_REG;
- st->tx[1] = (reg_address >> 8) & 0xFF;
- st->tx[2] = reg_address & 0xFF;
-
- ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
- if (ret) {
- dev_err(&st->spi->dev, "problem when reading 32 bit register 0x%02X",
- reg_address);
- goto error_ret;
+ switch (bits) {
+ case 8:
+ *val = st->rx[0];
+ break;
+ case 16:
+ *val = be16_to_cpup((const __be16 *)st->rx);
+ break;
+ case 24:
+ *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
+ break;
+ case 32:
+ *val = be32_to_cpup((const __be32 *)st->rx);
+ break;
}
- *val = be32_to_cpup((const __be32 *)st->rx);
-error_ret:
+unlock:
mutex_unlock(&st->buf_lock);
return ret;
}
@@ -282,14 +130,8 @@ static int ade7854_spi_probe(struct spi_device *spi)
return -ENOMEM;
st = iio_priv(indio_dev);
spi_set_drvdata(spi, indio_dev);
- st->read_reg_8 = ade7854_spi_read_reg_8;
- st->read_reg_16 = ade7854_spi_read_reg_16;
- st->read_reg_24 = ade7854_spi_read_reg_24;
- st->read_reg_32 = ade7854_spi_read_reg_32;
- st->write_reg_8 = ade7854_spi_write_reg_8;
- st->write_reg_16 = ade7854_spi_write_reg_16;
- st->write_reg_24 = ade7854_spi_write_reg_24;
- st->write_reg_32 = ade7854_spi_write_reg_32;
+ st->read_reg = ade7854_spi_read_reg;
+ st->write_reg = ade7854_spi_write_reg;
st->irq = spi->irq;
st->spi = spi;
diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c
index 90d07cdca4b8..029c3bf42d4d 100644
--- a/drivers/staging/iio/meter/ade7854.c
+++ b/drivers/staging/iio/meter/ade7854.c
@@ -27,13 +27,13 @@ static ssize_t ade7854_read_8bit(struct device *dev,
char *buf)
{
int ret;
- u8 val = 0;
+ u32 val = 0;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- ret = st->read_reg_8(dev, this_attr->address, &val);
- if (ret)
+ ret = st->read_reg(dev, this_attr->address, &val, 8);
+ if (ret < 0)
return ret;
return sprintf(buf, "%u\n", val);
@@ -44,13 +44,13 @@ static ssize_t ade7854_read_16bit(struct device *dev,
char *buf)
{
int ret;
- u16 val = 0;
+ u32 val = 0;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- ret = st->read_reg_16(dev, this_attr->address, &val);
- if (ret)
+ ret = st->read_reg(dev, this_attr->address, &val, 16);
+ if (ret < 0)
return ret;
return sprintf(buf, "%u\n", val);
@@ -66,8 +66,8 @@ static ssize_t ade7854_read_24bit(struct device *dev,
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- ret = st->read_reg_24(dev, this_attr->address, &val);
- if (ret)
+ ret = st->read_reg(dev, this_attr->address, &val, 24);
+ if (ret < 0)
return ret;
return sprintf(buf, "%u\n", val);
@@ -83,8 +83,8 @@ static ssize_t ade7854_read_32bit(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
- ret = st->read_reg_32(dev, this_attr->address, &val);
- if (ret)
+ ret = st->read_reg(dev, this_attr->address, &val, 32);
+ if (ret < 0)
return ret;
return sprintf(buf, "%u\n", val);
@@ -105,7 +105,7 @@ static ssize_t ade7854_write_8bit(struct device *dev,
ret = kstrtou8(buf, 10, &val);
if (ret)
goto error_ret;
- ret = st->write_reg_8(dev, this_attr->address, val);
+ ret = st->write_reg(dev, this_attr->address, val, 8);
error_ret:
return ret ? ret : len;
@@ -126,7 +126,7 @@ static ssize_t ade7854_write_16bit(struct device *dev,
ret = kstrtou16(buf, 10, &val);
if (ret)
goto error_ret;
- ret = st->write_reg_16(dev, this_attr->address, val);
+ ret = st->write_reg(dev, this_attr->address, val, 16);
error_ret:
return ret ? ret : len;
@@ -147,7 +147,7 @@ static ssize_t ade7854_write_24bit(struct device *dev,
ret = kstrtou32(buf, 10, &val);
if (ret)
goto error_ret;
- ret = st->write_reg_24(dev, this_attr->address, val);
+ ret = st->write_reg(dev, this_attr->address, val, 24);
error_ret:
return ret ? ret : len;
@@ -168,7 +168,7 @@ static ssize_t ade7854_write_32bit(struct device *dev,
ret = kstrtou32(buf, 10, &val);
if (ret)
goto error_ret;
- ret = st->write_reg_32(dev, this_attr->address, val);
+ ret = st->write_reg(dev, this_attr->address, val, 32);
error_ret:
return ret ? ret : len;
@@ -178,12 +178,12 @@ static int ade7854_reset(struct device *dev)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
- u16 val;
+ u32 val;
- st->read_reg_16(dev, ADE7854_CONFIG, &val);
+ st->read_reg(dev, ADE7854_CONFIG, &val, 16);
val |= BIT(7); /* Software Chip Reset */
- return st->write_reg_16(dev, ADE7854_CONFIG, val);
+ return st->write_reg(dev, ADE7854_CONFIG, val, 16);
}
static IIO_DEV_ATTR_AIGAIN(0644,
@@ -415,8 +415,8 @@ static int ade7854_set_irq(struct device *dev, bool enable)
int ret;
u32 irqen;
- ret = st->read_reg_32(dev, ADE7854_MASK0, &irqen);
- if (ret)
+ ret = st->read_reg(dev, ADE7854_MASK0, &irqen, 32);
+ if (ret < 0)
return ret;
if (enable)
@@ -426,7 +426,7 @@ static int ade7854_set_irq(struct device *dev, bool enable)
else
irqen &= ~BIT(17);
- return st->write_reg_32(dev, ADE7854_MASK0, irqen);
+ return st->write_reg(dev, ADE7854_MASK0, irqen, 32);
}
static int ade7854_initial_setup(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/meter/ade7854.h b/drivers/staging/iio/meter/ade7854.h
index a82d38224cbd..a51e6e3183d3 100644
--- a/drivers/staging/iio/meter/ade7854.h
+++ b/drivers/staging/iio/meter/ade7854.h
@@ -145,7 +145,9 @@
/**
* struct ade7854_state - device instance specific data
- * @spi: actual spi_device
+ * @spi: actual spi_device
+ * @read_reg Wrapper function for I2C and SPI read
+ * @write_reg Wrapper function for I2C and SPI write
* @indio_dev: industrial I/O device structure
* @buf_lock: mutex to protect tx and rx
* @tx: transmit buffer
@@ -154,14 +156,10 @@
struct ade7854_state {
struct spi_device *spi;
struct i2c_client *i2c;
- int (*read_reg_8)(struct device *dev, u16 reg_address, u8 *val);
- int (*read_reg_16)(struct device *dev, u16 reg_address, u16 *val);
- int (*read_reg_24)(struct device *dev, u16 reg_address, u32 *val);
- int (*read_reg_32)(struct device *dev, u16 reg_address, u32 *val);
- int (*write_reg_8)(struct device *dev, u16 reg_address, u8 val);
- int (*write_reg_16)(struct device *dev, u16 reg_address, u16 val);
- int (*write_reg_24)(struct device *dev, u16 reg_address, u32 val);
- int (*write_reg_32)(struct device *dev, u16 reg_address, u32 val);
+ int (*read_reg)(struct device *dev, u16 reg_address, u32 *val,
+ int bits);
+ int (*write_reg)(struct device *dev, u16 reg_address, u32 val,
+ int bits);
int irq;
struct mutex buf_lock;
u8 tx[ADE7854_MAX_TX] ____cacheline_aligned;
diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig
index 1c7e2860d6b7..6a469ee6101f 100644
--- a/drivers/staging/iio/resolver/Kconfig
+++ b/drivers/staging/iio/resolver/Kconfig
@@ -13,18 +13,6 @@ config AD2S90
To compile this driver as a module, choose M here: the
module will be called ad2s90.
-config AD2S1200
- tristate "Analog Devices ad2s1200/ad2s1205 driver"
- depends on SPI
- depends on GPIOLIB || COMPILE_TEST
- help
- Say yes here to build support for Analog Devices spi resolver
- to digital converters, ad2s1200 and ad2s1205, provides direct access
- via sysfs.
-
- To compile this driver as a module, choose M here: the
- module will be called ad2s1200.
-
config AD2S1210
tristate "Analog Devices ad2s1210 driver"
depends on SPI
diff --git a/drivers/staging/iio/resolver/Makefile b/drivers/staging/iio/resolver/Makefile
index 14375e444ebf..8d901dc7500b 100644
--- a/drivers/staging/iio/resolver/Makefile
+++ b/drivers/staging/iio/resolver/Makefile
@@ -3,5 +3,4 @@
#
obj-$(CONFIG_AD2S90) += ad2s90.o
-obj-$(CONFIG_AD2S1200) += ad2s1200.o
obj-$(CONFIG_AD2S1210) += ad2s1210.o
diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h
index 58c2a3dafca2..1eee774319ad 100644
--- a/drivers/staging/ks7010/eap_packet.h
+++ b/drivers/staging/ks7010/eap_packet.h
@@ -6,8 +6,6 @@
#include <linux/bitops.h>
#include <uapi/linux/if_ether.h>
-#define ETHER_HDR_SIZE 20
-
struct ether_hdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
@@ -19,6 +17,8 @@ struct ether_hdr {
/* followed by length octets of data */
} __packed;
+#define ETHER_HDR_SIZE sizeof(struct ether_hdr)
+
struct ieee802_1x_hdr {
unsigned char version;
unsigned char type;
@@ -26,60 +26,14 @@ struct ieee802_1x_hdr {
/* followed by length octets of data */
} __packed;
-#define EAPOL_VERSION 2
-
-enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
+enum {
+ IEEE802_1X_TYPE_EAP_PACKET = 0,
IEEE802_1X_TYPE_EAPOL_START = 1,
IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
IEEE802_1X_TYPE_EAPOL_KEY = 3,
IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
};
-enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
- EAPOL_KEY_TYPE_WPA = 254
-};
-
-#define IEEE8021X_REPLAY_COUNTER_LEN 8
-#define IEEE8021X_KEY_SIGN_LEN 16
-#define IEEE8021X_KEY_IV_LEN 16
-
-#define IEEE8021X_KEY_INDEX_FLAG 0x80
-#define IEEE8021X_KEY_INDEX_MASK 0x03
-
-struct ieee802_1x_eapol_key {
- unsigned char type;
- unsigned short key_length;
- /*
- * does not repeat within the life of the keying material used to
- * encrypt the Key field; 64-bit NTP timestamp MAY be used here
- */
- unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
- unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random
- * number
- */
- unsigned char key_index; /*
- * key flag in the most significant bit:
- * 0 = broadcast (default key),
- * 1 = unicast (key mapping key);
- * key index is in the 7 least
- * significant bits
- */
- /*
- * HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
- * the key
- */
- unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN];
-
- /*
- * followed by key: if packet body length = 44 + key length, then the
- * key field (of key_length bytes) contains the key in encrypted form;
- * if packet body length = 44, key field is absent and key_length
- * represents the number of least significant octets from
- * MS-MPPE-Send-Key attribute to be used as the keying material;
- * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key
- */
-} __packed;
-
#define WPA_NONCE_LEN 32
#define WPA_REPLAY_COUNTER_LEN 8
@@ -113,26 +67,4 @@ struct wpa_eapol_key {
#define WPA_KEY_INFO_REQUEST BIT(11)
#define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */
-#define WPA_CAPABILITY_PREAUTH BIT(0)
-
-#define GENERIC_INFO_ELEM 0xdd
-#define RSN_INFO_ELEM 0x30
-
-enum {
- REASON_UNSPECIFIED = 1,
- REASON_DEAUTH_LEAVING = 3,
- REASON_INVALID_IE = 13,
- REASON_MICHAEL_MIC_FAILURE = 14,
- REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
- REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
- REASON_IE_IN_4WAY_DIFFERS = 17,
- REASON_GROUP_CIPHER_NOT_VALID = 18,
- REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
- REASON_AKMP_NOT_VALID = 20,
- REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
- REASON_INVALID_RSN_IE_CAPAB = 22,
- REASON_IEEE_802_1X_AUTH_FAILED = 23,
- REASON_CIPHER_SUITE_REJECTED = 24
-};
-
#endif /* EAP_PACKET_H */
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a11ee1c..74551eb717fc 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1,76 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Driver for KeyStream, KS7010 based SDIO cards.
*
* Copyright (C) 2006-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
* Copyright (C) 2016 Sang Engineering, Wolfram Sang
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
+#include <linux/atomic.h>
#include <linux/firmware.h>
+#include <linux/jiffies.h>
#include <linux/mmc/card.h>
#include <linux/mmc/sdio_func.h>
+#include <linux/module.h>
#include <linux/workqueue.h>
-#include <linux/atomic.h>
-
#include "ks_wlan.h"
-#include "ks_wlan_ioctl.h"
#include "ks_hostif.h"
-#include "ks7010_sdio.h"
-#define KS7010_FUNC_NUM 1
-#define KS7010_IO_BLOCK_SIZE 512
-#define KS7010_MAX_CLOCK 25000000
+#define ROM_FILE "ks7010sd.rom"
-static const struct sdio_device_id ks7010_sdio_ids[] = {
- {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)},
- {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)},
- { /* all zero */ }
+/* SDIO KeyStream vendor and device */
+#define SDIO_VENDOR_ID_KS_CODE_A 0x005b
+#define SDIO_VENDOR_ID_KS_CODE_B 0x0023
+
+/* Older sources suggest earlier versions were named 7910 or 79xx */
+#define SDIO_DEVICE_ID_KS_7010 0x7910
+
+/* Read/Write Status Register */
+#define READ_STATUS_REG 0x000000
+#define WRITE_STATUS_REG 0x00000C
+enum reg_status_type {
+ REG_STATUS_BUSY,
+ REG_STATUS_IDLE
};
-MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
-static inline void inc_txqhead(struct ks_wlan_private *priv)
-{
- priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
-}
+/* Read Index Register */
+#define READ_INDEX_REG 0x000004
-static inline void inc_txqtail(struct ks_wlan_private *priv)
-{
- priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
-}
+/* Read Data Size Register */
+#define READ_DATA_SIZE_REG 0x000008
-static inline unsigned int cnt_txqbody(struct ks_wlan_private *priv)
-{
- unsigned int tx_cnt = priv->tx_dev.qtail - priv->tx_dev.qhead;
+/* Write Index Register */
+#define WRITE_INDEX_REG 0x000010
- return (tx_cnt + TX_DEVICE_BUFF_SIZE) % TX_DEVICE_BUFF_SIZE;
-}
+/*
+ * Write Status/Read Data Size Register
+ * for network packet (less than 2048 bytes data)
+ */
+#define WSTATUS_RSIZE_REG 0x000014
+
+/* Write Status Register value */
+#define WSTATUS_MASK 0x80
+
+/* Read Data Size Register value [10:4] */
+#define RSIZE_MASK 0x7F
+
+/* ARM to SD interrupt Enable */
+#define INT_ENABLE_REG 0x000020
+/* ARM to SD interrupt Pending */
+#define INT_PENDING_REG 0x000024
+
+#define INT_GCR_B BIT(7)
+#define INT_GCR_A BIT(6)
+#define INT_WRITE_STATUS BIT(5)
+#define INT_WRITE_INDEX BIT(4)
+#define INT_WRITE_SIZE BIT(3)
+#define INT_READ_STATUS BIT(2)
+#define INT_READ_INDEX BIT(1)
+#define INT_READ_SIZE BIT(0)
+
+/* General Communication Register A */
+#define GCR_A_REG 0x000028
+enum gen_com_reg_a {
+ GCR_A_INIT,
+ GCR_A_REMAP,
+ GCR_A_RUN
+};
-static inline void inc_rxqhead(struct ks_wlan_private *priv)
-{
- priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
-}
+/* General Communication Register B */
+#define GCR_B_REG 0x00002C
+enum gen_com_reg_b {
+ GCR_B_ACTIVE,
+ GCR_B_DOZE
+};
-static inline void inc_rxqtail(struct ks_wlan_private *priv)
-{
- priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
-}
+/* Wakeup Register */
+#define WAKEUP_REG 0x008018
+#define WAKEUP_REQ 0x5a
+
+/* AHB Data Window 0x010000-0x01FFFF */
+#define DATA_WINDOW 0x010000
+#define WINDOW_SIZE (64 * 1024)
-static inline unsigned int cnt_rxqbody(struct ks_wlan_private *priv)
+#define KS7010_IRAM_ADDRESS 0x06000000
+
+#define KS7010_IO_BLOCK_SIZE 512
+
+/**
+ * struct ks_sdio_card - SDIO device data.
+ *
+ * Structure is used as the &struct sdio_func private data.
+ *
+ * @func: Pointer to the SDIO function device.
+ * @priv: Pointer to the &struct net_device private data.
+ */
+struct ks_sdio_card {
+ struct sdio_func *func;
+ struct ks_wlan_private *priv;
+};
+
+static struct sdio_func *ks7010_to_func(struct ks_wlan_private *priv)
{
- unsigned int rx_cnt = priv->rx_dev.qtail - priv->rx_dev.qhead;
+ struct ks_sdio_card *ks_sdio = priv->if_hw;
- return (rx_cnt + RX_DEVICE_BUFF_SIZE) % RX_DEVICE_BUFF_SIZE;
+ return ks_sdio->func;
}
/* Read single byte from device address into byte (CMD52) */
-static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int address,
- unsigned char *byte)
+static int ks7010_sdio_readb(struct ks_wlan_private *priv,
+ u32 address, u8 *byte)
{
- struct sdio_func *func = priv->ks_sdio_card->func;
+ struct sdio_func *func = ks7010_to_func(priv);
int ret;
*byte = sdio_readb(func, address, &ret);
@@ -79,19 +129,19 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int address,
}
/* Read length bytes from device address into buffer (CMD53) */
-static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
- unsigned char *buffer, int length)
+static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
+ u8 *buffer, unsigned int length)
{
- struct sdio_func *func = priv->ks_sdio_card->func;
+ struct sdio_func *func = ks7010_to_func(priv);
return sdio_memcpy_fromio(func, buffer, address, length);
}
/* Write single byte to device address (CMD52) */
static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
- unsigned int address, unsigned char byte)
+ u32 address, u8 byte)
{
- struct sdio_func *func = priv->ks_sdio_card->func;
+ struct sdio_func *func = ks7010_to_func(priv);
int ret;
sdio_writeb(func, byte, address, &ret);
@@ -100,10 +150,10 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
}
/* Write length bytes to device address from buffer (CMD53) */
-static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,
- unsigned char *buffer, int length)
+static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address,
+ u8 *buffer, unsigned int length)
{
- struct sdio_func *func = priv->ks_sdio_card->func;
+ struct sdio_func *func = ks7010_to_func(priv);
return sdio_memcpy_toio(func, address, buffer, length);
}
@@ -116,9 +166,9 @@ static void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
atomic_set(&priv->sleepstatus.doze_request, 0);
if (atomic_read(&priv->sleepstatus.status) == 0) {
- ret = ks7010_sdio_writeb(priv, GCR_B, GCR_B_DOZE);
+ ret = ks7010_sdio_writeb(priv, GCR_B_REG, GCR_B_DOZE);
if (ret) {
- netdev_err(priv->net_dev, " error : GCR_B\n");
+ netdev_err(priv->net_dev, "write GCR_B_REG\n");
goto set_sleep_mode;
}
atomic_set(&priv->sleepstatus.status, 1);
@@ -137,9 +187,9 @@ static void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)
atomic_set(&priv->sleepstatus.wakeup_request, 0);
if (atomic_read(&priv->sleepstatus.status) == 1) {
- ret = ks7010_sdio_writeb(priv, WAKEUP, WAKEUP_REQ);
+ ret = ks7010_sdio_writeb(priv, WAKEUP_REG, WAKEUP_REQ);
if (ret) {
- netdev_err(priv->net_dev, " error : WAKEUP\n");
+ netdev_err(priv->net_dev, "write WAKEUP_REG\n");
goto set_sleep_mode;
}
atomic_set(&priv->sleepstatus.status, 0);
@@ -156,9 +206,9 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
int ret;
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- ret = ks7010_sdio_writeb(priv, WAKEUP, WAKEUP_REQ);
+ ret = ks7010_sdio_writeb(priv, WAKEUP_REG, WAKEUP_REQ);
if (ret)
- netdev_err(priv->net_dev, " error : WAKEUP\n");
+ netdev_err(priv->net_dev, "write WAKEUP_REG\n");
priv->last_wakeup = jiffies;
++priv->wakeup_count;
@@ -167,7 +217,7 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
{
- unsigned char byte;
+ u8 byte;
int ret;
if (priv->reg.power_mgmt == POWER_MGMT_ACTIVE)
@@ -185,30 +235,35 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE)
return;
- netdev_dbg(priv->net_dev, "\npsstatus.status=%d\npsstatus.confirm_wait=%d\npsstatus.snooze_guard=%d\ncnt_txqbody=%d\n",
+ netdev_dbg(priv->net_dev,
+ "STATUS:\n"
+ "- psstatus.status = %d\n"
+ "- psstatus.confirm_wait = %d\n"
+ "- psstatus.snooze_guard = %d\n"
+ "- txq_count = %d\n",
atomic_read(&priv->psstatus.status),
atomic_read(&priv->psstatus.confirm_wait),
atomic_read(&priv->psstatus.snooze_guard),
- cnt_txqbody(priv));
+ txq_count(priv));
if (atomic_read(&priv->psstatus.confirm_wait) ||
atomic_read(&priv->psstatus.snooze_guard) ||
- cnt_txqbody(priv)) {
+ txq_has_space(priv)) {
queue_delayed_work(priv->wq, &priv->rw_dwork, 0);
return;
}
- ret = ks7010_sdio_readb(priv, INT_PENDING, &byte);
+ ret = ks7010_sdio_readb(priv, INT_PENDING_REG, &byte);
if (ret) {
- netdev_err(priv->net_dev, " error : INT_PENDING\n");
+ netdev_err(priv->net_dev, "read INT_PENDING_REG\n");
goto queue_delayed_work;
}
if (byte)
goto queue_delayed_work;
- ret = ks7010_sdio_writeb(priv, GCR_B, GCR_B_DOZE);
+ ret = ks7010_sdio_writeb(priv, GCR_B_REG, GCR_B_DOZE);
if (ret) {
- netdev_err(priv->net_dev, " error : GCR_B\n");
+ netdev_err(priv->net_dev, "write GCR_B_REG\n");
goto queue_delayed_work;
}
atomic_set(&priv->psstatus.status, PS_SNOOZE);
@@ -239,7 +294,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
goto err_complete;
}
- if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
+ if ((TX_DEVICE_BUFF_SIZE - 1) <= txq_count(priv)) {
netdev_err(priv->net_dev, "tx buffer overflow\n");
ret = -EOVERFLOW;
goto err_complete;
@@ -263,7 +318,7 @@ err_complete:
}
/* write data */
-static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
+static int write_to_device(struct ks_wlan_private *priv, u8 *buffer,
unsigned long size)
{
struct hostif_hdr *hdr;
@@ -279,13 +334,13 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
ret = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size);
if (ret) {
- netdev_err(priv->net_dev, " write error : retval=%d\n", ret);
+ netdev_err(priv->net_dev, "write DATA_WINDOW\n");
return ret;
}
- ret = ks7010_sdio_writeb(priv, WRITE_STATUS, REG_STATUS_BUSY);
+ ret = ks7010_sdio_writeb(priv, WRITE_STATUS_REG, REG_STATUS_BUSY);
if (ret) {
- netdev_err(priv->net_dev, " error : WRITE_STATUS\n");
+ netdev_err(priv->net_dev, "write WRITE_STATUS_REG\n");
return ret;
}
@@ -297,7 +352,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
struct tx_device_buffer *sp;
int ret;
- if (cnt_txqbody(priv) <= 0 ||
+ if (!txq_has_space(priv) ||
atomic_read(&priv->psstatus.status) == PS_SNOOZE)
return;
@@ -305,7 +360,8 @@ static void tx_device_task(struct ks_wlan_private *priv)
if (priv->dev_state >= DEVICE_STATE_BOOT) {
ret = write_to_device(priv, sp->sendp, sp->size);
if (ret) {
- netdev_err(priv->net_dev, "write_to_device error !!(%d)\n", ret);
+ netdev_err(priv->net_dev,
+ "write_to_device error !!(%d)\n", ret);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return;
}
@@ -315,7 +371,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
(*sp->complete_handler)(priv, sp->skb);
inc_txqhead(priv);
- if (cnt_txqbody(priv) > 0)
+ if (txq_has_space(priv))
queue_delayed_work(priv->wq, &priv->rw_dwork, 0);
}
@@ -343,7 +399,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
result = enqueue_txdev(priv, p, size, complete_handler, skb);
spin_unlock(&priv->tx_dev.tx_dev_lock);
- if (cnt_txqbody(priv) > 0)
+ if (txq_has_space(priv))
queue_delayed_work(priv->wq, &priv->rw_dwork, 0);
return result;
@@ -354,25 +410,25 @@ static void rx_event_task(unsigned long dev)
struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
struct rx_device_buffer *rp;
- if (cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT) {
+ if (rxq_has_space(priv) && priv->dev_state >= DEVICE_STATE_BOOT) {
rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead];
hostif_receive(priv, rp->data, rp->size);
inc_rxqhead(priv);
- if (cnt_rxqbody(priv) > 0)
+ if (rxq_has_space(priv))
tasklet_schedule(&priv->rx_bh_task);
}
}
-static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
+static void ks_wlan_hw_rx(struct ks_wlan_private *priv, size_t size)
{
int ret;
struct rx_device_buffer *rx_buffer;
struct hostif_hdr *hdr;
- unsigned short event = 0;
+ u16 event = 0;
/* receive data */
- if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
+ if (rxq_count(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
netdev_err(priv->net_dev, "rx buffer overflow\n");
return;
}
@@ -390,9 +446,9 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
DUMP_PREFIX_OFFSET,
rx_buffer->data, 32);
#endif
- ret = ks7010_sdio_writeb(priv, READ_STATUS, REG_STATUS_IDLE);
+ ret = ks7010_sdio_writeb(priv, READ_STATUS_REG, REG_STATUS_IDLE);
if (ret)
- netdev_err(priv->net_dev, " error : READ_STATUS\n");
+ netdev_err(priv->net_dev, "write READ_STATUS_REG\n");
/* length check fail */
return;
@@ -403,15 +459,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
event = le16_to_cpu(hdr->event);
inc_rxqtail(priv);
- ret = ks7010_sdio_writeb(priv, READ_STATUS, REG_STATUS_IDLE);
+ ret = ks7010_sdio_writeb(priv, READ_STATUS_REG, REG_STATUS_IDLE);
if (ret)
- netdev_err(priv->net_dev, " error : READ_STATUS\n");
+ netdev_err(priv->net_dev, "write READ_STATUS_REG\n");
- if (atomic_read(&priv->psstatus.confirm_wait)) {
- if (IS_HIF_CONF(event)) {
- netdev_dbg(priv->net_dev, "IS_HIF_CONF true !!\n");
- atomic_dec(&priv->psstatus.confirm_wait);
- }
+ if (atomic_read(&priv->psstatus.confirm_wait) && is_hif_conf(event)) {
+ netdev_dbg(priv->net_dev, "IS_HIF_CONF true !!\n");
+ atomic_dec(&priv->psstatus.confirm_wait);
}
tasklet_schedule(&priv->rx_bh_task);
@@ -419,34 +473,33 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
static void ks7010_rw_function(struct work_struct *work)
{
- struct ks_wlan_private *priv;
- unsigned char byte;
+ struct ks_wlan_private *priv = container_of(work,
+ struct ks_wlan_private,
+ rw_dwork.work);
+ struct sdio_func *func = ks7010_to_func(priv);
+ u8 byte;
int ret;
- priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
-
/* wait after DOZE */
- if (time_after(priv->last_doze + ((30 * HZ) / 1000), jiffies)) {
+ if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after DOZE\n");
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return;
}
/* wait after WAKEUP */
- while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
+ while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
- dev_info(&priv->ks_sdio_card->func->dev,
- "wake: %lu %lu\n",
- priv->last_wakeup + (30 * HZ) / 1000,
- jiffies);
+ dev_info(&func->dev, "wake: %lu %lu\n",
+ priv->last_wakeup + msecs_to_jiffies(30), jiffies);
msleep(30);
}
- sdio_claim_host(priv->ks_sdio_card->func);
+ sdio_claim_host(func);
/* power save wakeup */
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- if (cnt_txqbody(priv) > 0) {
+ if (txq_has_space(priv)) {
ks_wlan_hw_wakeup_request(priv);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
}
@@ -465,15 +518,15 @@ static void ks7010_rw_function(struct work_struct *work)
}
/* read (WriteStatus/ReadDataSize FN1:00_0014) */
- ret = ks7010_sdio_readb(priv, WSTATUS_RSIZE, &byte);
+ ret = ks7010_sdio_readb(priv, WSTATUS_RSIZE_REG, &byte);
if (ret) {
- netdev_err(priv->net_dev, " error : WSTATUS_RSIZE psstatus=%d\n",
+ netdev_err(priv->net_dev, "read WSTATUS_RSIZE_REG psstatus=%d\n",
atomic_read(&priv->psstatus.status));
goto release_host;
}
if (byte & RSIZE_MASK) { /* Read schedule */
- ks_wlan_hw_rx(priv, (uint16_t)((byte & RSIZE_MASK) << 4));
+ ks_wlan_hw_rx(priv, (size_t)((byte & RSIZE_MASK) << 4));
}
if ((byte & WSTATUS_MASK))
tx_device_task(priv);
@@ -481,7 +534,7 @@ static void ks7010_rw_function(struct work_struct *work)
_ks_wlan_hw_power_save(priv);
release_host:
- sdio_release_host(priv->ks_sdio_card->func);
+ sdio_release_host(func);
}
static void ks_sdio_interrupt(struct sdio_func *func)
@@ -489,7 +542,7 @@ static void ks_sdio_interrupt(struct sdio_func *func)
int ret;
struct ks_sdio_card *card;
struct ks_wlan_private *priv;
- unsigned char status, rsize, byte;
+ u8 status, rsize, byte;
card = sdio_get_drvdata(func);
priv = card->priv;
@@ -497,9 +550,9 @@ static void ks_sdio_interrupt(struct sdio_func *func)
if (priv->dev_state < DEVICE_STATE_BOOT)
goto queue_delayed_work;
- ret = ks7010_sdio_readb(priv, INT_PENDING, &status);
+ ret = ks7010_sdio_readb(priv, INT_PENDING_REG, &status);
if (ret) {
- netdev_err(priv->net_dev, "error : INT_PENDING\n");
+ netdev_err(priv->net_dev, "read INT_PENDING_REG\n");
goto queue_delayed_work;
}
@@ -510,9 +563,9 @@ static void ks_sdio_interrupt(struct sdio_func *func)
/* bit2 -> Read Status Busy */
if (status & INT_GCR_B ||
atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- ret = ks7010_sdio_readb(priv, GCR_B, &byte);
+ ret = ks7010_sdio_readb(priv, GCR_B_REG, &byte);
if (ret) {
- netdev_err(priv->net_dev, " error : GCR_B\n");
+ netdev_err(priv->net_dev, "read GCR_B_REG\n");
goto queue_delayed_work;
}
if (byte == GCR_B_ACTIVE) {
@@ -526,20 +579,21 @@ static void ks_sdio_interrupt(struct sdio_func *func)
do {
/* read (WriteStatus/ReadDataSize FN1:00_0014) */
- ret = ks7010_sdio_readb(priv, WSTATUS_RSIZE, &byte);
+ ret = ks7010_sdio_readb(priv, WSTATUS_RSIZE_REG, &byte);
if (ret) {
- netdev_err(priv->net_dev, " error : WSTATUS_RSIZE\n");
+ netdev_err(priv->net_dev, "read WSTATUS_RSIZE_REG\n");
goto queue_delayed_work;
}
rsize = byte & RSIZE_MASK;
if (rsize != 0) /* Read schedule */
- ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
+ ks_wlan_hw_rx(priv, (size_t)(rsize << 4));
if (byte & WSTATUS_MASK) {
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- if (cnt_txqbody(priv)) {
+ if (txq_has_space(priv)) {
ks_wlan_hw_wakeup_request(priv);
- queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
+ queue_delayed_work(priv->wq,
+ &priv->rw_dwork, 1);
return;
}
} else {
@@ -573,7 +627,7 @@ static void trx_device_exit(struct ks_wlan_private *priv)
struct tx_device_buffer *sp;
/* tx buffer clear */
- while (cnt_txqbody(priv) > 0) {
+ while (txq_has_space(priv)) {
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
kfree(sp->sendp);
if (sp->complete_handler) /* TX Complete */
@@ -589,16 +643,15 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
int ret;
unsigned char *data_buf;
- data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
+ data_buf = kmemdup(&index, sizeof(u32), GFP_KERNEL);
if (!data_buf)
return -ENOMEM;
- memcpy(data_buf, &index, sizeof(index));
- ret = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
+ ret = ks7010_sdio_write(priv, WRITE_INDEX_REG, data_buf, sizeof(index));
if (ret)
goto err_free_data_buf;
- ret = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index));
+ ret = ks7010_sdio_write(priv, READ_INDEX_REG, data_buf, sizeof(index));
if (ret)
goto err_free_data_buf;
@@ -612,10 +665,10 @@ err_free_data_buf:
#define ROM_BUFF_SIZE (64 * 1024)
static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
- unsigned char *data, unsigned int size)
+ u8 *data, unsigned int size)
{
int ret;
- unsigned char *read_buf;
+ u8 *read_buf;
read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!read_buf)
@@ -639,37 +692,22 @@ err_free_read_buf:
return ret;
}
-static int ks7010_upload_firmware(struct ks_sdio_card *card)
+static int ks7010_copy_firmware(struct ks_wlan_private *priv,
+ const struct firmware *fw_entry)
{
- struct ks_wlan_private *priv = card->priv;
- unsigned int size, offset, n = 0;
- unsigned char *rom_buf;
- unsigned char byte = 0;
- int ret;
unsigned int length;
- const struct firmware *fw_entry = NULL;
+ unsigned int size;
+ unsigned int offset;
+ unsigned int n = 0;
+ u8 *rom_buf;
+ int ret;
rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!rom_buf)
return -ENOMEM;
- sdio_claim_host(card->func);
-
- /* Firmware running ? */
- ret = ks7010_sdio_readb(priv, GCR_A, &byte);
- if (byte == GCR_A_RUN) {
- netdev_dbg(priv->net_dev, "MAC firmware running ...\n");
- goto release_host_and_free;
- }
-
- ret = request_firmware(&fw_entry, ROM_FILE,
- &priv->ks_sdio_card->func->dev);
- if (ret)
- goto release_host_and_free;
-
length = fw_entry->size;
- n = 0;
do {
if (length >= ROM_BUFF_SIZE) {
size = ROM_BUFF_SIZE;
@@ -680,33 +718,69 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
}
if (size == 0)
break;
+
memcpy(rom_buf, fw_entry->data + n, size);
offset = n;
- ret = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS + offset);
+ ret = ks7010_sdio_update_index(priv,
+ KS7010_IRAM_ADDRESS + offset);
if (ret)
- goto release_firmware;
+ goto free_rom_buf;
ret = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
if (ret)
- goto release_firmware;
+ goto free_rom_buf;
- ret = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size);
+ ret = ks7010_sdio_data_compare(priv,
+ DATA_WINDOW, rom_buf, size);
if (ret)
- goto release_firmware;
+ goto free_rom_buf;
n += size;
} while (size);
- ret = ks7010_sdio_writeb(priv, GCR_A, GCR_A_REMAP);
+ ret = ks7010_sdio_writeb(priv, GCR_A_REG, GCR_A_REMAP);
+
+free_rom_buf:
+ kfree(rom_buf);
+ return ret;
+}
+
+static int ks7010_upload_firmware(struct ks_sdio_card *card)
+{
+ struct ks_wlan_private *priv = card->priv;
+ struct sdio_func *func = ks7010_to_func(priv);
+ unsigned int n;
+ u8 byte = 0;
+ int ret;
+ const struct firmware *fw_entry = NULL;
+
+ sdio_claim_host(func);
+
+ /* Firmware running ? */
+ ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte);
+ if (ret)
+ goto release_host;
+ if (byte == GCR_A_RUN) {
+ netdev_dbg(priv->net_dev, "MAC firmware running ...\n");
+ ret = -EBUSY;
+ goto release_host;
+ }
+
+ ret = request_firmware(&fw_entry, ROM_FILE,
+ &func->dev);
+ if (ret)
+ goto release_host;
+
+ ret = ks7010_copy_firmware(priv, fw_entry);
if (ret)
goto release_firmware;
/* Firmware running check */
for (n = 0; n < 50; ++n) {
- mdelay(10); /* wait_ms(10); */
- ret = ks7010_sdio_readb(priv, GCR_A, &byte);
+ usleep_range(10000, 11000); /* wait_ms(10); */
+ ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte);
if (ret)
goto release_firmware;
@@ -723,13 +797,29 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
release_firmware:
release_firmware(fw_entry);
- release_host_and_free:
- sdio_release_host(card->func);
- kfree(rom_buf);
+ release_host:
+ sdio_release_host(func);
return ret;
}
+static void ks7010_sme_enqueue_events(struct ks_wlan_private *priv)
+{
+ static const u16 init_events[] = {
+ SME_GET_EEPROM_CKSUM, SME_STOP_REQUEST,
+ SME_RTS_THRESHOLD_REQUEST, SME_FRAGMENTATION_THRESHOLD_REQUEST,
+ SME_WEP_INDEX_REQUEST, SME_WEP_KEY1_REQUEST,
+ SME_WEP_KEY2_REQUEST, SME_WEP_KEY3_REQUEST,
+ SME_WEP_KEY4_REQUEST, SME_WEP_FLAG_REQUEST,
+ SME_RSN_ENABLED_REQUEST, SME_MODE_SET_REQUEST,
+ SME_START_REQUEST
+ };
+ int ev;
+
+ for (ev = 0; ev < ARRAY_SIZE(init_events); ev++)
+ hostif_sme_enqueue(priv, init_events[ev]);
+}
+
static void ks7010_card_init(struct ks_wlan_private *priv)
{
init_completion(&priv->confirm_wait);
@@ -745,24 +835,7 @@ static void ks7010_card_init(struct ks_wlan_private *priv)
if (priv->mac_address_valid && priv->version_size != 0)
priv->dev_state = DEVICE_STATE_PREINIT;
- hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM);
-
- /* load initial wireless parameter */
- hostif_sme_enqueue(priv, SME_STOP_REQUEST);
-
- hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST);
- hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST);
-
- hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST);
- hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST);
- hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST);
- hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST);
- hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST);
-
- hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST);
- hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST);
- hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST);
- hostif_sme_enqueue(priv, SME_START_REQUEST);
+ ks7010_sme_enqueue_events(priv);
if (!wait_for_completion_interruptible_timeout
(&priv->confirm_wait, 5 * HZ)) {
@@ -802,18 +875,87 @@ static void ks7010_init_defaults(struct ks_wlan_private *priv)
priv->reg.rate_set.size = 12;
}
+static int ks7010_sdio_setup_irqs(struct sdio_func *func)
+{
+ int ret;
+
+ /* interrupt disable */
+ sdio_writeb(func, 0, INT_ENABLE_REG, &ret);
+ if (ret)
+ goto irq_error;
+
+ sdio_writeb(func, 0xff, INT_PENDING_REG, &ret);
+ if (ret)
+ goto irq_error;
+
+ /* setup interrupt handler */
+ ret = sdio_claim_irq(func, ks_sdio_interrupt);
+
+irq_error:
+ return ret;
+}
+
+static void ks7010_sdio_init_irqs(struct sdio_func *func,
+ struct ks_wlan_private *priv)
+{
+ u8 byte;
+ int ret;
+
+ /*
+ * interrupt setting
+ * clear Interrupt status write
+ * (ARMtoSD_InterruptPending FN1:00_0024)
+ */
+ sdio_claim_host(func);
+ ret = ks7010_sdio_writeb(priv, INT_PENDING_REG, 0xff);
+ sdio_release_host(func);
+ if (ret)
+ netdev_err(priv->net_dev, "write INT_PENDING_REG\n");
+
+ /* enable ks7010sdio interrupt */
+ byte = (INT_GCR_B | INT_READ_STATUS | INT_WRITE_STATUS);
+ sdio_claim_host(func);
+ ret = ks7010_sdio_writeb(priv, INT_ENABLE_REG, byte);
+ sdio_release_host(func);
+ if (ret)
+ netdev_err(priv->net_dev, "write INT_ENABLE_REG\n");
+}
+
+static void ks7010_private_init(struct ks_wlan_private *priv,
+ struct ks_sdio_card *card,
+ struct net_device *netdev)
+{
+ /* private memory initialize */
+ priv->if_hw = card;
+
+ priv->dev_state = DEVICE_STATE_PREBOOT;
+ priv->net_dev = netdev;
+ priv->firmware_version[0] = '\0';
+ priv->version_size = 0;
+ priv->last_doze = jiffies;
+ priv->last_wakeup = jiffies;
+ memset(&priv->nstats, 0, sizeof(priv->nstats));
+ memset(&priv->wstats, 0, sizeof(priv->wstats));
+
+ /* sleep mode */
+ atomic_set(&priv->sleepstatus.doze_request, 0);
+ atomic_set(&priv->sleepstatus.wakeup_request, 0);
+ atomic_set(&priv->sleepstatus.wakeup_request, 0);
+
+ trx_device_init(priv);
+ hostif_init(priv);
+ ks_wlan_net_start(netdev);
+ ks7010_init_defaults(priv);
+}
+
static int ks7010_sdio_probe(struct sdio_func *func,
const struct sdio_device_id *device)
{
- struct ks_wlan_private *priv;
+ struct ks_wlan_private *priv = NULL;
+ struct net_device *netdev = NULL;
struct ks_sdio_card *card;
- struct net_device *netdev;
- unsigned char byte;
int ret;
- priv = NULL;
- netdev = NULL;
-
card = kzalloc(sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
@@ -823,6 +965,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,
sdio_claim_host(func);
ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE);
+ if (ret)
+ goto err_free_card;
+
dev_dbg(&card->func->dev, "multi_block=%d sdio_set_block_size()=%d %d\n",
func->card->cccr.multi_block, func->cur_blksize, ret);
@@ -830,16 +975,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
if (ret)
goto err_free_card;
- /* interrupt disable */
- sdio_writeb(func, 0, INT_ENABLE, &ret);
- if (ret)
- goto err_free_card;
- sdio_writeb(func, 0xff, INT_PENDING, &ret);
- if (ret)
- goto err_disable_func;
-
- /* setup interrupt handler */
- ret = sdio_claim_irq(func, ks_sdio_interrupt);
+ ret = ks7010_sdio_setup_irqs(func);
if (ret)
goto err_disable_func;
@@ -853,70 +989,35 @@ static int ks7010_sdio_probe(struct sdio_func *func,
/* private memory allocate */
netdev = alloc_etherdev(sizeof(*priv));
if (!netdev) {
- dev_err(&card->func->dev, "ks7010 : Unable to alloc new net device\n");
+ dev_err(&card->func->dev, "Unable to alloc new net device\n");
goto err_release_irq;
}
- if (dev_alloc_name(netdev, "wlan%d") < 0) {
- dev_err(&card->func->dev,
- "ks7010 : Couldn't get name!\n");
+
+ ret = dev_alloc_name(netdev, "wlan%d");
+ if (ret < 0) {
+ dev_err(&card->func->dev, "Couldn't get name!\n");
goto err_free_netdev;
}
priv = netdev_priv(netdev);
card->priv = priv;
- SET_NETDEV_DEV(netdev, &card->func->dev); /* for create sysfs symlinks */
-
- /* private memory initialize */
- priv->ks_sdio_card = card;
-
- priv->dev_state = DEVICE_STATE_PREBOOT;
- priv->net_dev = netdev;
- priv->firmware_version[0] = '\0';
- priv->version_size = 0;
- priv->last_doze = jiffies;
- priv->last_wakeup = jiffies;
- memset(&priv->nstats, 0, sizeof(priv->nstats));
- memset(&priv->wstats, 0, sizeof(priv->wstats));
-
- /* sleep mode */
- atomic_set(&priv->sleepstatus.doze_request, 0);
- atomic_set(&priv->sleepstatus.wakeup_request, 0);
- atomic_set(&priv->sleepstatus.wakeup_request, 0);
+ SET_NETDEV_DEV(netdev, &card->func->dev);
- trx_device_init(priv);
- hostif_init(priv);
- ks_wlan_net_start(netdev);
-
- ks7010_init_defaults(priv);
+ ks7010_private_init(priv, card, netdev);
ret = ks7010_upload_firmware(card);
if (ret) {
netdev_err(priv->net_dev,
- "ks7010: firmware load failed !! return code = %d\n",
- ret);
+ "firmware load failed !! ret = %d\n", ret);
goto err_free_netdev;
}
- /* interrupt setting */
- /* clear Interrupt status write (ARMtoSD_InterruptPending FN1:00_0024) */
- sdio_claim_host(func);
- ret = ks7010_sdio_writeb(priv, INT_PENDING, 0xff);
- sdio_release_host(func);
- if (ret)
- netdev_err(priv->net_dev, " error : INT_PENDING\n");
-
- /* enable ks7010sdio interrupt */
- byte = (INT_GCR_B | INT_READ_STATUS | INT_WRITE_STATUS);
- sdio_claim_host(func);
- ret = ks7010_sdio_writeb(priv, INT_ENABLE, byte);
- sdio_release_host(func);
- if (ret)
- netdev_err(priv->net_dev, " err : INT_ENABLE\n");
+ ks7010_sdio_init_irqs(func, priv);
priv->dev_state = DEVICE_STATE_BOOT;
- priv->wq = create_workqueue("wq");
+ priv->wq = alloc_workqueue("wq", WQ_MEM_RECLAIM, 1);
if (!priv->wq) {
netdev_err(priv->net_dev, "create_workqueue failed !!\n");
goto err_free_netdev;
@@ -932,8 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return 0;
err_free_netdev:
- free_netdev(priv->net_dev);
- card->priv = NULL;
+ free_netdev(netdev);
err_release_irq:
sdio_claim_host(func);
sdio_release_irq(func);
@@ -950,25 +1050,22 @@ static int ks7010_sdio_probe(struct sdio_func *func,
/* send stop request to MAC */
static int send_stop_request(struct sdio_func *func)
{
- struct hostif_stop_request_t *pp;
+ struct hostif_stop_request *pp;
struct ks_sdio_card *card;
size_t size;
card = sdio_get_drvdata(func);
pp = kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL);
- if (!pp) {
- netdev_err(card->priv->net_dev, "allocate memory failed..\n");
+ if (!pp)
return -ENOMEM;
- }
size = sizeof(*pp) - sizeof(pp->header.size);
- pp->header.size = cpu_to_le16((uint16_t)size);
- pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
+ pp->header.size = cpu_to_le16(size);
+ pp->header.event = cpu_to_le16(HIF_STOP_REQ);
sdio_claim_host(func);
- write_to_device(card->priv, (unsigned char *)pp,
- hif_align_size(sizeof(*pp)));
+ write_to_device(card->priv, (u8 *)pp, hif_align_size(sizeof(*pp)));
sdio_release_host(func);
kfree(pp);
@@ -987,43 +1084,50 @@ static void ks7010_sdio_remove(struct sdio_func *func)
return;
priv = card->priv;
- if (priv) {
- struct net_device *netdev = priv->net_dev;
+ if (!priv)
+ goto err_free_card;
- ks_wlan_net_stop(netdev);
+ ks_wlan_net_stop(priv->net_dev);
- /* interrupt disable */
- sdio_claim_host(func);
- sdio_writeb(func, 0, INT_ENABLE, &ret);
- sdio_writeb(func, 0xff, INT_PENDING, &ret);
- sdio_release_host(func);
+ /* interrupt disable */
+ sdio_claim_host(func);
+ sdio_writeb(func, 0, INT_ENABLE_REG, &ret);
+ sdio_writeb(func, 0xff, INT_PENDING_REG, &ret);
+ sdio_release_host(func);
- ret = send_stop_request(func);
- if (ret) /* memory allocation failure */
- return;
+ ret = send_stop_request(func);
+ if (ret) /* memory allocation failure */
+ goto err_free_card;
- if (priv->wq) {
- flush_workqueue(priv->wq);
- destroy_workqueue(priv->wq);
- }
+ if (priv->wq) {
+ flush_workqueue(priv->wq);
+ destroy_workqueue(priv->wq);
+ }
- hostif_exit(priv);
+ hostif_exit(priv);
- unregister_netdev(netdev);
+ unregister_netdev(priv->net_dev);
- trx_device_exit(priv);
- free_netdev(priv->net_dev);
- card->priv = NULL;
- }
+ trx_device_exit(priv);
+ free_netdev(priv->net_dev);
+ card->priv = NULL;
sdio_claim_host(func);
sdio_release_irq(func);
sdio_disable_func(func);
sdio_release_host(func);
+err_free_card:
sdio_set_drvdata(func, NULL);
kfree(card);
}
+static const struct sdio_device_id ks7010_sdio_ids[] = {
+ {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)},
+ {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)},
+ { /* all zero */ }
+};
+MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
+
static struct sdio_driver ks7010_sdio_driver = {
.name = "ks7010_sdio",
.id_table = ks7010_sdio_ids,
diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h
deleted file mode 100644
index e4f56a11c888..000000000000
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Driver for KeyStream, KS7010 based SDIO cards.
- *
- * Copyright (C) 2006-2008 KeyStream Corp.
- * Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef _KS7010_SDIO_H
-#define _KS7010_SDIO_H
-
-#ifdef DEVICE_ALIGNMENT
-#undef DEVICE_ALIGNMENT
-#endif
-#define DEVICE_ALIGNMENT 32
-
-/* SDIO KeyStream vendor and device */
-#define SDIO_VENDOR_ID_KS_CODE_A 0x005b
-#define SDIO_VENDOR_ID_KS_CODE_B 0x0023
-/* Older sources suggest earlier versions were named 7910 or 79xx */
-#define SDIO_DEVICE_ID_KS_7010 0x7910
-
-/* Read/Write Status Register */
-#define READ_STATUS 0x000000
-#define WRITE_STATUS 0x00000C
-enum reg_status_type {
- REG_STATUS_BUSY,
- REG_STATUS_IDLE
-};
-
-/* Read Index Register */
-#define READ_INDEX 0x000004
-
-/* Read Data Size Register */
-#define READ_DATA_SIZE 0x000008
-
-/* Write Index Register */
-#define WRITE_INDEX 0x000010
-
-/* Write Status/Read Data Size Register
- * for network packet (less than 2048 bytes data)
- */
-#define WSTATUS_RSIZE 0x000014
-#define WSTATUS_MASK 0x80 /* Write Status Register value */
-#define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */
-
-/* ARM to SD interrupt Enable */
-#define INT_ENABLE 0x000020
-/* ARM to SD interrupt Pending */
-#define INT_PENDING 0x000024
-
-#define INT_GCR_B BIT(7)
-#define INT_GCR_A BIT(6)
-#define INT_WRITE_STATUS BIT(5)
-#define INT_WRITE_INDEX BIT(4)
-#define INT_WRITE_SIZE BIT(3)
-#define INT_READ_STATUS BIT(2)
-#define INT_READ_INDEX BIT(1)
-#define INT_READ_SIZE BIT(0)
-
-/* General Communication Register A */
-#define GCR_A 0x000028
-enum gen_com_reg_a {
- GCR_A_INIT,
- GCR_A_REMAP,
- GCR_A_RUN
-};
-
-/* General Communication Register B */
-#define GCR_B 0x00002C
-enum gen_com_reg_b {
- GCR_B_ACTIVE,
- GCR_B_DOZE
-};
-
-/* Wakeup Register */
-#define WAKEUP 0x008018
-#define WAKEUP_REQ 0x5a
-
-/* AHB Data Window 0x010000-0x01FFFF */
-#define DATA_WINDOW 0x010000
-#define WINDOW_SIZE (64 * 1024)
-
-#define KS7010_IRAM_ADDRESS 0x06000000
-
-/**
- * struct ks_sdio_card - SDIO device data.
- *
- * Structure is used as the &struct sdio_func private data.
- *
- * @func: Pointer to the SDIO function device.
- * @priv: Pointer to the &struct net_device private data.
- */
-struct ks_sdio_card {
- struct sdio_func *func;
- struct ks_wlan_private *priv;
-};
-
-/* Tx Device struct */
-#define TX_DEVICE_BUFF_SIZE 1024
-
-/**
- * struct tx_device_buffer - Queue item for the tx queue.
- * @sendp: Pointer to the send request data.
- * @size: Size of @sendp data.
- * @complete_handler: Function called once data write to device is complete.
- * @arg1: First argument to @complete_handler.
- * @arg2: Second argument to @complete_handler.
- */
-struct tx_device_buffer {
- unsigned char *sendp;
- unsigned int size;
- void (*complete_handler)(struct ks_wlan_private *priv,
- struct sk_buff *skb);
- struct sk_buff *skb;
-};
-
-/**
- * struct tx_device - Tx buffer queue.
- * @tx_device_buffer: Queue buffer.
- * @qhead: Head of tx queue.
- * @qtail: Tail of tx queue.
- * @tx_dev_lock: Queue lock.
- */
-struct tx_device {
- struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
- unsigned int qhead;
- unsigned int qtail;
- spinlock_t tx_dev_lock; /* protect access to the queue */
-};
-
-/* Rx Device struct */
-#define RX_DATA_SIZE (2 + 2 + 2347 + 1)
-#define RX_DEVICE_BUFF_SIZE 32
-
-/**
- * struct rx_device_buffer - Queue item for the rx queue.
- * @data: rx data.
- * @size: Size of @data.
- */
-struct rx_device_buffer {
- unsigned char data[RX_DATA_SIZE];
- unsigned int size;
-};
-
-/**
- * struct rx_device - Rx buffer queue.
- * @rx_device_buffer: Queue buffer.
- * @qhead: Head of rx queue.
- * @qtail: Tail of rx queue.
- * @rx_dev_lock: Queue lock.
- */
-struct rx_device {
- struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
- unsigned int qhead;
- unsigned int qtail;
- spinlock_t rx_dev_lock; /* protect access to the queue */
-};
-
-#define ROM_FILE "ks7010sd.rom"
-
-#endif /* _KS7010_SDIO_H */
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 676961cf4103..0ecffab52ec2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1,25 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Driver for KeyStream wireless LAN cards.
*
* Copyright (C) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
-#include "ks_wlan.h"
-#include "ks_hostif.h"
+#include <linux/circ_buf.h>
+#include <linux/if_arp.h>
+#include <net/iw_handler.h>
+#include <uapi/linux/llc.h>
#include "eap_packet.h"
+#include "ks_wlan.h"
#include "michael_mic.h"
-
-#include <linux/etherdevice.h>
-#include <linux/if_ether.h>
-#include <linux/if_arp.h>
-
-/* Include Wireless Extension definition and check version */
-#include <net/iw_handler.h> /* New driver API */
+#include "ks_hostif.h"
static inline void inc_smeqhead(struct ks_wlan_private *priv)
{
@@ -33,13 +27,10 @@ static inline void inc_smeqtail(struct ks_wlan_private *priv)
static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv)
{
- unsigned int sme_cnt = priv->sme_i.qtail - priv->sme_i.qhead;
-
- return (sme_cnt + SME_EVENT_BUFF_SIZE) % SME_EVENT_BUFF_SIZE;
+ return CIRC_CNT_TO_END(priv->sme_i.qhead, priv->sme_i.qtail,
+ SME_EVENT_BUFF_SIZE);
}
-#define KS_WLAN_MEM_FLAG (GFP_ATOMIC)
-
static inline u8 get_byte(struct ks_wlan_private *priv)
{
u8 data;
@@ -96,82 +87,59 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work)
tasklet_enable(&priv->sme_task);
}
-static
-int ks_wlan_do_power_save(struct ks_wlan_private *priv)
+static void ks_wlan_do_power_save(struct ks_wlan_private *priv)
{
if (is_connect_status(priv->connect_status))
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
else
priv->dev_state = DEVICE_STATE_READY;
- return 0;
}
static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
{
- struct local_ap_t *ap;
+ struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
+ u8 size;
ap = &priv->current_ap;
if (is_disconnect_status(priv->connect_status)) {
- memset(ap, 0, sizeof(struct local_ap_t));
+ memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
- /* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
- /* essid */
+ ether_addr_copy(ap->bssid, ap_info->bssid);
memcpy(ap->ssid.body, priv->reg.ssid.body,
priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
- /* rate_set */
memcpy(ap->rate_set.body, ap_info->rate_set.body,
ap_info->rate_set.size);
ap->rate_set.size = ap_info->rate_set.size;
if (ap_info->ext_rate_set.size != 0) {
- /* rate_set */
memcpy(&ap->rate_set.body[ap->rate_set.size],
ap_info->ext_rate_set.body,
ap_info->ext_rate_set.size);
ap->rate_set.size += ap_info->ext_rate_set.size;
}
- /* channel */
ap->channel = ap_info->ds_parameter.channel;
- /* rssi */
ap->rssi = ap_info->rssi;
- /* sq */
ap->sq = ap_info->sq;
- /* noise */
ap->noise = ap_info->noise;
- /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
- /* rsn */
+ size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
+ ap_info->rsn.size : RSN_IE_BODY_MAX;
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
- ap->rsn_ie.id = 0x30;
- if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
- ap->rsn_ie.size = ap_info->rsn.size;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
- ap_info->rsn.size);
- } else {
- ap->rsn_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
- RSN_IE_BODY_MAX);
- }
+ ap->rsn_ie.id = RSN_INFO_ELEM_ID;
+ ap->rsn_ie.size = size;
+ memcpy(ap->rsn_ie.body, ap_info->rsn.body, size);
} else if ((ap_info->rsn_mode & RSN_MODE_WPA) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
- ap->wpa_ie.id = 0xdd;
- if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
- ap->wpa_ie.size = ap_info->rsn.size;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
- ap_info->rsn.size);
- } else {
- ap->wpa_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
- RSN_IE_BODY_MAX);
- }
+ ap->wpa_ie.id = WPA_INFO_ELEM_ID;
+ ap->wpa_ie.size = size;
+ memcpy(ap->wpa_ie.body, ap_info->rsn.body, size);
} else {
ap->rsn_ie.id = 0;
ap->rsn_ie.size = 0;
@@ -183,20 +151,24 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
wrqu.data.flags = 0;
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
if (is_connect_status(priv->connect_status)) {
- memcpy(wrqu.ap_addr.sa_data,
- priv->current_ap.bssid, ETH_ALEN);
+ ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
- "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data);
+ "IWEVENT: connect bssid=%pM\n",
+ wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
}
- netdev_dbg(priv->net_dev, " Link AP\n");
- netdev_dbg(priv->net_dev, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n"
- " essid=%s\n"
- " rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n"
- " channel=%d\n"
- " rssi=%d\n"
- " sq=%d\n"
- " capability=%04X\n",
+ netdev_dbg(priv->net_dev, "Link AP\n"
+ "- bssid=%02X:%02X:%02X:%02X:%02X:%02X\n"
+ "- essid=%s\n"
+ "- rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n"
+ "- channel=%d\n"
+ "- rssi=%d\n"
+ "- sq=%d\n"
+ "- capability=%04X\n"
+ "- rsn.mode=%d\n"
+ "- rsn.size=%d\n"
+ "- ext_rate_set_size=%d\n"
+ "- rate_set_size=%d\n",
ap->bssid[0], ap->bssid[1], ap->bssid[2],
ap->bssid[3], ap->bssid[4], ap->bssid[5],
&(ap->ssid.body[0]),
@@ -204,10 +176,8 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
ap->rate_set.body[2], ap->rate_set.body[3],
ap->rate_set.body[4], ap->rate_set.body[5],
ap->rate_set.body[6], ap->rate_set.body[7],
- ap->channel, ap->rssi, ap->sq, ap->capability);
- netdev_dbg(priv->net_dev, " Link AP\n rsn.mode=%d\n rsn.size=%d\n",
- ap_info->rsn_mode, ap_info->rsn.size);
- netdev_dbg(priv->net_dev, " ext_rate_set_size=%d\n rate_set_size=%d\n",
+ ap->channel, ap->rssi, ap->sq, ap->capability,
+ ap_info->rsn_mode, ap_info->rsn.size,
ap_info->ext_rate_set.size, ap_info->rate_set.size);
return 0;
@@ -223,25 +193,19 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
- struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+ struct local_ap *ap)
{
unsigned char *bp;
int bsize, offset;
- memset(ap, 0, sizeof(struct local_ap_t));
+ memset(ap, 0, sizeof(struct local_ap));
- /* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
- /* rssi */
+ ether_addr_copy(ap->bssid, ap_info->bssid);
ap->rssi = ap_info->rssi;
- /* sq */
ap->sq = ap_info->sq;
- /* noise */
ap->noise = ap_info->noise;
- /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
- /* channel */
ap->channel = ap_info->ch_info;
bp = ap_info->body;
@@ -269,8 +233,6 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
(RATE_SET_MAX_SIZE - ap->rate_set.size);
}
break;
- case WLAN_EID_DS_PARAMS:
- break;
case WLAN_EID_RSN:
ap->rsn_ie.id = *bp;
ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
@@ -284,7 +246,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
ap->wpa_ie.body);
}
break;
-
+ case WLAN_EID_DS_PARAMS:
case WLAN_EID_FH_PARAMS:
case WLAN_EID_CF_PARAMS:
case WLAN_EID_TIM:
@@ -293,7 +255,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
case WLAN_EID_ERP_INFO:
break;
default:
- netdev_err(priv->net_dev, "unknown Element ID=%d\n", *bp);
+ netdev_err(priv->net_dev,
+ "unknown Element ID=%d\n", *bp);
break;
}
@@ -314,11 +277,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
- struct mic_failure_t *mic_failure;
- struct michael_mic_t michael_mic;
+ struct mic_failure *mic_failure;
+ struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
- struct wpa_key_t *key = &priv->wpa.key[key_index];
+ struct wpa_key *key = &priv->wpa.key[key_index];
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -341,12 +304,9 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
memcpy(&recv_mic[0], (priv->rxp) + ((priv->rx_size) - 8), 8);
priv->rx_size = priv->rx_size - 8;
if (auth_type > 0 && auth_type < 4) { /* auth_type check */
- michael_mic_function(&michael_mic,
- (uint8_t *)key->rx_mic_key,
- (uint8_t *)priv->rxp,
- (int)priv->rx_size,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ michael_mic_function(&michael_mic, key->rx_mic_key,
+ priv->rxp, priv->rx_size,
+ 0, michael_mic.result);
}
if (memcmp(michael_mic.result, recv_mic, 8) != 0) {
now = jiffies;
@@ -363,8 +323,9 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
} else if (mic_failure->failure == 1) {
mic_failure->failure = 2;
mic_failure->counter =
- (uint16_t)((now - mic_failure->last_failure_time) / HZ);
- if (!mic_failure->counter) /* range 1-60 */
+ (u16)((now - mic_failure->last_failure_time) / HZ);
+ /* range 1-60 */
+ if (!mic_failure->counter)
mic_failure->counter = 1;
}
priv->wpa.mic_failure.last_failure_time = now;
@@ -390,7 +351,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
{
unsigned int rx_ind_size; /* indicate data size */
struct sk_buff *skb;
- unsigned short auth_type;
+ u16 auth_type;
unsigned char temp[256];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
@@ -411,7 +372,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
eth_proto = ntohs(eth_hdr->h_proto);
/* source address check */
- if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
+ if (ether_addr_equal(&priv->eth_addr[0], eth_hdr->h_source)) {
netdev_err(priv->net_dev, "invalid : source is own mac address !!\n");
netdev_err(priv->net_dev,
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
@@ -436,7 +397,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
/* check 13th byte at rx data */
switch (*(priv->rxp + 12)) {
- case 0xAA: /* SNAP */
+ case LLC_SAP_SNAP:
rx_ind_size = priv->rx_size - 6;
skb = dev_alloc_skb(rx_ind_size);
if (!skb) {
@@ -456,7 +417,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
break;
- case 0xF0: /* NETBEUI/NetBIOS */
+ case LLC_SAP_NETBEUI:
rx_ind_size = (priv->rx_size + 2);
skb = dev_alloc_skb(rx_ind_size);
if (!skb) {
@@ -506,13 +467,12 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
u16 mib_val_size;
u16 mib_val_type;
- mib_status = get_dword(priv); /* MIB status */
- mib_attribute = get_dword(priv); /* MIB atttibute */
- mib_val_size = get_word(priv); /* MIB value size */
- mib_val_type = get_word(priv); /* MIB value type */
+ mib_status = get_dword(priv);
+ mib_attribute = get_dword(priv);
+ mib_val_size = get_word(priv);
+ mib_val_type = get_word(priv);
if (mib_status) {
- /* in case of error */
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
mib_attribute, mib_status);
return;
@@ -520,22 +480,13 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
switch (mib_attribute) {
case DOT11_MAC_ADDRESS:
- /* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
- memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+ ether_addr_copy(priv->eth_addr, priv->rxp);
priv->mac_address_valid = true;
- dev->dev_addr[0] = priv->eth_addr[0];
- dev->dev_addr[1] = priv->eth_addr[1];
- dev->dev_addr[2] = priv->eth_addr[2];
- dev->dev_addr[3] = priv->eth_addr[3];
- dev->dev_addr[4] = priv->eth_addr[4];
- dev->dev_addr[5] = priv->eth_addr[5];
- dev->dev_addr[6] = 0x00;
- dev->dev_addr[7] = 0x00;
+ ether_addr_copy(dev->dev_addr, priv->eth_addr);
netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
break;
case DOT11_PRODUCT_VERSION:
- /* firmware version */
priv->version_size = priv->rx_size;
memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
priv->firmware_version[priv->rx_size] = '\0';
@@ -553,18 +504,15 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
break;
case LOCAL_EEPROM_SUM:
memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
- if (priv->eeprom_sum.type == 0) {
- priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
- } else if (priv->eeprom_sum.type == 1) {
- if (priv->eeprom_sum.result == 0) {
- priv->eeprom_checksum = EEPROM_NG;
- netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
- } else if (priv->eeprom_sum.result == 1) {
- priv->eeprom_checksum = EEPROM_OK;
- }
- } else {
+ if (priv->eeprom_sum.type != 0 &&
+ priv->eeprom_sum.type != 1) {
netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
+ return;
}
+ priv->eeprom_checksum = (priv->eeprom_sum.type == 0) ?
+ EEPROM_CHECKSUM_NONE :
+ (priv->eeprom_sum.result == 0) ?
+ EEPROM_NG : EEPROM_OK;
break;
default:
netdev_err(priv->net_dev, "mib_attribute=%08x\n",
@@ -576,11 +524,11 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
static
void hostif_mib_set_confirm(struct ks_wlan_private *priv)
{
- u32 mib_status; /* +04 MIB Status */
- u32 mib_attribute; /* +08 MIB attribute */
+ u32 mib_status;
+ u32 mib_attribute;
- mib_status = get_dword(priv); /* MIB Status */
- mib_attribute = get_dword(priv); /* MIB attribute */
+ mib_status = get_dword(priv);
+ mib_attribute = get_dword(priv);
if (mib_status) {
/* in case of error */
@@ -649,8 +597,6 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
case DOT11_RSN_CONFIG_AUTH_SUITE:
hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
break;
- case DOT11_PMK_TSC:
- break;
case DOT11_GMK1_TSC:
if (atomic_read(&priv->psstatus.snooze_guard))
atomic_set(&priv->psstatus.snooze_guard, 0);
@@ -659,16 +605,11 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
if (atomic_read(&priv->psstatus.snooze_guard))
atomic_set(&priv->psstatus.snooze_guard, 0);
break;
+ case DOT11_PMK_TSC:
case LOCAL_PMK:
- break;
case LOCAL_GAIN:
- break;
-#ifdef WPS
case LOCAL_WPS_ENABLE:
- break;
case LOCAL_WPS_PROBE_REQ:
- break;
-#endif /* WPS */
case LOCAL_REGION:
default:
break;
@@ -698,7 +639,6 @@ void hostif_sleep_confirm(struct ks_wlan_private *priv)
static
void hostif_start_confirm(struct ks_wlan_private *priv)
{
-#ifdef WPS
union iwreq_data wrqu;
wrqu.data.length = 0;
@@ -708,7 +648,6 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
eth_zero_addr(wrqu.ap_addr.sa_data);
wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif
netdev_dbg(priv->net_dev, " scan_ind_count=%d\n", priv->scan_ind_count);
hostif_sme_enqueue(priv, SME_START_CONFIRM);
}
@@ -716,7 +655,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
static
void hostif_connect_indication(struct ks_wlan_private *priv)
{
- unsigned short connect_code;
+ u16 connect_code;
unsigned int tmp = 0;
unsigned int old_status = priv->connect_status;
struct net_device *netdev = priv->net_dev;
@@ -725,13 +664,13 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
connect_code = get_word(priv);
switch (connect_code) {
- case RESULT_CONNECT: /* connect */
+ case RESULT_CONNECT:
if (!(priv->connect_status & FORCE_DISCONNECT))
netif_carrier_on(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + CONNECT_STATUS;
break;
- case RESULT_DISCONNECT: /* disconnect */
+ case RESULT_DISCONNECT:
netif_carrier_off(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + DISCONNECT_STATUS;
@@ -745,7 +684,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
- get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+ get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -771,10 +710,11 @@ static
void hostif_scan_indication(struct ks_wlan_private *priv)
{
int i;
- struct ap_info_t *ap_info;
+ struct ap_info *ap_info;
- netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", priv->scan_ind_count);
- ap_info = (struct ap_info_t *)(priv->rxp);
+ netdev_dbg(priv->net_dev,
+ "scan_ind_count = %d\n", priv->scan_ind_count);
+ ap_info = (struct ap_info *)(priv->rxp);
if (priv->scan_ind_count) {
/* bssid check */
@@ -794,7 +734,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
- get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+ get_ap_information(priv, (struct ap_info *)(priv->rxp),
&(priv->aplist.ap[priv->scan_ind_count - 1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -863,8 +803,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
static
void hostif_associate_indication(struct ks_wlan_private *priv)
{
- struct association_request_t *assoc_req;
- struct association_response_t *assoc_resp;
+ struct association_request *assoc_req;
+ struct association_response *assoc_resp;
unsigned char *pb;
union iwreq_data wrqu;
char buf[IW_CUSTOM_MAX];
@@ -874,8 +814,8 @@ void hostif_associate_indication(struct ks_wlan_private *priv)
static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs=";
static const char associnfo_leader1[] = " RespIEs=";
- assoc_req = (struct association_request_t *)(priv->rxp);
- assoc_resp = (struct association_response_t *)(assoc_req + 1);
+ assoc_req = (struct association_request *)(priv->rxp);
+ assoc_resp = (struct association_response *)(assoc_req + 1);
pb = (unsigned char *)(assoc_resp + 1);
memset(&wrqu, 0, sizeof(wrqu));
@@ -905,13 +845,13 @@ void hostif_associate_indication(struct ks_wlan_private *priv)
static
void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
{
- unsigned int result_code;
+ u32 result_code;
struct net_device *dev = priv->net_dev;
union iwreq_data wrqu;
result_code = get_dword(priv);
- netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", result_code,
- priv->scan_ind_count);
+ netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n",
+ result_code, priv->scan_ind_count);
priv->sme_i.sme_flag &= ~SME_AP_SCAN;
hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
@@ -926,10 +866,10 @@ static
void hostif_phy_information_confirm(struct ks_wlan_private *priv)
{
struct iw_statistics *wstats = &priv->wstats;
- unsigned char rssi, signal, noise;
- unsigned char link_speed;
- unsigned int transmitted_frame_count, received_fragment_count;
- unsigned int failed_count, fcs_error_count;
+ u8 rssi, signal, noise;
+ u8 link_speed;
+ u32 transmitted_frame_count, received_fragment_count;
+ u32 failed_count, fcs_error_count;
rssi = get_byte(priv);
signal = get_byte(priv);
@@ -964,16 +904,17 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv)
static
void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
{
- netdev_dbg(priv->net_dev, "mic_failure=%u\n", priv->wpa.mic_failure.failure);
+ netdev_dbg(priv->net_dev, "mic_failure=%u\n",
+ priv->wpa.mic_failure.failure);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
}
static
void hostif_event_check(struct ks_wlan_private *priv)
{
- unsigned short event;
+ u16 event;
- event = get_word(priv); /* get event */
+ event = get_word(priv);
switch (event) {
case HIF_DATA_IND:
hostif_data_indication(priv);
@@ -1044,11 +985,11 @@ static void *hostif_generic_request(size_t size, int event)
{
struct hostif_hdr *p;
- p = kzalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+ p = kzalloc(hif_align_size(size), GFP_ATOMIC);
if (!p)
return NULL;
- p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
+ p->size = cpu_to_le16(size - sizeof(p->size));
p->event = cpu_to_le16(event);
return p;
@@ -1057,15 +998,14 @@ static void *hostif_generic_request(size_t size, int event)
int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
{
unsigned int skb_len = 0;
-
unsigned char *buffer = NULL;
unsigned int length = 0;
- struct hostif_data_request_t *pp;
+ struct hostif_data_request *pp;
unsigned char *p;
int result = 0;
unsigned short eth_proto;
struct ether_hdr *eth_hdr;
- struct michael_mic_t michael_mic;
+ struct michael_mic michael_mic;
unsigned short keyinfo = 0;
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
@@ -1098,7 +1038,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
}
size = sizeof(*pp) + 6 + skb_len + 8;
- pp = kmalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+ pp = kmalloc(hif_align_size(size), GFP_ATOMIC);
if (!pp) {
ret = -ENOMEM;
goto err_kfree_skb;
@@ -1111,9 +1051,10 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
/* skb check */
eth = (struct ethhdr *)skb->data;
- if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
- netdev_err(priv->net_dev, "invalid mac address !!\n");
- netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", eth->h_source);
+ if (!ether_addr_equal(&priv->eth_addr[0], eth->h_source)) {
+ netdev_err(priv->net_dev,
+ "Invalid mac address: ethernet->h_source=%pM\n",
+ eth->h_source);
ret = -ENXIO;
goto err_kfree;
}
@@ -1128,7 +1069,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
/* EtherType/Length check */
if (*(buffer + 1) + (*buffer << 8) > 1500) {
/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
- /* netdev_dbg(priv->net_dev, "Send [SNAP]Type %x\n",ProtocolEAP); */
/* SAP/CTL/OUI(6 byte) add */
*p++ = 0xAA; /* DSAP */
*p++ = 0xAA; /* SSAP */
@@ -1169,40 +1109,37 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
priv->wpa.key[1].key_len == 0 &&
priv->wpa.key[2].key_len == 0 &&
priv->wpa.key[3].key_len == 0) {
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
+ pp->auth_type = cpu_to_le16(TYPE_AUTH);
} else {
if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
michael_mic_function(&michael_mic,
- (uint8_t *)priv->wpa.key[0].tx_mic_key,
- (uint8_t *)&pp->data[0],
- (int)skb_len,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ priv->wpa.key[0].tx_mic_key,
+ &pp->data[0], skb_len,
+ 0, michael_mic.result);
memcpy(p, michael_mic.result, 8);
length += 8;
skb_len += 8;
p += 8;
pp->auth_type =
- cpu_to_le16((uint16_t)TYPE_DATA);
+ cpu_to_le16(TYPE_DATA);
} else if (priv->wpa.pairwise_suite ==
IW_AUTH_CIPHER_CCMP) {
pp->auth_type =
- cpu_to_le16((uint16_t)TYPE_DATA);
+ cpu_to_le16(TYPE_DATA);
}
}
} else {
if (eth_proto == ETH_P_PAE)
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
+ pp->auth_type = cpu_to_le16(TYPE_AUTH);
else
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA);
+ pp->auth_type = cpu_to_le16(TYPE_DATA);
}
/* header value set */
pp->header.size =
- cpu_to_le16((uint16_t)
- (sizeof(*pp) - sizeof(pp->header.size) + skb_len));
- pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ);
+ cpu_to_le16((sizeof(*pp) - sizeof(pp->header.size) + skb_len));
+ pp->header.event = cpu_to_le16(HIF_DATA_REQ);
/* tx request */
result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len),
@@ -1213,7 +1150,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
priv->wpa.mic_failure.failure > 0) {
if (keyinfo & WPA_KEY_INFO_ERROR &&
keyinfo & WPA_KEY_INFO_REQUEST) {
- netdev_err(priv->net_dev, " MIC ERROR Report SET : %04X\n", keyinfo);
+ netdev_err(priv->net_dev,
+ "MIC ERROR Report SET : %04X\n", keyinfo);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST);
}
if (priv->wpa.mic_failure.failure == 2)
@@ -1236,27 +1174,31 @@ static inline void ps_confirm_wait_inc(struct ks_wlan_private *priv)
atomic_inc(&priv->psstatus.confirm_wait);
}
-static
-void hostif_mib_get_request(struct ks_wlan_private *priv,
- unsigned long mib_attribute)
+static inline void send_request_to_device(struct ks_wlan_private *priv,
+ void *data, size_t size)
+{
+ ps_confirm_wait_inc(priv);
+ ks_wlan_hw_tx(priv, data, size, NULL, NULL);
+}
+
+static void hostif_mib_get_request(struct ks_wlan_private *priv,
+ u32 mib_attribute)
{
- struct hostif_mib_get_request_t *pp;
+ struct hostif_mib_get_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ);
if (!pp)
return;
- pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
+ pp->mib_attribute = cpu_to_le32(mib_attribute);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
-static
-void hostif_mib_set_request(struct ks_wlan_private *priv,
- unsigned long mib_attribute, unsigned short size,
- unsigned short type, void *vp)
+static void hostif_mib_set_request(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ enum mib_data_type type,
+ void *data, size_t size)
{
struct hostif_mib_set_request_t *pp;
@@ -1267,30 +1209,52 @@ void hostif_mib_set_request(struct ks_wlan_private *priv,
if (!pp)
return;
- pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
- pp->mib_value.size = cpu_to_le16((uint16_t)size);
- pp->mib_value.type = cpu_to_le16((uint16_t)type);
- memcpy(&pp->mib_value.body, vp, size);
+ pp->mib_attribute = cpu_to_le32(attr);
+ pp->mib_value.size = cpu_to_le16(size);
+ pp->mib_value.type = cpu_to_le16(type);
+ memcpy(&pp->mib_value.body, data, size);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp) + size));
+}
+
+static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
+ enum mib_attribute attr, int val)
+{
+ __le32 v = cpu_to_le32(val);
+ size_t size = sizeof(v);
+
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, &v, size);
+}
+
+static inline void hostif_mib_set_request_bool(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ bool val)
+{
+ __le32 v = cpu_to_le32(val);
+ size_t size = sizeof(v);
+
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, &v, size);
+}
+
+static inline void hostif_mib_set_request_ostring(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ void *data, size_t size)
+{
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_OSTRING, data, size);
}
static
void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
{
- struct hostif_start_request_t *pp;
+ struct hostif_start_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ);
if (!pp)
return;
- pp->mode = cpu_to_le16((uint16_t)mode);
+ pp->mode = cpu_to_le16(mode);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1310,14 +1274,15 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv)
capability &= ~(WLAN_CAPABILITY_DSSS_OFDM);
}
- return cpu_to_le16((uint16_t)capability);
+ return cpu_to_le16(capability);
}
-static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *req)
+static void init_request(struct ks_wlan_private *priv,
+ struct hostif_request *req)
{
- req->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
- req->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
- req->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
+ req->phy_type = cpu_to_le16(priv->reg.phy_type);
+ req->cts_mode = cpu_to_le16(priv->reg.cts_mode);
+ req->scan_type = cpu_to_le16(priv->reg.scan_type);
req->rate_set.size = priv->reg.rate_set.size;
req->capability = ks_wlan_cap(priv);
memcpy(&req->rate_set.body[0], &priv->reg.rate_set.body[0],
@@ -1327,24 +1292,22 @@ static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *
static
void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
{
- struct hostif_ps_adhoc_set_request_t *pp;
+ struct hostif_ps_adhoc_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ);
if (!pp)
return;
init_request(priv, &pp->request);
- pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
+ pp->channel = cpu_to_le16(priv->reg.channel);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
{
- struct hostif_infrastructure_set_request_t *pp;
+ struct hostif_infrastructure_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), event);
if (!pp)
@@ -1354,8 +1317,8 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->beacon_lost_count =
- cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
- pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
+ cpu_to_le16(priv->reg.beacon_lost_count);
+ pp->auth_type = cpu_to_le16(priv->reg.authenticate_type);
pp->channel_list.body[0] = 1;
pp->channel_list.body[1] = 8;
@@ -1377,34 +1340,30 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
pp->channel_list.size = 14;
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_adhoc_set_request(struct ks_wlan_private *priv)
{
- struct hostif_adhoc_set_request_t *pp;
+ struct hostif_adhoc_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
if (!pp)
return;
init_request(priv, &pp->request);
- pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
+ pp->channel = cpu_to_le16(priv->reg.channel);
pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
{
- struct hostif_adhoc_set2_request_t *pp;
+ struct hostif_adhoc_set2_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
if (!pp)
@@ -1418,82 +1377,70 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
pp->channel_list.size = 1;
memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_stop_request(struct ks_wlan_private *priv)
{
- struct hostif_stop_request_t *pp;
+ struct hostif_stop_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ);
if (!pp)
return;
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_phy_information_request(struct ks_wlan_private *priv)
{
- struct hostif_phy_information_request_t *pp;
+ struct hostif_phy_information_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ);
if (!pp)
return;
if (priv->reg.phy_info_timer) {
- pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
- pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
+ pp->type = cpu_to_le16(TIME_TYPE);
+ pp->time = cpu_to_le16(priv->reg.phy_info_timer);
} else {
- pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE);
- pp->time = cpu_to_le16((uint16_t)0);
+ pp->type = cpu_to_le16(NORMAL_TYPE);
+ pp->time = cpu_to_le16(0);
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_power_mgmt_request(struct ks_wlan_private *priv,
- unsigned long mode, unsigned long wake_up,
- unsigned long receive_dtims)
+ u32 mode, u32 wake_up, u32 receive_dtims)
{
- struct hostif_power_mgmt_request_t *pp;
+ struct hostif_power_mgmt_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_POWER_MGMT_REQ);
if (!pp)
return;
- pp->mode = cpu_to_le32((uint32_t)mode);
- pp->wake_up = cpu_to_le32((uint32_t)wake_up);
- pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
+ pp->mode = cpu_to_le32(mode);
+ pp->wake_up = cpu_to_le32(wake_up);
+ pp->receive_dtims = cpu_to_le32(receive_dtims);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_sleep_request(struct ks_wlan_private *priv,
enum sleep_mode_type mode)
{
- struct hostif_sleep_request_t *pp;
+ struct hostif_sleep_request *pp;
if (mode == SLP_SLEEP) {
pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
if (!pp)
return;
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL,
- NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
} else if (mode == SLP_ACTIVE) {
atomic_set(&priv->sleepstatus.wakeup_request, 1);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
@@ -1505,10 +1452,10 @@ void hostif_sleep_request(struct ks_wlan_private *priv,
static
void hostif_bss_scan_request(struct ks_wlan_private *priv,
- unsigned long scan_type, uint8_t *scan_ssid,
- uint8_t scan_ssid_len)
+ unsigned long scan_type, u8 *scan_ssid,
+ u8 scan_ssid_len)
{
- struct hostif_bss_scan_request_t *pp;
+ struct hostif_bss_scan_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ);
if (!pp)
@@ -1516,8 +1463,8 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
pp->scan_type = scan_type;
- pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */
- pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */
+ pp->ch_time_min = cpu_to_le32(110); /* default value */
+ pp->ch_time_max = cpu_to_le32(130); /* default value */
pp->channel_list.body[0] = 1;
pp->channel_list.body[1] = 8;
pp->channel_list.body[2] = 2;
@@ -1545,9 +1492,7 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1555,45 +1500,42 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
static
void hostif_mic_failure_request(struct ks_wlan_private *priv,
- unsigned short failure_count,
- unsigned short timer)
+ u16 failure_count, u16 timer)
{
- struct hostif_mic_failure_request_t *pp;
+ struct hostif_mic_failure_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ);
if (!pp)
return;
- pp->failure_count = cpu_to_le16((uint16_t)failure_count);
- pp->timer = cpu_to_le16((uint16_t)timer);
+ pp->failure_count = cpu_to_le16(failure_count);
+ pp->timer = cpu_to_le16(timer);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
/* Device I/O Receive indicate */
static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
unsigned int size)
{
- if (priv->device_open_status) {
- spin_lock(&priv->dev_read_lock); /* request spin lock */
- priv->dev_data[atomic_read(&priv->rec_count)] = p;
- priv->dev_size[atomic_read(&priv->rec_count)] = size;
-
- if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
- /* rx event count inc */
- atomic_inc(&priv->event_count);
- }
- atomic_inc(&priv->rec_count);
- if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
- atomic_set(&priv->rec_count, 0);
+ if (!priv->is_device_open)
+ return;
- wake_up_interruptible_all(&priv->devread_wait);
+ spin_lock(&priv->dev_read_lock);
+ priv->dev_data[atomic_read(&priv->rec_count)] = p;
+ priv->dev_size[atomic_read(&priv->rec_count)] = size;
- /* release spin lock */
- spin_unlock(&priv->dev_read_lock);
+ if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
+ /* rx event count inc */
+ atomic_inc(&priv->event_count);
}
+ atomic_inc(&priv->rec_count);
+ if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
+ atomic_set(&priv->rec_count, 0);
+
+ wake_up_interruptible_all(&priv->devread_wait);
+
+ spin_unlock(&priv->dev_read_lock);
}
void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
@@ -1604,247 +1546,183 @@ void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
priv->rxp = p;
priv->rx_size = size;
- if (get_word(priv) == priv->rx_size) { /* length check !! */
- hostif_event_check(priv); /* event check */
- }
+ if (get_word(priv) == priv->rx_size)
+ hostif_event_check(priv);
}
-static
-void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
{
- __le32 val;
-
switch (type) {
case SME_WEP_INDEX_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+ priv->reg.wep_index);
break;
case SME_WEP_KEY1_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE1,
- priv->reg.wep_key[0].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[0].val[0]);
+ &priv->reg.wep_key[0].val[0],
+ priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE2,
- priv->reg.wep_key[1].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[1].val[0]);
+ &priv->reg.wep_key[1].val[0],
+ priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE3,
- priv->reg.wep_key[2].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[2].val[0]);
+ &priv->reg.wep_key[2].val[0],
+ priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE4,
- priv->reg.wep_key[3].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[3].val[0]);
+ &priv->reg.wep_key[3].val[0],
+ priv->reg.wep_key[3].size);
break;
case SME_WEP_FLAG_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
- hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+ priv->reg.privacy_invoked);
break;
}
}
-struct wpa_suite_t {
+struct wpa_suite {
__le16 size;
unsigned char suite[4][CIPHER_ID_LEN];
} __packed;
-struct rsn_mode_t {
+struct rsn_mode {
__le32 rsn_mode;
__le16 rsn_capability;
} __packed;
-static
-void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
{
- struct wpa_suite_t wpa_suite;
- struct rsn_mode_t rsn_mode;
- __le32 val;
+ struct wpa_suite wpa_suite;
+ struct rsn_mode rsn_mode;
+ size_t size;
+ u32 mode;
+ const u8 *buf = NULL;
memset(&wpa_suite, 0, sizeof(wpa_suite));
switch (type) {
case SME_RSN_UCAST_REQUEST:
- wpa_suite.size = cpu_to_le16((uint16_t)1);
+ wpa_suite.size = cpu_to_le16(1);
switch (priv->wpa.pairwise_suite) {
case IW_AUTH_CIPHER_NONE:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
- sizeof(wpa_suite.size) +
- CIPHER_ID_LEN *
- le16_to_cpu(wpa_suite.size),
- MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
+ size = sizeof(wpa_suite.size) +
+ (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_UNICAST_CIPHER,
+ &wpa_suite, size);
break;
case SME_RSN_MCAST_REQUEST:
switch (priv->wpa.group_suite) {
case IW_AUTH_CIPHER_NONE:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
-
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
- CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
- &wpa_suite.suite[0][0]);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_MULTICAST_CIPHER,
+ &wpa_suite.suite[0][0],
+ CIPHER_ID_LEN);
break;
case SME_RSN_AUTH_REQUEST:
- wpa_suite.size = cpu_to_le16((uint16_t)1);
+ wpa_suite.size = cpu_to_le16(1);
switch (priv->wpa.key_mgmt_suite) {
case IW_AUTH_KEY_MGMT_802_1X:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_1X : KEY_MGMT_ID_WPA_1X;
break;
case IW_AUTH_KEY_MGMT_PSK:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_PSK : KEY_MGMT_ID_WPA_PSK;
break;
case 0:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_NONE : KEY_MGMT_ID_WPA_NONE;
break;
case 4:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_WPANONE,
- KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_WPANONE,
- KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_WPANONE :
+ KEY_MGMT_ID_WPA_WPANONE;
break;
}
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
- sizeof(wpa_suite.size) +
- KEY_MGMT_ID_LEN *
- le16_to_cpu(wpa_suite.size),
- MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, KEY_MGMT_ID_LEN);
+ size = sizeof(wpa_suite.size) +
+ (KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size));
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_AUTH_SUITE,
+ &wpa_suite, size);
break;
case SME_RSN_ENABLED_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
- hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_RSN_ENABLED,
+ priv->wpa.rsn_enabled);
break;
case SME_RSN_MODE_REQUEST:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_WPA2);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_WPA);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- } else {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_NONE);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- }
- hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
- MIB_VALUE_TYPE_OSTRING, &rsn_mode);
+ mode = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ RSN_MODE_WPA2 :
+ (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) ?
+ RSN_MODE_WPA : RSN_MODE_NONE;
+ rsn_mode.rsn_mode = cpu_to_le32(mode);
+ rsn_mode.rsn_capability = cpu_to_le16(0);
+ hostif_mib_set_request_ostring(priv, LOCAL_RSN_MODE,
+ &rsn_mode, sizeof(rsn_mode));
break;
}
}
@@ -1884,7 +1762,7 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
/* rate mask by phy setting */
if (priv->reg.phy_type == D_11B_ONLY_MODE) {
for (i = 0; i < priv->reg.rate_set.size; i++) {
- if (!IS_11B_RATE(priv->reg.rate_set.body[i]))
+ if (!is_11b_rate(priv->reg.rate_set.body[i]))
break;
if ((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) {
@@ -1897,10 +1775,10 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
} else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
for (i = 0; i < priv->reg.rate_set.size; i++) {
- if (!IS_11BG_RATE(priv->reg.rate_set.body[i]))
+ if (!is_11bg_rate(priv->reg.rate_set.body[i]))
break;
- if (IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) {
+ if (is_ofdm_ext_rate(priv->reg.rate_set.body[i])) {
rate_octet[i] = priv->reg.rate_set.body[i] &
RATE_MASK;
} else {
@@ -1923,21 +1801,20 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
switch (priv->reg.operation_mode) {
case MODE_PSEUDO_ADHOC:
- /* Pseudo Ad-Hoc mode */
hostif_ps_adhoc_set_request(priv);
break;
case MODE_INFRASTRUCTURE:
- /* Infrastructure mode */
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
- hostif_infrastructure_set_request(priv, HIF_INFRA_SET_REQ);
+ hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET_REQ);
} else {
- hostif_infrastructure_set_request(priv, HIF_INFRA_SET2_REQ);
+ hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET2_REQ);
netdev_dbg(priv->net_dev,
"Infra bssid = %pM\n", priv->reg.bssid);
}
break;
case MODE_ADHOC:
- /* IEEE802.11 Ad-Hoc mode */
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
hostif_adhoc_set_request(priv);
} else {
@@ -1958,7 +1835,6 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
int mc_count;
struct netdev_hw_addr *ha;
char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
- __le32 filter_type;
int i = 0;
spin_lock(&priv->multicast_spin);
@@ -1966,156 +1842,117 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
if (dev->flags & IFF_PROMISC) {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_PROMISC);
goto spin_unlock;
}
if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) ||
(dev->flags & IFF_ALLMULTI)) {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_MCASTALL);
goto spin_unlock;
}
if (priv->sme_i.sme_flag & SME_MULTICAST) {
mc_count = netdev_mc_count(dev);
netdev_for_each_mc_addr(ha, dev) {
- memcpy(&set_address[i * ETH_ALEN], ha->addr, ETH_ALEN);
+ ether_addr_copy(&set_address[i * ETH_ALEN], ha->addr);
i++;
}
priv->sme_i.sme_flag &= ~SME_MULTICAST;
- hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
- ETH_ALEN * mc_count,
- MIB_VALUE_TYPE_OSTRING,
- &set_address[0]);
+ hostif_mib_set_request_ostring(priv, LOCAL_MULTICAST_ADDRESS,
+ &set_address[0],
+ ETH_ALEN * mc_count);
} else {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
priv->sme_i.sme_flag |= SME_MULTICAST;
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_MCAST);
}
spin_unlock:
spin_unlock(&priv->multicast_spin);
}
-static
-void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
+static void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
{
- unsigned long mode, wake_up, receive_dtims;
+ u32 mode, wake_up, receive_dtims;
- switch (priv->reg.power_mgmt) {
- case POWER_MGMT_ACTIVE:
+ if (priv->reg.power_mgmt != POWER_MGMT_SAVE1 &&
+ priv->reg.power_mgmt != POWER_MGMT_SAVE2) {
mode = POWER_ACTIVE;
wake_up = 0;
receive_dtims = 0;
- break;
- case POWER_MGMT_SAVE1:
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
- mode = POWER_SAVE;
- wake_up = 0;
- receive_dtims = 0;
- } else {
- mode = POWER_ACTIVE;
- wake_up = 0;
- receive_dtims = 0;
- }
- break;
- case POWER_MGMT_SAVE2:
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
- mode = POWER_SAVE;
- wake_up = 0;
- receive_dtims = 1;
- } else {
- mode = POWER_ACTIVE;
- wake_up = 0;
- receive_dtims = 0;
- }
- break;
- default:
- mode = POWER_ACTIVE;
+ } else {
+ mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
+ POWER_SAVE : POWER_ACTIVE;
wake_up = 0;
- receive_dtims = 0;
- break;
+ receive_dtims = (priv->reg.operation_mode == MODE_INFRASTRUCTURE &&
+ priv->reg.power_mgmt == POWER_MGMT_SAVE2);
}
+
hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
}
-static
-void hostif_sme_sleep_set(struct ks_wlan_private *priv)
+static void hostif_sme_sleep_set(struct ks_wlan_private *priv)
{
- switch (priv->sleep_mode) {
- case SLP_SLEEP:
- hostif_sleep_request(priv, priv->sleep_mode);
- break;
- case SLP_ACTIVE:
- hostif_sleep_request(priv, priv->sleep_mode);
- break;
- default:
- break;
- }
+ if (priv->sleep_mode != SLP_SLEEP &&
+ priv->sleep_mode != SLP_ACTIVE)
+ return;
+
+ hostif_sleep_request(priv, priv->sleep_mode);
}
static
void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
{
- __le32 val;
-
switch (type) {
case SME_SET_FLAG:
- val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
- hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+ priv->reg.privacy_invoked);
break;
case SME_SET_TXKEY:
- val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+ priv->wpa.txkey);
break;
case SME_SET_KEY1:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
- priv->wpa.key[0].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[0].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE1,
+ &priv->wpa.key[0].key_val[0],
+ priv->wpa.key[0].key_len);
break;
case SME_SET_KEY2:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
- priv->wpa.key[1].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[1].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE2,
+ &priv->wpa.key[1].key_val[0],
+ priv->wpa.key[1].key_len);
break;
case SME_SET_KEY3:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
- priv->wpa.key[2].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[2].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE3,
+ &priv->wpa.key[2].key_val[0],
+ priv->wpa.key[2].key_len);
break;
case SME_SET_KEY4:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
- priv->wpa.key[3].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[3].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE4,
+ &priv->wpa.key[3].key_val[0],
+ priv->wpa.key[3].key_len);
break;
case SME_SET_PMK_TSC:
- hostif_mib_set_request(priv, DOT11_PMK_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[0].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_PMK_TSC,
+ &priv->wpa.key[0].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
case SME_SET_GMK1_TSC:
- hostif_mib_set_request(priv, DOT11_GMK1_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[1].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_GMK1_TSC,
+ &priv->wpa.key[1].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
case SME_SET_GMK2_TSC:
- hostif_mib_set_request(priv, DOT11_GMK2_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[2].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_GMK2_TSC,
+ &priv->wpa.key[2].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
}
}
@@ -2123,38 +1960,34 @@ void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
static
void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
{
- struct pmk_cache_t {
+ struct pmk_cache {
__le16 size;
struct {
u8 bssid[ETH_ALEN];
u8 pmkid[IW_PMKID_LEN];
} __packed list[PMK_LIST_MAX];
} __packed pmkcache;
- struct pmk_t *pmk;
- int i;
+ struct pmk *pmk;
+ size_t size;
+ int i = 0;
- i = 0;
list_for_each_entry(pmk, &priv->pmklist.head, list) {
- if (i < PMK_LIST_MAX) {
- memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
- memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
- IW_PMKID_LEN);
- i++;
- }
+ if (i >= PMK_LIST_MAX)
+ break;
+ ether_addr_copy(pmkcache.list[i].bssid, pmk->bssid);
+ memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN);
+ i++;
}
- pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
- hostif_mib_set_request(priv, LOCAL_PMK,
- sizeof(priv->pmklist.size) + (ETH_ALEN +
- IW_PMKID_LEN) *
- (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
- &pmkcache);
+ pmkcache.size = cpu_to_le16(priv->pmklist.size);
+ size = sizeof(priv->pmklist.size) +
+ ((ETH_ALEN + IW_PMKID_LEN) * priv->pmklist.size);
+ hostif_mib_set_request_ostring(priv, LOCAL_PMK, &pmkcache, size);
}
/* execute sme */
-static
-void hostif_sme_execute(struct ks_wlan_private *priv, int event)
+static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
{
- __le32 val;
+ u16 failure;
switch (event) {
case SME_START:
@@ -2165,9 +1998,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_sme_multicast_set(priv);
break;
case SME_MACADDRESS_SET_REQUEST:
- hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
- MIB_VALUE_TYPE_OSTRING,
- &priv->eth_addr[0]);
+ hostif_mib_set_request_ostring(priv, LOCAL_CURRENTADDRESS,
+ &priv->eth_addr[0], ETH_ALEN);
break;
case SME_BSS_SCAN_REQUEST:
hostif_bss_scan_request(priv, priv->reg.scan_type,
@@ -2180,18 +2012,15 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_phy_information_request(priv);
break;
case SME_MIC_FAILURE_REQUEST:
- if (priv->wpa.mic_failure.failure == 1) {
- hostif_mic_failure_request(priv,
- priv->wpa.mic_failure.failure - 1,
- 0);
- } else if (priv->wpa.mic_failure.failure == 2) {
- hostif_mic_failure_request(priv,
- priv->wpa.mic_failure.failure - 1,
- priv->wpa.mic_failure.counter);
- } else {
- netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
- priv->wpa.mic_failure.failure);
+ failure = priv->wpa.mic_failure.failure;
+ if (failure != 1 && failure != 2) {
+ netdev_err(priv->net_dev,
+ "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
+ failure);
+ return;
}
+ hostif_mic_failure_request(priv, failure - 1, (failure == 1) ?
+ 0 : priv->wpa.mic_failure.counter);
break;
case SME_MIC_FAILURE_CONFIRM:
if (priv->wpa.mic_failure.failure == 2) {
@@ -2213,14 +2042,12 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_stop_request(priv);
break;
case SME_RTS_THRESHOLD_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.rts));
- hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_RTS_THRESHOLD,
+ priv->reg.rts);
break;
case SME_FRAGMENTATION_THRESHOLD_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.fragment));
- hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_FRAGMENTATION_THRESHOLD,
+ priv->reg.fragment);
break;
case SME_WEP_INDEX_REQUEST:
case SME_WEP_KEY1_REQUEST:
@@ -2251,26 +2078,20 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
case SME_SET_PMKSA:
hostif_sme_set_pmksa(priv);
break;
-#ifdef WPS
case SME_WPS_ENABLE_REQUEST:
- hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
- sizeof(priv->wps.wps_enabled),
- MIB_VALUE_TYPE_INT,
- &priv->wps.wps_enabled);
+ hostif_mib_set_request_int(priv, LOCAL_WPS_ENABLE,
+ priv->wps.wps_enabled);
break;
case SME_WPS_PROBE_REQUEST:
- hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
- priv->wps.ielen,
- MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
+ hostif_mib_set_request_ostring(priv, LOCAL_WPS_PROBE_REQ,
+ priv->wps.ie, priv->wps.ielen);
break;
-#endif /* WPS */
case SME_MODE_SET_REQUEST:
hostif_sme_mode_setup(priv);
break;
case SME_SET_GAIN:
- hostif_mib_set_request(priv, LOCAL_GAIN,
- sizeof(priv->gain),
- MIB_VALUE_TYPE_OSTRING, &priv->gain);
+ hostif_mib_set_request_ostring(priv, LOCAL_GAIN,
+ &priv->gain, sizeof(priv->gain));
break;
case SME_GET_GAIN:
hostif_mib_get_request(priv, LOCAL_GAIN);
@@ -2295,9 +2116,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_sme_sleep_set(priv);
break;
case SME_SET_REGION:
- val = cpu_to_le32((uint32_t)(priv->region));
- hostif_mib_set_request(priv, LOCAL_REGION,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, LOCAL_REGION, priv->region);
break;
case SME_MULTICAST_CONFIRM:
case SME_BSS_SCAN_CONFIRM:
@@ -2318,7 +2137,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
case SME_RSN_ENABLED_CONFIRM:
case SME_RSN_MODE_CONFIRM:
case SME_MODE_SET_CONFIRM:
- break;
case SME_TERMINATE:
default:
break;
@@ -2343,7 +2161,7 @@ void hostif_sme_task(unsigned long dev)
}
/* send to Station Management Entity module */
-void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event)
{
/* enqueue sme event */
if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
@@ -2359,7 +2177,8 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
static inline void hostif_aplist_init(struct ks_wlan_private *priv)
{
- size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t);
+ size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap);
+
priv->aplist.size = 0;
memset(&priv->aplist.ap[0], 0, size);
}
@@ -2384,7 +2203,7 @@ static inline void hostif_sme_init(struct ks_wlan_private *priv)
static inline void hostif_wpa_init(struct ks_wlan_private *priv)
{
memset(&priv->wpa, 0, sizeof(priv->wpa));
- priv->wpa.rsn_enabled = 0;
+ priv->wpa.rsn_enabled = false;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;
diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index 2f918b11b337..ca7dc8f5166c 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for KeyStream wireless LAN
*
* Copyright (c) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef _KS_HOSTIF_H_
@@ -67,7 +64,7 @@ struct hostif_hdr {
__le16 event;
} __packed;
-struct hostif_data_request_t {
+struct hostif_data_request {
struct hostif_hdr header;
__le16 auth_type;
#define TYPE_DATA 0x0000
@@ -76,85 +73,127 @@ struct hostif_data_request_t {
u8 data[0];
} __packed;
-struct hostif_data_indication_t {
- struct hostif_hdr header;
- __le16 auth_type;
-/* #define TYPE_DATA 0x0000 */
#define TYPE_PMK1 0x0001
#define TYPE_GMK1 0x0002
#define TYPE_GMK2 0x0003
- __le16 reserved;
- u8 data[0];
-} __packed;
#define CHANNEL_LIST_MAX_SIZE 14
-struct channel_list_t {
+struct channel_list {
u8 size;
u8 body[CHANNEL_LIST_MAX_SIZE];
u8 pad;
} __packed;
-/* MIB Attribute */
-#define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */
-#define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R) */
-#define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */
-#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */
-#define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */
-#define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */
-#define DOT11_WEP_LIST 0x13020100 /* WEP LIST */
-#define DOT11_DESIRED_SSID 0x11090100 /* SSID */
-#define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */
-#define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */
-
-#define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */
-#define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Address change (W) */
-#define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Address (W) */
-#define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Address Filter enable/disable (W) */
-#define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */
-#define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */
-#define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */
-#define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */
-
-#define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */
-#define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */
-#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */
-#define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */
-#define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */
-#define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */
-#define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */
-#define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */
-#define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */
-#define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */
-#define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */
-#define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */
-
-#define LOCAL_REGION 0xF10A0100 /* Region setting */
-
-#ifdef WPS
-#define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */
-#define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */
-#endif /* WPS */
-
-#define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */
-#define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */
-
-struct hostif_mib_get_request_t {
+/**
+ * enum mib_attribute - Management Information Base attribute
+ * Attribute value used for accessing and updating MIB
+ *
+ * @DOT11_MAC_ADDRESS: MAC Address (R)
+ * @DOT11_PRODUCT_VERSION: FirmWare Version (R)
+ * @DOT11_RTS_THRESHOLD: RTS Threshold (R/W)
+ * @DOT11_FRAGMENTATION_THRESHOLD: Fragment Threshold (R/W)
+ * @DOT11_PRIVACY_INVOKED: WEP ON/OFF (W)
+ * @DOT11_WEP_DEFAULT_KEY_ID: WEP Index (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE1: WEP Key#1(TKIP AES: PairwiseTemporalKey) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE2: WEP Key#2(TKIP AES: GroupKey1) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE3: WEP Key#3(TKIP AES: GroupKey2) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE4: WEP Key#4 (W)
+ * @DOT11_WEP_LIST: WEP LIST
+ * @DOT11_DESIRED_SSID: SSID
+ * @DOT11_CURRENT_CHANNEL: channel set
+ * @DOT11_OPERATION_RATE_SET: rate set
+ * @LOCAL_AP_SEARCH_INTERVAL: AP search interval (R/W)
+ * @LOCAL_CURRENTADDRESS: MAC Address change (W)
+ * @LOCAL_MULTICAST_ADDRESS: Multicast Address (W)
+ * @LOCAL_MULTICAST_FILTER: Multicast Address Filter enable/disable (W)
+ * @LOCAL_SEARCHED_AP_LIST: AP list (R)
+ * @LOCAL_LINK_AP_STATUS: Link AP status (R)
+ * @LOCAL_PACKET_STATISTICS: tx,rx packets statistics
+ * @LOCAL_AP_SCAN_LIST_TYPE_SET: AP_SCAN_LIST_TYPE
+ * @DOT11_RSN_ENABLED: WPA enable/disable (W)
+ * @LOCAL_RSN_MODE: RSN mode WPA/WPA2 (W)
+ * @DOT11_RSN_CONFIG_MULTICAST_CIPHER: GroupKeyCipherSuite (W)
+ * @DOT11_RSN_CONFIG_UNICAST_CIPHER: PairwiseKeyCipherSuite (W)
+ * @DOT11_RSN_CONFIG_AUTH_SUITE: AuthenticationKeyManagementSuite (W)
+ * @DOT11_RSN_CONFIG_VERSION: RSN version (W)
+ * @LOCAL_RSN_CONFIG_ALL: RSN CONFIG ALL (W)
+ * @DOT11_PMK_TSC: PMK_TSC (W)
+ * @DOT11_GMK1_TSC: GMK1_TSC (W)
+ * @DOT11_GMK2_TSC: GMK2_TSC (W)
+ * @DOT11_GMK3_TSC: GMK3_TSC
+ * @LOCAL_PMK: Pairwise Master Key cache (W)
+ * @LOCAL_REGION: Region setting
+ * @LOCAL_WPS_ENABLE: WiFi Protected Setup
+ * @LOCAL_WPS_PROBE_REQ: WPS Probe Request
+ * @LOCAL_GAIN: Carrer sense threshold for demo ato show
+ * @LOCAL_EEPROM_SUM: EEPROM checksum information
+ */
+enum mib_attribute {
+ DOT11_MAC_ADDRESS = 0x21010100,
+ DOT11_PRODUCT_VERSION = 0x31024100,
+ DOT11_RTS_THRESHOLD = 0x21020100,
+ DOT11_FRAGMENTATION_THRESHOLD = 0x21050100,
+ DOT11_PRIVACY_INVOKED = 0x15010100,
+ DOT11_WEP_DEFAULT_KEY_ID = 0x15020100,
+ DOT11_WEP_DEFAULT_KEY_VALUE1 = 0x13020101,
+ DOT11_WEP_DEFAULT_KEY_VALUE2 = 0x13020102,
+ DOT11_WEP_DEFAULT_KEY_VALUE3 = 0x13020103,
+ DOT11_WEP_DEFAULT_KEY_VALUE4 = 0x13020104,
+ DOT11_WEP_LIST = 0x13020100,
+ DOT11_DESIRED_SSID = 0x11090100,
+ DOT11_CURRENT_CHANNEL = 0x45010100,
+ DOT11_OPERATION_RATE_SET = 0x11110100,
+ LOCAL_AP_SEARCH_INTERVAL = 0xF1010100,
+ LOCAL_CURRENTADDRESS = 0xF1050100,
+ LOCAL_MULTICAST_ADDRESS = 0xF1060100,
+ LOCAL_MULTICAST_FILTER = 0xF1060200,
+ LOCAL_SEARCHED_AP_LIST = 0xF1030100,
+ LOCAL_LINK_AP_STATUS = 0xF1040100,
+ LOCAL_PACKET_STATISTICS = 0xF1020100,
+ LOCAL_AP_SCAN_LIST_TYPE_SET = 0xF1030200,
+ DOT11_RSN_ENABLED = 0x15070100,
+ LOCAL_RSN_MODE = 0x56010100,
+ DOT11_RSN_CONFIG_MULTICAST_CIPHER = 0x51040100,
+ DOT11_RSN_CONFIG_UNICAST_CIPHER = 0x52020100,
+ DOT11_RSN_CONFIG_AUTH_SUITE = 0x53020100,
+ DOT11_RSN_CONFIG_VERSION = 0x51020100,
+ LOCAL_RSN_CONFIG_ALL = 0x5F010100,
+ DOT11_PMK_TSC = 0x55010100,
+ DOT11_GMK1_TSC = 0x55010101,
+ DOT11_GMK2_TSC = 0x55010102,
+ DOT11_GMK3_TSC = 0x55010103,
+ LOCAL_PMK = 0x58010100,
+ LOCAL_REGION = 0xF10A0100,
+ LOCAL_WPS_ENABLE = 0xF10B0100,
+ LOCAL_WPS_PROBE_REQ = 0xF10C0100,
+ LOCAL_GAIN = 0xF10D0100,
+ LOCAL_EEPROM_SUM = 0xF10E0100
+};
+
+struct hostif_mib_get_request {
struct hostif_hdr header;
__le32 mib_attribute;
} __packed;
-struct hostif_mib_value_t {
+/**
+ * enum mib_data_type - Message Information Base data type.
+ * @MIB_VALUE_TYPE_NULL: NULL type
+ * @MIB_VALUE_TYPE_INT: INTEGER type
+ * @MIB_VALUE_TYPE_BOOL: BOOL type
+ * @MIB_VALUE_TYPE_COUNT32: unused
+ * @MIB_VALUE_TYPE_OSTRING: Chunk of memory
+ */
+enum mib_data_type {
+ MIB_VALUE_TYPE_NULL = 0,
+ MIB_VALUE_TYPE_INT,
+ MIB_VALUE_TYPE_BOOL,
+ MIB_VALUE_TYPE_COUNT32,
+ MIB_VALUE_TYPE_OSTRING
+};
+
+struct hostif_mib_value {
__le16 size;
__le16 type;
-#define MIB_VALUE_TYPE_NULL 0
-#define MIB_VALUE_TYPE_INT 1
-#define MIB_VALUE_TYPE_BOOL 2
-#define MIB_VALUE_TYPE_COUNT32 3
-#define MIB_VALUE_TYPE_OSTRING 4
u8 body[0];
} __packed;
@@ -166,22 +205,16 @@ struct hostif_mib_get_confirm_t {
#define MIB_READ_ONLY 2
#define MIB_WRITE_ONLY 3
__le32 mib_attribute;
- struct hostif_mib_value_t mib_value;
+ struct hostif_mib_value mib_value;
} __packed;
struct hostif_mib_set_request_t {
struct hostif_hdr header;
__le32 mib_attribute;
- struct hostif_mib_value_t mib_value;
-} __packed;
-
-struct hostif_mib_set_confirm_t {
- struct hostif_hdr header;
- __le32 mib_status;
- __le32 mib_attribute;
+ struct hostif_mib_value mib_value;
} __packed;
-struct hostif_power_mgmt_request_t {
+struct hostif_power_mgmt_request {
struct hostif_hdr header;
__le32 mode;
#define POWER_ACTIVE 1
@@ -206,12 +239,7 @@ enum power_mgmt_mode_type {
/* #define RESULT_ALREADY_RUNNING 3 */
#define RESULT_ALREADY_RUNNING 7
-struct hostif_power_mgmt_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
-struct hostif_start_request_t {
+struct hostif_start_request {
struct hostif_hdr header;
__le16 mode;
#define MODE_PSEUDO_ADHOC 0
@@ -220,43 +248,38 @@ struct hostif_start_request_t {
#define MODE_ADHOC 3
} __packed;
-struct hostif_start_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
-struct ssid_t {
+struct ssid {
u8 size;
u8 body[IEEE80211_MAX_SSID_LEN];
u8 ssid_pad;
} __packed;
#define RATE_SET_MAX_SIZE 16
-struct rate_set8_t {
+struct rate_set8 {
u8 size;
u8 body[8];
u8 rate_pad;
} __packed;
-struct fh_parms_t {
+struct fh_parms {
__le16 dwell_time;
u8 hop_set;
u8 hop_pattern;
u8 hop_index;
} __packed;
-struct ds_parms_t {
+struct ds_parms {
u8 channel;
} __packed;
-struct cf_parms_t {
+struct cf_parms {
u8 count;
u8 period;
__le16 max_duration;
__le16 dur_remaining;
} __packed;
-struct ibss_parms_t {
+struct ibss_parms {
__le16 atim_window;
} __packed;
@@ -270,13 +293,13 @@ struct erp_params_t {
u8 erp_info;
} __packed;
-struct rate_set16_t {
+struct rate_set16 {
u8 size;
u8 body[16];
u8 rate_pad;
} __packed;
-struct ap_info_t {
+struct ap_info {
u8 bssid[6]; /* +00 */
u8 rssi; /* +06 */
u8 sq; /* +07 */
@@ -291,7 +314,7 @@ struct ap_info_t {
/* +1032 */
} __packed;
-struct link_ap_info_t {
+struct link_ap_info {
u8 bssid[6]; /* +00 */
u8 rssi; /* +06 */
u8 sq; /* +07 */
@@ -299,14 +322,14 @@ struct link_ap_info_t {
u8 pad0; /* +09 */
__le16 beacon_period; /* +10 */
__le16 capability; /* +12 */
- struct rate_set8_t rate_set; /* +14 */
- struct fh_parms_t fh_parameter; /* +24 */
- struct ds_parms_t ds_parameter; /* +29 */
- struct cf_parms_t cf_parameter; /* +30 */
- struct ibss_parms_t ibss_parameter; /* +36 */
+ struct rate_set8 rate_set; /* +14 */
+ struct fh_parms fh_parameter; /* +24 */
+ struct ds_parms ds_parameter; /* +29 */
+ struct cf_parms cf_parameter; /* +30 */
+ struct ibss_parms ibss_parameter; /* +36 */
struct erp_params_t erp_parameter; /* +38 */
u8 pad1; /* +39 */
- struct rate_set8_t ext_rate_set; /* +40 */
+ struct rate_set8 ext_rate_set; /* +40 */
u8 DTIM_period; /* +50 */
u8 rsn_mode; /* +51 */
#define RSN_MODE_NONE 0
@@ -318,23 +341,13 @@ struct link_ap_info_t {
} __packed rsn;
} __packed;
-struct hostif_connect_indication_t {
- struct hostif_hdr header;
- __le16 connect_code;
#define RESULT_CONNECT 0
#define RESULT_DISCONNECT 1
- struct link_ap_info_t link_ap_info;
-} __packed;
-struct hostif_stop_request_t {
+struct hostif_stop_request {
struct hostif_hdr header;
} __packed;
-struct hostif_stop_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
#define D_11B_ONLY_MODE 0
#define D_11G_ONLY_MODE 1
#define D_11BG_COMPATIBLE_MODE 2
@@ -343,98 +356,78 @@ struct hostif_stop_confirm_t {
#define CTS_MODE_FALSE 0
#define CTS_MODE_TRUE 1
-struct hostif_request_t {
+struct hostif_request {
__le16 phy_type;
__le16 cts_mode;
__le16 scan_type;
__le16 capability;
- struct rate_set16_t rate_set;
+ struct rate_set16 rate_set;
} __packed;
/**
- * struct hostif_ps_adhoc_set_request_t - pseudo adhoc mode
+ * struct hostif_ps_adhoc_set_request - pseudo adhoc mode
* @capability: bit5 : preamble
* bit6 : pbcc - Not supported always 0
* bit10 : ShortSlotTime
* bit13 : DSSS-OFDM - Not supported always 0
*/
-struct hostif_ps_adhoc_set_request_t {
+struct hostif_ps_adhoc_set_request {
struct hostif_hdr header;
- struct hostif_request_t request;
+ struct hostif_request request;
__le16 channel;
} __packed;
-struct hostif_ps_adhoc_set_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
#define AUTH_TYPE_OPEN_SYSTEM 0
#define AUTH_TYPE_SHARED_KEY 1
/**
- * struct hostif_infrastructure_set_request_t
+ * struct hostif_infrastructure_set_request
* @capability: bit5 : preamble
* bit6 : pbcc - Not supported always 0
* bit10 : ShortSlotTime
* bit13 : DSSS-OFDM - Not supported always 0
*/
-struct hostif_infrastructure_set_request_t {
+struct hostif_infrastructure_set_request {
struct hostif_hdr header;
- struct hostif_request_t request;
- struct ssid_t ssid;
+ struct hostif_request request;
+ struct ssid ssid;
__le16 beacon_lost_count;
__le16 auth_type;
- struct channel_list_t channel_list;
+ struct channel_list channel_list;
u8 bssid[ETH_ALEN];
} __packed;
-struct hostif_infrastructure_set_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
/**
- * struct hostif_adhoc_set_request_t
+ * struct hostif_adhoc_set_request
* @capability: bit5 : preamble
* bit6 : pbcc - Not supported always 0
* bit10 : ShortSlotTime
* bit13 : DSSS-OFDM - Not supported always 0
*/
-struct hostif_adhoc_set_request_t {
+struct hostif_adhoc_set_request {
struct hostif_hdr header;
- struct hostif_request_t request;
- struct ssid_t ssid;
+ struct hostif_request request;
+ struct ssid ssid;
__le16 channel;
} __packed;
/**
- * struct hostif_adhoc_set2_request_t
+ * struct hostif_adhoc_set2_request
* @capability: bit5 : preamble
* bit6 : pbcc - Not supported always 0
* bit10 : ShortSlotTime
* bit13 : DSSS-OFDM - Not supported always 0
*/
-struct hostif_adhoc_set2_request_t {
+struct hostif_adhoc_set2_request {
struct hostif_hdr header;
- struct hostif_request_t request;
+ struct hostif_request request;
__le16 reserved;
- struct ssid_t ssid;
- struct channel_list_t channel_list;
+ struct ssid ssid;
+ struct channel_list channel_list;
u8 bssid[ETH_ALEN];
} __packed;
-struct hostif_adhoc_set_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
-struct last_associate_t {
- u8 type;
- u8 status;
-} __packed;
-
-struct association_request_t {
+struct association_request {
u8 type;
u8 pad;
__le16 capability;
@@ -443,7 +436,7 @@ struct association_request_t {
__le16 req_ies_size;
} __packed;
-struct association_response_t {
+struct association_response {
u8 type;
u8 pad;
__le16 capability;
@@ -452,15 +445,7 @@ struct association_response_t {
__le16 resp_ies_size;
} __packed;
-struct hostif_associate_indication_t {
- struct hostif_hdr header;
- struct association_request_t assoc_req;
- struct association_response_t assoc_resp;
- /* followed by (req_ies_size + resp_ies_size) octets of data */
- /* reqIEs data *//* respIEs data */
-} __packed;
-
-struct hostif_bss_scan_request_t {
+struct hostif_bss_scan_request {
struct hostif_hdr header;
u8 scan_type;
#define ACTIVE_SCAN 0
@@ -468,17 +453,11 @@ struct hostif_bss_scan_request_t {
u8 pad[3];
__le32 ch_time_min;
__le32 ch_time_max;
- struct channel_list_t channel_list;
- struct ssid_t ssid;
+ struct channel_list channel_list;
+ struct ssid ssid;
} __packed;
-struct hostif_bss_scan_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
- __le16 reserved;
-} __packed;
-
-struct hostif_phy_information_request_t {
+struct hostif_phy_information_request {
struct hostif_hdr header;
__le16 type;
#define NORMAL_TYPE 0
@@ -486,43 +465,21 @@ struct hostif_phy_information_request_t {
__le16 time; /* unit 100ms */
} __packed;
-struct hostif_phy_information_confirm_t {
- struct hostif_hdr header;
- u8 rssi;
- u8 sq;
- u8 noise;
- u8 link_speed;
- __le32 tx_frame;
- __le32 rx_frame;
- __le32 tx_error;
- __le32 rx_error;
-} __packed;
-
enum sleep_mode_type {
SLP_ACTIVE,
SLP_SLEEP
};
-struct hostif_sleep_request_t {
+struct hostif_sleep_request {
struct hostif_hdr header;
} __packed;
-struct hostif_sleep_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
-struct hostif_mic_failure_request_t {
+struct hostif_mic_failure_request {
struct hostif_hdr header;
__le16 failure_count;
__le16 timer;
} __packed;
-struct hostif_mic_failure_confirm_t {
- struct hostif_hdr header;
- __le16 result_code;
-} __packed;
-
#define BASIC_RATE 0x80
#define RATE_MASK 0x7F
@@ -541,34 +498,54 @@ struct hostif_mic_failure_confirm_t {
#define TX_RATE_FIXED 5
/* 11b rate */
-#define TX_RATE_1M (uint8_t)(10 / 5) /* 11b 11g basic rate */
-#define TX_RATE_2M (uint8_t)(20 / 5) /* 11b 11g basic rate */
-#define TX_RATE_5M (uint8_t)(55 / 5) /* 11g basic rate */
-#define TX_RATE_11M (uint8_t)(110 / 5) /* 11g basic rate */
+#define TX_RATE_1M (u8)(10 / 5) /* 11b 11g basic rate */
+#define TX_RATE_2M (u8)(20 / 5) /* 11b 11g basic rate */
+#define TX_RATE_5M (u8)(55 / 5) /* 11g basic rate */
+#define TX_RATE_11M (u8)(110 / 5) /* 11g basic rate */
/* 11g rate */
-#define TX_RATE_6M (uint8_t)(60 / 5) /* 11g basic rate */
-#define TX_RATE_12M (uint8_t)(120 / 5) /* 11g basic rate */
-#define TX_RATE_24M (uint8_t)(240 / 5) /* 11g basic rate */
-#define TX_RATE_9M (uint8_t)(90 / 5)
-#define TX_RATE_18M (uint8_t)(180 / 5)
-#define TX_RATE_36M (uint8_t)(360 / 5)
-#define TX_RATE_48M (uint8_t)(480 / 5)
-#define TX_RATE_54M (uint8_t)(540 / 5)
-
-#define IS_11B_RATE(A) (((A & RATE_MASK) == TX_RATE_1M) || ((A & RATE_MASK) == TX_RATE_2M) || \
- ((A & RATE_MASK) == TX_RATE_5M) || ((A & RATE_MASK) == TX_RATE_11M))
+#define TX_RATE_6M (u8)(60 / 5) /* 11g basic rate */
+#define TX_RATE_12M (u8)(120 / 5) /* 11g basic rate */
+#define TX_RATE_24M (u8)(240 / 5) /* 11g basic rate */
+#define TX_RATE_9M (u8)(90 / 5)
+#define TX_RATE_18M (u8)(180 / 5)
+#define TX_RATE_36M (u8)(360 / 5)
+#define TX_RATE_48M (u8)(480 / 5)
+#define TX_RATE_54M (u8)(540 / 5)
+
+static inline bool is_11b_rate(u8 rate)
+{
+ return (((rate & RATE_MASK) == TX_RATE_1M) ||
+ ((rate & RATE_MASK) == TX_RATE_2M) ||
+ ((rate & RATE_MASK) == TX_RATE_5M) ||
+ ((rate & RATE_MASK) == TX_RATE_11M));
+}
-#define IS_OFDM_RATE(A) (((A & RATE_MASK) == TX_RATE_6M) || ((A & RATE_MASK) == TX_RATE_12M) || \
- ((A & RATE_MASK) == TX_RATE_24M) || ((A & RATE_MASK) == TX_RATE_9M) || \
- ((A & RATE_MASK) == TX_RATE_18M) || ((A & RATE_MASK) == TX_RATE_36M) || \
- ((A & RATE_MASK) == TX_RATE_48M) || ((A & RATE_MASK) == TX_RATE_54M))
+static inline bool is_ofdm_rate(u8 rate)
+{
+ return (((rate & RATE_MASK) == TX_RATE_6M) ||
+ ((rate & RATE_MASK) == TX_RATE_12M) ||
+ ((rate & RATE_MASK) == TX_RATE_24M) ||
+ ((rate & RATE_MASK) == TX_RATE_9M) ||
+ ((rate & RATE_MASK) == TX_RATE_18M) ||
+ ((rate & RATE_MASK) == TX_RATE_36M) ||
+ ((rate & RATE_MASK) == TX_RATE_48M) ||
+ ((rate & RATE_MASK) == TX_RATE_54M));
+}
-#define IS_11BG_RATE(A) (IS_11B_RATE(A) || IS_OFDM_RATE(A))
+static inline bool is_11bg_rate(u8 rate)
+{
+ return (is_11b_rate(rate) || is_ofdm_rate(rate));
+}
-#define IS_OFDM_EXT_RATE(A) (((A & RATE_MASK) == TX_RATE_9M) || ((A & RATE_MASK) == TX_RATE_18M) || \
- ((A & RATE_MASK) == TX_RATE_36M) || ((A & RATE_MASK) == TX_RATE_48M) || \
- ((A & RATE_MASK) == TX_RATE_54M))
+static inline bool is_ofdm_ext_rate(u8 rate)
+{
+ return (((rate & RATE_MASK) == TX_RATE_9M) ||
+ ((rate & RATE_MASK) == TX_RATE_18M) ||
+ ((rate & RATE_MASK) == TX_RATE_36M) ||
+ ((rate & RATE_MASK) == TX_RATE_48M) ||
+ ((rate & RATE_MASK) == TX_RATE_54M));
+}
enum connect_status_type {
CONNECT_STATUS,
@@ -588,19 +565,25 @@ enum multicast_filter_type {
#define NIC_MAX_MCAST_LIST 32
-/* macro function */
#define HIF_EVENT_MASK 0xE800
-#define IS_HIF_IND(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
- ((_EVENT & ~HIF_EVENT_MASK) == 0x0001 || \
- (_EVENT & ~HIF_EVENT_MASK) == 0x0006 || \
- (_EVENT & ~HIF_EVENT_MASK) == 0x000C || \
- (_EVENT & ~HIF_EVENT_MASK) == 0x0011 || \
- (_EVENT & ~HIF_EVENT_MASK) == 0x0012))
-
-#define IS_HIF_CONF(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
- (_EVENT & ~HIF_EVENT_MASK) > 0x0000 && \
- (_EVENT & ~HIF_EVENT_MASK) < 0x0012 && \
- !IS_HIF_IND(_EVENT))
+
+static inline bool is_hif_ind(unsigned short event)
+{
+ return (((event & HIF_EVENT_MASK) == HIF_EVENT_MASK) &&
+ (((event & ~HIF_EVENT_MASK) == 0x0001) ||
+ ((event & ~HIF_EVENT_MASK) == 0x0006) ||
+ ((event & ~HIF_EVENT_MASK) == 0x000C) ||
+ ((event & ~HIF_EVENT_MASK) == 0x0011) ||
+ ((event & ~HIF_EVENT_MASK) == 0x0012)));
+}
+
+static inline bool is_hif_conf(unsigned short event)
+{
+ return (((event & HIF_EVENT_MASK) == HIF_EVENT_MASK) &&
+ ((event & ~HIF_EVENT_MASK) > 0x0000) &&
+ ((event & ~HIF_EVENT_MASK) < 0x0012) &&
+ !is_hif_ind(event));
+}
#ifdef __KERNEL__
@@ -610,7 +593,7 @@ enum multicast_filter_type {
int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb);
void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
unsigned int size);
-void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event);
int hostif_init(struct ks_wlan_private *priv);
void hostif_exit(struct ks_wlan_private *priv);
int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
@@ -622,19 +605,11 @@ void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb);
void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv);
int ks_wlan_hw_power_save(struct ks_wlan_private *priv);
-static
-inline int hif_align_size(int size)
+#define KS7010_SIZE_ALIGNMENT 32
+
+static inline size_t hif_align_size(size_t size)
{
-#ifdef KS_ATOM
- if (size < 1024)
- size = 1024;
-#endif
-#ifdef DEVICE_ALIGNMENT
- return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
- (size % DEVICE_ALIGNMENT) : size;
-#else
- return size;
-#endif
+ return ALIGN(size, KS7010_SIZE_ALIGNMENT);
}
#endif /* __KERNEL__ */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 1b7036c32d1c..7aaf8d780939 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -1,60 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for KeyStream IEEE802.11 b/g wireless LAN cards.
*
* Copyright (C) 2006-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef _KS_WLAN_H
#define _KS_WLAN_H
-#define WPS
-
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-
-#include <linux/spinlock.h> /* spinlock_t */
-#include <linux/sched.h> /* wait_queue_head_t */
-#include <linux/types.h> /* pid_t */
-#include <linux/netdevice.h> /* struct net_device_stats, struct sk_buff */
-#include <linux/etherdevice.h>
+#include <linux/atomic.h>
+#include <linux/circ_buf.h>
+#include <linux/completion.h>
+#include <linux/netdevice.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
#include <linux/wireless.h>
-#include <linux/atomic.h> /* struct atomic_t */
-#include <linux/timer.h> /* struct timer_list */
-#include <linux/string.h>
-#include <linux/completion.h> /* struct completion */
-#include <linux/workqueue.h>
-
-#include <linux/io.h>
-
-#include "ks7010_sdio.h"
struct ks_wlan_parameter {
- u8 operation_mode; /* Operation Mode */
- u8 channel; /* Channel */
- u8 tx_rate; /* Transmit Rate */
+ u8 operation_mode;
+ u8 channel;
+ u8 tx_rate;
struct {
u8 size;
u8 body[16];
} rate_set;
- u8 bssid[ETH_ALEN]; /* BSSID */
+ u8 bssid[ETH_ALEN];
struct {
u8 size;
u8 body[32 + 1];
- } ssid; /* SSID */
- u8 preamble; /* Preamble */
+ } ssid;
+ u8 preamble;
u8 power_mgmt;
- u32 scan_type; /* AP List Scan Type */
-#define BEACON_LOST_COUNT_MIN 0
+ u32 scan_type;
#define BEACON_LOST_COUNT_MAX 65535
- u32 beacon_lost_count; /* Beacon Lost Count */
- u32 rts; /* RTS Threashold */
- u32 fragment; /* Fragmentation Threshold */
+ u32 beacon_lost_count;
+ u32 rts;
+ u32 fragment;
u32 privacy_invoked;
u32 wep_index;
struct {
@@ -62,9 +44,9 @@ struct ks_wlan_parameter {
u8 val[13 * 2 + 1];
} wep_key[4];
u16 authenticate_type;
- u16 phy_type; /* 11b/11g/11bg mode type */
- u16 cts_mode; /* for 11g/11bg mode cts mode */
- u16 phy_info_timer; /* phy information timer */
+ u16 phy_type;
+ u16 cts_mode;
+ u16 phy_info_timer;
};
enum {
@@ -133,10 +115,8 @@ enum {
SME_RSN_AUTH_REQUEST,
SME_RSN_ENABLED_REQUEST,
SME_RSN_MODE_REQUEST,
-#ifdef WPS
SME_WPS_ENABLE_REQUEST,
SME_WPS_PROBE_REQUEST,
-#endif
SME_SET_GAIN,
SME_GET_GAIN,
SME_SLEEP_REQUEST,
@@ -174,7 +154,7 @@ enum {
SME_WEP_SET_CONFIRM,
SME_TERMINATE,
- SME_EVENT_SIZE /* end */
+ SME_EVENT_SIZE
};
/* SME Status */
@@ -196,29 +176,30 @@ struct sme_info {
unsigned long sme_flag;
};
-struct hostt_t {
+struct hostt {
int buff[SME_EVENT_BUFF_SIZE];
unsigned int qhead;
unsigned int qtail;
};
#define RSN_IE_BODY_MAX 64
-struct rsn_ie_t {
+struct rsn_ie {
u8 id; /* 0xdd = WPA or 0x30 = RSN */
u8 size; /* max ? 255 ? */
u8 body[RSN_IE_BODY_MAX];
} __packed;
-#ifdef WPS
+#define WPA_INFO_ELEM_ID 0xdd
+#define RSN_INFO_ELEM_ID 0x30
+
#define WPS_IE_BODY_MAX 255
-struct wps_ie_t {
+struct wps_ie {
u8 id; /* 221 'dd <len> 00 50 F2 04' */
u8 size; /* max ? 255 ? */
u8 body[WPS_IE_BODY_MAX];
} __packed;
-#endif /* WPS */
-struct local_ap_t {
+struct local_ap {
u8 bssid[6];
u8 rssi;
u8 sq;
@@ -235,28 +216,26 @@ struct local_ap_t {
u16 capability;
u8 channel;
u8 noise;
- struct rsn_ie_t wpa_ie;
- struct rsn_ie_t rsn_ie;
-#ifdef WPS
- struct wps_ie_t wps_ie;
-#endif /* WPS */
+ struct rsn_ie wpa_ie;
+ struct rsn_ie rsn_ie;
+ struct wps_ie wps_ie;
};
#define LOCAL_APLIST_MAX 31
#define LOCAL_CURRENT_AP LOCAL_APLIST_MAX
-struct local_aplist_t {
+struct local_aplist {
int size;
- struct local_ap_t ap[LOCAL_APLIST_MAX + 1];
+ struct local_ap ap[LOCAL_APLIST_MAX + 1];
};
-struct local_gain_t {
+struct local_gain {
u8 tx_mode;
u8 rx_mode;
u8 tx_gain;
u8 rx_gain;
};
-struct local_eeprom_sum_t {
+struct local_eeprom_sum {
u8 type;
u8 result;
};
@@ -278,33 +257,25 @@ enum {
PS_WAKEUP
};
-struct power_save_status_t {
+struct power_save_status {
atomic_t status; /* initialvalue 0 */
struct completion wakeup_wait;
atomic_t confirm_wait;
atomic_t snooze_guard;
};
-struct sleep_status_t {
+struct sleep_status {
atomic_t status; /* initialvalue 0 */
atomic_t doze_request;
atomic_t wakeup_request;
};
/* WPA */
-struct scan_ext_t {
+struct scan_ext {
unsigned int flag;
char ssid[IW_ESSID_MAX_SIZE + 1];
};
-enum {
- CIPHER_NONE,
- CIPHER_WEP40,
- CIPHER_TKIP,
- CIPHER_CCMP,
- CIPHER_WEP104
-};
-
#define CIPHER_ID_WPA_NONE "\x00\x50\xf2\x00"
#define CIPHER_ID_WPA_WEP40 "\x00\x50\xf2\x01"
#define CIPHER_ID_WPA_TKIP "\x00\x50\xf2\x02"
@@ -339,7 +310,7 @@ enum {
#define MIC_KEY_SIZE 8
-struct wpa_key_t {
+struct wpa_key {
u32 ext_flags; /* IW_ENCODE_EXT_xxx */
u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
@@ -357,50 +328,111 @@ struct wpa_key_t {
#define WPA_KEY_INDEX_MAX 4
#define WPA_RX_SEQ_LEN 6
-struct mic_failure_t {
+struct mic_failure {
u16 failure; /* MIC Failure counter 0 or 1 or 2 */
u16 counter; /* 1sec counter 0-60 */
u32 last_failure_time;
- int stop; /* stop flag */
+ int stop;
};
-struct wpa_status_t {
+struct wpa_status {
int wpa_enabled;
- unsigned int rsn_enabled;
+ bool rsn_enabled;
int version;
int pairwise_suite; /* unicast cipher */
int group_suite; /* multicast cipher */
- int key_mgmt_suite; /* authentication key management suite */
+ int key_mgmt_suite;
int auth_alg;
int txkey;
- struct wpa_key_t key[WPA_KEY_INDEX_MAX];
- struct scan_ext_t scan_ext;
- struct mic_failure_t mic_failure;
+ struct wpa_key key[WPA_KEY_INDEX_MAX];
+ struct scan_ext scan_ext;
+ struct mic_failure mic_failure;
};
#include <linux/list.h>
#define PMK_LIST_MAX 8
-struct pmk_list_t {
+struct pmk_list {
u16 size;
struct list_head head;
- struct pmk_t {
+ struct pmk {
struct list_head list;
u8 bssid[ETH_ALEN];
u8 pmkid[IW_PMKID_LEN];
} pmk[PMK_LIST_MAX];
};
-#ifdef WPS
-struct wps_status_t {
+struct wps_status {
int wps_enabled;
int ielen;
u8 ie[255];
};
-#endif /* WPS */
+
+/* Tx Device struct */
+#define TX_DEVICE_BUFF_SIZE 1024
+
+struct ks_wlan_private;
+
+/**
+ * struct tx_device_buffer - Queue item for the tx queue.
+ * @sendp: Pointer to the send request data.
+ * @size: Size of @sendp data.
+ * @complete_handler: Function called once data write to device is complete.
+ * @arg1: First argument to @complete_handler.
+ * @arg2: Second argument to @complete_handler.
+ */
+struct tx_device_buffer {
+ unsigned char *sendp;
+ unsigned int size;
+ void (*complete_handler)(struct ks_wlan_private *priv,
+ struct sk_buff *skb);
+ struct sk_buff *skb;
+};
+
+/**
+ * struct tx_device - Tx buffer queue.
+ * @tx_device_buffer: Queue buffer.
+ * @qhead: Head of tx queue.
+ * @qtail: Tail of tx queue.
+ * @tx_dev_lock: Queue lock.
+ */
+struct tx_device {
+ struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
+ unsigned int qhead;
+ unsigned int qtail;
+ spinlock_t tx_dev_lock; /* protect access to the queue */
+};
+
+/* Rx Device struct */
+#define RX_DATA_SIZE (2 + 2 + 2347 + 1)
+#define RX_DEVICE_BUFF_SIZE 32
+
+/**
+ * struct rx_device_buffer - Queue item for the rx queue.
+ * @data: rx data.
+ * @size: Size of @data.
+ */
+struct rx_device_buffer {
+ unsigned char data[RX_DATA_SIZE];
+ unsigned int size;
+};
+
+/**
+ * struct rx_device - Rx buffer queue.
+ * @rx_device_buffer: Queue buffer.
+ * @qhead: Head of rx queue.
+ * @qtail: Tail of rx queue.
+ * @rx_dev_lock: Queue lock.
+ */
+struct rx_device {
+ struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
+ unsigned int qhead;
+ unsigned int qtail;
+ spinlock_t rx_dev_lock; /* protect access to the queue */
+};
struct ks_wlan_private {
/* hardware information */
- struct ks_sdio_card *ks_sdio_card;
+ void *if_hw;
struct workqueue_struct *wq;
struct delayed_work rw_dwork;
struct tasklet_struct rx_bh_task;
@@ -423,12 +455,12 @@ struct ks_wlan_private {
unsigned char eth_addr[ETH_ALEN];
- struct local_aplist_t aplist;
- struct local_ap_t current_ap;
- struct power_save_status_t psstatus;
- struct sleep_status_t sleepstatus;
- struct wpa_status_t wpa;
- struct pmk_list_t pmklist;
+ struct local_aplist aplist;
+ struct local_ap current_ap;
+ struct power_save_status psstatus;
+ struct sleep_status sleepstatus;
+ struct wpa_status wpa;
+ struct pmk_list pmklist;
/* wireless parameter */
struct ks_wlan_parameter reg;
u8 current_rate;
@@ -443,7 +475,7 @@ struct ks_wlan_private {
unsigned int need_commit; /* for ioctl */
/* DeviceIoControl */
- int device_open_status;
+ bool is_device_open;
atomic_t event_count;
atomic_t rec_count;
int dev_count;
@@ -455,42 +487,78 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
- bool mac_address_valid; /* Mac Address Status */
+ bool mac_address_valid;
int dev_state;
struct sk_buff *skb;
unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */
- /* spinlock_t lock; */
#define FORCE_DISCONNECT 0x80000000
#define CONNECT_STATUS_MASK 0x7FFFFFFF
- u32 connect_status; /* connect status */
- int infra_status; /* Infractructure status */
-
- u8 data_buff[0x1000];
-
+ u32 connect_status;
+ int infra_status;
u8 scan_ssid_len;
u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
- struct local_gain_t gain;
-#ifdef WPS
- struct net_device *l2_dev;
- int l2_fd;
- struct wps_status_t wps;
-#endif /* WPS */
+ struct local_gain gain;
+ struct wps_status wps;
u8 sleep_mode;
u8 region;
- struct local_eeprom_sum_t eeprom_sum;
+ struct local_eeprom_sum eeprom_sum;
u8 eeprom_checksum;
- struct hostt_t hostt;
+ struct hostt hostt;
unsigned long last_doze;
unsigned long last_wakeup;
- uint wakeup_count; /* for detect wakeup loop */
+ unsigned int wakeup_count; /* for detect wakeup loop */
};
+static inline void inc_txqhead(struct ks_wlan_private *priv)
+{
+ priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
+}
+
+static inline void inc_txqtail(struct ks_wlan_private *priv)
+{
+ priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
+}
+
+static inline bool txq_has_space(struct ks_wlan_private *priv)
+{
+ return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
+ TX_DEVICE_BUFF_SIZE) > 0);
+}
+
+static inline void inc_rxqhead(struct ks_wlan_private *priv)
+{
+ priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
+}
+
+static inline void inc_rxqtail(struct ks_wlan_private *priv)
+{
+ priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
+}
+
+static inline bool rxq_has_space(struct ks_wlan_private *priv)
+{
+ return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
+ RX_DEVICE_BUFF_SIZE) > 0);
+}
+
+static inline unsigned int txq_count(struct ks_wlan_private *priv)
+{
+ return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
+ TX_DEVICE_BUFF_SIZE);
+}
+
+static inline unsigned int rxq_count(struct ks_wlan_private *priv)
+{
+ return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
+ RX_DEVICE_BUFF_SIZE);
+}
+
int ks_wlan_net_start(struct net_device *dev);
int ks_wlan_net_stop(struct net_device *dev);
bool is_connect_status(u32 status);
diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h
index 121e7cb808a2..97c7d95de411 100644
--- a/drivers/staging/ks7010/ks_wlan_ioctl.h
+++ b/drivers/staging/ks7010/ks_wlan_ioctl.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for KeyStream 11b/g wireless LAN
*
* Copyright (c) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef _KS_WLAN_IOCTL_H
@@ -19,11 +16,9 @@
/* former KS_WLAN_GET_DRIVER_VERSION (SIOCIWFIRSTPRIV + 1) */
/* (SIOCIWFIRSTPRIV + 2) */
#define KS_WLAN_GET_FIRM_VERSION (SIOCIWFIRSTPRIV + 3)
-#ifdef WPS
#define KS_WLAN_SET_WPS_ENABLE (SIOCIWFIRSTPRIV + 4)
#define KS_WLAN_GET_WPS_ENABLE (SIOCIWFIRSTPRIV + 5)
#define KS_WLAN_SET_WPS_PROBE_REQ (SIOCIWFIRSTPRIV + 6)
-#endif
#define KS_WLAN_GET_EEPROM_CKSUM (SIOCIWFIRSTPRIV + 7)
#define KS_WLAN_SET_PREAMBLE (SIOCIWFIRSTPRIV + 8)
#define KS_WLAN_GET_PREAMBLE (SIOCIWFIRSTPRIV + 9)
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 9078e13b0d4a..dc5459ae0b51 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1,31 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Driver for KeyStream 11b/g wireless LAN
*
* Copyright (C) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/compiler.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/if_arp.h>
-#include <linux/rtnetlink.h>
-#include <linux/delay.h>
+#include <linux/atomic.h>
#include <linux/completion.h>
-#include <linux/mii.h>
-#include <linux/pci.h>
-#include <linux/ctype.h>
+#include <linux/if_arp.h>
+#include <linux/netdevice.h>
#include <linux/timer.h>
-#include <linux/atomic.h>
-#include <linux/io.h>
#include <linux/uaccess.h>
static int wep_on_off;
@@ -43,7 +28,8 @@ static int wep_on_off;
#include <net/iw_handler.h> /* New driver API */
/* Frequency list (map channels to frequencies) */
-static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
+static const long frequency_list[] = {
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484
};
@@ -55,17 +41,6 @@ struct wep_key {
u8 key[16]; /* 40-bit and 104-bit keys */
};
-/* Backward compatibility */
-#ifndef IW_ENCODE_NOKEY
-#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
-#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN)
-#endif /* IW_ENCODE_NOKEY */
-
-/* List of Wireless Handlers (new API) */
-static const struct iw_handler_def ks_wlan_handler_def;
-
-#define KSC_OPNOTSUPP /* Operation Not Support */
-
/*
* function prototypes
*/
@@ -73,7 +48,7 @@ static int ks_wlan_open(struct net_device *dev);
static void ks_wlan_tx_timeout(struct net_device *dev);
static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
static int ks_wlan_close(struct net_device *dev);
-static void ks_wlan_set_multicast_list(struct net_device *dev);
+static void ks_wlan_set_rx_mode(struct net_device *dev);
static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
@@ -172,7 +147,8 @@ int ks_wlan_setup_parameter(struct ks_wlan_private *priv,
*/
static int ks_wlan_get_name(struct net_device *dev,
- struct iw_request_info *info, char *cwrq,
+ struct iw_request_info *info,
+ union iwreq_data *cwrq,
char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -182,20 +158,20 @@ static int ks_wlan_get_name(struct net_device *dev,
/* for SLEEP MODE */
if (priv->dev_state < DEVICE_STATE_READY)
- strcpy(cwrq, "NOT READY!");
+ strcpy(cwrq->name, "NOT READY!");
else if (priv->reg.phy_type == D_11B_ONLY_MODE)
- strcpy(cwrq, "IEEE 802.11b");
+ strcpy(cwrq->name, "IEEE 802.11b");
else if (priv->reg.phy_type == D_11G_ONLY_MODE)
- strcpy(cwrq, "IEEE 802.11g");
+ strcpy(cwrq->name, "IEEE 802.11g");
else
- strcpy(cwrq, "IEEE 802.11b/g");
+ strcpy(cwrq->name, "IEEE 802.11b/g");
return 0;
}
static int ks_wlan_set_freq(struct net_device *dev,
- struct iw_request_info *info, struct iw_freq *fwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *fwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
int channel;
@@ -205,28 +181,28 @@ static int ks_wlan_set_freq(struct net_device *dev,
/* for SLEEP MODE */
/* If setting by frequency, convert to a channel */
- if ((fwrq->e == 1) &&
- (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) {
- int f = fwrq->m / 100000;
+ if ((fwrq->freq.e == 1) &&
+ (fwrq->freq.m >= (int)2.412e8) && (fwrq->freq.m <= (int)2.487e8)) {
+ int f = fwrq->freq.m / 100000;
int c = 0;
while ((c < 14) && (f != frequency_list[c]))
c++;
/* Hack to fall through... */
- fwrq->e = 0;
- fwrq->m = c + 1;
+ fwrq->freq.e = 0;
+ fwrq->freq.m = c + 1;
}
/* Setting by channel number */
- if ((fwrq->m > 1000) || (fwrq->e > 0))
+ if ((fwrq->freq.m > 1000) || (fwrq->freq.e > 0))
return -EOPNOTSUPP;
- channel = fwrq->m;
+ channel = fwrq->freq.m;
/* We should do a better check than that,
* based on the card capability !!!
*/
if ((channel < 1) || (channel > 14)) {
netdev_dbg(dev, "%s: New channel value of %d is invalid!\n",
- dev->name, fwrq->m);
+ dev->name, fwrq->freq.m);
return -EINVAL;
}
@@ -238,8 +214,8 @@ static int ks_wlan_set_freq(struct net_device *dev,
}
static int ks_wlan_get_freq(struct net_device *dev,
- struct iw_request_info *info, struct iw_freq *fwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *fwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
int f;
@@ -253,15 +229,15 @@ static int ks_wlan_get_freq(struct net_device *dev,
else
f = (int)priv->reg.channel;
- fwrq->m = frequency_list[f - 1] * 100000;
- fwrq->e = 1;
+ fwrq->freq.m = frequency_list[f - 1] * 100000;
+ fwrq->freq.e = 1;
return 0;
}
static int ks_wlan_set_essid(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
size_t len;
@@ -271,12 +247,12 @@ static int ks_wlan_set_essid(struct net_device *dev,
/* for SLEEP MODE */
/* Check if we asked for `any' */
- if (!dwrq->flags) {
+ if (!dwrq->essid.flags) {
/* Just send an empty SSID list */
memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body));
priv->reg.ssid.size = 0;
} else {
- len = dwrq->length;
+ len = dwrq->essid.length;
/* iwconfig uses nul termination in SSID.. */
if (len > 0 && extra[len - 1] == '\0')
len--;
@@ -300,7 +276,7 @@ static int ks_wlan_set_essid(struct net_device *dev,
static int ks_wlan_get_essid(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -318,18 +294,18 @@ static int ks_wlan_get_essid(struct net_device *dev,
/* If none, we may want to get the one that was set */
/* Push it out ! */
- dwrq->length = priv->reg.ssid.size;
- dwrq->flags = 1; /* active */
+ dwrq->essid.length = priv->reg.ssid.size;
+ dwrq->essid.flags = 1; /* active */
} else {
- dwrq->length = 0;
- dwrq->flags = 0; /* ANY */
+ dwrq->essid.length = 0;
+ dwrq->essid.flags = 0; /* ANY */
}
return 0;
}
static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
+ union iwreq_data *awrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -337,18 +313,16 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
return -EPERM;
/* for SLEEP MODE */
- if (priv->reg.operation_mode == MODE_ADHOC ||
- priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
- memcpy(priv->reg.bssid, &ap_addr->sa_data, ETH_ALEN);
-
- if (is_valid_ether_addr((u8 *)priv->reg.bssid))
- priv->need_commit |= SME_MODE_SET;
-
- } else {
+ if (priv->reg.operation_mode != MODE_ADHOC &&
+ priv->reg.operation_mode != MODE_INFRASTRUCTURE) {
eth_zero_addr(priv->reg.bssid);
return -EOPNOTSUPP;
}
+ ether_addr_copy(priv->reg.bssid, awrq->ap_addr.sa_data);
+ if (is_valid_ether_addr((u8 *)priv->reg.bssid))
+ priv->need_commit |= SME_MODE_SET;
+
netdev_dbg(dev, "bssid = %pM\n", priv->reg.bssid);
/* Write it to the card */
@@ -360,7 +334,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
}
static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
- struct sockaddr *awrq, char *extra)
+ union iwreq_data *awrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -369,18 +343,18 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
/* for SLEEP MODE */
if (is_connect_status(priv->connect_status))
- memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN);
+ ether_addr_copy(awrq->ap_addr.sa_data, priv->current_ap.bssid);
else
- eth_zero_addr(awrq->sa_data);
+ eth_zero_addr(awrq->ap_addr.sa_data);
- awrq->sa_family = ARPHRD_ETHER;
+ awrq->ap_addr.sa_family = ARPHRD_ETHER;
return 0;
}
static int ks_wlan_set_nick(struct net_device *dev,
- struct iw_request_info *info, struct iw_point *dwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -389,18 +363,18 @@ static int ks_wlan_set_nick(struct net_device *dev,
/* for SLEEP MODE */
/* Check the size of the string */
- if (dwrq->length > 16 + 1)
+ if (dwrq->data.length > 16 + 1)
return -E2BIG;
memset(priv->nick, 0, sizeof(priv->nick));
- memcpy(priv->nick, extra, dwrq->length);
+ memcpy(priv->nick, extra, dwrq->data.length);
return -EINPROGRESS; /* Call commit handler */
}
static int ks_wlan_get_nick(struct net_device *dev,
- struct iw_request_info *info, struct iw_point *dwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -410,14 +384,14 @@ static int ks_wlan_get_nick(struct net_device *dev,
/* for SLEEP MODE */
strncpy(extra, priv->nick, 16);
extra[16] = '\0';
- dwrq->length = strlen(extra) + 1;
+ dwrq->data.length = strlen(extra) + 1;
return 0;
}
static int ks_wlan_set_rate(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
int i = 0;
@@ -427,17 +401,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
/* for SLEEP MODE */
if (priv->reg.phy_type == D_11B_ONLY_MODE) {
- if (vwrq->fixed == 1) {
- switch (vwrq->value) {
+ if (vwrq->bitrate.fixed == 1) {
+ switch (vwrq->bitrate.value) {
case 11000000:
case 5500000:
priv->reg.rate_set.body[0] =
- (uint8_t)(vwrq->value / 500000);
+ (u8)(vwrq->bitrate.value / 500000);
break;
case 2000000:
case 1000000:
priv->reg.rate_set.body[0] =
- ((uint8_t)(vwrq->value / 500000)) |
+ ((u8)(vwrq->bitrate.value / 500000)) |
BASIC_RATE;
break;
default:
@@ -446,8 +420,8 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.tx_rate = TX_RATE_FIXED;
priv->reg.rate_set.size = 1;
} else { /* vwrq->fixed == 0 */
- if (vwrq->value > 0) {
- switch (vwrq->value) {
+ if (vwrq->bitrate.value > 0) {
+ switch (vwrq->bitrate.value) {
case 11000000:
priv->reg.rate_set.body[3] =
TX_RATE_11M;
@@ -484,15 +458,15 @@ static int ks_wlan_set_rate(struct net_device *dev,
}
}
} else { /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
- if (vwrq->fixed == 1) {
- switch (vwrq->value) {
+ if (vwrq->bitrate.fixed == 1) {
+ switch (vwrq->bitrate.value) {
case 54000000:
case 48000000:
case 36000000:
case 18000000:
case 9000000:
priv->reg.rate_set.body[0] =
- (uint8_t)(vwrq->value / 500000);
+ (u8)(vwrq->bitrate.value / 500000);
break;
case 24000000:
case 12000000:
@@ -502,7 +476,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
case 2000000:
case 1000000:
priv->reg.rate_set.body[0] =
- ((uint8_t)(vwrq->value / 500000)) |
+ ((u8)(vwrq->bitrate.value / 500000)) |
BASIC_RATE;
break;
default:
@@ -511,8 +485,8 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.tx_rate = TX_RATE_FIXED;
priv->reg.rate_set.size = 1;
} else { /* vwrq->fixed == 0 */
- if (vwrq->value > 0) {
- switch (vwrq->value) {
+ if (vwrq->bitrate.value > 0) {
+ switch (vwrq->bitrate.value) {
case 54000000:
priv->reg.rate_set.body[11] =
TX_RATE_54M;
@@ -534,7 +508,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
case 11000000:
case 9000000:
case 6000000:
- if (vwrq->value == 24000000) {
+ if (vwrq->bitrate.value == 24000000) {
priv->reg.rate_set.body[8] =
TX_RATE_18M;
i++;
@@ -553,7 +527,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M | BASIC_RATE;
i++;
- } else if (vwrq->value == 18000000) {
+ } else if (vwrq->bitrate.value == 18000000) {
priv->reg.rate_set.body[7] =
TX_RATE_18M;
i++;
@@ -569,7 +543,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M | BASIC_RATE;
i++;
- } else if (vwrq->value == 12000000) {
+ } else if (vwrq->bitrate.value == 12000000) {
priv->reg.rate_set.body[6] =
TX_RATE_9M;
i++;
@@ -582,7 +556,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M | BASIC_RATE;
i++;
- } else if (vwrq->value == 11000000) {
+ } else if (vwrq->bitrate.value == 11000000) {
priv->reg.rate_set.body[5] =
TX_RATE_9M;
i++;
@@ -592,7 +566,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M | BASIC_RATE;
i++;
- } else if (vwrq->value == 9000000) {
+ } else if (vwrq->bitrate.value == 9000000) {
priv->reg.rate_set.body[4] =
TX_RATE_9M;
i++;
@@ -657,8 +631,8 @@ static int ks_wlan_set_rate(struct net_device *dev,
}
static int ks_wlan_get_rate(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -672,26 +646,23 @@ static int ks_wlan_get_rate(struct net_device *dev,
if (!atomic_read(&update_phyinfo))
ks_wlan_update_phy_information(priv);
- vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000;
- if (priv->reg.tx_rate == TX_RATE_FIXED)
- vwrq->fixed = 1;
- else
- vwrq->fixed = 0;
+ vwrq->bitrate.value = ((priv->current_rate) & RATE_MASK) * 500000;
+ vwrq->bitrate.fixed = (priv->reg.tx_rate == TX_RATE_FIXED) ? 1 : 0;
return 0;
}
static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- int rthr = vwrq->value;
+ int rthr = vwrq->rts.value;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (vwrq->disabled)
+ if (vwrq->rts.disabled)
rthr = 2347;
if ((rthr < 0) || (rthr > 2347))
return -EINVAL;
@@ -703,7 +674,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
}
static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -711,25 +682,25 @@ static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
return -EPERM;
/* for SLEEP MODE */
- vwrq->value = priv->reg.rts;
- vwrq->disabled = (vwrq->value >= 2347);
- vwrq->fixed = 1;
+ vwrq->rts.value = priv->reg.rts;
+ vwrq->rts.disabled = (vwrq->rts.value >= 2347);
+ vwrq->rts.fixed = 1;
return 0;
}
static int ks_wlan_set_frag(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- int fthr = vwrq->value;
+ int fthr = vwrq->frag.value;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (vwrq->disabled)
+ if (vwrq->frag.disabled)
fthr = 2346;
if ((fthr < 256) || (fthr > 2346))
return -EINVAL;
@@ -742,8 +713,8 @@ static int ks_wlan_set_frag(struct net_device *dev,
}
static int ks_wlan_get_frag(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -751,134 +722,99 @@ static int ks_wlan_get_frag(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- vwrq->value = priv->reg.fragment;
- vwrq->disabled = (vwrq->value >= 2346);
- vwrq->fixed = 1;
+ vwrq->frag.value = priv->reg.fragment;
+ vwrq->frag.disabled = (vwrq->frag.value >= 2346);
+ vwrq->frag.fixed = 1;
return 0;
}
static int ks_wlan_set_mode(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- /* for SLEEP MODE */
- switch (*uwrq) {
- case IW_MODE_ADHOC:
- priv->reg.operation_mode = MODE_ADHOC;
- priv->need_commit |= SME_MODE_SET;
- break;
- case IW_MODE_INFRA:
- priv->reg.operation_mode = MODE_INFRASTRUCTURE;
- priv->need_commit |= SME_MODE_SET;
- break;
- case IW_MODE_AUTO:
- case IW_MODE_MASTER:
- case IW_MODE_REPEAT:
- case IW_MODE_SECOND:
- case IW_MODE_MONITOR:
- default:
+ if (uwrq->mode != IW_MODE_ADHOC &&
+ uwrq->mode != IW_MODE_INFRA)
return -EINVAL;
- }
+
+ priv->reg.operation_mode = (uwrq->mode == IW_MODE_ADHOC) ?
+ MODE_ADHOC : MODE_INFRASTRUCTURE;
+ priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
static int ks_wlan_get_mode(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- /* for SLEEP MODE */
/* If not managed, assume it's ad-hoc */
- switch (priv->reg.operation_mode) {
- case MODE_INFRASTRUCTURE:
- *uwrq = IW_MODE_INFRA;
- break;
- case MODE_ADHOC:
- *uwrq = IW_MODE_ADHOC;
- break;
- default:
- *uwrq = IW_MODE_ADHOC;
- }
+ uwrq->mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
+ IW_MODE_INFRA : IW_MODE_ADHOC;
return 0;
}
static int ks_wlan_set_encode(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
-
+ struct iw_point *enc = &dwrq->encoding;
struct wep_key key;
- int index = (dwrq->flags & IW_ENCODE_INDEX);
- int current_index = priv->reg.wep_index;
- int i;
+ int index = (enc->flags & IW_ENCODE_INDEX);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
+ if (enc->length > MAX_KEY_SIZE)
+ return -EINVAL;
+
/* for SLEEP MODE */
- /* index check */
if ((index < 0) || (index > 4))
return -EINVAL;
- else if (index == 0)
- index = current_index;
- else
- index--;
+
+ index = (index == 0) ? priv->reg.wep_index : (index - 1);
/* Is WEP supported ? */
/* Basic checking: do we have a key to set ? */
- if (dwrq->length > 0) {
- if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */
- return -EINVAL;
- }
- if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */
- key.len = MAX_KEY_SIZE;
- priv->reg.privacy_invoked = 0x01;
- priv->need_commit |= SME_WEP_FLAG;
- wep_on_off = WEP_ON_128BIT;
- } else {
- if (dwrq->length > 0) {
- key.len = MIN_KEY_SIZE;
- priv->reg.privacy_invoked = 0x01;
- priv->need_commit |= SME_WEP_FLAG;
- wep_on_off = WEP_ON_64BIT;
- } else { /* Disable the key */
- key.len = 0;
- }
- }
+ if (enc->length > 0) {
+ key.len = (enc->length > MIN_KEY_SIZE) ?
+ MAX_KEY_SIZE : MIN_KEY_SIZE;
+ priv->reg.privacy_invoked = 0x01;
+ priv->need_commit |= SME_WEP_FLAG;
+ wep_on_off = (enc->length > MIN_KEY_SIZE) ?
+ WEP_ON_128BIT : WEP_ON_64BIT;
/* Check if the key is not marked as invalid */
- if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
- /* Cleanup */
- memset(key.key, 0, MAX_KEY_SIZE);
- /* Copy the key in the driver */
- if (copy_from_user
- (key.key, dwrq->pointer, dwrq->length)) {
- key.len = 0;
- return -EFAULT;
- }
- /* Send the key to the card */
- priv->reg.wep_key[index].size = key.len;
- for (i = 0; i < (priv->reg.wep_key[index].size); i++)
- priv->reg.wep_key[index].val[i] = key.key[i];
+ if (enc->flags & IW_ENCODE_NOKEY)
+ return 0;
- priv->need_commit |= (SME_WEP_VAL1 << index);
- priv->reg.wep_index = index;
- priv->need_commit |= SME_WEP_INDEX;
+ /* Cleanup */
+ memset(key.key, 0, MAX_KEY_SIZE);
+ /* Copy the key in the driver */
+ if (copy_from_user(key.key, enc->pointer, enc->length)) {
+ key.len = 0;
+ return -EFAULT;
}
+ /* Send the key to the card */
+ priv->reg.wep_key[index].size = key.len;
+ memcpy(&priv->reg.wep_key[index].val[0], &key.key[0],
+ priv->reg.wep_key[index].size);
+ priv->need_commit |= (SME_WEP_VAL1 << index);
+ priv->reg.wep_index = index;
+ priv->need_commit |= SME_WEP_INDEX;
} else {
- if (dwrq->flags & IW_ENCODE_DISABLED) {
+ if (enc->flags & IW_ENCODE_DISABLED) {
priv->reg.wep_key[0].size = 0;
priv->reg.wep_key[1].size = 0;
priv->reg.wep_key[2].size = 0;
@@ -891,35 +827,29 @@ static int ks_wlan_set_encode(struct net_device *dev,
wep_on_off = WEP_OFF;
priv->need_commit |= SME_WEP_FLAG;
} else {
- /* Do we want to just set the transmit key index ? */
- if ((index >= 0) && (index < 4)) {
- /* set_wep_key(priv, index, 0, 0, 1); xxx */
- if (priv->reg.wep_key[index].size != 0) {
- priv->reg.wep_index = index;
- priv->need_commit |= SME_WEP_INDEX;
- } else {
- return -EINVAL;
- }
- }
+ /* set_wep_key(priv, index, 0, 0, 1); xxx */
+ if (priv->reg.wep_key[index].size == 0)
+ return -EINVAL;
+ priv->reg.wep_index = index;
+ priv->need_commit |= SME_WEP_INDEX;
}
}
/* Commit the changes if needed */
- if (dwrq->flags & IW_ENCODE_MODE)
+ if (enc->flags & IW_ENCODE_MODE)
priv->need_commit |= SME_WEP_FLAG;
- if (dwrq->flags & IW_ENCODE_OPEN) {
+ if (enc->flags & IW_ENCODE_OPEN) {
if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY)
priv->need_commit |= SME_MODE_SET;
priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM;
- } else if (dwrq->flags & IW_ENCODE_RESTRICTED) {
+ } else if (enc->flags & IW_ENCODE_RESTRICTED) {
if (priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM)
priv->need_commit |= SME_MODE_SET;
priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY;
}
-// return -EINPROGRESS; /* Call commit handler */
if (priv->need_commit) {
ks_wlan_setup_parameter(priv, priv->need_commit);
priv->need_commit = 0;
@@ -929,104 +859,49 @@ static int ks_wlan_set_encode(struct net_device *dev,
static int ks_wlan_get_encode(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- char zeros[16];
- int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
+ struct iw_point *enc = &dwrq->encoding;
+ int index = (enc->flags & IW_ENCODE_INDEX) - 1;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- dwrq->flags = IW_ENCODE_DISABLED;
+ enc->flags = IW_ENCODE_DISABLED;
/* Check encryption mode */
switch (priv->reg.authenticate_type) {
case AUTH_TYPE_OPEN_SYSTEM:
- dwrq->flags = IW_ENCODE_OPEN;
+ enc->flags = IW_ENCODE_OPEN;
break;
case AUTH_TYPE_SHARED_KEY:
- dwrq->flags = IW_ENCODE_RESTRICTED;
+ enc->flags = IW_ENCODE_RESTRICTED;
break;
}
- memset(zeros, 0, sizeof(zeros));
-
/* Which key do we want ? -1 -> tx index */
if ((index < 0) || (index >= 4))
index = priv->reg.wep_index;
if (priv->reg.privacy_invoked) {
- dwrq->flags &= ~IW_ENCODE_DISABLED;
+ enc->flags &= ~IW_ENCODE_DISABLED;
/* dwrq->flags |= IW_ENCODE_NOKEY; */
}
- dwrq->flags |= index + 1;
+ enc->flags |= index + 1;
/* Copy the key to the user buffer */
- if ((index >= 0) && (index < 4))
- dwrq->length = priv->reg.wep_key[index].size;
- if (dwrq->length > 16)
- dwrq->length = 0;
-#if 1 /* IW_ENCODE_NOKEY; */
- if (dwrq->length) {
- if ((index >= 0) && (index < 4))
- memcpy(extra, priv->reg.wep_key[index].val,
- dwrq->length);
- } else {
- memcpy(extra, zeros, dwrq->length);
+ if (index >= 0 && index < 4) {
+ enc->length = (priv->reg.wep_key[index].size <= 16) ?
+ priv->reg.wep_key[index].size : 0;
+ memcpy(extra, priv->reg.wep_key[index].val, enc->length);
}
-#endif
- return 0;
-}
-
-#ifndef KSC_OPNOTSUPP
-static int ks_wlan_set_txpow(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
-{
- return -EOPNOTSUPP; /* Not Support */
-}
-
-static int ks_wlan_get_txpow(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
-{
- if (priv->sleep_mode == SLP_SLEEP)
- return -EPERM;
- /* for SLEEP MODE */
- /* Not Support */
- vwrq->value = 0;
- vwrq->disabled = (vwrq->value == 0);
- vwrq->fixed = 1;
return 0;
}
-static int ks_wlan_set_retry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
-{
- return -EOPNOTSUPP; /* Not Support */
-}
-
-static int ks_wlan_get_retry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
-{
- if (priv->sleep_mode == SLP_SLEEP)
- return -EPERM;
-
- /* for SLEEP MODE */
- /* Not Support */
- vwrq->value = 0;
- vwrq->disabled = (vwrq->value == 0);
- vwrq->fixed = 1;
- return 0;
-}
-#endif /* KSC_OPNOTSUPP */
-
static int ks_wlan_get_range(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_range *range = (struct iw_range *)extra;
@@ -1036,7 +911,7 @@ static int ks_wlan_get_range(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- dwrq->length = sizeof(struct iw_range);
+ dwrq->data.length = sizeof(struct iw_range);
memset(range, 0, sizeof(*range));
range->min_nwid = 0x0000;
range->max_nwid = 0x0000;
@@ -1051,7 +926,8 @@ static int ks_wlan_get_range(struct net_device *dev,
range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */
}
range->num_frequency = k;
- if (priv->reg.phy_type == D_11B_ONLY_MODE || priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */
+ if (priv->reg.phy_type == D_11B_ONLY_MODE ||
+ priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */
range->freq[13].i = 14; /* List index */
range->freq[13].m = frequency_list[13] * 100000;
range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */
@@ -1156,20 +1032,19 @@ static int ks_wlan_get_range(struct net_device *dev,
static int ks_wlan_set_power(struct net_device *dev,
struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- if (vwrq->disabled) {
+ if (vwrq->power.disabled) {
priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
} else {
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
- priv->reg.power_mgmt = POWER_MGMT_SAVE1;
- else
+ if (priv->reg.operation_mode != MODE_INFRASTRUCTURE)
return -EINVAL;
+ priv->reg.power_mgmt = POWER_MGMT_SAVE1;
}
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
@@ -1179,76 +1054,50 @@ static int ks_wlan_set_power(struct net_device *dev,
static int ks_wlan_get_power(struct net_device *dev,
struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (priv->reg.power_mgmt > 0)
- vwrq->disabled = 0;
- else
- vwrq->disabled = 1;
+ vwrq->power.disabled = (priv->reg.power_mgmt <= 0);
return 0;
}
static int ks_wlan_get_iwstats(struct net_device *dev,
struct iw_request_info *info,
- struct iw_quality *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- vwrq->qual = 0; /* not supported */
- vwrq->level = priv->wstats.qual.level;
- vwrq->noise = 0; /* not supported */
- vwrq->updated = 0;
+ vwrq->qual.qual = 0; /* not supported */
+ vwrq->qual.level = priv->wstats.qual.level;
+ vwrq->qual.noise = 0; /* not supported */
+ vwrq->qual.updated = 0;
return 0;
}
-#ifndef KSC_OPNOTSUPP
-
-static int ks_wlan_set_sens(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
-{
- return -EOPNOTSUPP; /* Not Support */
-}
-
-static int ks_wlan_get_sens(struct net_device *dev,
- struct iw_request_info *info, struct iw_param *vwrq,
- char *extra)
-{
- /* Not Support */
- vwrq->value = 0;
- vwrq->disabled = (vwrq->value == 0);
- vwrq->fixed = 1;
- return 0;
-}
-#endif /* KSC_OPNOTSUPP */
-
/* Note : this is deprecated in favor of IWSCAN */
static int ks_wlan_get_aplist(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct sockaddr *address = (struct sockaddr *)extra;
struct iw_quality qual[LOCAL_APLIST_MAX];
-
int i;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
- memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
- ETH_ALEN);
+ ether_addr_copy(address[i].sa_data, priv->aplist.ap[i].bssid);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
qual[i].qual = priv->aplist.ap[i].sq;
@@ -1256,11 +1105,11 @@ static int ks_wlan_get_aplist(struct net_device *dev,
qual[i].updated = 7;
}
if (i) {
- dwrq->flags = 1; /* Should be define'd */
+ dwrq->data.flags = 1; /* Should be define'd */
memcpy(extra + sizeof(struct sockaddr) * i,
&qual, sizeof(struct iw_quality) * i);
}
- dwrq->length = i;
+ dwrq->data.length = i;
return 0;
}
@@ -1294,6 +1143,33 @@ static int ks_wlan_set_scan(struct net_device *dev,
return 0;
}
+static char *ks_wlan_add_leader_event(const char *rsn_leader, char *end_buf,
+ char *current_ev, struct rsn_ie *rsn,
+ struct iw_event *iwe,
+ struct iw_request_info *info)
+{
+ char buffer[RSN_IE_BODY_MAX * 2 + 30];
+ char *pbuf;
+ int i;
+
+ pbuf = &buffer[0];
+ memset(iwe, 0, sizeof(*iwe));
+ iwe->cmd = IWEVCUSTOM;
+ memcpy(buffer, rsn_leader, sizeof(rsn_leader) - 1);
+ iwe->u.data.length += sizeof(rsn_leader) - 1;
+ pbuf += sizeof(rsn_leader) - 1;
+ pbuf += sprintf(pbuf, "%02x", rsn->id);
+ pbuf += sprintf(pbuf, "%02x", rsn->size);
+ iwe->u.data.length += 4;
+
+ for (i = 0; i < rsn->size; i++)
+ pbuf += sprintf(pbuf, "%02x", rsn->body[i]);
+
+ iwe->u.data.length += rsn->size * 2;
+
+ return iwe_stream_add_point(info, current_ev, end_buf, iwe, &buffer[0]);
+}
+
/*
* Translate scan data returned from the card to a card independent
* format that the Wireless Tools will understand - Jean II
@@ -1301,25 +1177,22 @@ static int ks_wlan_set_scan(struct net_device *dev,
static inline char *ks_wlan_translate_scan(struct net_device *dev,
struct iw_request_info *info,
char *current_ev, char *end_buf,
- struct local_ap_t *ap)
+ struct local_ap *ap)
{
/* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */
+ static const char rsn_leader[] = "rsn_ie=";
+ static const char wpa_leader[] = "wpa_ie=";
struct iw_event iwe; /* Temporary buffer */
u16 capabilities;
char *current_val; /* For rates */
int i;
- static const char rsn_leader[] = "rsn_ie=";
- static const char wpa_leader[] = "wpa_ie=";
- char buf0[RSN_IE_BODY_MAX * 2 + 30];
- char buf1[RSN_IE_BODY_MAX * 2 + 30];
- char *pbuf;
+
/* First entry *MUST* be the AP MAC address */
iwe.cmd = SIOCGIWAP;
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN);
- current_ev =
- iwe_stream_add_event(info, current_ev, end_buf, &iwe,
- IW_EV_ADDR_LEN);
+ ether_addr_copy(iwe.u.ap_addr.sa_data, ap->bssid);
+ current_ev = iwe_stream_add_event(info, current_ev,
+ end_buf, &iwe, IW_EV_ADDR_LEN);
/* Other entries will be displayed in the order we give them */
@@ -1329,21 +1202,17 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.length = 32;
iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1;
- current_ev =
- iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- ap->ssid.body);
+ current_ev = iwe_stream_add_point(info, current_ev,
+ end_buf, &iwe, ap->ssid.body);
/* Add mode */
iwe.cmd = SIOCGIWMODE;
capabilities = ap->capability;
if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
- if (capabilities & WLAN_CAPABILITY_ESS)
- iwe.u.mode = IW_MODE_INFRA;
- else
- iwe.u.mode = IW_MODE_ADHOC;
- current_ev =
- iwe_stream_add_event(info, current_ev, end_buf, &iwe,
- IW_EV_UINT_LEN);
+ iwe.u.mode = (capabilities & WLAN_CAPABILITY_ESS) ?
+ IW_MODE_INFRA : IW_MODE_ADHOC;
+ current_ev = iwe_stream_add_event(info, current_ev,
+ end_buf, &iwe, IW_EV_UINT_LEN);
}
/* Add frequency */
@@ -1351,32 +1220,29 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.freq.m = ap->channel;
iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 100000;
iwe.u.freq.e = 1;
- current_ev =
- iwe_stream_add_event(info, current_ev, end_buf, &iwe,
- IW_EV_FREQ_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev,
+ end_buf, &iwe, IW_EV_FREQ_LEN);
/* Add quality statistics */
iwe.cmd = IWEVQUAL;
iwe.u.qual.level = 256 - ap->rssi;
iwe.u.qual.qual = ap->sq;
iwe.u.qual.noise = 0; /* invalid noise value */
- current_ev =
- iwe_stream_add_event(info, current_ev, end_buf, &iwe,
- IW_EV_QUAL_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf,
+ &iwe, IW_EV_QUAL_LEN);
/* Add encryption capability */
iwe.cmd = SIOCGIWENCODE;
- if (capabilities & WLAN_CAPABILITY_PRIVACY)
- iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
+ iwe.u.data.flags = (capabilities & WLAN_CAPABILITY_PRIVACY) ?
+ (IW_ENCODE_ENABLED | IW_ENCODE_NOKEY) :
+ IW_ENCODE_DISABLED;
iwe.u.data.length = 0;
- current_ev =
- iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- ap->ssid.body);
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf,
+ &iwe, ap->ssid.body);
- /* Rate : stuffing multiple values in a single event require a bit
- * more of magic - Jean II
+ /*
+ * Rate : stuffing multiple values in a single event
+ * require a bit more of magic - Jean II
*/
current_val = current_ev + IW_EV_LCP_LEN;
@@ -1394,71 +1260,34 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
/* Bit rate given in 500 kb/s units (+ 0x80) */
iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000);
/* Add new value to event */
- current_val =
- iwe_stream_add_value(info, current_ev, current_val, end_buf,
- &iwe, IW_EV_PARAM_LEN);
+ current_val = iwe_stream_add_value(info, current_ev,
+ current_val, end_buf, &iwe,
+ IW_EV_PARAM_LEN);
}
/* Check if we added any event */
if ((current_val - current_ev) > IW_EV_LCP_LEN)
current_ev = current_val;
-#define GENERIC_INFO_ELEM_ID 0xdd
-#define RSN_INFO_ELEM_ID 0x30
- if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) {
- pbuf = &buf0[0];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVCUSTOM;
- memcpy(buf0, rsn_leader, sizeof(rsn_leader) - 1);
- iwe.u.data.length += sizeof(rsn_leader) - 1;
- pbuf += sizeof(rsn_leader) - 1;
-
- pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id);
- pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size);
- iwe.u.data.length += 4;
-
- for (i = 0; i < ap->rsn_ie.size; i++)
- pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]);
- iwe.u.data.length += (ap->rsn_ie.size) * 2;
-
- netdev_dbg(dev, "ap->rsn.size=%d\n", ap->rsn_ie.size);
-
- current_ev =
- iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &buf0[0]);
- }
- if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) {
- pbuf = &buf1[0];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVCUSTOM;
- memcpy(buf1, wpa_leader, sizeof(wpa_leader) - 1);
- iwe.u.data.length += sizeof(wpa_leader) - 1;
- pbuf += sizeof(wpa_leader) - 1;
-
- pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id);
- pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size);
- iwe.u.data.length += 4;
-
- for (i = 0; i < ap->wpa_ie.size; i++)
- pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]);
- iwe.u.data.length += (ap->wpa_ie.size) * 2;
-
- netdev_dbg(dev, "ap->rsn.size=%d\n", ap->wpa_ie.size);
- netdev_dbg(dev, "iwe.u.data.length=%d\n", iwe.u.data.length);
-
- current_ev =
- iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &buf1[0]);
- }
+ if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0)
+ current_ev = ks_wlan_add_leader_event(rsn_leader, end_buf,
+ current_ev, &ap->rsn_ie,
+ &iwe, info);
+
+ if (ap->wpa_ie.id == WPA_INFO_ELEM_ID && ap->wpa_ie.size != 0)
+ current_ev = ks_wlan_add_leader_event(wpa_leader, end_buf,
+ current_ev, &ap->wpa_ie,
+ &iwe, info);
- /* The other data in the scan result are not really
+ /*
+ * The other data in the scan result are not really
* interesting, so for now drop it - Jean II
*/
return current_ev;
}
static int ks_wlan_get_scan(struct net_device *dev,
- struct iw_request_info *info, struct iw_point *dwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
int i;
@@ -1479,25 +1308,26 @@ static int ks_wlan_get_scan(struct net_device *dev,
/* Read and parse all entries */
for (i = 0; i < priv->aplist.size; i++) {
- if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) {
- dwrq->length = 0;
+ if ((extra + dwrq->data.length) - current_ev <= IW_EV_ADDR_LEN) {
+ dwrq->data.length = 0;
return -E2BIG;
}
/* Translate to WE format this entry */
current_ev = ks_wlan_translate_scan(dev, info, current_ev,
- extra + dwrq->length,
+ extra + dwrq->data.length,
&priv->aplist.ap[i]);
}
/* Length of data */
- dwrq->length = (current_ev - extra);
- dwrq->flags = 0;
+ dwrq->data.length = (current_ev - extra);
+ dwrq->data.flags = 0;
return 0;
}
/* called after a bunch of SET operations */
static int ks_wlan_config_commit(struct net_device *dev,
- struct iw_request_info *info, void *zwrq,
+ struct iw_request_info *info,
+ union iwreq_data *zwrq,
char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1513,7 +1343,7 @@ static int ks_wlan_config_commit(struct net_device *dev,
/* set association ie params */
static int ks_wlan_set_genie(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1526,11 +1356,12 @@ static int ks_wlan_set_genie(struct net_device *dev,
static int ks_wlan_set_auth_mode(struct net_device *dev,
struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- int index = (vwrq->flags & IW_AUTH_INDEX);
- int value = vwrq->value;
+ struct iw_param *param = &vwrq->param;
+ int index = (param->flags & IW_AUTH_INDEX);
+ int value = param->value;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
@@ -1541,14 +1372,14 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
case IW_AUTH_WPA_VERSION_DISABLED:
priv->wpa.version = value;
if (priv->wpa.rsn_enabled)
- priv->wpa.rsn_enabled = 0;
+ priv->wpa.rsn_enabled = false;
priv->need_commit |= SME_RSN;
break;
case IW_AUTH_WPA_VERSION_WPA:
case IW_AUTH_WPA_VERSION_WPA2:
priv->wpa.version = value;
if (!(priv->wpa.rsn_enabled))
- priv->wpa.rsn_enabled = 1;
+ priv->wpa.rsn_enabled = true;
priv->need_commit |= SME_RSN;
break;
default:
@@ -1658,10 +1489,11 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
static int ks_wlan_get_auth_mode(struct net_device *dev,
struct iw_request_info *info,
- struct iw_param *vwrq, char *extra)
+ union iwreq_data *vwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- int index = (vwrq->flags & IW_AUTH_INDEX);
+ struct iw_param *param = &vwrq->param;
+ int index = (param->flags & IW_AUTH_INDEX);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
@@ -1670,22 +1502,22 @@ static int ks_wlan_get_auth_mode(struct net_device *dev,
/* WPA (not used ?? wpa_supplicant) */
switch (index) {
case IW_AUTH_WPA_VERSION:
- vwrq->value = priv->wpa.version;
+ param->value = priv->wpa.version;
break;
case IW_AUTH_CIPHER_PAIRWISE:
- vwrq->value = priv->wpa.pairwise_suite;
+ param->value = priv->wpa.pairwise_suite;
break;
case IW_AUTH_CIPHER_GROUP:
- vwrq->value = priv->wpa.group_suite;
+ param->value = priv->wpa.group_suite;
break;
case IW_AUTH_KEY_MGMT:
- vwrq->value = priv->wpa.key_mgmt_suite;
+ param->value = priv->wpa.key_mgmt_suite;
break;
case IW_AUTH_80211_AUTH_ALG:
- vwrq->value = priv->wpa.auth_alg;
+ param->value = priv->wpa.auth_alg;
break;
case IW_AUTH_WPA_ENABLED:
- vwrq->value = priv->wpa.rsn_enabled;
+ param->value = priv->wpa.rsn_enabled;
break;
case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */
case IW_AUTH_TKIP_COUNTERMEASURES:
@@ -1700,13 +1532,13 @@ static int ks_wlan_get_auth_mode(struct net_device *dev,
/* set encoding token & mode (WPA)*/
static int ks_wlan_set_encode_ext(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_encode_ext *enc;
- int index = dwrq->flags & IW_ENCODE_INDEX;
+ int index = dwrq->encoding.flags & IW_ENCODE_INDEX;
unsigned int commit = 0;
- struct wpa_key_t *key;
+ struct wpa_key *key;
enc = (struct iw_encode_ext *)extra;
if (!enc)
@@ -1721,7 +1553,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
index--;
key = &priv->wpa.key[index];
- if (dwrq->flags & IW_ENCODE_DISABLED)
+ if (dwrq->encoding.flags & IW_ENCODE_DISABLED)
key->key_len = 0;
key->ext_flags = enc->ext_flags;
@@ -1732,7 +1564,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
memcpy(&key->rx_seq[0], &enc->rx_seq[0], IW_ENCODE_SEQ_MAX_SIZE);
}
- memcpy(&key->addr.sa_data[0], &enc->addr.sa_data[0], ETH_ALEN);
+ ether_addr_copy(&key->addr.sa_data[0], &enc->addr.sa_data[0]);
switch (enc->alg) {
case IW_ENCODE_ALG_NONE:
@@ -1793,7 +1625,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
/* get encoding token & mode (WPA)*/
static int ks_wlan_get_encode_ext(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1813,12 +1645,12 @@ static int ks_wlan_get_encode_ext(struct net_device *dev,
static int ks_wlan_set_pmksa(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_pmksa *pmksa;
int i;
- struct pmk_t *pmk;
+ struct pmk *pmk;
struct list_head *ptr;
if (priv->sleep_mode == SLP_SLEEP)
@@ -1832,68 +1664,65 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
switch (pmksa->cmd) {
case IW_PMKSA_ADD:
- if (list_empty(&priv->pmklist.head)) { /* new list */
+ if (list_empty(&priv->pmklist.head)) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
- if (memcmp("\x00\x00\x00\x00\x00\x00",
- pmk->bssid, ETH_ALEN) == 0)
- break; /* loop */
+ if (is_zero_ether_addr(pmk->bssid))
+ break;
}
- memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+ ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++;
- break; /* case */
+ break;
}
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
- pmk = list_entry(ptr, struct pmk_t, list);
- if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
+ pmk = list_entry(ptr, struct pmk, list);
+ if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) {
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
- break; /* list_for_each */
+ break;
}
}
- if (ptr != &priv->pmklist.head) /* not find address. */
- break; /* case */
-
- if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */
+ /* not find address. */
+ if (ptr != &priv->pmklist.head)
+ break;
+ /* new cache data */
+ if (priv->pmklist.size < PMK_LIST_MAX) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
- if (memcmp("\x00\x00\x00\x00\x00\x00",
- pmk->bssid, ETH_ALEN) == 0)
- break; /* loop */
+ if (is_zero_ether_addr(pmk->bssid))
+ break;
}
- memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+ ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++;
- } else { /* overwrite old cache data */
- pmk = list_entry(priv->pmklist.head.prev, struct pmk_t,
+ } else { /* overwrite old cache data */
+ pmk = list_entry(priv->pmklist.head.prev, struct pmk,
list);
- memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+ ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
}
break;
case IW_PMKSA_REMOVE:
- if (list_empty(&priv->pmklist.head)) { /* list empty */
+ if (list_empty(&priv->pmklist.head))
return -EINVAL;
- }
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
- pmk = list_entry(ptr, struct pmk_t, list);
- if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
+ pmk = list_entry(ptr, struct pmk, list);
+ if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) {
eth_zero_addr(pmk->bssid);
memset(pmk->pmkid, 0, IW_PMKID_LEN);
list_del_init(&pmk->list);
break;
}
}
- if (ptr == &priv->pmklist.head) { /* not find address. */
+ /* not find address. */
+ if (ptr == &priv->pmklist.head)
return 0;
- }
-
break;
case IW_PMKSA_FLUSH:
memset(&priv->pmklist, 0, sizeof(priv->pmklist));
@@ -1914,14 +1743,11 @@ static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev)
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_statistics *wstats = &priv->wstats;
- if (!atomic_read(&update_phyinfo)) {
- if (priv->dev_state < DEVICE_STATE_READY)
- return NULL; /* not finished initialize */
- else
- return wstats;
- }
+ if (!atomic_read(&update_phyinfo))
+ return (priv->dev_state < DEVICE_STATE_READY) ? NULL : wstats;
- /* Packets discarded in the wireless adapter due to wireless
+ /*
+ * Packets discarded in the wireless adapter due to wireless
* specific problems
*/
wstats->discard.nwid = 0; /* Rx invalid nwid */
@@ -1953,28 +1779,25 @@ static int ks_wlan_set_stop_request(struct net_device *dev,
#include <linux/ieee80211.h>
static int ks_wlan_set_mlme(struct net_device *dev,
- struct iw_request_info *info, struct iw_point *dwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
- __u32 mode;
+ __u32 mode = 1;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- /* for SLEEP MODE */
- switch (mlme->cmd) {
- case IW_MLME_DEAUTH:
- if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
- return 0;
- /* fall through */
- case IW_MLME_DISASSOC:
- mode = 1;
- return ks_wlan_set_stop_request(dev, NULL, &mode, NULL);
- default:
- return -EOPNOTSUPP; /* Not Support */
- }
+ if (mlme->cmd != IW_MLME_DEAUTH &&
+ mlme->cmd != IW_MLME_DISASSOC)
+ return -EOPNOTSUPP;
+
+ if (mlme->cmd == IW_MLME_DEAUTH &&
+ mlme->reason_code == WLAN_REASON_MIC_FAILURE)
+ return 0;
+
+ return ks_wlan_set_stop_request(dev, NULL, &mode, NULL);
}
static int ks_wlan_get_firmware_version(struct net_device *dev,
@@ -1998,14 +1821,10 @@ static int ks_wlan_set_preamble(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq == LONG_PREAMBLE) { /* 0 */
- priv->reg.preamble = LONG_PREAMBLE;
- } else if (*uwrq == SHORT_PREAMBLE) { /* 1 */
- priv->reg.preamble = SHORT_PREAMBLE;
- } else {
+ if (*uwrq != LONG_PREAMBLE && *uwrq != SHORT_PREAMBLE)
return -EINVAL;
- }
+ priv->reg.preamble = *uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
@@ -2033,23 +1852,16 @@ static int ks_wlan_set_power_mgmt(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- /* for SLEEP MODE */
- if (*uwrq == POWER_MGMT_ACTIVE) { /* 0 */
- priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
- } else if (*uwrq == POWER_MGMT_SAVE1) { /* 1 */
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
- priv->reg.power_mgmt = POWER_MGMT_SAVE1;
- else
- return -EINVAL;
- } else if (*uwrq == POWER_MGMT_SAVE2) { /* 2 */
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
- priv->reg.power_mgmt = POWER_MGMT_SAVE2;
- else
- return -EINVAL;
- } else {
+ if (*uwrq != POWER_MGMT_ACTIVE &&
+ *uwrq != POWER_MGMT_SAVE1 &&
+ *uwrq != POWER_MGMT_SAVE2)
+ return -EINVAL;
+
+ if ((*uwrq == POWER_MGMT_SAVE1 || *uwrq == POWER_MGMT_SAVE2) &&
+ (priv->reg.operation_mode != MODE_INFRASTRUCTURE))
return -EINVAL;
- }
+ priv->reg.power_mgmt = *uwrq;
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
return 0;
@@ -2078,14 +1890,11 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq == ACTIVE_SCAN) { /* 0 */
- priv->reg.scan_type = ACTIVE_SCAN;
- } else if (*uwrq == PASSIVE_SCAN) { /* 1 */
- priv->reg.scan_type = PASSIVE_SCAN;
- } else {
+
+ if (*uwrq != ACTIVE_SCAN && *uwrq != PASSIVE_SCAN)
return -EINVAL;
- }
+ priv->reg.scan_type = *uwrq;
return 0;
}
@@ -2111,17 +1920,17 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX)
- priv->reg.beacon_lost_count = *uwrq;
- else
+ if (*uwrq > BEACON_LOST_COUNT_MAX)
return -EINVAL;
+ priv->reg.beacon_lost_count = *uwrq;
+
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
- } else {
- return 0;
}
+
+ return 0;
}
static int ks_wlan_get_beacon_lost(struct net_device *dev,
@@ -2145,17 +1954,14 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- /* for SLEEP MODE */
- if (*uwrq == D_11B_ONLY_MODE) { /* 0 */
- priv->reg.phy_type = D_11B_ONLY_MODE;
- } else if (*uwrq == D_11G_ONLY_MODE) { /* 1 */
- priv->reg.phy_type = D_11G_ONLY_MODE;
- } else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */
- priv->reg.phy_type = D_11BG_COMPATIBLE_MODE;
- } else {
+
+ if (*uwrq != D_11B_ONLY_MODE &&
+ *uwrq != D_11G_ONLY_MODE &&
+ *uwrq != D_11BG_COMPATIBLE_MODE)
return -EINVAL;
- }
+ /* for SLEEP MODE */
+ priv->reg.phy_type = *uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
@@ -2182,18 +1988,13 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq == CTS_MODE_FALSE) { /* 0 */
- priv->reg.cts_mode = CTS_MODE_FALSE;
- } else if (*uwrq == CTS_MODE_TRUE) { /* 1 */
- if (priv->reg.phy_type == D_11G_ONLY_MODE ||
- priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) {
- priv->reg.cts_mode = CTS_MODE_TRUE;
- } else {
- priv->reg.cts_mode = CTS_MODE_FALSE;
- }
- } else {
+ if (*uwrq != CTS_MODE_FALSE && *uwrq != CTS_MODE_TRUE)
return -EINVAL;
- }
+
+ priv->reg.cts_mode = (*uwrq == CTS_MODE_FALSE) ? *uwrq :
+ (priv->reg.phy_type == D_11G_ONLY_MODE ||
+ priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) ?
+ *uwrq : !*uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
@@ -2218,22 +2019,20 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
{
struct ks_wlan_private *priv = netdev_priv(dev);
- if (*uwrq == SLP_SLEEP) {
- priv->sleep_mode = *uwrq;
- netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
-
- hostif_sme_enqueue(priv, SME_STOP_REQUEST);
- hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
-
- } else if (*uwrq == SLP_ACTIVE) {
- priv->sleep_mode = *uwrq;
- netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
- hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
- } else {
+ if (*uwrq != SLP_SLEEP &&
+ *uwrq != SLP_ACTIVE) {
netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq);
return -EINVAL;
}
+ priv->sleep_mode = *uwrq;
+ netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
+
+ if (*uwrq == SLP_SLEEP)
+ hostif_sme_enqueue(priv, SME_STOP_REQUEST);
+
+ hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
+
return 0;
}
@@ -2248,8 +2047,6 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev,
return 0;
}
-#ifdef WPS
-
static int ks_wlan_set_wps_enable(struct net_device *dev,
struct iw_request_info *info, __u32 *uwrq,
char *extra)
@@ -2259,11 +2056,10 @@ static int ks_wlan_set_wps_enable(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq == 0 || *uwrq == 1)
- priv->wps.wps_enabled = *uwrq;
- else
+ if (*uwrq != 0 && *uwrq != 1)
return -EINVAL;
+ priv->wps.wps_enabled = *uwrq;
hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST);
return 0;
@@ -2314,7 +2110,6 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev,
return 0;
}
-#endif /* WPS */
static int ks_wlan_set_tx_gain(struct net_device *dev,
struct iw_request_info *info, __u32 *uwrq,
@@ -2325,16 +2120,11 @@ static int ks_wlan_set_tx_gain(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */
- priv->gain.tx_gain = (uint8_t)*uwrq;
- else
+ if (*uwrq > 0xFF)
return -EINVAL;
- if (priv->gain.tx_gain < 0xFF)
- priv->gain.tx_mode = 1;
- else
- priv->gain.tx_mode = 0;
-
+ priv->gain.tx_gain = (u8)*uwrq;
+ priv->gain.tx_mode = (priv->gain.tx_gain < 0xFF) ? 1 : 0;
hostif_sme_enqueue(priv, SME_SET_GAIN);
return 0;
}
@@ -2362,16 +2152,11 @@ static int ks_wlan_set_rx_gain(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */
- priv->gain.rx_gain = (uint8_t)*uwrq;
- else
+ if (*uwrq > 0xFF)
return -EINVAL;
- if (priv->gain.rx_gain < 0xFF)
- priv->gain.rx_mode = 1;
- else
- priv->gain.rx_mode = 0;
-
+ priv->gain.rx_gain = (u8)*uwrq;
+ priv->gain.rx_mode = (priv->gain.rx_gain < 0xFF) ? 1 : 0;
hostif_sme_enqueue(priv, SME_SET_GAIN);
return 0;
}
@@ -2535,14 +2320,12 @@ static const struct iw_priv_args ks_wlan_private_args[] = {
/*{ cmd, set_args, get_args, name[16] } */
{KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE,
IW_PRIV_TYPE_CHAR | (128 + 1), "GetFirmwareVer"},
-#ifdef WPS
{KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
IW_PRIV_TYPE_NONE, "SetWPSEnable"},
{KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW"},
{KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE,
"SetWPSProbeReq"},
-#endif /* WPS */
{KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
IW_PRIV_TYPE_NONE, "SetPreamble"},
{KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE,
@@ -2586,105 +2369,62 @@ static const struct iw_priv_args ks_wlan_private_args[] = {
};
static const iw_handler ks_wlan_handler[] = {
- (iw_handler)ks_wlan_config_commit, /* SIOCSIWCOMMIT */
- (iw_handler)ks_wlan_get_name, /* SIOCGIWNAME */
- (iw_handler)NULL, /* SIOCSIWNWID */
- (iw_handler)NULL, /* SIOCGIWNWID */
- (iw_handler)ks_wlan_set_freq, /* SIOCSIWFREQ */
- (iw_handler)ks_wlan_get_freq, /* SIOCGIWFREQ */
- (iw_handler)ks_wlan_set_mode, /* SIOCSIWMODE */
- (iw_handler)ks_wlan_get_mode, /* SIOCGIWMODE */
-#ifndef KSC_OPNOTSUPP
- (iw_handler)ks_wlan_set_sens, /* SIOCSIWSENS */
- (iw_handler)ks_wlan_get_sens, /* SIOCGIWSENS */
-#else /* KSC_OPNOTSUPP */
- (iw_handler)NULL, /* SIOCSIWSENS */
- (iw_handler)NULL, /* SIOCGIWSENS */
-#endif /* KSC_OPNOTSUPP */
- (iw_handler)NULL, /* SIOCSIWRANGE */
- (iw_handler)ks_wlan_get_range, /* SIOCGIWRANGE */
- (iw_handler)NULL, /* SIOCSIWPRIV */
- (iw_handler)NULL, /* SIOCGIWPRIV */
- (iw_handler)NULL, /* SIOCSIWSTATS */
- (iw_handler)ks_wlan_get_iwstats, /* SIOCGIWSTATS */
- (iw_handler)NULL, /* SIOCSIWSPY */
- (iw_handler)NULL, /* SIOCGIWSPY */
- (iw_handler)NULL, /* SIOCSIWTHRSPY */
- (iw_handler)NULL, /* SIOCGIWTHRSPY */
- (iw_handler)ks_wlan_set_wap, /* SIOCSIWAP */
- (iw_handler)ks_wlan_get_wap, /* SIOCGIWAP */
-// (iw_handler)NULL, /* SIOCSIWMLME */
- (iw_handler)ks_wlan_set_mlme, /* SIOCSIWMLME */
- (iw_handler)ks_wlan_get_aplist, /* SIOCGIWAPLIST */
- (iw_handler)ks_wlan_set_scan, /* SIOCSIWSCAN */
- (iw_handler)ks_wlan_get_scan, /* SIOCGIWSCAN */
- (iw_handler)ks_wlan_set_essid, /* SIOCSIWESSID */
- (iw_handler)ks_wlan_get_essid, /* SIOCGIWESSID */
- (iw_handler)ks_wlan_set_nick, /* SIOCSIWNICKN */
- (iw_handler)ks_wlan_get_nick, /* SIOCGIWNICKN */
- (iw_handler)NULL, /* -- hole -- */
- (iw_handler)NULL, /* -- hole -- */
- (iw_handler)ks_wlan_set_rate, /* SIOCSIWRATE */
- (iw_handler)ks_wlan_get_rate, /* SIOCGIWRATE */
- (iw_handler)ks_wlan_set_rts, /* SIOCSIWRTS */
- (iw_handler)ks_wlan_get_rts, /* SIOCGIWRTS */
- (iw_handler)ks_wlan_set_frag, /* SIOCSIWFRAG */
- (iw_handler)ks_wlan_get_frag, /* SIOCGIWFRAG */
-#ifndef KSC_OPNOTSUPP
- (iw_handler)ks_wlan_set_txpow, /* SIOCSIWTXPOW */
- (iw_handler)ks_wlan_get_txpow, /* SIOCGIWTXPOW */
- (iw_handler)ks_wlan_set_retry, /* SIOCSIWRETRY */
- (iw_handler)ks_wlan_get_retry, /* SIOCGIWRETRY */
-#else /* KSC_OPNOTSUPP */
- (iw_handler)NULL, /* SIOCSIWTXPOW */
- (iw_handler)NULL, /* SIOCGIWTXPOW */
- (iw_handler)NULL, /* SIOCSIWRETRY */
- (iw_handler)NULL, /* SIOCGIWRETRY */
-#endif /* KSC_OPNOTSUPP */
- (iw_handler)ks_wlan_set_encode, /* SIOCSIWENCODE */
- (iw_handler)ks_wlan_get_encode, /* SIOCGIWENCODE */
- (iw_handler)ks_wlan_set_power, /* SIOCSIWPOWER */
- (iw_handler)ks_wlan_get_power, /* SIOCGIWPOWER */
- (iw_handler)NULL, /* -- hole -- */
- (iw_handler)NULL, /* -- hole -- */
-// (iw_handler)NULL, /* SIOCSIWGENIE */
- (iw_handler)ks_wlan_set_genie, /* SIOCSIWGENIE */
- (iw_handler)NULL, /* SIOCGIWGENIE */
- (iw_handler)ks_wlan_set_auth_mode, /* SIOCSIWAUTH */
- (iw_handler)ks_wlan_get_auth_mode, /* SIOCGIWAUTH */
- (iw_handler)ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */
- (iw_handler)ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */
- (iw_handler)ks_wlan_set_pmksa, /* SIOCSIWPMKSA */
- (iw_handler)NULL, /* -- hole -- */
+ IW_HANDLER(SIOCSIWCOMMIT, ks_wlan_config_commit),
+ IW_HANDLER(SIOCGIWNAME, ks_wlan_get_name),
+ IW_HANDLER(SIOCSIWFREQ, ks_wlan_set_freq),
+ IW_HANDLER(SIOCGIWFREQ, ks_wlan_get_freq),
+ IW_HANDLER(SIOCSIWMODE, ks_wlan_set_mode),
+ IW_HANDLER(SIOCGIWMODE, ks_wlan_get_mode),
+ IW_HANDLER(SIOCGIWRANGE, ks_wlan_get_range),
+ IW_HANDLER(SIOCGIWSTATS, ks_wlan_get_iwstats),
+ IW_HANDLER(SIOCSIWAP, ks_wlan_set_wap),
+ IW_HANDLER(SIOCGIWAP, ks_wlan_get_wap),
+ IW_HANDLER(SIOCSIWMLME, ks_wlan_set_mlme),
+ IW_HANDLER(SIOCGIWAPLIST, ks_wlan_get_aplist),
+ IW_HANDLER(SIOCSIWSCAN, ks_wlan_set_scan),
+ IW_HANDLER(SIOCGIWSCAN, ks_wlan_get_scan),
+ IW_HANDLER(SIOCSIWESSID, ks_wlan_set_essid),
+ IW_HANDLER(SIOCGIWESSID, ks_wlan_get_essid),
+ IW_HANDLER(SIOCSIWNICKN, ks_wlan_set_nick),
+ IW_HANDLER(SIOCGIWNICKN, ks_wlan_get_nick),
+ IW_HANDLER(SIOCSIWRATE, ks_wlan_set_rate),
+ IW_HANDLER(SIOCGIWRATE, ks_wlan_get_rate),
+ IW_HANDLER(SIOCSIWRTS, ks_wlan_set_rts),
+ IW_HANDLER(SIOCGIWRTS, ks_wlan_get_rts),
+ IW_HANDLER(SIOCSIWFRAG, ks_wlan_set_frag),
+ IW_HANDLER(SIOCGIWFRAG, ks_wlan_get_frag),
+ IW_HANDLER(SIOCSIWENCODE, ks_wlan_set_encode),
+ IW_HANDLER(SIOCGIWENCODE, ks_wlan_get_encode),
+ IW_HANDLER(SIOCSIWPOWER, ks_wlan_set_power),
+ IW_HANDLER(SIOCGIWPOWER, ks_wlan_get_power),
+ IW_HANDLER(SIOCSIWGENIE, ks_wlan_set_genie),
+ IW_HANDLER(SIOCSIWAUTH, ks_wlan_set_auth_mode),
+ IW_HANDLER(SIOCGIWAUTH, ks_wlan_get_auth_mode),
+ IW_HANDLER(SIOCSIWENCODEEXT, ks_wlan_set_encode_ext),
+ IW_HANDLER(SIOCGIWENCODEEXT, ks_wlan_get_encode_ext),
+ IW_HANDLER(SIOCSIWPMKSA, ks_wlan_set_pmksa),
};
/* private_handler */
static const iw_handler ks_wlan_private_handler[] = {
- (iw_handler)NULL, /* 0 */
- (iw_handler)NULL, /* 1, used to be: KS_WLAN_GET_DRIVER_VERSION */
- (iw_handler)NULL, /* 2 */
- (iw_handler)ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */
-#ifdef WPS
- (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */
- (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */
- (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */
-#else
- (iw_handler)NULL, /* 4 */
- (iw_handler)NULL, /* 5 */
- (iw_handler)NULL, /* 6 */
-#endif /* WPS */
-
- (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */
- (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */
- (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */
+ (iw_handler)NULL, /* 0 */
+ (iw_handler)NULL, /* 1, KS_WLAN_GET_DRIVER_VERSION */
+ (iw_handler)NULL, /* 2 */
+ (iw_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERSION */
+ (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */
+ (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */
+ (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */
+ (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */
+ (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */
+ (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */
(iw_handler)ks_wlan_set_power_mgmt, /* 10 KS_WLAN_SET_POWER_SAVE */
(iw_handler)ks_wlan_get_power_mgmt, /* 11 KS_WLAN_GET_POWER_SAVE */
(iw_handler)ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */
(iw_handler)ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */
(iw_handler)ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */
(iw_handler)ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */
- (iw_handler)ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */
- (iw_handler)NULL, /* 17 */
+ (iw_handler)ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */
+ (iw_handler)NULL, /* 17 */
(iw_handler)ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */
(iw_handler)ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */
(iw_handler)ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */
@@ -2693,22 +2433,21 @@ static const iw_handler ks_wlan_private_handler[] = {
(iw_handler)ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */
(iw_handler)ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */
(iw_handler)ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */
- (iw_handler)NULL, /* 26 */
- (iw_handler)NULL, /* 27 */
+ (iw_handler)NULL, /* 26 */
+ (iw_handler)NULL, /* 27 */
(iw_handler)ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */
(iw_handler)ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */
- (iw_handler)NULL, /* 30 */
- (iw_handler)NULL, /* 31 */
+ (iw_handler)NULL, /* 30 */
+ (iw_handler)NULL, /* 31 */
};
static const struct iw_handler_def ks_wlan_handler_def = {
- .num_standard = sizeof(ks_wlan_handler) / sizeof(iw_handler),
- .num_private = sizeof(ks_wlan_private_handler) / sizeof(iw_handler),
- .num_private_args =
- sizeof(ks_wlan_private_args) / sizeof(struct iw_priv_args),
- .standard = (iw_handler *)ks_wlan_handler,
- .private = (iw_handler *)ks_wlan_private_handler,
- .private_args = (struct iw_priv_args *)ks_wlan_private_args,
+ .num_standard = ARRAY_SIZE(ks_wlan_handler),
+ .num_private = ARRAY_SIZE(ks_wlan_private_handler),
+ .num_private_args = ARRAY_SIZE(ks_wlan_private_args),
+ .standard = ks_wlan_handler,
+ .private = ks_wlan_private_handler,
+ .private_args = ks_wlan_private_args,
.get_wireless_stats = ks_get_wireless_stats,
};
@@ -2750,7 +2489,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void *addr)
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
- memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
+ ether_addr_copy(priv->eth_addr, mac_addr->sa_data);
priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
@@ -2818,7 +2557,7 @@ void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb)
* This routine is not state sensitive and need not be SMP locked.
*/
static
-void ks_wlan_set_multicast_list(struct net_device *dev)
+void ks_wlan_set_rx_mode(struct net_device *dev)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -2866,7 +2605,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = {
.ndo_set_mac_address = ks_wlan_set_mac_address,
.ndo_get_stats = ks_wlan_get_stats,
.ndo_tx_timeout = ks_wlan_tx_timeout,
- .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+ .ndo_set_rx_mode = ks_wlan_set_rx_mode,
};
int ks_wlan_net_start(struct net_device *dev)
@@ -2876,24 +2615,15 @@ int ks_wlan_net_start(struct net_device *dev)
priv = netdev_priv(dev);
priv->mac_address_valid = false;
+ priv->is_device_open = true;
priv->need_commit = 0;
-
- priv->device_open_status = 1;
-
/* phy information update timer */
atomic_set(&update_phyinfo, 0);
timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
/* dummy address set */
- memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
- dev->dev_addr[0] = priv->eth_addr[0];
- dev->dev_addr[1] = priv->eth_addr[1];
- dev->dev_addr[2] = priv->eth_addr[2];
- dev->dev_addr[3] = priv->eth_addr[3];
- dev->dev_addr[4] = priv->eth_addr[4];
- dev->dev_addr[5] = priv->eth_addr[5];
- dev->dev_addr[6] = 0x00;
- dev->dev_addr[7] = 0x00;
+ ether_addr_copy(priv->eth_addr, dummy_addr);
+ ether_addr_copy(dev->dev_addr, priv->eth_addr);
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = &ks_wlan_netdev_ops;
@@ -2909,7 +2639,7 @@ int ks_wlan_net_stop(struct net_device *dev)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- priv->device_open_status = 0;
+ priv->is_device_open = false;
del_timer_sync(&update_phyinfo_timer);
if (netif_running(dev))
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 292eae29c552..e6bd70846e98 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -1,30 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Driver for KeyStream wireless LAN
*
* Copyright (C) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/bitops.h>
#include <asm/unaligned.h>
+#include <linux/bitops.h>
+#include <linux/string.h>
#include "michael_mic.h"
// Reset the state to the empty message.
-static inline void michael_clear(struct michael_mic_t *mic)
+static inline void michael_clear(struct michael_mic *mic)
{
mic->l = mic->k0;
mic->r = mic->k1;
mic->m_bytes = 0;
}
-static void michael_init(struct michael_mic_t *mic, u8 *key)
+static void michael_init(struct michael_mic *mic, u8 *key)
{
// Set the key
mic->k0 = get_unaligned_le32(key);
@@ -34,20 +30,20 @@ static void michael_init(struct michael_mic_t *mic, u8 *key)
michael_clear(mic);
}
-static inline void michael_block(struct michael_mic_t *mic)
+static inline void michael_block(struct michael_mic *mic)
{
mic->r ^= rol32(mic->l, 17);
mic->l += mic->r;
mic->r ^= ((mic->l & 0xff00ff00) >> 8) |
((mic->l & 0x00ff00ff) << 8);
mic->l += mic->r;
- mic->r ^= rol32(mic->l, 3); \
+ mic->r ^= rol32(mic->l, 3);
mic->l += mic->r;
- mic->r ^= ror32(mic->l, 2); \
+ mic->r ^= ror32(mic->l, 2);
mic->l += mic->r;
}
-static void michael_append(struct michael_mic_t *mic, u8 *src, int bytes)
+static void michael_append(struct michael_mic *mic, u8 *src, int bytes)
{
int addlen;
@@ -81,7 +77,7 @@ static void michael_append(struct michael_mic_t *mic, u8 *src, int bytes)
}
}
-static void michael_get_mic(struct michael_mic_t *mic, u8 *dst)
+static void michael_get_mic(struct michael_mic *mic, u8 *dst)
{
u8 *data = mic->m;
@@ -110,8 +106,8 @@ static void michael_get_mic(struct michael_mic_t *mic, u8 *dst)
michael_clear(mic);
}
-void michael_mic_function(struct michael_mic_t *mic, u8 *key,
- u8 *data, int len, u8 priority, u8 *result)
+void michael_mic_function(struct michael_mic *mic, u8 *key,
+ u8 *data, unsigned int len, u8 priority, u8 *result)
{
u8 pad_data[4] = { priority, 0, 0, 0 };
// Compute the MIC value
diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h
index 894a8d4121a4..f0ac164b999b 100644
--- a/drivers/staging/ks7010/michael_mic.h
+++ b/drivers/staging/ks7010/michael_mic.h
@@ -1,16 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for KeyStream wireless LAN
*
* Copyright (C) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
/* MichaelMIC routine define */
-struct michael_mic_t {
+struct michael_mic {
u32 k0; // Key
u32 k1; // Key
u32 l; // Current state
@@ -20,5 +17,5 @@ struct michael_mic_t {
u8 result[8];
};
-void michael_mic_function(struct michael_mic_t *mic, u8 *key,
- u8 *data, int len, u8 priority, u8 *result);
+void michael_mic_function(struct michael_mic *mic, u8 *key,
+ u8 *data, unsigned int len, u8 priority, u8 *result);
diff --git a/drivers/staging/lustre/README.txt b/drivers/staging/lustre/README.txt
index 0676243eea9e..783959240490 100644
--- a/drivers/staging/lustre/README.txt
+++ b/drivers/staging/lustre/README.txt
@@ -4,7 +4,7 @@ Lustre Parallel Filesystem Client
The Lustre file system is an open-source, parallel file system
that supports many requirements of leadership class HPC simulation
environments.
-Born from from a research project at Carnegie Mellon University,
+Born from a research project at Carnegie Mellon University,
the Lustre file system is a widely-used option in HPC.
The Lustre file system provides a POSIX compliant file system interface,
can scale to thousands of clients, petabytes of storage and
diff --git a/drivers/staging/lustre/TODO b/drivers/staging/lustre/TODO
index 94446487748a..5332cdb19bfa 100644
--- a/drivers/staging/lustre/TODO
+++ b/drivers/staging/lustre/TODO
@@ -12,7 +12,7 @@ addressed:
* https://jira.hpdd.intel.com/browse/LU-9859
*
* Track all the cleanups and simplification of the libcfs module. Remove
-* functions the kernel provides. Possible intergrate some of the functionality
+* functions the kernel provides. Possibly integrate some of the functionality
* into the kernel proper.
*
******************************************************************************
diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
deleted file mode 100644
index 4702956805a6..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/curproc.h
- *
- * Lustre curproc API declaration
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_CURPROC_H__
-#define __LIBCFS_CURPROC_H__
-
-/*
- * Plus, platform-specific constant
- *
- * CFS_CURPROC_COMM_MAX,
- *
- * and opaque scalar type
- *
- * kernel_cap_t
- */
-
-/* check if task is running in compat mode.*/
-#define current_pid() (current->pid)
-#define current_comm() (current->comm)
-
-typedef u32 cfs_cap_t;
-
-#define CFS_CAP_FS_MASK (BIT(CAP_CHOWN) | \
- BIT(CAP_DAC_OVERRIDE) | \
- BIT(CAP_DAC_READ_SEARCH) | \
- BIT(CAP_FOWNER) | \
- BIT(CAP_FSETID) | \
- BIT(CAP_LINUX_IMMUTABLE) | \
- BIT(CAP_SYS_ADMIN) | \
- BIT(CAP_SYS_BOOT) | \
- BIT(CAP_SYS_RESOURCE))
-
-static inline cfs_cap_t cfs_curproc_cap_pack(void)
-{
- /* cfs_cap_t is only the first word of kernel_cap_t */
- return (cfs_cap_t)(current_cap().cap[0]);
-}
-
-/* __LIBCFS_CURPROC_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..edc7ed0dcb94 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -34,102 +34,43 @@
#ifndef __LIBCFS_LIBCFS_H__
#define __LIBCFS_LIBCFS_H__
-#include <linux/gfp.h>
-#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/workqueue.h>
+#include <linux/sysctl.h>
-#include <uapi/linux/lnet/libcfs_ioctl.h>
-#include <linux/libcfs/linux/libcfs.h>
#include <linux/libcfs/libcfs_debug.h>
#include <linux/libcfs/libcfs_private.h>
-#include <linux/libcfs/libcfs_cpu.h>
-#include <linux/libcfs/libcfs_prim.h>
-#include <linux/libcfs/libcfs_time.h>
-#include <linux/libcfs/libcfs_string.h>
-#include <linux/libcfs/libcfs_hash.h>
#include <linux/libcfs/libcfs_fail.h>
-#include <linux/libcfs/curproc.h>
#define LIBCFS_VERSION "0.7.0"
-#define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
-
-/*
- * Lustre Error Checksum: calculates checksum
- * of Hex number by XORing each bit.
- */
-#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
- ((hexnum) >> 8 & 0xf))
-
-/* need both kernel and user-land acceptor */
-#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
-#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
-
-/* Block all signals except for the @sigs */
-static inline void cfs_block_sigsinv(unsigned long sigs, sigset_t *old)
-{
- sigset_t new;
-
- siginitsetinv(&new, sigs);
- sigorsets(&new, &current->blocked, &new);
- sigprocmask(SIG_BLOCK, &new, old);
-}
-
-static inline void
-cfs_restore_sigs(sigset_t *old)
-{
- sigprocmask(SIG_SETMASK, old, NULL);
-}
-
-struct libcfs_ioctl_handler {
- struct list_head item;
- int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
-};
-
-#define DECLARE_IOCTL_HANDLER(ident, func) \
- struct libcfs_ioctl_handler ident = { \
- .item = LIST_HEAD_INIT(ident.item), \
- .handle_ioctl = func \
- }
-
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
-
-int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
- const struct libcfs_ioctl_hdr __user *uparam);
-int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
-int libcfs_ioctl(unsigned long cmd, void __user *arg);
-
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
+extern struct blocking_notifier_head libcfs_ioctl_list;
+static inline int notifier_from_ioctl_errno(int err)
{
- if (IS_ERR_OR_NULL(ptr))
- return ptr;
- return (char *)ptr - shift;
+ if (err == -EINVAL)
+ return NOTIFY_OK;
+ return notifier_from_errno(err) | NOTIFY_STOP_MASK;
}
-#define container_of0(ptr, type, member) \
- ((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
-#define _LIBCFS_H
-
-extern struct miscdevice libcfs_dev;
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
+int libcfs_setup(void);
extern struct workqueue_struct *cfs_rehash_wq;
-struct lnet_debugfs_symlink_def {
- char *name;
- char *target;
-};
-
-void lustre_insert_debugfs(struct ctl_table *table,
- const struct lnet_debugfs_symlink_def *symlinks);
+void lustre_insert_debugfs(struct ctl_table *table);
int lprocfs_call_handler(void *data, int write, loff_t *ppos,
void __user *buffer, size_t *lenp,
int (*handler)(void *data, int write, loff_t pos,
void __user *buffer, int len));
-#endif /* _LIBCFS_H */
+/*
+ * Memory
+ */
+#if BITS_PER_LONG == 32
+/* limit to lowmem on 32-bit systems */
+#define NUM_CACHEPAGES \
+ min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
+#else
+#define NUM_CACHEPAGES totalram_pages
+#endif
+
+#endif /* __LIBCFS_LIBCFS_H__ */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 61bce77fddd6..61641c41c492 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -59,9 +59,9 @@
* . NUMA allocators, CPU affinity threads are built over CPU partitions,
* instead of HW CPUs or HW nodes.
*
- * . By default, Lustre modules should refer to the global cfs_cpt_table,
+ * . By default, Lustre modules should refer to the global cfs_cpt_tab,
* instead of accessing HW CPUs directly, so concurrency of Lustre can be
- * configured by cpu_npartitions of the global cfs_cpt_table
+ * configured by cpu_npartitions of the global cfs_cpt_tab
*
* . If cpu_npartitions=1(all CPUs in one pool), lustre should work the
* same way as 2.2 or earlier versions
@@ -72,53 +72,53 @@
#ifndef __LIBCFS_CPU_H__
#define __LIBCFS_CPU_H__
+#include <linux/cpu.h>
+#include <linux/cpuset.h>
+#include <linux/topology.h>
+
/* any CPU partition */
#define CFS_CPT_ANY (-1)
#ifdef CONFIG_SMP
-/**
- * return cpumask of CPU partition \a cpt
- */
-cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt);
-/**
- * print string information of cpt-table
- */
-int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
-#else /* !CONFIG_SMP */
-struct cfs_cpt_table {
- /* # of CPU partitions */
- int ctb_nparts;
- /* cpu mask */
- cpumask_t ctb_mask;
- /* node mask */
- nodemask_t ctb_nodemask;
- /* version */
- u64 ctb_version;
+/** virtual processing unit */
+struct cfs_cpu_partition {
+ /* CPUs mask for this partition */
+ cpumask_var_t cpt_cpumask;
+ /* nodes mask for this partition */
+ nodemask_t *cpt_nodemask;
+ /* spread rotor for NUMA allocator */
+ unsigned int cpt_spread_rotor;
};
-static inline cpumask_var_t *
-cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
-{
- return NULL;
-}
-static inline int
-cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
-{
- return 0;
-}
-#endif /* CONFIG_SMP */
+/** descriptor for CPU partitions */
+struct cfs_cpt_table {
+ /* version, reserved for hotplug */
+ unsigned int ctb_version;
+ /* spread rotor for NUMA allocator */
+ unsigned int ctb_spread_rotor;
+ /* # of CPU partitions */
+ unsigned int ctb_nparts;
+ /* partitions tables */
+ struct cfs_cpu_partition *ctb_parts;
+ /* shadow HW CPU to CPU partition ID */
+ int *ctb_cpu2cpt;
+ /* all cpus in this partition table */
+ cpumask_var_t ctb_cpumask;
+ /* all nodes in this partition table */
+ nodemask_t *ctb_nodemask;
+};
-extern struct cfs_cpt_table *cfs_cpt_table;
+extern struct cfs_cpt_table *cfs_cpt_tab;
/**
- * destroy a CPU partition table
+ * return cpumask of CPU partition \a cpt
*/
-void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
+cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt);
/**
- * create a cfs_cpt_table with \a ncpt number of partitions
+ * print string information of cpt-table
*/
-struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
+int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
/**
* return total number of CPU partitions in \a cptab
*/
@@ -204,6 +204,148 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);
*/
int cfs_cpu_ht_nsiblings(int cpu);
+int cfs_cpu_init(void);
+void cfs_cpu_fini(void);
+
+#else /* !CONFIG_SMP */
+struct cfs_cpt_table;
+#define cfs_cpt_tab ((struct cfs_cpt_table *)NULL)
+
+static inline cpumask_var_t *
+cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+{
+ return NULL;
+}
+
+static inline int
+cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
+{
+ return 0;
+}
+static inline int
+cfs_cpt_number(struct cfs_cpt_table *cptab)
+{
+ return 1;
+}
+
+static inline int
+cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
+{
+ return 1;
+}
+
+static inline int
+cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
+{
+ return 1;
+}
+
+static inline nodemask_t *
+cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
+{
+ return NULL;
+}
+
+static inline int
+cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+ return 1;
+}
+
+static inline void
+cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+}
+
+static inline int
+cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+{
+ return 1;
+}
+
+static inline void
+cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+{
+}
+
+static inline int
+cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+ return 1;
+}
+
+static inline void
+cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+}
+
+static inline int
+cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
+{
+ return 1;
+}
+
+static inline void
+cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
+{
+}
+
+static inline void
+cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
+{
+}
+
+static inline int
+cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
+{
+ return 0;
+}
+
+static inline int
+cfs_cpu_ht_nsiblings(int cpu)
+{
+ return 1;
+}
+
+static inline int
+cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
+{
+ return 0;
+}
+
+static inline int
+cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
+{
+ return 0;
+}
+
+static inline int
+cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
+{
+ return 0;
+}
+
+static inline int
+cfs_cpu_init(void)
+{
+ return 0;
+}
+
+static inline void cfs_cpu_fini(void)
+{
+}
+
+#endif /* CONFIG_SMP */
+
+/**
+ * destroy a CPU partition table
+ */
+void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
+/**
+ * create a cfs_cpt_table with \a ncpt number of partitions
+ */
+struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
+
/*
* allocate per-cpu-partition data, returned value is an array of pointers,
* variable can be indexed by CPU ID.
@@ -289,7 +431,4 @@ void cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int index);
#define cfs_cpt_for_each(i, cptab) \
for (i = 0; i < cfs_cpt_number(cptab); i++)
-int cfs_cpu_init(void);
-void cfs_cpu_fini(void);
-
#endif /* __LIBCFS_CPU_H__ */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index 3a72117140ed..176fae7319e3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -29,6 +29,9 @@
#ifndef _LIBCFS_CRYPTO_H
#define _LIBCFS_CRYPTO_H
+#include <linux/string.h>
+struct page;
+
struct cfs_crypto_hash_type {
char *cht_name; /*< hash algorithm name, equal to
* format name for crypto api
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 9290a19429e7..17534a76362a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -39,6 +39,7 @@
#ifndef __LIBCFS_DEBUG_H__
#define __LIBCFS_DEBUG_H__
+#include <linux/limits.h>
#include <uapi/linux/lnet/libcfs_debug.h>
/*
@@ -62,6 +63,38 @@ int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
extern unsigned int libcfs_catastrophe;
extern unsigned int libcfs_panic_on_lbug;
+/* Enable debug-checks on stack size - except on x86_64 */
+#if !defined(__x86_64__)
+# ifdef __ia64__
+# define CDEBUG_STACK() (THREAD_SIZE - \
+ ((unsigned long)__builtin_dwarf_cfa() & \
+ (THREAD_SIZE - 1)))
+# else
+# define CDEBUG_STACK() (THREAD_SIZE - \
+ ((unsigned long)__builtin_frame_address(0) & \
+ (THREAD_SIZE - 1)))
+# endif /* __ia64__ */
+
+#define __CHECK_STACK(msgdata, mask, cdls) \
+do { \
+ if (unlikely(CDEBUG_STACK() > libcfs_stack)) { \
+ LIBCFS_DEBUG_MSG_DATA_INIT(msgdata, D_WARNING, NULL); \
+ libcfs_stack = CDEBUG_STACK(); \
+ libcfs_debug_msg(msgdata, \
+ "maximum lustre stack %lu\n", \
+ CDEBUG_STACK()); \
+ (msgdata)->msg_mask = mask; \
+ (msgdata)->msg_cdls = cdls; \
+ dump_stack(); \
+ /*panic("LBUG");*/ \
+ } \
+} while (0)
+#define CFS_CHECK_STACK(msgdata, mask, cdls) __CHECK_STACK(msgdata, mask, cdls)
+#else /* __x86_64__ */
+#define CFS_CHECK_STACK(msgdata, mask, cdls) do {} while (0)
+#define CDEBUG_STACK() (0L)
+#endif /* __x86_64__ */
+
#ifndef DEBUG_SUBSYSTEM
# define DEBUG_SUBSYSTEM S_UNDEFINED
#endif
@@ -133,6 +166,13 @@ do { \
__CDEBUG(&cdls, mask, format, ## __VA_ARGS__); \
} while (0)
+/*
+ * Lustre Error Checksum: calculates checksum
+ * of Hex number by XORing the nybbles.
+ */
+#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
+ ((hexnum) >> 8 & 0xf))
+
#define CWARN(format, ...) CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__)
#define CERROR(format, ...) CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__)
#define CNETERR(format, a...) CDEBUG_LIMIT(D_NETERROR, format, ## a)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index d6fc3164e7e7..8074e390b4d1 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -33,6 +33,9 @@
#ifndef _LIBCFS_FAIL_H
#define _LIBCFS_FAIL_H
+#include <linux/sched.h>
+#include <linux/wait.h>
+
extern unsigned long cfs_fail_loc;
extern unsigned int cfs_fail_val;
extern int cfs_fail_err;
@@ -140,7 +143,7 @@ static inline int cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)
/* If id hit cfs_fail_loc, sleep for seconds or milliseconds */
#define CFS_FAIL_TIMEOUT(id, secs) \
- cfs_fail_timeout_set(id, 0, secs * 1000, CFS_FAIL_LOC_NOSET)
+ cfs_fail_timeout_set(id, 0, (secs) * 1000, CFS_FAIL_LOC_NOSET)
#define CFS_FAIL_TIMEOUT_MS(id, ms) \
cfs_fail_timeout_set(id, 0, ms, CFS_FAIL_LOC_NOSET)
@@ -150,10 +153,10 @@ static inline int cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)
* sleep seconds or milliseconds
*/
#define CFS_FAIL_TIMEOUT_ORSET(id, value, secs) \
- cfs_fail_timeout_set(id, value, secs * 1000, CFS_FAIL_LOC_ORSET)
+ cfs_fail_timeout_set(id, value, (secs) * 1000, CFS_FAIL_LOC_ORSET)
#define CFS_FAIL_TIMEOUT_RESET(id, value, secs) \
- cfs_fail_timeout_set(id, value, secs * 1000, CFS_FAIL_LOC_RESET)
+ cfs_fail_timeout_set(id, value, (secs) * 1000, CFS_FAIL_LOC_RESET)
#define CFS_FAIL_TIMEOUT_MS_ORSET(id, value, ms) \
cfs_fail_timeout_set(id, value, ms, CFS_FAIL_LOC_ORSET)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index 0506f1d45757..be315958a4b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -40,6 +40,9 @@
#define __LIBCFS_HASH_H__
#include <linux/hash.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/libcfs/libcfs.h>
/*
* Knuth recommends primes in approximately golden ratio to the maximum
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
deleted file mode 100644
index d4c5965c43b1..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_prim.h
- *
- * General primitives.
- *
- */
-
-#ifndef __LIBCFS_PRIM_H__
-#define __LIBCFS_PRIM_H__
-
-/*
- * Memory
- */
-#if BITS_PER_LONG == 32
-/* limit to lowmem on 32-bit systems */
-#define NUM_CACHEPAGES \
- min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
-#else
-#define NUM_CACHEPAGES totalram_pages
-#endif
-
-static inline unsigned int memory_pressure_get(void)
-{
- return current->flags & PF_MEMALLOC;
-}
-
-static inline void memory_pressure_set(void)
-{
- current->flags |= PF_MEMALLOC;
-}
-
-static inline void memory_pressure_clr(void)
-{
- current->flags &= ~PF_MEMALLOC;
-}
-
-static inline int cfs_memory_pressure_get_and_set(void)
-{
- int old = memory_pressure_get();
-
- if (!old)
- memory_pressure_set();
- return old;
-}
-
-static inline void cfs_memory_pressure_restore(int old)
-{
- if (old)
- memory_pressure_set();
- else
- memory_pressure_clr();
-}
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 66463477074a..cd7c3ccb2dc0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -40,6 +40,8 @@
#ifndef __LIBCFS_STRING_H__
#define __LIBCFS_STRING_H__
+#include <linux/mm.h>
+
/* libcfs_string.c */
/* Convert a text string to a bitmask */
int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index c4f25be78268..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline unsigned long cfs_time_add(unsigned long t, long d)
-{
- return (unsigned long)(t + d);
-}
-
-static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
-{
- return (unsigned long)(t1 - t2);
-}
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
- return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
- return time_before_eq(t2, t1);
-}
-
-static inline unsigned long cfs_time_shift(int seconds)
-{
- return cfs_time_add(cfs_time_current(), seconds * HZ);
-}
-
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
- if (timeout < CFS_TICK)
- timeout = CFS_TICK;
- return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
deleted file mode 100644
index 30e333af8d0d..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_LINUX_LIBCFS_H__
-#define __LIBCFS_LINUX_LIBCFS_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#include <linux/bitops.h>
-#include <linux/compiler.h>
-#include <linux/ctype.h>
-#include <linux/errno.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/highmem.h>
-#include <linux/interrupt.h>
-#include <linux/kallsyms.h>
-#include <linux/kernel.h>
-#include <linux/kmod.h>
-#include <linux/kthread.h>
-#include <linux/miscdevice.h>
-#include <linux/mm.h>
-#include <linux/mm_inline.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/mutex.h>
-#include <linux/notifier.h>
-#include <linux/pagemap.h>
-#include <linux/random.h>
-#include <linux/rbtree.h>
-#include <linux/rwsem.h>
-#include <linux/scatterlist.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/slab.h>
-#include <linux/smp.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/time.h>
-#include <linux/timer.h>
-#include <linux/types.h>
-#include <linux/unistd.h>
-#include <linux/vmalloc.h>
-#include <net/sock.h>
-#include <linux/atomic.h>
-#include <asm/div64.h>
-#include <linux/timex.h>
-#include <linux/uaccess.h>
-#include <stdarg.h>
-#include "linux-cpu.h"
-#include "linux-time.h"
-
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
-#if !defined(__x86_64__)
-# ifdef __ia64__
-# define CDEBUG_STACK() (THREAD_SIZE - \
- ((unsigned long)__builtin_dwarf_cfa() & \
- (THREAD_SIZE - 1)))
-# else
-# define CDEBUG_STACK() (THREAD_SIZE - \
- ((unsigned long)__builtin_frame_address(0) & \
- (THREAD_SIZE - 1)))
-# endif /* __ia64__ */
-
-#define __CHECK_STACK(msgdata, mask, cdls) \
-do { \
- if (unlikely(CDEBUG_STACK() > libcfs_stack)) { \
- LIBCFS_DEBUG_MSG_DATA_INIT(msgdata, D_WARNING, NULL); \
- libcfs_stack = CDEBUG_STACK(); \
- libcfs_debug_msg(msgdata, \
- "maximum lustre stack %lu\n", \
- CDEBUG_STACK()); \
- (msgdata)->msg_mask = mask; \
- (msgdata)->msg_cdls = cdls; \
- dump_stack(); \
- /*panic("LBUG");*/ \
- } \
-} while (0)
-#define CFS_CHECK_STACK(msgdata, mask, cdls) __CHECK_STACK(msgdata, mask, cdls)
-#else /* __x86_64__ */
-#define CFS_CHECK_STACK(msgdata, mask, cdls) do {} while (0)
-#define CDEBUG_STACK() (0L)
-#endif /* __x86_64__ */
-
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include <linux/capability.h>
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
-#endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
deleted file mode 100644
index 6035376f2830..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-cpu.h
- *
- * Basic library routines.
- *
- * Author: liang@whamcloud.com
- */
-
-#ifndef __LIBCFS_LINUX_CPU_H__
-#define __LIBCFS_LINUX_CPU_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#include <linux/cpu.h>
-#include <linux/cpuset.h>
-#include <linux/topology.h>
-
-#ifdef CONFIG_SMP
-
-#define HAVE_LIBCFS_CPT
-
-/** virtual processing unit */
-struct cfs_cpu_partition {
- /* CPUs mask for this partition */
- cpumask_var_t cpt_cpumask;
- /* nodes mask for this partition */
- nodemask_t *cpt_nodemask;
- /* spread rotor for NUMA allocator */
- unsigned int cpt_spread_rotor;
-};
-
-/** descriptor for CPU partitions */
-struct cfs_cpt_table {
- /* version, reserved for hotplug */
- unsigned int ctb_version;
- /* spread rotor for NUMA allocator */
- unsigned int ctb_spread_rotor;
- /* # of CPU partitions */
- unsigned int ctb_nparts;
- /* partitions tables */
- struct cfs_cpu_partition *ctb_parts;
- /* shadow HW CPU to CPU partition ID */
- int *ctb_cpu2cpt;
- /* all cpus in this partition table */
- cpumask_var_t ctb_cpumask;
- /* all nodes in this partition table */
- nodemask_t *ctb_nodemask;
-};
-
-#endif /* CONFIG_SMP */
-#endif /* __LIBCFS_LINUX_CPU_H__ */
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index 805cb326af86..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION 1000000
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <asm/div64.h>
-
-/*
- * post 2.5 kernels.
- */
-
-#include <linux/jiffies.h>
-
-/*
- * Generic kernel stuff
- */
-
-static inline unsigned long cfs_time_current(void)
-{
- return jiffies;
-}
-
-static inline long cfs_duration_sec(long d)
-{
- return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
-#define cfs_time_current_64 get_jiffies_64
-
-static inline u64 cfs_time_add_64(u64 t, u64 d)
-{
- return t + d;
-}
-
-static inline u64 cfs_time_shift_64(int seconds)
-{
- return cfs_time_add_64(cfs_time_current_64(),
- seconds * HZ);
-}
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
- return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
- return (__s64)t2 - (__s64)t1 >= 0;
-}
-
-/*
- * One jiffy
- */
-#define CFS_TICK (1)
-
-#define CFS_DURATION_T "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index df4c72507a15..973c17a1c4a1 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -37,6 +37,10 @@
#define __LNET_LIB_LNET_H__
#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/libcfs/libcfs_string.h>
+#include <net/sock.h>
+
#include <linux/lnet/api.h>
#include <linux/lnet/lib-types.h>
#include <uapi/linux/lnet/lnet-dlc.h>
@@ -68,6 +72,10 @@ extern struct lnet the_lnet; /* THE network */
/** exclusive lock */
#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
+/* need both kernel and user-land acceptor */
+#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
+#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
+
static inline int lnet_is_route_alive(struct lnet_route *route)
{
/* gateway is down */
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index e45d828bfd1b..c1619f411d81 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -53,7 +53,8 @@ struct lnet_ioctl_config_o2iblnd_tunables {
__u32 lnd_fmr_pool_size;
__u32 lnd_fmr_flush_trigger;
__u32 lnd_fmr_cache;
- __u32 pad;
+ __u16 lnd_conns_per_peer;
+ __u16 pad;
};
struct lnet_ioctl_config_lnd_tunables {
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnetctl.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnetctl.h
index d9da625d70de..cccb32dd28f2 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnetctl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnetctl.h
@@ -119,16 +119,5 @@ struct lnet_fault_stat {
#define LNET_DEV_ID 0
#define LNET_DEV_PATH "/dev/lnet"
-#define LNET_DEV_MAJOR 10
-#define LNET_DEV_MINOR 240
-#define OBD_DEV_ID 1
-#define OBD_DEV_NAME "obd"
-#define OBD_DEV_PATH "/dev/" OBD_DEV_NAME
-#define OBD_DEV_MAJOR 10
-#define OBD_DEV_MINOR 241
-#define SMFS_DEV_ID 2
-#define SMFS_DEV_PATH "/dev/snapdev"
-#define SMFS_DEV_MAJOR 10
-#define SMFS_DEV_MINOR 242
#endif
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
index f5214dc33c60..d375a476f5ea 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
@@ -51,7 +51,7 @@ static inline size_t fiemap_count_to_size(size_t extent_count)
sizeof(struct fiemap_extent);
}
-static inline unsigned fiemap_size_to_count(size_t array_size)
+static inline unsigned int fiemap_size_to_count(size_t array_size)
{
return (array_size - sizeof(struct fiemap)) /
sizeof(struct fiemap_extent);
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
index aac98dbcf6e3..8a7301a76122 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
@@ -1526,9 +1526,11 @@ struct mdt_rec_setattr {
#define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */
#define MDS_OPEN_NORESTORE 0100000000000ULL /* Do not restore file at open */
#define MDS_OPEN_NEWSTRIPE 0200000000000ULL /* New stripe needed (restripe or
- * hsm restore) */
+ * hsm restore)
+ */
#define MDS_OPEN_VOLATILE 0400000000000ULL /* File is volatile = created
- unlinked */
+ * unlinked
+ */
#define MDS_OPEN_LEASE 01000000000000ULL /* Open the file and grant lease
* delegation, succeed if it's not
* being opened with conflict mode.
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_ioctl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_ioctl.h
index 9590864e0b50..6e4e109fb874 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_ioctl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_ioctl.h
@@ -51,8 +51,6 @@ enum md_echo_cmd {
#define OBD_DEV_ID 1
#define OBD_DEV_NAME "obd"
#define OBD_DEV_PATH "/dev/" OBD_DEV_NAME
-#define OBD_DEV_MAJOR 10
-#define OBD_DEV_MINOR 241
#define OBD_IOCTL_VERSION 0x00010004
#define OBD_DEV_BY_DEVNAME 0xffffd0de
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
index 5e332e3af68a..69387f36d1f1 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
@@ -405,7 +405,8 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
/* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
* use this. It is unsafe to #define those values in this header as it
- * is possible the application has already #included <sys/stat.h>. */
+ * is possible the application has already #included <sys/stat.h>.
+ */
#ifdef HAVE_LOV_USER_MDS_DATA
#define lov_user_mds_data lov_user_mds_data_v1
struct lov_user_mds_data_v1 {
@@ -468,7 +469,8 @@ struct ll_fid {
__u64 id; /* holds object id */
__u32 generation; /* holds object generation */
__u32 f_type; /* holds object type or stripe idx when passing it to
- * OST for saving into EA. */
+ * OST for saving into EA.
+ */
};
#define UUID_MAX 40
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7ae2955c4db6..f0b4eb42bc1d 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
unsigned long *when)
{
unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
rwlock_t *glock = &kiblnd_data.kib_global_lock;
struct kib_peer *peer;
unsigned long flags;
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
libcfs_nid2str(nid), peer,
- last_alive ? cfs_duration_sec(now - last_alive) : -1);
+ last_alive ? (now - last_alive) / HZ : -1);
}
static void kiblnd_free_pages(struct kib_pages *p)
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
if (rc)
goto out_fpo;
- fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+ fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_owner = fps;
*pp_fpo = fpo;
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now)
return 0;
if (fpo->fpo_failed)
return 1;
- return cfs_time_aftereq(now, fpo->fpo_deadline);
+ return time_after_eq(now, fpo->fpo_deadline);
}
static int
@@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
LIST_HEAD(zombies);
struct kib_fmr_pool *fpo = fmr->fmr_pool;
struct kib_fmr_poolset *fps;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
struct kib_fmr_pool *tmp;
int rc;
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
spin_lock(&fps->fps_lock);
version = fps->fps_version;
list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
- fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+ fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_map_count++;
if (fpo->fpo_is_fmr) {
@@ -1702,7 +1702,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
return 0;
}
spin_unlock(&fps->fps_lock);
- rc = -EBUSY;
+ rc = -EAGAIN;
}
spin_lock(&fps->fps_lock);
@@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
goto again;
}
- if (time_before(cfs_time_current(), fps->fps_next_retry)) {
+ if (time_before(jiffies, fps->fps_next_retry)) {
/* someone failed recently */
spin_unlock(&fps->fps_lock);
return -EAGAIN;
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
fps->fps_version++;
list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
} else {
- fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+ fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
}
spin_unlock(&fps->fps_lock);
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
memset(pool, 0, sizeof(*pool));
INIT_LIST_HEAD(&pool->po_free_list);
- pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+ pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
pool->po_owner = ps;
pool->po_size = size;
}
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now)
return 0;
if (pool->po_failed)
return 1;
- return cfs_time_aftereq(now, pool->po_deadline);
+ return time_after_eq(now, pool->po_deadline);
}
void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
@@ -1858,7 +1858,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
LIST_HEAD(zombies);
struct kib_poolset *ps = pool->po_owner;
struct kib_pool *tmp;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
spin_lock(&ps->ps_lock);
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
continue;
pool->po_allocated++;
- pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+ pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
node = pool->po_free_list.next;
list_del(node);
@@ -1927,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
goto again;
}
- if (time_before(cfs_time_current(), ps->ps_next_retry)) {
+ if (time_before(jiffies, ps->ps_next_retry)) {
/* someone failed recently */
spin_unlock(&ps->ps_lock);
return NULL;
@@ -1937,17 +1937,17 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
spin_unlock(&ps->ps_lock);
CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
- time_before = cfs_time_current();
+ time_before = jiffies;
rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
CDEBUG(D_NET, "ps_pool_create took %lu HZ to complete",
- cfs_time_current() - time_before);
+ jiffies - time_before);
spin_lock(&ps->ps_lock);
ps->ps_increasing = 0;
if (!rc) {
list_add_tail(&pool->po_list, &ps->ps_pool_list);
} else {
- ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+ ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
CERROR("Can't allocate new %s pool because out of memory\n",
ps->ps_name);
}
@@ -2928,6 +2928,8 @@ static void __exit ko2iblnd_exit(void)
static int __init ko2iblnd_init(void)
{
+ int rc;
+
BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE);
BUILD_BUG_ON(offsetof(struct kib_msg,
ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
@@ -2938,6 +2940,10 @@ static int __init ko2iblnd_init(void)
kiblnd_tunables_init();
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
lnet_register_lnd(&the_o2iblnd);
return 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..217503f125bc 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -64,7 +64,6 @@
#define DEBUG_SUBSYSTEM S_LND
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#define IBLND_PEER_HASH_SIZE 101 /* # peer lists */
@@ -568,6 +567,8 @@ struct kib_peer {
lnet_nid_t ibp_nid; /* who's on the other end(s) */
struct lnet_ni *ibp_ni; /* LNet interface */
struct list_head ibp_conns; /* all active connections */
+ struct kib_conn *ibp_next_conn; /* next connection to send on for
+ * round robin */
struct list_head ibp_tx_queue; /* msgs waiting for a conn */
__u64 ibp_incarnation; /* incarnation of peer */
/* when (in jiffies) I was last alive */
@@ -581,7 +582,7 @@ struct kib_peer {
/* current active connection attempts */
unsigned short ibp_connecting;
/* reconnect this peer later */
- unsigned short ibp_reconnecting:1;
+ unsigned char ibp_reconnecting;
/* counter of how many times we triggered a conn race */
unsigned char ibp_races;
/* # consecutive reconnection attempts to this peer */
@@ -744,19 +745,28 @@ kiblnd_peer_active(struct kib_peer *peer)
static inline struct kib_conn *
kiblnd_get_conn_locked(struct kib_peer *peer)
{
+ struct list_head *next;
+
LASSERT(!list_empty(&peer->ibp_conns));
- /* just return the first connection */
- return list_entry(peer->ibp_conns.next, struct kib_conn, ibc_list);
+ /* Advance to next connection, be sure to skip the head node */
+ if (!peer->ibp_next_conn ||
+ peer->ibp_next_conn->ibc_list.next == &peer->ibp_conns)
+ next = peer->ibp_conns.next;
+ else
+ next = peer->ibp_next_conn->ibc_list.next;
+ peer->ibp_next_conn = list_entry(next, struct kib_conn, ibc_list);
+
+ return peer->ibp_next_conn;
}
static inline int
kiblnd_send_keepalive(struct kib_conn *conn)
{
return (*kiblnd_tunables.kib_keepalive > 0) &&
- cfs_time_after(jiffies, conn->ibc_last_send +
- msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
- MSEC_PER_SEC));
+ time_after(jiffies, conn->ibc_last_send +
+ msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+ MSEC_PER_SEC));
}
static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 6690a6cd4e34..47eb8b4c28db 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -48,7 +48,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type,
__u64 dstcookie);
static void kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn);
static void kiblnd_queue_tx(struct kib_tx *tx, struct kib_conn *conn);
-static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx);
+static void kiblnd_unmap_tx(struct kib_tx *tx);
static void kiblnd_check_sends_locked(struct kib_conn *conn);
static void
@@ -66,7 +66,7 @@ kiblnd_tx_done(struct lnet_ni *ni, struct kib_tx *tx)
LASSERT(!tx->tx_waiting); /* mustn't be awaiting peer response */
LASSERT(tx->tx_pool);
- kiblnd_unmap_tx(ni, tx);
+ kiblnd_unmap_tx(tx);
/* tx may have up to 2 lnet msgs to finalise */
lntmsg[0] = tx->tx_lntmsg[0]; tx->tx_lntmsg[0] = NULL;
@@ -591,13 +591,9 @@ kiblnd_fmr_map_tx(struct kib_net *net, struct kib_tx *tx, struct kib_rdma_desc *
return 0;
}
-static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx)
+static void kiblnd_unmap_tx(struct kib_tx *tx)
{
- struct kib_net *net = ni->ni_data;
-
- LASSERT(net);
-
- if (net->ibn_fmr_ps)
+ if (tx->fmr.fmr_pfmr || tx->fmr.fmr_frd)
kiblnd_fmr_pool_unmap(&tx->fmr, tx->tx_status);
if (tx->tx_nfrags) {
@@ -1250,7 +1246,6 @@ kiblnd_connect_peer(struct kib_peer *peer)
LASSERT(net);
LASSERT(peer->ibp_connecting > 0);
- LASSERT(!peer->ibp_reconnecting);
cmid = kiblnd_rdma_create_id(kiblnd_cm_callback, peer, RDMA_PS_TCP,
IB_QPT_RC);
@@ -1290,11 +1285,6 @@ kiblnd_connect_peer(struct kib_peer *peer)
goto failed2;
}
- LASSERT(cmid->device);
- CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n",
- libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
- &dev->ibd_ifip, cmid->device->name);
-
return;
failed2:
@@ -1332,7 +1322,7 @@ kiblnd_reconnect_peer(struct kib_peer *peer)
LASSERT(!peer->ibp_accepting && !peer->ibp_connecting &&
list_empty(&peer->ibp_conns));
- peer->ibp_reconnecting = 0;
+ peer->ibp_reconnecting--;
if (!kiblnd_peer_active(peer)) {
list_splice_init(&peer->ibp_tx_queue, &txs);
@@ -1365,6 +1355,8 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
unsigned long flags;
int rc;
+ int i;
+ struct lnet_ioctl_config_o2iblnd_tunables *tunables;
/*
* If I get here, I've committed to send, so I complete the tx with
@@ -1461,7 +1453,8 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
/* Brand new peer */
LASSERT(!peer->ibp_connecting);
- peer->ibp_connecting = 1;
+ tunables = &peer->ibp_ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ peer->ibp_connecting = tunables->lnd_conns_per_peer;
/* always called with a ref on ni, which prevents ni being shutdown */
LASSERT(!((struct kib_net *)ni->ni_data)->ibn_shutdown);
@@ -1474,7 +1467,8 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
write_unlock_irqrestore(g_lock, flags);
- kiblnd_connect_peer(peer);
+ for (i = 0; i < tunables->lnd_conns_per_peer; i++)
+ kiblnd_connect_peer(peer);
kiblnd_peer_decref(peer);
}
@@ -1853,8 +1847,8 @@ kiblnd_thread_fini(void)
static void
kiblnd_peer_alive(struct kib_peer *peer)
{
- /* This is racy, but everyone's only writing cfs_time_current() */
- peer->ibp_last_alive = cfs_time_current();
+ /* This is racy, but everyone's only writing jiffies */
+ peer->ibp_last_alive = jiffies;
mb();
}
@@ -1923,6 +1917,9 @@ kiblnd_close_conn_locked(struct kib_conn *conn, int error)
}
dev = ((struct kib_net *)peer->ibp_ni->ni_data)->ibn_dev;
+ if (peer->ibp_next_conn == conn)
+ /* clear next_conn so it won't be used */
+ peer->ibp_next_conn = NULL;
list_del(&conn->ibc_list);
/* connd (see below) takes over ibc_list's ref */
@@ -1968,13 +1965,14 @@ kiblnd_handle_early_rxs(struct kib_conn *conn)
{
unsigned long flags;
struct kib_rx *rx;
- struct kib_rx *tmp;
LASSERT(!in_interrupt());
LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
- list_for_each_entry_safe(rx, tmp, &conn->ibc_early_rxs, rx_list) {
+ while (!list_empty(&conn->ibc_early_rxs)) {
+ rx = list_entry(conn->ibc_early_rxs.next,
+ struct kib_rx, rx_list);
list_del(&rx->rx_list);
write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
@@ -2192,7 +2190,11 @@ kiblnd_connreq_done(struct kib_conn *conn, int status)
kiblnd_conn_addref(conn);
write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
- /* Schedule blocked txs */
+ /* Schedule blocked txs
+ * Note: if we are running with conns_per_peer > 1, these blocked
+ * txs will all get scheduled to the first connection which gets
+ * scheduled. We won't be using round robin on this first batch.
+ */
spin_lock(&conn->ibc_lock);
list_for_each_entry_safe(tx, tmp, &txs, tx_list) {
list_del(&tx->tx_list);
@@ -2561,7 +2563,6 @@ kiblnd_check_reconnect(struct kib_conn *conn, int version,
LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
LASSERT(peer->ibp_connecting > 0); /* 'conn' at least */
- LASSERT(!peer->ibp_reconnecting);
if (cp) {
msg_size = cp->ibcp_max_msg_size;
@@ -2579,7 +2580,7 @@ kiblnd_check_reconnect(struct kib_conn *conn, int version,
*/
reconnect = (!list_empty(&peer->ibp_tx_queue) ||
peer->ibp_version != version) &&
- peer->ibp_connecting == 1 &&
+ peer->ibp_connecting &&
!peer->ibp_accepting;
if (!reconnect) {
reason = "no need";
@@ -2640,7 +2641,7 @@ kiblnd_check_reconnect(struct kib_conn *conn, int version,
}
conn->ibc_reconnect = 1;
- peer->ibp_reconnecting = 1;
+ peer->ibp_reconnecting++;
peer->ibp_version = version;
if (incarnation)
peer->ibp_incarnation = incarnation;
@@ -2996,8 +2997,19 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
} else {
rc = rdma_resolve_route(
cmid, *kiblnd_tunables.kib_timeout * 1000);
- if (!rc)
+ if (!rc) {
+ struct kib_net *net = peer->ibp_ni->ni_data;
+ struct kib_dev *dev = net->ibn_dev;
+
+ CDEBUG(D_NET, "%s: connection bound to "\
+ "%s:%pI4h:%s\n",
+ libcfs_nid2str(peer->ibp_nid),
+ dev->ibd_ifname,
+ &dev->ibd_ifip, cmid->device->name);
+
return 0;
+ }
+
/* Can't initiate route resolution */
CERROR("Can't resolve route for %s: %d\n",
libcfs_nid2str(peer->ibp_nid), rc);
@@ -3141,10 +3153,10 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
LASSERT(tx->tx_waiting || tx->tx_sending);
}
- if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+ if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
kiblnd_queue2str(conn, txs),
- cfs_duration_sec(jiffies - tx->tx_deadline));
+ (jiffies - tx->tx_deadline) / HZ);
return 1;
}
}
@@ -3206,8 +3218,7 @@ kiblnd_check_conns(int idx)
if (timedout) {
CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
libcfs_nid2str(peer->ibp_nid),
- cfs_duration_sec(cfs_time_current() -
- peer->ibp_last_alive),
+ (jiffies - peer->ibp_last_alive) / HZ,
conn->ibc_credits,
conn->ibc_outstanding_credits,
conn->ibc_reserved_credits);
@@ -3681,7 +3692,7 @@ kiblnd_failover_thread(void *arg)
list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
ibd_fail_list) {
- if (time_before(cfs_time_current(),
+ if (time_before(jiffies,
dev->ibd_next_failover))
continue;
do_failover = 1;
@@ -3700,13 +3711,13 @@ kiblnd_failover_thread(void *arg)
LASSERT(dev->ibd_failover);
dev->ibd_failover = 0;
if (rc >= 0) { /* Device is OK or failover succeed */
- dev->ibd_next_failover = cfs_time_shift(3);
+ dev->ibd_next_failover = jiffies + 3 * HZ;
continue;
}
/* failed to failover, retry later */
dev->ibd_next_failover =
- cfs_time_shift(min(dev->ibd_failed_failover, 10));
+ jiffies + min(dev->ibd_failed_failover, 10) * HZ;
if (kiblnd_dev_can_failover(dev)) {
list_add_tail(&dev->ibd_fail_list,
&kiblnd_data.kib_failed_devs);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index b9235400bf1d..39d07926d603 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -57,6 +57,10 @@ static int nscheds;
module_param(nscheds, int, 0444);
MODULE_PARM_DESC(nscheds, "number of threads in each scheduler pool");
+static unsigned int conns_per_peer = 1;
+module_param(conns_per_peer, uint, 0444);
+MODULE_PARM_DESC(conns_per_peer, "number of connections per peer");
+
/* NB: this value is shared by all CPTs, it can grow at runtime */
static int ntx = 512;
module_param(ntx, int, 0444);
@@ -271,6 +275,10 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)
tunables->lnd_fmr_flush_trigger = fmr_flush_trigger;
if (!tunables->lnd_fmr_cache)
tunables->lnd_fmr_cache = fmr_cache;
+ if (!tunables->lnd_conns_per_peer) {
+ tunables->lnd_conns_per_peer = (conns_per_peer) ?
+ conns_per_peer : 1;
+ }
return 0;
}
@@ -284,4 +292,5 @@ void kiblnd_tunables_init(void)
default_tunables.lnd_fmr_pool_size = fmr_pool_size;
default_tunables.lnd_fmr_flush_trigger = fmr_flush_trigger;
default_tunables.lnd_fmr_cache = fmr_cache;
+ default_tunables.lnd_conns_per_peer = conns_per_peer;
}
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7086678e1c3e..f01b34ac1a53 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1276,7 +1276,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
}
conn->ksnc_peer = peer; /* conn takes my ref on peer */
- peer->ksnp_last_alive = cfs_time_current();
+ peer->ksnp_last_alive = jiffies;
peer->ksnp_send_keepalive = 0;
peer->ksnp_error = 0;
@@ -1284,10 +1284,10 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
sched->kss_nconns++;
conn->ksnc_scheduler = sched;
- conn->ksnc_tx_last_post = cfs_time_current();
+ conn->ksnc_tx_last_post = jiffies;
/* Set the deadline for the outgoing HELLO to drain */
conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
- conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
mb(); /* order with adding to peer's conn list */
list_add(&conn->ksnc_list, &peer->ksnp_conns);
@@ -1682,8 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
&conn->ksnc_ipaddr, conn->ksnc_port,
iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
- cfs_duration_sec(cfs_time_sub(cfs_time_current(),
- last_rcv)));
+ (jiffies - last_rcv) / HZ);
lnet_finalize(conn->ksnc_peer->ksnp_ni,
conn->ksnc_cookie, -EIO);
break;
@@ -1832,7 +1831,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
{
int connect = 1;
unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
struct ksock_peer *peer = NULL;
rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
struct lnet_process_id id = {
@@ -1853,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
if (bufnob < conn->ksnc_tx_bufnob) {
/* something got ACKed */
conn->ksnc_tx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
peer->ksnp_last_alive = now;
conn->ksnc_tx_bufnob = bufnob;
}
@@ -1871,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
libcfs_nid2str(nid), peer,
- last_alive ? cfs_duration_sec(now - last_alive) : -1,
+ last_alive ? (now - last_alive) / HZ : -1,
connect);
if (!connect)
@@ -2904,6 +2903,10 @@ static int __init ksocklnd_init(void)
if (rc)
return rc;
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
lnet_register_lnd(&the_ksocklnd);
return 0;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index 570f54ed57b1..4e5c89a692a3 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -47,7 +47,6 @@
#include <net/sock.h>
#include <net/tcp.h>
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#include <linux/lnet/socklnd.h>
@@ -58,7 +57,7 @@
#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */
-#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */
+#define SOCKNAL_ENOMEM_RETRY 1 /* jiffies between retries */
#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */
#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 036fecbcede8..01b31a6bb588 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -22,6 +22,7 @@
*
*/
+#include <linux/sched/mm.h>
#include "socklnd.h"
struct ksock_tx *
@@ -221,8 +222,8 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
* something got ACKed
*/
conn->ksnc_tx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
- conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
+ conn->ksnc_peer->ksnp_last_alive = jiffies;
conn->ksnc_tx_bufnob = bufnob;
mb();
}
@@ -267,9 +268,9 @@ ksocknal_recv_iter(struct ksock_conn *conn)
/* received something... */
nob = rc;
- conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+ conn->ksnc_peer->ksnp_last_alive = jiffies;
conn->ksnc_rx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
mb(); /* order with setting rx_started */
conn->ksnc_rx_started = 1;
@@ -405,7 +406,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
/* ZC_REQ is going to be pinned to the peer */
tx->tx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
@@ -481,8 +482,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
LASSERT(conn->ksnc_tx_scheduled);
list_add_tail(&conn->ksnc_tx_list,
&ksocknal_data.ksnd_enomem_conns);
- if (!cfs_time_aftereq(cfs_time_add(cfs_time_current(),
- SOCKNAL_ENOMEM_RETRY),
+ if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY,
ksocknal_data.ksnd_reaper_waketime))
wake_up(&ksocknal_data.ksnd_reaper_waitq);
@@ -591,7 +591,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
case SOCKNAL_MATCH_YES: /* typed connection */
if (!typed || tnob > nob ||
(tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
- cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+ time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
typed = c;
tnob = nob;
}
@@ -600,7 +600,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
case SOCKNAL_MATCH_MAY: /* fallback connection */
if (!fallback || fnob > nob ||
(fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
- cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+ time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
fallback = c;
fnob = nob;
}
@@ -612,7 +612,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
conn = (typed) ? typed : fallback;
if (conn)
- conn->ksnc_tx_last_post = cfs_time_current();
+ conn->ksnc_tx_last_post = jiffies;
return conn;
}
@@ -678,9 +678,9 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
/* First packet starts the timeout */
conn->ksnc_tx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
- conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+ conn->ksnc_peer->ksnp_last_alive = jiffies;
conn->ksnc_tx_bufnob = 0;
mb(); /* order with adding to tx_queue */
}
@@ -728,7 +728,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
struct ksock_route *
ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
{
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
struct list_head *tmp;
struct ksock_route *route;
@@ -746,13 +746,13 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
continue;
if (!(!route->ksnr_retry_interval || /* first attempt */
- cfs_time_aftereq(now, route->ksnr_timeout))) {
+ time_after_eq(now, route->ksnr_timeout))) {
CDEBUG(D_NET,
"Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n",
&route->ksnr_ipaddr,
route->ksnr_connected,
route->ksnr_retry_interval,
- cfs_duration_sec(route->ksnr_timeout - now));
+ (route->ksnr_timeout - now) / HZ);
continue;
}
@@ -859,7 +859,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
ksocknal_find_connecting_route_locked(peer)) {
/* the message is going to be pinned to the peer */
tx->tx_deadline =
- cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+ jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
/* Queue the message until a connection is established */
list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
@@ -877,7 +877,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
int
ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
{
- int mpflag = 1;
+ unsigned int mpflag = 0;
int type = lntmsg->msg_type;
struct lnet_process_id target = lntmsg->msg_target;
unsigned int payload_niov = lntmsg->msg_niov;
@@ -910,13 +910,13 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
tx_frags.paged.kiov[payload_niov]);
if (lntmsg->msg_vmflush)
- mpflag = cfs_memory_pressure_get_and_set();
+ mpflag = memalloc_noreclaim_save();
tx = ksocknal_alloc_tx(KSOCK_MSG_LNET, desc_size);
if (!tx) {
CERROR("Can't allocate tx desc type %d size %d\n",
type, desc_size);
if (lntmsg->msg_vmflush)
- cfs_memory_pressure_restore(mpflag);
+ memalloc_noreclaim_restore(mpflag);
return -ENOMEM;
}
@@ -950,8 +950,8 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
/* The first fragment will be set later in pro_pack */
rc = ksocknal_launch_packet(ni, tx, target);
- if (!mpflag)
- cfs_memory_pressure_restore(mpflag);
+ if (mpflag)
+ memalloc_noreclaim_restore(mpflag);
if (!rc)
return 0;
@@ -1777,8 +1777,7 @@ ksocknal_connect(struct ksock_route *route)
int retry_later = 0;
int rc = 0;
- deadline = cfs_time_add(cfs_time_current(),
- *ksocknal_tunables.ksnd_timeout * HZ);
+ deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1825,7 +1824,7 @@ ksocknal_connect(struct ksock_route *route)
write_unlock_bh(&ksocknal_data.ksnd_global_lock);
- if (cfs_time_aftereq(cfs_time_current(), deadline)) {
+ if (time_after_eq(jiffies, deadline)) {
rc = -ETIMEDOUT;
lnet_connect_console_error(rc, peer->ksnp_id.nid,
route->ksnr_ipaddr,
@@ -1877,8 +1876,7 @@ ksocknal_connect(struct ksock_route *route)
*/
route->ksnr_retry_interval =
*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
- route->ksnr_timeout = cfs_time_add(cfs_time_current(),
- route->ksnr_retry_interval);
+ route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
}
ksocknal_launch_connection_locked(route);
@@ -1903,8 +1901,7 @@ ksocknal_connect(struct ksock_route *route)
(long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
LASSERT(route->ksnr_retry_interval);
- route->ksnr_timeout = cfs_time_add(cfs_time_current(),
- route->ksnr_retry_interval);
+ route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
if (!list_empty(&peer->ksnp_tx_queue) &&
!peer->ksnp_accepting &&
@@ -2050,13 +2047,13 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
struct ksock_route *route;
unsigned long now;
- now = cfs_time_current();
+ now = jiffies;
/* connd_routes can contain both pending and ordinary routes */
list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
ksnr_connd_list) {
if (!route->ksnr_retry_interval ||
- cfs_time_aftereq(now, route->ksnr_timeout))
+ time_after_eq(now, route->ksnr_timeout))
return route;
if (*timeout_p == MAX_SCHEDULE_TIMEOUT ||
@@ -2228,8 +2225,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
}
if (conn->ksnc_rx_started &&
- cfs_time_aftereq(cfs_time_current(),
- conn->ksnc_rx_deadline)) {
+ time_after_eq(jiffies,
+ conn->ksnc_rx_deadline)) {
/* Timed out incomplete incoming message */
ksocknal_conn_addref(conn);
CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %zd left %d\n",
@@ -2244,8 +2241,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
if ((!list_empty(&conn->ksnc_tx_queue) ||
conn->ksnc_sock->sk->sk_wmem_queued) &&
- cfs_time_aftereq(cfs_time_current(),
- conn->ksnc_tx_deadline)) {
+ time_after_eq(jiffies,
+ conn->ksnc_tx_deadline)) {
/*
* Timed out messages queued for sending or
* buffered in the socket's send buffer
@@ -2272,8 +2269,8 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
write_lock_bh(&ksocknal_data.ksnd_global_lock);
list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
- if (!cfs_time_aftereq(cfs_time_current(),
- tx->tx_deadline))
+ if (!time_after_eq(jiffies,
+ tx->tx_deadline))
break;
list_del(&tx->tx_list);
@@ -2301,19 +2298,18 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
return 0;
if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
- time_before(cfs_time_current(),
- cfs_time_add(peer->ksnp_last_alive,
- *ksocknal_tunables.ksnd_keepalive * HZ)))
+ time_before(jiffies,
+ peer->ksnp_last_alive + *ksocknal_tunables.ksnd_keepalive * HZ))
return 0;
- if (time_before(cfs_time_current(), peer->ksnp_send_keepalive))
+ if (time_before(jiffies, peer->ksnp_send_keepalive))
return 0;
/*
* retry 10 secs later, so we wouldn't put pressure
* on this peer if we failed to send keepalive this time
*/
- peer->ksnp_send_keepalive = cfs_time_shift(10);
+ peer->ksnp_send_keepalive = jiffies + 10 * HZ;
conn = ksocknal_find_conn_locked(peer, NULL, 1);
if (conn) {
@@ -2400,8 +2396,8 @@ ksocknal_check_peer_timeouts(int idx)
tx = list_entry(peer->ksnp_tx_queue.next,
struct ksock_tx, tx_list);
- if (cfs_time_aftereq(cfs_time_current(),
- tx->tx_deadline)) {
+ if (time_after_eq(jiffies,
+ tx->tx_deadline)) {
ksocknal_peer_addref(peer);
read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -2418,8 +2414,8 @@ ksocknal_check_peer_timeouts(int idx)
tx_stale = NULL;
spin_lock(&peer->ksnp_lock);
list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
- if (!cfs_time_aftereq(cfs_time_current(),
- tx->tx_deadline))
+ if (!time_after_eq(jiffies,
+ tx->tx_deadline))
break;
/* ignore the TX if connection is being closed */
if (tx->tx_conn->ksnc_closing)
@@ -2444,7 +2440,7 @@ ksocknal_check_peer_timeouts(int idx)
CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
- cfs_duration_sec(cfs_time_current() - deadline),
+ (jiffies - deadline) / HZ,
resid, conn->ksnc_sock->sk->sk_wmem_queued);
ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
@@ -2466,7 +2462,7 @@ ksocknal_reaper(void *arg)
long timeout;
int i;
int peer_index = 0;
- unsigned long deadline = cfs_time_current();
+ unsigned long deadline = jiffies;
INIT_LIST_HEAD(&enomem_conns);
init_waitqueue_entry(&wait, current);
@@ -2531,8 +2527,7 @@ ksocknal_reaper(void *arg)
}
/* careful with the jiffy wrap... */
- while ((timeout = cfs_time_sub(deadline,
- cfs_time_current())) <= 0) {
+ while ((timeout = deadline - jiffies) <= 0) {
const int n = 4;
const int p = 1;
int chunk = ksocknal_data.ksnd_peer_hash_size;
@@ -2557,7 +2552,7 @@ ksocknal_reaper(void *arg)
ksocknal_data.ksnd_peer_hash_size;
}
- deadline = cfs_time_add(deadline, p * HZ);
+ deadline = deadline + p * HZ;
}
if (nenomem_conns) {
@@ -2568,8 +2563,7 @@ ksocknal_reaper(void *arg)
*/
timeout = SOCKNAL_ENOMEM_RETRY;
}
- ksocknal_data.ksnd_reaper_waketime =
- cfs_time_add(cfs_time_current(), timeout);
+ ksocknal_data.ksnd_reaper_waketime = jiffies + timeout;
set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index 7941cfa526bc..93a02cd6b6b5 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -31,6 +31,7 @@
* Lustre is a trademark of Sun Microsystems, Inc.
*/
+#include <linux/highmem.h>
#include "socklnd.h"
int
diff --git a/drivers/staging/lustre/lnet/libcfs/Makefile b/drivers/staging/lustre/lnet/libcfs/Makefile
index b7dc7ac11cc5..6a1b232da495 100644
--- a/drivers/staging/lustre/lnet/libcfs/Makefile
+++ b/drivers/staging/lustre/lnet/libcfs/Makefile
@@ -4,16 +4,13 @@ subdir-ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include
obj-$(CONFIG_LNET) += libcfs.o
-libcfs-linux-objs := linux-tracefile.o linux-debug.o
-libcfs-linux-objs += linux-cpu.o
-libcfs-linux-objs += linux-module.o
-libcfs-linux-objs += linux-crypto.o
-libcfs-linux-objs += linux-crypto-adler.o
+libcfs-obj-y += linux-tracefile.o linux-debug.o
+libcfs-obj-y += linux-crypto.o
+libcfs-obj-y += linux-crypto-adler.o
-libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
+libcfs-obj-y += debug.o fail.o module.o tracefile.o
+libcfs-obj-y += libcfs_string.o hash.o
+libcfs-obj-$(CONFIG_SMP) += libcfs_cpu.o
+libcfs-obj-y += libcfs_mem.o libcfs_lock.o
-libcfs-all-objs := debug.o fail.o module.o tracefile.o \
- libcfs_string.o hash.o \
- libcfs_cpu.o libcfs_mem.o libcfs_lock.o
-
-libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
+libcfs-objs := $(libcfs-obj-y)
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
index 1371224a8cb9..06f694f6a28f 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -38,7 +38,10 @@
# define DEBUG_SUBSYSTEM S_LNET
-#include <linux/libcfs/libcfs.h>
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/libcfs/libcfs_string.h>
+#include <linux/kthread.h>
#include "tracefile.h"
static char debug_file_name[1024];
@@ -126,7 +129,7 @@ static int param_get_delay(char *buffer, const struct kernel_param *kp)
{
unsigned int d = *(unsigned int *)kp->arg;
- return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+ return sprintf(buffer, "%u", (unsigned int)(d * 100) / HZ);
}
unsigned int libcfs_console_max_delay;
@@ -373,7 +376,7 @@ void libcfs_debug_dumplog(void)
add_wait_queue(&debug_ctlwq, &wait);
dumper = kthread_run(libcfs_debug_dumplog_thread,
- (void *)(long)current_pid(),
+ (void *)(long)current->pid,
"libcfs_debug_dumper");
set_current_state(TASK_INTERRUPTIBLE);
if (IS_ERR(dumper))
diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c b/drivers/staging/lustre/lnet/libcfs/fail.c
index d3f1e866c6a7..bd86b3b5bc34 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -30,7 +30,11 @@
* Lustre is a trademark of Oracle Corporation, Inc.
*/
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/module.h>
#include <linux/libcfs/libcfs.h>
+#include <linux/random.h>
unsigned long cfs_fail_loc;
EXPORT_SYMBOL(cfs_fail_loc);
diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c
index f7b3c9306456..48be66f0d654 100644
--- a/drivers/staging/lustre/lnet/libcfs/hash.c
+++ b/drivers/staging/lustre/lnet/libcfs/hash.c
@@ -105,8 +105,9 @@
*/
#include <linux/seq_file.h>
#include <linux/log2.h>
-
-#include <linux/libcfs/libcfs.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/libcfs/libcfs_hash.h>
#if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
static unsigned int warn_on_depth = 8;
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 76291a350406..3d1cf457b286 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -31,13 +31,58 @@
#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/cpu.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/cache.h>
+
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/libcfs/libcfs_string.h>
#include <linux/libcfs/libcfs.h>
/** Global CPU partition table */
-struct cfs_cpt_table *cfs_cpt_table __read_mostly;
-EXPORT_SYMBOL(cfs_cpt_table);
+struct cfs_cpt_table *cfs_cpt_tab __read_mostly;
+EXPORT_SYMBOL(cfs_cpt_tab);
-#ifndef HAVE_LIBCFS_CPT
+/**
+ * modparam for setting number of partitions
+ *
+ * 0 : estimate best value based on cores or NUMA nodes
+ * 1 : disable multiple partitions
+ * >1 : specify number of partitions
+ */
+static int cpu_npartitions;
+module_param(cpu_npartitions, int, 0444);
+MODULE_PARM_DESC(cpu_npartitions, "# of CPU partitions");
+
+/**
+ * modparam for setting CPU partitions patterns:
+ *
+ * i.e: "0[0,1,2,3] 1[4,5,6,7]", number before bracket is CPU partition ID,
+ * number in bracket is processor ID (core or HT)
+ *
+ * i.e: "N 0[0,1] 1[2,3]" the first character 'N' means numbers in bracket
+ * are NUMA node ID, number before bracket is CPU partition ID.
+ *
+ * i.e: "N", shortcut expression to create CPT from NUMA & CPU topology
+ *
+ * NB: If user specified cpu_pattern, cpu_npartitions will be ignored
+ */
+static char *cpu_pattern = "N";
+module_param(cpu_pattern, charp, 0444);
+MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern");
+
+static struct cfs_cpt_data {
+ /* serialize hotplug etc */
+ spinlock_t cpt_lock;
+ /* reserved for hotplug */
+ unsigned long cpt_version;
+ /* mutex to protect cpt_cpumask */
+ struct mutex cpt_mutex;
+ /* scratch buffer for set/unset_node */
+ cpumask_var_t cpt_cpumask;
+} cpt_data;
#define CFS_CPU_VERSION_MAGIC 0xbabecafe
@@ -45,79 +90,221 @@ struct cfs_cpt_table *
cfs_cpt_table_alloc(unsigned int ncpt)
{
struct cfs_cpt_table *cptab;
+ int i;
- if (ncpt != 1) {
- CERROR("Can't support cpu partition number %d\n", ncpt);
+ cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
+ if (!cptab)
return NULL;
- }
- cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
- if (cptab) {
- cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
- node_set(0, cptab->ctb_nodemask);
- cptab->ctb_nparts = ncpt;
+ cptab->ctb_nparts = ncpt;
+
+ cptab->ctb_nodemask = kzalloc(sizeof(*cptab->ctb_nodemask),
+ GFP_NOFS);
+ if (!zalloc_cpumask_var(&cptab->ctb_cpumask, GFP_NOFS) ||
+ !cptab->ctb_nodemask)
+ goto failed;
+
+ cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
+ sizeof(cptab->ctb_cpu2cpt[0]),
+ GFP_KERNEL);
+ if (!cptab->ctb_cpu2cpt)
+ goto failed;
+
+ memset(cptab->ctb_cpu2cpt, -1,
+ num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
+
+ cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
+ GFP_KERNEL);
+ if (!cptab->ctb_parts)
+ goto failed;
+
+ for (i = 0; i < ncpt; i++) {
+ struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
+
+ part->cpt_nodemask = kzalloc(sizeof(*part->cpt_nodemask),
+ GFP_NOFS);
+ if (!zalloc_cpumask_var(&part->cpt_cpumask, GFP_NOFS) ||
+ !part->cpt_nodemask)
+ goto failed;
}
+ spin_lock(&cpt_data.cpt_lock);
+ /* Reserved for hotplug */
+ cptab->ctb_version = cpt_data.cpt_version;
+ spin_unlock(&cpt_data.cpt_lock);
+
return cptab;
+
+ failed:
+ cfs_cpt_table_free(cptab);
+ return NULL;
}
EXPORT_SYMBOL(cfs_cpt_table_alloc);
void
cfs_cpt_table_free(struct cfs_cpt_table *cptab)
{
- LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
+ int i;
+
+ kvfree(cptab->ctb_cpu2cpt);
+
+ for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
+ struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
+
+ kfree(part->cpt_nodemask);
+ free_cpumask_var(part->cpt_cpumask);
+ }
+
+ kvfree(cptab->ctb_parts);
+
+ kfree(cptab->ctb_nodemask);
+ free_cpumask_var(cptab->ctb_cpumask);
kfree(cptab);
}
EXPORT_SYMBOL(cfs_cpt_table_free);
-#ifdef CONFIG_SMP
int
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
- int rc;
+ char *tmp = buf;
+ int rc = 0;
+ int i;
+ int j;
- rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
- len -= rc;
- if (len <= 0)
- return -EFBIG;
+ for (i = 0; i < cptab->ctb_nparts; i++) {
+ if (len > 0) {
+ rc = snprintf(tmp, len, "%d\t: ", i);
+ len -= rc;
+ }
- return rc;
+ if (len <= 0) {
+ rc = -EFBIG;
+ goto out;
+ }
+
+ tmp += rc;
+ for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
+ rc = snprintf(tmp, len, "%d ", j);
+ len -= rc;
+ if (len <= 0) {
+ rc = -EFBIG;
+ goto out;
+ }
+ tmp += rc;
+ }
+
+ *tmp = '\n';
+ tmp++;
+ len--;
+ }
+
+ out:
+ if (rc < 0)
+ return rc;
+
+ return tmp - buf;
}
EXPORT_SYMBOL(cfs_cpt_table_print);
-#endif /* CONFIG_SMP */
+
+static void
+cfs_node_to_cpumask(int node, cpumask_t *mask)
+{
+ const cpumask_t *tmp = cpumask_of_node(node);
+
+ if (tmp)
+ cpumask_copy(mask, tmp);
+ else
+ cpumask_clear(mask);
+}
int
cfs_cpt_number(struct cfs_cpt_table *cptab)
{
- return 1;
+ return cptab->ctb_nparts;
}
EXPORT_SYMBOL(cfs_cpt_number);
int
cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
{
- return 1;
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ return cpt == CFS_CPT_ANY ?
+ cpumask_weight(cptab->ctb_cpumask) :
+ cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask);
}
EXPORT_SYMBOL(cfs_cpt_weight);
int
cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
{
- return 1;
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ return cpt == CFS_CPT_ANY ?
+ cpumask_any_and(cptab->ctb_cpumask,
+ cpu_online_mask) < nr_cpu_ids :
+ cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask,
+ cpu_online_mask) < nr_cpu_ids;
}
EXPORT_SYMBOL(cfs_cpt_online);
+cpumask_var_t *
+cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+{
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ return cpt == CFS_CPT_ANY ?
+ &cptab->ctb_cpumask : &cptab->ctb_parts[cpt].cpt_cpumask;
+}
+EXPORT_SYMBOL(cfs_cpt_cpumask);
+
nodemask_t *
cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
{
- return &cptab->ctb_nodemask;
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ return cpt == CFS_CPT_ANY ?
+ cptab->ctb_nodemask : cptab->ctb_parts[cpt].cpt_nodemask;
}
EXPORT_SYMBOL(cfs_cpt_nodemask);
int
cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
{
+ int node;
+
+ LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);
+
+ if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) {
+ CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
+ return 0;
+ }
+
+ if (cptab->ctb_cpu2cpt[cpu] != -1) {
+ CDEBUG(D_INFO, "CPU %d is already in partition %d\n",
+ cpu, cptab->ctb_cpu2cpt[cpu]);
+ return 0;
+ }
+
+ cptab->ctb_cpu2cpt[cpu] = cpt;
+
+ LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
+ LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
+
+ cpumask_set_cpu(cpu, cptab->ctb_cpumask);
+ cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+
+ node = cpu_to_node(cpu);
+
+ /* first CPU of @node in this CPT table */
+ if (!node_isset(node, *cptab->ctb_nodemask))
+ node_set(node, *cptab->ctb_nodemask);
+
+ /* first CPU of @node in this partition */
+ if (!node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask))
+ node_set(node, *cptab->ctb_parts[cpt].cpt_nodemask);
+
return 1;
}
EXPORT_SYMBOL(cfs_cpt_set_cpu);
@@ -125,12 +312,80 @@ EXPORT_SYMBOL(cfs_cpt_set_cpu);
void
cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
{
+ int node;
+ int i;
+
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ if (cpu < 0 || cpu >= nr_cpu_ids) {
+ CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
+ return;
+ }
+
+ if (cpt == CFS_CPT_ANY) {
+ /* caller doesn't know the partition ID */
+ cpt = cptab->ctb_cpu2cpt[cpu];
+ if (cpt < 0) { /* not set in this CPT-table */
+ CDEBUG(D_INFO, "Try to unset cpu %d which is not in CPT-table %p\n",
+ cpt, cptab);
+ return;
+ }
+
+ } else if (cpt != cptab->ctb_cpu2cpt[cpu]) {
+ CDEBUG(D_INFO,
+ "CPU %d is not in cpu-partition %d\n", cpu, cpt);
+ return;
+ }
+
+ LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
+ LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask));
+
+ cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+ cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
+ cptab->ctb_cpu2cpt[cpu] = -1;
+
+ node = cpu_to_node(cpu);
+
+ LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
+ LASSERT(node_isset(node, *cptab->ctb_nodemask));
+
+ for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) {
+ /* this CPT has other CPU belonging to this node? */
+ if (cpu_to_node(i) == node)
+ break;
+ }
+
+ if (i >= nr_cpu_ids)
+ node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
+
+ for_each_cpu(i, cptab->ctb_cpumask) {
+ /* this CPT-table has other CPU belonging to this node? */
+ if (cpu_to_node(i) == node)
+ break;
+ }
+
+ if (i >= nr_cpu_ids)
+ node_clear(node, *cptab->ctb_nodemask);
}
EXPORT_SYMBOL(cfs_cpt_unset_cpu);
int
cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
{
+ int i;
+
+ if (!cpumask_weight(mask) ||
+ cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
+ CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
+ cpt);
+ return 0;
+ }
+
+ for_each_cpu(i, mask) {
+ if (!cfs_cpt_set_cpu(cptab, cpt, i))
+ return 0;
+ }
+
return 1;
}
EXPORT_SYMBOL(cfs_cpt_set_cpumask);
@@ -138,25 +393,65 @@ EXPORT_SYMBOL(cfs_cpt_set_cpumask);
void
cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
{
+ int i;
+
+ for_each_cpu(i, mask)
+ cfs_cpt_unset_cpu(cptab, cpt, i);
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
int
cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
- return 1;
+ int rc;
+
+ if (node < 0 || node >= MAX_NUMNODES) {
+ CDEBUG(D_INFO,
+ "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
+ return 0;
+ }
+
+ mutex_lock(&cpt_data.cpt_mutex);
+
+ cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
+
+ rc = cfs_cpt_set_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
+
+ mutex_unlock(&cpt_data.cpt_mutex);
+
+ return rc;
}
EXPORT_SYMBOL(cfs_cpt_set_node);
void
cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
+ if (node < 0 || node >= MAX_NUMNODES) {
+ CDEBUG(D_INFO,
+ "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
+ return;
+ }
+
+ mutex_lock(&cpt_data.cpt_mutex);
+
+ cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
+
+ cfs_cpt_unset_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
+
+ mutex_unlock(&cpt_data.cpt_mutex);
}
EXPORT_SYMBOL(cfs_cpt_unset_node);
int
cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
{
+ int i;
+
+ for_each_node_mask(i, *mask) {
+ if (!cfs_cpt_set_node(cptab, cpt, i))
+ return 0;
+ }
+
return 1;
}
EXPORT_SYMBOL(cfs_cpt_set_nodemask);
@@ -164,65 +459,628 @@ EXPORT_SYMBOL(cfs_cpt_set_nodemask);
void
cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
{
+ int i;
+
+ for_each_node_mask(i, *mask)
+ cfs_cpt_unset_node(cptab, cpt, i);
}
EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
void
cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
{
+ int last;
+ int i;
+
+ if (cpt == CFS_CPT_ANY) {
+ last = cptab->ctb_nparts - 1;
+ cpt = 0;
+ } else {
+ last = cpt;
+ }
+
+ for (; cpt <= last; cpt++) {
+ for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask)
+ cfs_cpt_unset_cpu(cptab, cpt, i);
+ }
}
EXPORT_SYMBOL(cfs_cpt_clear);
int
cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
{
+ nodemask_t *mask;
+ int weight;
+ int rotor;
+ int node;
+
+ /* convert CPU partition ID to HW node id */
+
+ if (cpt < 0 || cpt >= cptab->ctb_nparts) {
+ mask = cptab->ctb_nodemask;
+ rotor = cptab->ctb_spread_rotor++;
+ } else {
+ mask = cptab->ctb_parts[cpt].cpt_nodemask;
+ rotor = cptab->ctb_parts[cpt].cpt_spread_rotor++;
+ }
+
+ weight = nodes_weight(*mask);
+ LASSERT(weight > 0);
+
+ rotor %= weight;
+
+ for_each_node_mask(node, *mask) {
+ if (!rotor--)
+ return node;
+ }
+
+ LBUG();
return 0;
}
EXPORT_SYMBOL(cfs_cpt_spread_node);
int
-cfs_cpu_ht_nsiblings(int cpu)
-{
- return 1;
-}
-EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);
-
-int
cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
{
- return 0;
+ int cpu;
+ int cpt;
+
+ preempt_disable();
+ cpu = smp_processor_id();
+ cpt = cptab->ctb_cpu2cpt[cpu];
+
+ if (cpt < 0 && remap) {
+ /* don't return negative value for safety of upper layer,
+ * instead we shadow the unknown cpu to a valid partition ID
+ */
+ cpt = cpu % cptab->ctb_nparts;
+ }
+ preempt_enable();
+ return cpt;
}
EXPORT_SYMBOL(cfs_cpt_current);
int
cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
{
- return 0;
+ LASSERT(cpu >= 0 && cpu < nr_cpu_ids);
+
+ return cptab->ctb_cpu2cpt[cpu];
}
EXPORT_SYMBOL(cfs_cpt_of_cpu);
int
cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
{
+ cpumask_var_t *cpumask;
+ nodemask_t *nodemask;
+ int rc;
+ int i;
+
+ LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
+
+ if (cpt == CFS_CPT_ANY) {
+ cpumask = &cptab->ctb_cpumask;
+ nodemask = cptab->ctb_nodemask;
+ } else {
+ cpumask = &cptab->ctb_parts[cpt].cpt_cpumask;
+ nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
+ }
+
+ if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
+ CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
+ cpt);
+ return -EINVAL;
+ }
+
+ for_each_online_cpu(i) {
+ if (cpumask_test_cpu(i, *cpumask))
+ continue;
+
+ rc = set_cpus_allowed_ptr(current, *cpumask);
+ set_mems_allowed(*nodemask);
+ if (!rc)
+ schedule(); /* switch to allowed CPU */
+
+ return rc;
+ }
+
+ /* don't need to set affinity because all online CPUs are covered */
return 0;
}
EXPORT_SYMBOL(cfs_cpt_bind);
+/**
+ * Choose max to \a number CPUs from \a node and set them in \a cpt.
+ * We always prefer to choose CPU in the same core/socket.
+ */
+static int
+cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
+ cpumask_t *node, int number)
+{
+ cpumask_var_t socket;
+ cpumask_var_t core;
+ int rc = 0;
+ int cpu;
+
+ LASSERT(number > 0);
+
+ if (number >= cpumask_weight(node)) {
+ while (!cpumask_empty(node)) {
+ cpu = cpumask_first(node);
+
+ rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
+ if (!rc)
+ return -EINVAL;
+ cpumask_clear_cpu(cpu, node);
+ }
+ return 0;
+ }
+
+ /*
+ * Allocate scratch buffers
+ * As we cannot initialize a cpumask_var_t, we need
+ * to alloc both before we can risk trying to free either
+ */
+ if (!zalloc_cpumask_var(&socket, GFP_NOFS))
+ rc = -ENOMEM;
+ if (!zalloc_cpumask_var(&core, GFP_NOFS))
+ rc = -ENOMEM;
+ if (rc)
+ goto out;
+
+ while (!cpumask_empty(node)) {
+ cpu = cpumask_first(node);
+
+ /* get cpumask for cores in the same socket */
+ cpumask_copy(socket, topology_core_cpumask(cpu));
+ cpumask_and(socket, socket, node);
+
+ LASSERT(!cpumask_empty(socket));
+
+ while (!cpumask_empty(socket)) {
+ int i;
+
+ /* get cpumask for hts in the same core */
+ cpumask_copy(core, topology_sibling_cpumask(cpu));
+ cpumask_and(core, core, node);
+
+ LASSERT(!cpumask_empty(core));
+
+ for_each_cpu(i, core) {
+ cpumask_clear_cpu(i, socket);
+ cpumask_clear_cpu(i, node);
+
+ rc = cfs_cpt_set_cpu(cptab, cpt, i);
+ if (!rc) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ if (!--number)
+ goto out;
+ }
+ cpu = cpumask_first(socket);
+ }
+ }
+
+out:
+ free_cpumask_var(socket);
+ free_cpumask_var(core);
+ return rc;
+}
+
+#define CPT_WEIGHT_MIN 4u
+
+static unsigned int
+cfs_cpt_num_estimate(void)
+{
+ unsigned int nnode = num_online_nodes();
+ unsigned int ncpu = num_online_cpus();
+ unsigned int ncpt;
+
+ if (ncpu <= CPT_WEIGHT_MIN) {
+ ncpt = 1;
+ goto out;
+ }
+
+ /* generate reasonable number of CPU partitions based on total number
+ * of CPUs, Preferred N should be power2 and match this condition:
+ * 2 * (N - 1)^2 < NCPUS <= 2 * N^2
+ */
+ for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1)
+ ;
+
+ if (ncpt <= nnode) { /* fat numa system */
+ while (nnode > ncpt)
+ nnode >>= 1;
+
+ } else { /* ncpt > nnode */
+ while ((nnode << 1) <= ncpt)
+ nnode <<= 1;
+ }
+
+ ncpt = nnode;
+
+out:
+#if (BITS_PER_LONG == 32)
+ /* config many CPU partitions on 32-bit system could consume
+ * too much memory
+ */
+ ncpt = min(2U, ncpt);
+#endif
+ while (ncpu % ncpt)
+ ncpt--; /* worst case is 1 */
+
+ return ncpt;
+}
+
+static struct cfs_cpt_table *
+cfs_cpt_table_create(int ncpt)
+{
+ struct cfs_cpt_table *cptab = NULL;
+ cpumask_var_t mask;
+ int cpt = 0;
+ int num;
+ int rc;
+ int i;
+
+ rc = cfs_cpt_num_estimate();
+ if (ncpt <= 0)
+ ncpt = rc;
+
+ if (ncpt > num_online_cpus() || ncpt > 4 * rc) {
+ CWARN("CPU partition number %d is larger than suggested value (%d), your system may have performance issue or run out of memory while under pressure\n",
+ ncpt, rc);
+ }
+
+ if (num_online_cpus() % ncpt) {
+ CERROR("CPU number %d is not multiple of cpu_npartition %d, please try different cpu_npartitions value or set pattern string by cpu_pattern=STRING\n",
+ (int)num_online_cpus(), ncpt);
+ goto failed;
+ }
+
+ cptab = cfs_cpt_table_alloc(ncpt);
+ if (!cptab) {
+ CERROR("Failed to allocate CPU map(%d)\n", ncpt);
+ goto failed;
+ }
+
+ num = num_online_cpus() / ncpt;
+ if (!num) {
+ CERROR("CPU changed while setting CPU partition\n");
+ goto failed;
+ }
+
+ if (!zalloc_cpumask_var(&mask, GFP_NOFS)) {
+ CERROR("Failed to allocate scratch cpumask\n");
+ goto failed;
+ }
+
+ for_each_online_node(i) {
+ cfs_node_to_cpumask(i, mask);
+
+ while (!cpumask_empty(mask)) {
+ struct cfs_cpu_partition *part;
+ int n;
+
+ /*
+ * Each emulated NUMA node has all allowed CPUs in
+ * the mask.
+ * End loop when all partitions have assigned CPUs.
+ */
+ if (cpt == ncpt)
+ break;
+
+ part = &cptab->ctb_parts[cpt];
+
+ n = num - cpumask_weight(part->cpt_cpumask);
+ LASSERT(n > 0);
+
+ rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
+ if (rc < 0)
+ goto failed_mask;
+
+ LASSERT(num >= cpumask_weight(part->cpt_cpumask));
+ if (num == cpumask_weight(part->cpt_cpumask))
+ cpt++;
+ }
+ }
+
+ if (cpt != ncpt ||
+ num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
+ CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n",
+ cptab->ctb_nparts, num, cpt,
+ cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask));
+ goto failed_mask;
+ }
+
+ free_cpumask_var(mask);
+
+ return cptab;
+
+ failed_mask:
+ free_cpumask_var(mask);
+ failed:
+ CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
+ ncpt, num_online_nodes(), num_online_cpus());
+
+ if (cptab)
+ cfs_cpt_table_free(cptab);
+
+ return NULL;
+}
+
+static struct cfs_cpt_table *
+cfs_cpt_table_create_pattern(char *pattern)
+{
+ struct cfs_cpt_table *cptab;
+ char *str;
+ int node = 0;
+ int high;
+ int ncpt = 0;
+ int cpt;
+ int rc;
+ int c;
+ int i;
+
+ str = strim(pattern);
+ if (*str == 'n' || *str == 'N') {
+ pattern = str + 1;
+ if (*pattern != '\0') {
+ node = 1;
+ } else { /* shortcut to create CPT from NUMA & CPU topology */
+ node = -1;
+ ncpt = num_online_nodes();
+ }
+ }
+
+ if (!ncpt) { /* scanning bracket which is mark of partition */
+ for (str = pattern;; str++, ncpt++) {
+ str = strchr(str, '[');
+ if (!str)
+ break;
+ }
+ }
+
+ if (!ncpt ||
+ (node && ncpt > num_online_nodes()) ||
+ (!node && ncpt > num_online_cpus())) {
+ CERROR("Invalid pattern %s, or too many partitions %d\n",
+ pattern, ncpt);
+ return NULL;
+ }
+
+ cptab = cfs_cpt_table_alloc(ncpt);
+ if (!cptab) {
+ CERROR("Failed to allocate cpu partition table\n");
+ return NULL;
+ }
+
+ if (node < 0) { /* shortcut to create CPT from NUMA & CPU topology */
+ cpt = 0;
+
+ for_each_online_node(i) {
+ if (cpt >= ncpt) {
+ CERROR("CPU changed while setting CPU partition table, %d/%d\n",
+ cpt, ncpt);
+ goto failed;
+ }
+
+ rc = cfs_cpt_set_node(cptab, cpt++, i);
+ if (!rc)
+ goto failed;
+ }
+ return cptab;
+ }
+
+ high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
+
+ for (str = strim(pattern), c = 0;; c++) {
+ struct cfs_range_expr *range;
+ struct cfs_expr_list *el;
+ char *bracket = strchr(str, '[');
+ int n;
+
+ if (!bracket) {
+ if (*str) {
+ CERROR("Invalid pattern %s\n", str);
+ goto failed;
+ }
+ if (c != ncpt) {
+ CERROR("expect %d partitions but found %d\n",
+ ncpt, c);
+ goto failed;
+ }
+ break;
+ }
+
+ if (sscanf(str, "%d%n", &cpt, &n) < 1) {
+ CERROR("Invalid cpu pattern %s\n", str);
+ goto failed;
+ }
+
+ if (cpt < 0 || cpt >= ncpt) {
+ CERROR("Invalid partition id %d, total partitions %d\n",
+ cpt, ncpt);
+ goto failed;
+ }
+
+ if (cfs_cpt_weight(cptab, cpt)) {
+ CERROR("Partition %d has already been set.\n", cpt);
+ goto failed;
+ }
+
+ str = strim(str + n);
+ if (str != bracket) {
+ CERROR("Invalid pattern %s\n", str);
+ goto failed;
+ }
+
+ bracket = strchr(str, ']');
+ if (!bracket) {
+ CERROR("missing right bracket for cpt %d, %s\n",
+ cpt, str);
+ goto failed;
+ }
+
+ if (cfs_expr_list_parse(str, (bracket - str) + 1,
+ 0, high, &el)) {
+ CERROR("Can't parse number range: %s\n", str);
+ goto failed;
+ }
+
+ list_for_each_entry(range, &el->el_exprs, re_link) {
+ for (i = range->re_lo; i <= range->re_hi; i++) {
+ if ((i - range->re_lo) % range->re_stride)
+ continue;
+
+ rc = node ? cfs_cpt_set_node(cptab, cpt, i) :
+ cfs_cpt_set_cpu(cptab, cpt, i);
+ if (!rc) {
+ cfs_expr_list_free(el);
+ goto failed;
+ }
+ }
+ }
+
+ cfs_expr_list_free(el);
+
+ if (!cfs_cpt_online(cptab, cpt)) {
+ CERROR("No online CPU is found on partition %d\n", cpt);
+ goto failed;
+ }
+
+ str = strim(bracket + 1);
+ }
+
+ return cptab;
+
+ failed:
+ cfs_cpt_table_free(cptab);
+ return NULL;
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+static enum cpuhp_state lustre_cpu_online;
+
+static void cfs_cpu_incr_cpt_version(void)
+{
+ spin_lock(&cpt_data.cpt_lock);
+ cpt_data.cpt_version++;
+ spin_unlock(&cpt_data.cpt_lock);
+}
+
+static int cfs_cpu_online(unsigned int cpu)
+{
+ cfs_cpu_incr_cpt_version();
+ return 0;
+}
+
+static int cfs_cpu_dead(unsigned int cpu)
+{
+ bool warn;
+
+ cfs_cpu_incr_cpt_version();
+
+ mutex_lock(&cpt_data.cpt_mutex);
+ /* if all HTs in a core are offline, it may break affinity */
+ cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu));
+ warn = cpumask_any_and(cpt_data.cpt_cpumask,
+ cpu_online_mask) >= nr_cpu_ids;
+ mutex_unlock(&cpt_data.cpt_mutex);
+ CDEBUG(warn ? D_WARNING : D_INFO,
+ "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n",
+ cpu);
+ return 0;
+}
+#endif
+
void
cfs_cpu_fini(void)
{
- if (cfs_cpt_table) {
- cfs_cpt_table_free(cfs_cpt_table);
- cfs_cpt_table = NULL;
- }
+ if (cfs_cpt_tab)
+ cfs_cpt_table_free(cfs_cpt_tab);
+
+#ifdef CONFIG_HOTPLUG_CPU
+ if (lustre_cpu_online > 0)
+ cpuhp_remove_state_nocalls(lustre_cpu_online);
+ cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD);
+#endif
+ free_cpumask_var(cpt_data.cpt_cpumask);
}
int
cfs_cpu_init(void)
{
- cfs_cpt_table = cfs_cpt_table_alloc(1);
+ int ret = 0;
- return cfs_cpt_table ? 0 : -1;
-}
+ LASSERT(!cfs_cpt_tab);
+
+ memset(&cpt_data, 0, sizeof(cpt_data));
+
+ if (!zalloc_cpumask_var(&cpt_data.cpt_cpumask, GFP_NOFS)) {
+ CERROR("Failed to allocate scratch buffer\n");
+ return -1;
+ }
+
+ spin_lock_init(&cpt_data.cpt_lock);
+ mutex_init(&cpt_data.cpt_mutex);
+
+#ifdef CONFIG_HOTPLUG_CPU
+ ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD,
+ "staging/lustre/cfe:dead", NULL,
+ cfs_cpu_dead);
+ if (ret < 0)
+ goto failed;
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+ "staging/lustre/cfe:online",
+ cfs_cpu_online, NULL);
+ if (ret < 0)
+ goto failed;
+ lustre_cpu_online = ret;
+#endif
+ ret = -EINVAL;
+
+ if (*cpu_pattern) {
+ char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
+
+ if (!cpu_pattern_dup) {
+ CERROR("Failed to duplicate cpu_pattern\n");
+ goto failed;
+ }
-#endif /* HAVE_LIBCFS_CPT */
+ cfs_cpt_tab = cfs_cpt_table_create_pattern(cpu_pattern_dup);
+ kfree(cpu_pattern_dup);
+ if (!cfs_cpt_tab) {
+ CERROR("Failed to create cptab from pattern %s\n",
+ cpu_pattern);
+ goto failed;
+ }
+
+ } else {
+ cfs_cpt_tab = cfs_cpt_table_create(cpu_npartitions);
+ if (!cfs_cpt_tab) {
+ CERROR("Failed to create ptable with npartitions %d\n",
+ cpu_npartitions);
+ goto failed;
+ }
+ }
+
+ spin_lock(&cpt_data.cpt_lock);
+ if (cfs_cpt_tab->ctb_version != cpt_data.cpt_version) {
+ spin_unlock(&cpt_data.cpt_lock);
+ CERROR("CPU hotplug/unplug during setup\n");
+ goto failed;
+ }
+ spin_unlock(&cpt_data.cpt_lock);
+
+ LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
+ num_online_nodes(), num_online_cpus(),
+ cfs_cpt_number(cfs_cpt_tab));
+ return 0;
+
+ failed:
+ cfs_cpu_fini();
+ return ret;
+}
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
index 670ad5a34224..223505c37545 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
@@ -28,7 +28,10 @@
#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_cpu.h>
/** destroy cpu-partition lock, see libcfs_private.h for more detail */
void
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c b/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
index 7faed94994ea..2d533be9bb30 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_mem.c
@@ -29,7 +29,11 @@
#define DEBUG_SUBSYSTEM S_LNET
-#include <linux/libcfs/libcfs.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
struct cfs_var_array {
unsigned int va_count; /* # of buffers */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
index 442889a3d729..e1fb1263e3ae 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c
@@ -37,7 +37,13 @@
* Author: Nathan Rutman <nathan.rutman@sun.com>
*/
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_string.h>
/* Convert a text string to a bitmask */
int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
index db81ed527452..db81ed527452 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lnet/libcfs/linux-crypto.c
index b55006264155..21ff9bf6da47 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto.c
@@ -30,8 +30,10 @@
#include <crypto/hash.h>
#include <linux/scatterlist.h>
-#include <linux/libcfs/libcfs.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
#include <linux/libcfs/libcfs_crypto.h>
+#include <linux/libcfs/libcfs.h>
#include "linux-crypto.h"
/**
@@ -426,7 +428,8 @@ int cfs_crypto_register(void)
{
request_module("crc32c");
- adler32 = cfs_crypto_adler32_register();
+ if (cfs_crypto_adler32_register() == 0)
+ adler32 = 1;
/* check all algorithms and do performance test */
cfs_crypto_test_hashes();
@@ -438,6 +441,7 @@ int cfs_crypto_register(void)
*/
void cfs_crypto_unregister(void)
{
- if (!adler32)
+ if (adler32)
cfs_crypto_adler32_unregister();
+ adler32 = 0;
}
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h b/drivers/staging/lustre/lnet/libcfs/linux-crypto.h
index 5616e9ea1450..5616e9ea1450 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto.h
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lnet/libcfs/linux-debug.c
index 0092166af258..15ab849374c2 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-debug.c
@@ -48,13 +48,10 @@
#include <linux/completion.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
# define DEBUG_SUBSYSTEM S_LNET
-#include <linux/libcfs/libcfs.h>
-
-#include "../tracefile.h"
+#include "tracefile.h"
#include <linux/kallsyms.h>
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
index 7928d7182634..347138409eba 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
@@ -34,8 +34,9 @@
#define DEBUG_SUBSYSTEM S_LNET
#define LUSTRE_TRACEFILE_PRIVATE
-#include <linux/libcfs/libcfs.h>
-#include "../tracefile.h"
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include "tracefile.h"
/* percents to share the total debug memory for each type */
static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
deleted file mode 100644
index 388521e4e354..000000000000
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ /dev/null
@@ -1,1079 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- *
- * Copyright (c) 2012, 2015 Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * Author: liang@whamcloud.com
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <linux/cpu.h>
-#include <linux/sched.h>
-#include <linux/libcfs/libcfs.h>
-
-#ifdef CONFIG_SMP
-
-/**
- * modparam for setting number of partitions
- *
- * 0 : estimate best value based on cores or NUMA nodes
- * 1 : disable multiple partitions
- * >1 : specify number of partitions
- */
-static int cpu_npartitions;
-module_param(cpu_npartitions, int, 0444);
-MODULE_PARM_DESC(cpu_npartitions, "# of CPU partitions");
-
-/**
- * modparam for setting CPU partitions patterns:
- *
- * i.e: "0[0,1,2,3] 1[4,5,6,7]", number before bracket is CPU partition ID,
- * number in bracket is processor ID (core or HT)
- *
- * i.e: "N 0[0,1] 1[2,3]" the first character 'N' means numbers in bracket
- * are NUMA node ID, number before bracket is CPU partition ID.
- *
- * i.e: "N", shortcut expression to create CPT from NUMA & CPU topology
- *
- * NB: If user specified cpu_pattern, cpu_npartitions will be ignored
- */
-static char *cpu_pattern = "N";
-module_param(cpu_pattern, charp, 0444);
-MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern");
-
-struct cfs_cpt_data {
- /* serialize hotplug etc */
- spinlock_t cpt_lock;
- /* reserved for hotplug */
- unsigned long cpt_version;
- /* mutex to protect cpt_cpumask */
- struct mutex cpt_mutex;
- /* scratch buffer for set/unset_node */
- cpumask_var_t cpt_cpumask;
-};
-
-static struct cfs_cpt_data cpt_data;
-
-static void
-cfs_node_to_cpumask(int node, cpumask_t *mask)
-{
- const cpumask_t *tmp = cpumask_of_node(node);
-
- if (tmp)
- cpumask_copy(mask, tmp);
- else
- cpumask_clear(mask);
-}
-
-void
-cfs_cpt_table_free(struct cfs_cpt_table *cptab)
-{
- int i;
-
- kvfree(cptab->ctb_cpu2cpt);
-
- for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
- struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
-
- kfree(part->cpt_nodemask);
- free_cpumask_var(part->cpt_cpumask);
- }
-
- kvfree(cptab->ctb_parts);
-
- kfree(cptab->ctb_nodemask);
- free_cpumask_var(cptab->ctb_cpumask);
-
- kfree(cptab);
-}
-EXPORT_SYMBOL(cfs_cpt_table_free);
-
-struct cfs_cpt_table *
-cfs_cpt_table_alloc(unsigned int ncpt)
-{
- struct cfs_cpt_table *cptab;
- int i;
-
- cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
- if (!cptab)
- return NULL;
-
- cptab->ctb_nparts = ncpt;
-
- cptab->ctb_nodemask = kzalloc(sizeof(*cptab->ctb_nodemask),
- GFP_NOFS);
- if (!zalloc_cpumask_var(&cptab->ctb_cpumask, GFP_NOFS) ||
- !cptab->ctb_nodemask)
- goto failed;
-
- cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
- sizeof(cptab->ctb_cpu2cpt[0]),
- GFP_KERNEL);
- if (!cptab->ctb_cpu2cpt)
- goto failed;
-
- memset(cptab->ctb_cpu2cpt, -1,
- num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
-
- cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
- GFP_KERNEL);
- if (!cptab->ctb_parts)
- goto failed;
-
- for (i = 0; i < ncpt; i++) {
- struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
-
- part->cpt_nodemask = kzalloc(sizeof(*part->cpt_nodemask),
- GFP_NOFS);
- if (!zalloc_cpumask_var(&part->cpt_cpumask, GFP_NOFS) ||
- !part->cpt_nodemask)
- goto failed;
- }
-
- spin_lock(&cpt_data.cpt_lock);
- /* Reserved for hotplug */
- cptab->ctb_version = cpt_data.cpt_version;
- spin_unlock(&cpt_data.cpt_lock);
-
- return cptab;
-
- failed:
- cfs_cpt_table_free(cptab);
- return NULL;
-}
-EXPORT_SYMBOL(cfs_cpt_table_alloc);
-
-int
-cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
-{
- char *tmp = buf;
- int rc = 0;
- int i;
- int j;
-
- for (i = 0; i < cptab->ctb_nparts; i++) {
- if (len > 0) {
- rc = snprintf(tmp, len, "%d\t: ", i);
- len -= rc;
- }
-
- if (len <= 0) {
- rc = -EFBIG;
- goto out;
- }
-
- tmp += rc;
- for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
- rc = snprintf(tmp, len, "%d ", j);
- len -= rc;
- if (len <= 0) {
- rc = -EFBIG;
- goto out;
- }
- tmp += rc;
- }
-
- *tmp = '\n';
- tmp++;
- len--;
- }
-
- out:
- if (rc < 0)
- return rc;
-
- return tmp - buf;
-}
-EXPORT_SYMBOL(cfs_cpt_table_print);
-
-int
-cfs_cpt_number(struct cfs_cpt_table *cptab)
-{
- return cptab->ctb_nparts;
-}
-EXPORT_SYMBOL(cfs_cpt_number);
-
-int
-cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
-{
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- return cpt == CFS_CPT_ANY ?
- cpumask_weight(cptab->ctb_cpumask) :
- cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask);
-}
-EXPORT_SYMBOL(cfs_cpt_weight);
-
-int
-cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
-{
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- return cpt == CFS_CPT_ANY ?
- cpumask_any_and(cptab->ctb_cpumask,
- cpu_online_mask) < nr_cpu_ids :
- cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask,
- cpu_online_mask) < nr_cpu_ids;
-}
-EXPORT_SYMBOL(cfs_cpt_online);
-
-cpumask_var_t *
-cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
-{
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- return cpt == CFS_CPT_ANY ?
- &cptab->ctb_cpumask : &cptab->ctb_parts[cpt].cpt_cpumask;
-}
-EXPORT_SYMBOL(cfs_cpt_cpumask);
-
-nodemask_t *
-cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
-{
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- return cpt == CFS_CPT_ANY ?
- cptab->ctb_nodemask : cptab->ctb_parts[cpt].cpt_nodemask;
-}
-EXPORT_SYMBOL(cfs_cpt_nodemask);
-
-int
-cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
-{
- int node;
-
- LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);
-
- if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) {
- CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
- return 0;
- }
-
- if (cptab->ctb_cpu2cpt[cpu] != -1) {
- CDEBUG(D_INFO, "CPU %d is already in partition %d\n",
- cpu, cptab->ctb_cpu2cpt[cpu]);
- return 0;
- }
-
- cptab->ctb_cpu2cpt[cpu] = cpt;
-
- LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
- LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
-
- cpumask_set_cpu(cpu, cptab->ctb_cpumask);
- cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
-
- node = cpu_to_node(cpu);
-
- /* first CPU of @node in this CPT table */
- if (!node_isset(node, *cptab->ctb_nodemask))
- node_set(node, *cptab->ctb_nodemask);
-
- /* first CPU of @node in this partition */
- if (!node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask))
- node_set(node, *cptab->ctb_parts[cpt].cpt_nodemask);
-
- return 1;
-}
-EXPORT_SYMBOL(cfs_cpt_set_cpu);
-
-void
-cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
-{
- int node;
- int i;
-
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- if (cpu < 0 || cpu >= nr_cpu_ids) {
- CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
- return;
- }
-
- if (cpt == CFS_CPT_ANY) {
- /* caller doesn't know the partition ID */
- cpt = cptab->ctb_cpu2cpt[cpu];
- if (cpt < 0) { /* not set in this CPT-table */
- CDEBUG(D_INFO, "Try to unset cpu %d which is not in CPT-table %p\n",
- cpt, cptab);
- return;
- }
-
- } else if (cpt != cptab->ctb_cpu2cpt[cpu]) {
- CDEBUG(D_INFO,
- "CPU %d is not in cpu-partition %d\n", cpu, cpt);
- return;
- }
-
- LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
- LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask));
-
- cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
- cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
- cptab->ctb_cpu2cpt[cpu] = -1;
-
- node = cpu_to_node(cpu);
-
- LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
- LASSERT(node_isset(node, *cptab->ctb_nodemask));
-
- for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) {
- /* this CPT has other CPU belonging to this node? */
- if (cpu_to_node(i) == node)
- break;
- }
-
- if (i >= nr_cpu_ids)
- node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
-
- for_each_cpu(i, cptab->ctb_cpumask) {
- /* this CPT-table has other CPU belonging to this node? */
- if (cpu_to_node(i) == node)
- break;
- }
-
- if (i >= nr_cpu_ids)
- node_clear(node, *cptab->ctb_nodemask);
-}
-EXPORT_SYMBOL(cfs_cpt_unset_cpu);
-
-int
-cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
-{
- int i;
-
- if (!cpumask_weight(mask) ||
- cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
- CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
- cpt);
- return 0;
- }
-
- for_each_cpu(i, mask) {
- if (!cfs_cpt_set_cpu(cptab, cpt, i))
- return 0;
- }
-
- return 1;
-}
-EXPORT_SYMBOL(cfs_cpt_set_cpumask);
-
-void
-cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
-{
- int i;
-
- for_each_cpu(i, mask)
- cfs_cpt_unset_cpu(cptab, cpt, i);
-}
-EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
-
-int
-cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
-{
- int rc;
-
- if (node < 0 || node >= MAX_NUMNODES) {
- CDEBUG(D_INFO,
- "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
- return 0;
- }
-
- mutex_lock(&cpt_data.cpt_mutex);
-
- cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
-
- rc = cfs_cpt_set_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
-
- mutex_unlock(&cpt_data.cpt_mutex);
-
- return rc;
-}
-EXPORT_SYMBOL(cfs_cpt_set_node);
-
-void
-cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
-{
- if (node < 0 || node >= MAX_NUMNODES) {
- CDEBUG(D_INFO,
- "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
- return;
- }
-
- mutex_lock(&cpt_data.cpt_mutex);
-
- cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
-
- cfs_cpt_unset_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
-
- mutex_unlock(&cpt_data.cpt_mutex);
-}
-EXPORT_SYMBOL(cfs_cpt_unset_node);
-
-int
-cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
-{
- int i;
-
- for_each_node_mask(i, *mask) {
- if (!cfs_cpt_set_node(cptab, cpt, i))
- return 0;
- }
-
- return 1;
-}
-EXPORT_SYMBOL(cfs_cpt_set_nodemask);
-
-void
-cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
-{
- int i;
-
- for_each_node_mask(i, *mask)
- cfs_cpt_unset_node(cptab, cpt, i);
-}
-EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
-
-void
-cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
-{
- int last;
- int i;
-
- if (cpt == CFS_CPT_ANY) {
- last = cptab->ctb_nparts - 1;
- cpt = 0;
- } else {
- last = cpt;
- }
-
- for (; cpt <= last; cpt++) {
- for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask)
- cfs_cpt_unset_cpu(cptab, cpt, i);
- }
-}
-EXPORT_SYMBOL(cfs_cpt_clear);
-
-int
-cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
-{
- nodemask_t *mask;
- int weight;
- int rotor;
- int node;
-
- /* convert CPU partition ID to HW node id */
-
- if (cpt < 0 || cpt >= cptab->ctb_nparts) {
- mask = cptab->ctb_nodemask;
- rotor = cptab->ctb_spread_rotor++;
- } else {
- mask = cptab->ctb_parts[cpt].cpt_nodemask;
- rotor = cptab->ctb_parts[cpt].cpt_spread_rotor++;
- }
-
- weight = nodes_weight(*mask);
- LASSERT(weight > 0);
-
- rotor %= weight;
-
- for_each_node_mask(node, *mask) {
- if (!rotor--)
- return node;
- }
-
- LBUG();
- return 0;
-}
-EXPORT_SYMBOL(cfs_cpt_spread_node);
-
-int
-cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
-{
- int cpu;
- int cpt;
-
- preempt_disable();
- cpu = smp_processor_id();
- cpt = cptab->ctb_cpu2cpt[cpu];
-
- if (cpt < 0 && remap) {
- /* don't return negative value for safety of upper layer,
- * instead we shadow the unknown cpu to a valid partition ID
- */
- cpt = cpu % cptab->ctb_nparts;
- }
- preempt_enable();
- return cpt;
-}
-EXPORT_SYMBOL(cfs_cpt_current);
-
-int
-cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
-{
- LASSERT(cpu >= 0 && cpu < nr_cpu_ids);
-
- return cptab->ctb_cpu2cpt[cpu];
-}
-EXPORT_SYMBOL(cfs_cpt_of_cpu);
-
-int
-cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
-{
- cpumask_var_t *cpumask;
- nodemask_t *nodemask;
- int rc;
- int i;
-
- LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
-
- if (cpt == CFS_CPT_ANY) {
- cpumask = &cptab->ctb_cpumask;
- nodemask = cptab->ctb_nodemask;
- } else {
- cpumask = &cptab->ctb_parts[cpt].cpt_cpumask;
- nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
- }
-
- if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
- CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
- cpt);
- return -EINVAL;
- }
-
- for_each_online_cpu(i) {
- if (cpumask_test_cpu(i, *cpumask))
- continue;
-
- rc = set_cpus_allowed_ptr(current, *cpumask);
- set_mems_allowed(*nodemask);
- if (!rc)
- schedule(); /* switch to allowed CPU */
-
- return rc;
- }
-
- /* don't need to set affinity because all online CPUs are covered */
- return 0;
-}
-EXPORT_SYMBOL(cfs_cpt_bind);
-
-/**
- * Choose max to \a number CPUs from \a node and set them in \a cpt.
- * We always prefer to choose CPU in the same core/socket.
- */
-static int
-cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
- cpumask_t *node, int number)
-{
- cpumask_var_t socket;
- cpumask_var_t core;
- int rc = 0;
- int cpu;
-
- LASSERT(number > 0);
-
- if (number >= cpumask_weight(node)) {
- while (!cpumask_empty(node)) {
- cpu = cpumask_first(node);
-
- rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
- if (!rc)
- return -EINVAL;
- cpumask_clear_cpu(cpu, node);
- }
- return 0;
- }
-
- /*
- * Allocate scratch buffers
- * As we cannot initialize a cpumask_var_t, we need
- * to alloc both before we can risk trying to free either
- */
- if (!zalloc_cpumask_var(&socket, GFP_NOFS))
- rc = -ENOMEM;
- if (!zalloc_cpumask_var(&core, GFP_NOFS))
- rc = -ENOMEM;
- if (rc)
- goto out;
-
- while (!cpumask_empty(node)) {
- cpu = cpumask_first(node);
-
- /* get cpumask for cores in the same socket */
- cpumask_copy(socket, topology_core_cpumask(cpu));
- cpumask_and(socket, socket, node);
-
- LASSERT(!cpumask_empty(socket));
-
- while (!cpumask_empty(socket)) {
- int i;
-
- /* get cpumask for hts in the same core */
- cpumask_copy(core, topology_sibling_cpumask(cpu));
- cpumask_and(core, core, node);
-
- LASSERT(!cpumask_empty(core));
-
- for_each_cpu(i, core) {
- cpumask_clear_cpu(i, socket);
- cpumask_clear_cpu(i, node);
-
- rc = cfs_cpt_set_cpu(cptab, cpt, i);
- if (!rc) {
- rc = -EINVAL;
- goto out;
- }
-
- if (!--number)
- goto out;
- }
- cpu = cpumask_first(socket);
- }
- }
-
-out:
- free_cpumask_var(socket);
- free_cpumask_var(core);
- return rc;
-}
-
-#define CPT_WEIGHT_MIN 4u
-
-static unsigned int
-cfs_cpt_num_estimate(void)
-{
- unsigned int nnode = num_online_nodes();
- unsigned int ncpu = num_online_cpus();
- unsigned int ncpt;
-
- if (ncpu <= CPT_WEIGHT_MIN) {
- ncpt = 1;
- goto out;
- }
-
- /* generate reasonable number of CPU partitions based on total number
- * of CPUs, Preferred N should be power2 and match this condition:
- * 2 * (N - 1)^2 < NCPUS <= 2 * N^2
- */
- for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1)
- ;
-
- if (ncpt <= nnode) { /* fat numa system */
- while (nnode > ncpt)
- nnode >>= 1;
-
- } else { /* ncpt > nnode */
- while ((nnode << 1) <= ncpt)
- nnode <<= 1;
- }
-
- ncpt = nnode;
-
-out:
-#if (BITS_PER_LONG == 32)
- /* config many CPU partitions on 32-bit system could consume
- * too much memory
- */
- ncpt = min(2U, ncpt);
-#endif
- while (ncpu % ncpt)
- ncpt--; /* worst case is 1 */
-
- return ncpt;
-}
-
-static struct cfs_cpt_table *
-cfs_cpt_table_create(int ncpt)
-{
- struct cfs_cpt_table *cptab = NULL;
- cpumask_var_t mask;
- int cpt = 0;
- int num;
- int rc;
- int i;
-
- rc = cfs_cpt_num_estimate();
- if (ncpt <= 0)
- ncpt = rc;
-
- if (ncpt > num_online_cpus() || ncpt > 4 * rc) {
- CWARN("CPU partition number %d is larger than suggested value (%d), your system may have performance issue or run out of memory while under pressure\n",
- ncpt, rc);
- }
-
- if (num_online_cpus() % ncpt) {
- CERROR("CPU number %d is not multiple of cpu_npartition %d, please try different cpu_npartitions value or set pattern string by cpu_pattern=STRING\n",
- (int)num_online_cpus(), ncpt);
- goto failed;
- }
-
- cptab = cfs_cpt_table_alloc(ncpt);
- if (!cptab) {
- CERROR("Failed to allocate CPU map(%d)\n", ncpt);
- goto failed;
- }
-
- num = num_online_cpus() / ncpt;
- if (!num) {
- CERROR("CPU changed while setting CPU partition\n");
- goto failed;
- }
-
- if (!zalloc_cpumask_var(&mask, GFP_NOFS)) {
- CERROR("Failed to allocate scratch cpumask\n");
- goto failed;
- }
-
- for_each_online_node(i) {
- cfs_node_to_cpumask(i, mask);
-
- while (!cpumask_empty(mask)) {
- struct cfs_cpu_partition *part;
- int n;
-
- /*
- * Each emulated NUMA node has all allowed CPUs in
- * the mask.
- * End loop when all partitions have assigned CPUs.
- */
- if (cpt == ncpt)
- break;
-
- part = &cptab->ctb_parts[cpt];
-
- n = num - cpumask_weight(part->cpt_cpumask);
- LASSERT(n > 0);
-
- rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
- if (rc < 0)
- goto failed_mask;
-
- LASSERT(num >= cpumask_weight(part->cpt_cpumask));
- if (num == cpumask_weight(part->cpt_cpumask))
- cpt++;
- }
- }
-
- if (cpt != ncpt ||
- num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
- CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n",
- cptab->ctb_nparts, num, cpt,
- cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask));
- goto failed_mask;
- }
-
- free_cpumask_var(mask);
-
- return cptab;
-
- failed_mask:
- free_cpumask_var(mask);
- failed:
- CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
- ncpt, num_online_nodes(), num_online_cpus());
-
- if (cptab)
- cfs_cpt_table_free(cptab);
-
- return NULL;
-}
-
-static struct cfs_cpt_table *
-cfs_cpt_table_create_pattern(char *pattern)
-{
- struct cfs_cpt_table *cptab;
- char *str;
- int node = 0;
- int high;
- int ncpt = 0;
- int cpt;
- int rc;
- int c;
- int i;
-
- str = strim(pattern);
- if (*str == 'n' || *str == 'N') {
- pattern = str + 1;
- if (*pattern != '\0') {
- node = 1;
- } else { /* shortcut to create CPT from NUMA & CPU topology */
- node = -1;
- ncpt = num_online_nodes();
- }
- }
-
- if (!ncpt) { /* scanning bracket which is mark of partition */
- for (str = pattern;; str++, ncpt++) {
- str = strchr(str, '[');
- if (!str)
- break;
- }
- }
-
- if (!ncpt ||
- (node && ncpt > num_online_nodes()) ||
- (!node && ncpt > num_online_cpus())) {
- CERROR("Invalid pattern %s, or too many partitions %d\n",
- pattern, ncpt);
- return NULL;
- }
-
- cptab = cfs_cpt_table_alloc(ncpt);
- if (!cptab) {
- CERROR("Failed to allocate cpu partition table\n");
- return NULL;
- }
-
- if (node < 0) { /* shortcut to create CPT from NUMA & CPU topology */
- cpt = 0;
-
- for_each_online_node(i) {
- if (cpt >= ncpt) {
- CERROR("CPU changed while setting CPU partition table, %d/%d\n",
- cpt, ncpt);
- goto failed;
- }
-
- rc = cfs_cpt_set_node(cptab, cpt++, i);
- if (!rc)
- goto failed;
- }
- return cptab;
- }
-
- high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
-
- for (str = strim(pattern), c = 0;; c++) {
- struct cfs_range_expr *range;
- struct cfs_expr_list *el;
- char *bracket = strchr(str, '[');
- int n;
-
- if (!bracket) {
- if (*str) {
- CERROR("Invalid pattern %s\n", str);
- goto failed;
- }
- if (c != ncpt) {
- CERROR("expect %d partitions but found %d\n",
- ncpt, c);
- goto failed;
- }
- break;
- }
-
- if (sscanf(str, "%d%n", &cpt, &n) < 1) {
- CERROR("Invalid cpu pattern %s\n", str);
- goto failed;
- }
-
- if (cpt < 0 || cpt >= ncpt) {
- CERROR("Invalid partition id %d, total partitions %d\n",
- cpt, ncpt);
- goto failed;
- }
-
- if (cfs_cpt_weight(cptab, cpt)) {
- CERROR("Partition %d has already been set.\n", cpt);
- goto failed;
- }
-
- str = strim(str + n);
- if (str != bracket) {
- CERROR("Invalid pattern %s\n", str);
- goto failed;
- }
-
- bracket = strchr(str, ']');
- if (!bracket) {
- CERROR("missing right bracket for cpt %d, %s\n",
- cpt, str);
- goto failed;
- }
-
- if (cfs_expr_list_parse(str, (bracket - str) + 1,
- 0, high, &el)) {
- CERROR("Can't parse number range: %s\n", str);
- goto failed;
- }
-
- list_for_each_entry(range, &el->el_exprs, re_link) {
- for (i = range->re_lo; i <= range->re_hi; i++) {
- if ((i - range->re_lo) % range->re_stride)
- continue;
-
- rc = node ? cfs_cpt_set_node(cptab, cpt, i) :
- cfs_cpt_set_cpu(cptab, cpt, i);
- if (!rc) {
- cfs_expr_list_free(el);
- goto failed;
- }
- }
- }
-
- cfs_expr_list_free(el);
-
- if (!cfs_cpt_online(cptab, cpt)) {
- CERROR("No online CPU is found on partition %d\n", cpt);
- goto failed;
- }
-
- str = strim(bracket + 1);
- }
-
- return cptab;
-
- failed:
- cfs_cpt_table_free(cptab);
- return NULL;
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-static enum cpuhp_state lustre_cpu_online;
-
-static void cfs_cpu_incr_cpt_version(void)
-{
- spin_lock(&cpt_data.cpt_lock);
- cpt_data.cpt_version++;
- spin_unlock(&cpt_data.cpt_lock);
-}
-
-static int cfs_cpu_online(unsigned int cpu)
-{
- cfs_cpu_incr_cpt_version();
- return 0;
-}
-
-static int cfs_cpu_dead(unsigned int cpu)
-{
- bool warn;
-
- cfs_cpu_incr_cpt_version();
-
- mutex_lock(&cpt_data.cpt_mutex);
- /* if all HTs in a core are offline, it may break affinity */
- cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu));
- warn = cpumask_any_and(cpt_data.cpt_cpumask,
- cpu_online_mask) >= nr_cpu_ids;
- mutex_unlock(&cpt_data.cpt_mutex);
- CDEBUG(warn ? D_WARNING : D_INFO,
- "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n",
- cpu);
- return 0;
-}
-#endif
-
-void
-cfs_cpu_fini(void)
-{
- if (cfs_cpt_table)
- cfs_cpt_table_free(cfs_cpt_table);
-
-#ifdef CONFIG_HOTPLUG_CPU
- if (lustre_cpu_online > 0)
- cpuhp_remove_state_nocalls(lustre_cpu_online);
- cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD);
-#endif
- free_cpumask_var(cpt_data.cpt_cpumask);
-}
-
-int
-cfs_cpu_init(void)
-{
- int ret = 0;
-
- LASSERT(!cfs_cpt_table);
-
- memset(&cpt_data, 0, sizeof(cpt_data));
-
- if (!zalloc_cpumask_var(&cpt_data.cpt_cpumask, GFP_NOFS)) {
- CERROR("Failed to allocate scratch buffer\n");
- return -1;
- }
-
- spin_lock_init(&cpt_data.cpt_lock);
- mutex_init(&cpt_data.cpt_mutex);
-
-#ifdef CONFIG_HOTPLUG_CPU
- ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD,
- "staging/lustre/cfe:dead", NULL,
- cfs_cpu_dead);
- if (ret < 0)
- goto failed;
- ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
- "staging/lustre/cfe:online",
- cfs_cpu_online, NULL);
- if (ret < 0)
- goto failed;
- lustre_cpu_online = ret;
-#endif
- ret = -EINVAL;
-
- if (*cpu_pattern) {
- char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
-
- if (!cpu_pattern_dup) {
- CERROR("Failed to duplicate cpu_pattern\n");
- goto failed;
- }
-
- cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern_dup);
- kfree(cpu_pattern_dup);
- if (!cfs_cpt_table) {
- CERROR("Failed to create cptab from pattern %s\n",
- cpu_pattern);
- goto failed;
- }
-
- } else {
- cfs_cpt_table = cfs_cpt_table_create(cpu_npartitions);
- if (!cfs_cpt_table) {
- CERROR("Failed to create ptable with npartitions %d\n",
- cpu_npartitions);
- goto failed;
- }
- }
-
- spin_lock(&cpt_data.cpt_lock);
- if (cfs_cpt_table->ctb_version != cpt_data.cpt_version) {
- spin_unlock(&cpt_data.cpt_lock);
- CERROR("CPU hotplug/unplug during setup\n");
- goto failed;
- }
- spin_unlock(&cpt_data.cpt_lock);
-
- LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
- num_online_nodes(), num_online_cpus(),
- cfs_cpt_number(cfs_cpt_table));
- return 0;
-
- failed:
- cfs_cpu_fini();
- return ret;
-}
-
-#endif
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
deleted file mode 100644
index ddf625669bff..000000000000
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ /dev/null
@@ -1,197 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <linux/libcfs/libcfs.h>
-
-#define LNET_MINOR 240
-
-static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
-{
- size_t len = sizeof(*data);
-
- len += cfs_size_round(data->ioc_inllen1);
- len += cfs_size_round(data->ioc_inllen2);
- return len;
-}
-
-static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
-{
- if (data->ioc_hdr.ioc_len > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
- return true;
- }
- if (data->ioc_inllen1 > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
- return true;
- }
- if (data->ioc_inllen2 > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
- return true;
- }
- if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
- CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
- return true;
- }
- if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
- CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
- return true;
- }
- if (data->ioc_pbuf1 && !data->ioc_plen1) {
- CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
- return true;
- }
- if (data->ioc_pbuf2 && !data->ioc_plen2) {
- CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
- return true;
- }
- if (data->ioc_plen1 && !data->ioc_pbuf1) {
- CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
- return true;
- }
- if (data->ioc_plen2 && !data->ioc_pbuf2) {
- CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
- return true;
- }
- if ((u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
- CERROR("LIBCFS ioctl: packlen != ioc_len\n");
- return true;
- }
- if (data->ioc_inllen1 &&
- data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
- return true;
- }
- if (data->ioc_inllen2 &&
- data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
- data->ioc_inllen2 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
- return true;
- }
- return false;
-}
-
-int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
-{
- if (libcfs_ioctl_is_invalid(data)) {
- CERROR("libcfs ioctl: parameter not correctly formatted\n");
- return -EINVAL;
- }
-
- if (data->ioc_inllen1)
- data->ioc_inlbuf1 = &data->ioc_bulk[0];
-
- if (data->ioc_inllen2)
- data->ioc_inlbuf2 = &data->ioc_bulk[0] +
- cfs_size_round(data->ioc_inllen1);
-
- return 0;
-}
-
-int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
- const struct libcfs_ioctl_hdr __user *uhdr)
-{
- struct libcfs_ioctl_hdr hdr;
- int err;
-
- if (copy_from_user(&hdr, uhdr, sizeof(hdr)))
- return -EFAULT;
-
- if (hdr.ioc_version != LIBCFS_IOCTL_VERSION &&
- hdr.ioc_version != LIBCFS_IOCTL_VERSION2) {
- CERROR("libcfs ioctl: version mismatch expected %#x, got %#x\n",
- LIBCFS_IOCTL_VERSION, hdr.ioc_version);
- return -EINVAL;
- }
-
- if (hdr.ioc_len < sizeof(hdr)) {
- CERROR("libcfs ioctl: user buffer too small for ioctl\n");
- return -EINVAL;
- }
-
- if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) {
- CERROR("libcfs ioctl: user buffer is too large %d/%d\n",
- hdr.ioc_len, LIBCFS_IOC_DATA_MAX);
- return -EINVAL;
- }
-
- *hdr_pp = kvmalloc(hdr.ioc_len, GFP_KERNEL);
- if (!*hdr_pp)
- return -ENOMEM;
-
- if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) {
- err = -EFAULT;
- goto free;
- }
-
- if ((*hdr_pp)->ioc_version != hdr.ioc_version ||
- (*hdr_pp)->ioc_len != hdr.ioc_len) {
- err = -EINVAL;
- goto free;
- }
-
- return 0;
-
-free:
- kvfree(*hdr_pp);
- return err;
-}
-
-static long
-libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
-
- if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
- _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR ||
- _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) {
- CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
- _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
- return -EINVAL;
- }
-
- return libcfs_ioctl(cmd, (void __user *)arg);
-}
-
-static const struct file_operations libcfs_fops = {
- .owner = THIS_MODULE,
- .unlocked_ioctl = libcfs_psdev_ioctl,
-};
-
-struct miscdevice libcfs_dev = {
- .minor = LNET_MINOR,
- .name = "lnet",
- .fops = &libcfs_fops,
-};
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index a03f924f1d7c..5dc7de9e6478 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -30,6 +30,7 @@
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
+#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
@@ -51,7 +52,6 @@
# define DEBUG_SUBSYSTEM S_LNET
-#include <linux/libcfs/libcfs.h>
#include <asm/div64.h>
#include <linux/libcfs/libcfs_crypto.h>
@@ -59,42 +59,148 @@
#include <uapi/linux/lnet/lnet-dlc.h>
#include "tracefile.h"
+struct lnet_debugfs_symlink_def {
+ char *name;
+ char *target;
+};
+
static struct dentry *lnet_debugfs_root;
-static DECLARE_RWSEM(ioctl_list_sem);
-static LIST_HEAD(ioctl_list);
+BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list);
+EXPORT_SYMBOL(libcfs_ioctl_list);
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
+static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
{
- int rc = 0;
+ size_t len = sizeof(*data);
- down_write(&ioctl_list_sem);
- if (!list_empty(&hand->item))
- rc = -EBUSY;
- else
- list_add_tail(&hand->item, &ioctl_list);
- up_write(&ioctl_list_sem);
+ len += cfs_size_round(data->ioc_inllen1);
+ len += cfs_size_round(data->ioc_inllen2);
+ return len;
+}
- return rc;
+static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
+{
+ if (data->ioc_hdr.ioc_len > BIT(30)) {
+ CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
+ return true;
+ }
+ if (data->ioc_inllen1 > BIT(30)) {
+ CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
+ return true;
+ }
+ if (data->ioc_inllen2 > BIT(30)) {
+ CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
+ return true;
+ }
+ if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
+ CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
+ return true;
+ }
+ if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
+ CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
+ return true;
+ }
+ if (data->ioc_pbuf1 && !data->ioc_plen1) {
+ CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
+ return true;
+ }
+ if (data->ioc_pbuf2 && !data->ioc_plen2) {
+ CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
+ return true;
+ }
+ if (data->ioc_plen1 && !data->ioc_pbuf1) {
+ CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
+ return true;
+ }
+ if (data->ioc_plen2 && !data->ioc_pbuf2) {
+ CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
+ return true;
+ }
+ if ((u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
+ CERROR("LIBCFS ioctl: packlen != ioc_len\n");
+ return true;
+ }
+ if (data->ioc_inllen1 &&
+ data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
+ CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
+ return true;
+ }
+ if (data->ioc_inllen2 &&
+ data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
+ data->ioc_inllen2 - 1] != '\0') {
+ CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
+ return true;
+ }
+ return false;
}
-EXPORT_SYMBOL(libcfs_register_ioctl);
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
+static int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
{
- int rc = 0;
+ if (libcfs_ioctl_is_invalid(data)) {
+ CERROR("libcfs ioctl: parameter not correctly formatted\n");
+ return -EINVAL;
+ }
- down_write(&ioctl_list_sem);
- if (list_empty(&hand->item))
- rc = -ENOENT;
- else
- list_del_init(&hand->item);
- up_write(&ioctl_list_sem);
+ if (data->ioc_inllen1)
+ data->ioc_inlbuf1 = &data->ioc_bulk[0];
- return rc;
+ if (data->ioc_inllen2)
+ data->ioc_inlbuf2 = &data->ioc_bulk[0] +
+ cfs_size_round(data->ioc_inllen1);
+
+ return 0;
}
-EXPORT_SYMBOL(libcfs_deregister_ioctl);
-int libcfs_ioctl(unsigned long cmd, void __user *uparam)
+static int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+ const struct libcfs_ioctl_hdr __user *uhdr)
+{
+ struct libcfs_ioctl_hdr hdr;
+ int err;
+
+ if (copy_from_user(&hdr, uhdr, sizeof(hdr)))
+ return -EFAULT;
+
+ if (hdr.ioc_version != LIBCFS_IOCTL_VERSION &&
+ hdr.ioc_version != LIBCFS_IOCTL_VERSION2) {
+ CERROR("libcfs ioctl: version mismatch expected %#x, got %#x\n",
+ LIBCFS_IOCTL_VERSION, hdr.ioc_version);
+ return -EINVAL;
+ }
+
+ if (hdr.ioc_len < sizeof(hdr)) {
+ CERROR("libcfs ioctl: user buffer too small for ioctl\n");
+ return -EINVAL;
+ }
+
+ if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) {
+ CERROR("libcfs ioctl: user buffer is too large %d/%d\n",
+ hdr.ioc_len, LIBCFS_IOC_DATA_MAX);
+ return -EINVAL;
+ }
+
+ *hdr_pp = kvmalloc(hdr.ioc_len, GFP_KERNEL);
+ if (!*hdr_pp)
+ return -ENOMEM;
+
+ if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) {
+ err = -EFAULT;
+ goto free;
+ }
+
+ if ((*hdr_pp)->ioc_version != hdr.ioc_version ||
+ (*hdr_pp)->ioc_len != hdr.ioc_len) {
+ err = -EINVAL;
+ goto free;
+ }
+
+ return 0;
+
+free:
+ kvfree(*hdr_pp);
+ return err;
+}
+
+static int libcfs_ioctl(unsigned long cmd, void __user *uparam)
{
struct libcfs_ioctl_data *data = NULL;
struct libcfs_ioctl_hdr *hdr;
@@ -136,30 +242,54 @@ int libcfs_ioctl(unsigned long cmd, void __user *uparam)
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
break;
- default: {
- struct libcfs_ioctl_handler *hand;
-
- err = -EINVAL;
- down_read(&ioctl_list_sem);
- list_for_each_entry(hand, &ioctl_list, item) {
- err = hand->handle_ioctl(cmd, hdr);
- if (err == -EINVAL)
- continue;
-
- if (!err) {
- if (copy_to_user(uparam, hdr, hdr->ioc_len))
- err = -EFAULT;
- }
- break;
- }
- up_read(&ioctl_list_sem);
- break; }
+ default:
+ err = blocking_notifier_call_chain(&libcfs_ioctl_list,
+ cmd, hdr);
+ if (!(err & NOTIFY_STOP_MASK))
+ /* No-one claimed the ioctl */
+ err = -EINVAL;
+ else
+ err = notifier_to_errno(err);
+ if (!err)
+ if (copy_to_user(uparam, hdr, hdr->ioc_len))
+ err = -EFAULT;
+ break;
}
out:
kvfree(hdr);
return err;
}
+static long
+libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
+
+ if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
+ _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR ||
+ _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) {
+ CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
+ _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
+ return -EINVAL;
+ }
+
+ return libcfs_ioctl(cmd, (void __user *)arg);
+}
+
+static const struct file_operations libcfs_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = libcfs_psdev_ioctl,
+};
+
+static struct miscdevice libcfs_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "lnet",
+ .fops = &libcfs_fops,
+};
+
+static int libcfs_dev_registered;
+
int lprocfs_call_handler(void *data, int write, loff_t *ppos,
void __user *buffer, size_t *lenp,
int (*handler)(void *data, int write, loff_t pos,
@@ -299,14 +429,12 @@ static int __proc_cpt_table(void *data, int write,
if (write)
return -EPERM;
- LASSERT(cfs_cpt_table);
-
while (1) {
buf = kzalloc(len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
- rc = cfs_cpt_table_print(cfs_cpt_table, buf, len);
+ rc = cfs_cpt_table_print(cfs_cpt_tab, buf, len);
if (rc >= 0)
break;
@@ -496,8 +624,7 @@ static const struct file_operations *lnet_debugfs_fops_select(umode_t mode)
return &lnet_debugfs_file_operations_rw;
}
-void lustre_insert_debugfs(struct ctl_table *table,
- const struct lnet_debugfs_symlink_def *symlinks)
+void lustre_insert_debugfs(struct ctl_table *table)
{
if (!lnet_debugfs_root)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
@@ -506,19 +633,24 @@ void lustre_insert_debugfs(struct ctl_table *table,
if (IS_ERR_OR_NULL(lnet_debugfs_root))
return;
- /* We don't save the dentry returned in next two calls, because
- * we don't call debugfs_remove() but rather remove_recursive()
+ /*
+ * We don't save the dentry returned because we don't call
+ * debugfs_remove() but rather remove_recursive()
*/
for (; table->procname; table++)
debugfs_create_file(table->procname, table->mode,
lnet_debugfs_root, table,
lnet_debugfs_fops_select(table->mode));
+}
+EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
+static void lustre_insert_debugfs_links(
+ const struct lnet_debugfs_symlink_def *symlinks)
+{
for (; symlinks && symlinks->name; symlinks++)
debugfs_create_symlink(symlinks->name, lnet_debugfs_root,
symlinks->target);
}
-EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
static void lustre_remove_debugfs(void)
{
@@ -527,49 +659,72 @@ static void lustre_remove_debugfs(void)
lnet_debugfs_root = NULL;
}
-static int libcfs_init(void)
+static DEFINE_MUTEX(libcfs_startup);
+static int libcfs_active;
+
+int libcfs_setup(void)
{
- int rc;
+ int rc = -EINVAL;
+
+ mutex_lock(&libcfs_startup);
+ if (libcfs_active)
+ goto out;
+
+ if (!libcfs_dev_registered)
+ goto err;
rc = libcfs_debug_init(5 * 1024 * 1024);
if (rc < 0) {
pr_err("LustreError: libcfs_debug_init: %d\n", rc);
- return rc;
+ goto err;
}
rc = cfs_cpu_init();
if (rc)
- goto cleanup_debug;
-
- rc = misc_register(&libcfs_dev);
- if (rc) {
- CERROR("misc_register: error %d\n", rc);
- goto cleanup_cpu;
- }
+ goto err;
cfs_rehash_wq = alloc_workqueue("cfs_rh", WQ_SYSFS, 4);
if (!cfs_rehash_wq) {
CERROR("Failed to start rehash workqueue.\n");
rc = -ENOMEM;
- goto cleanup_deregister;
+ goto err;
}
rc = cfs_crypto_register();
if (rc) {
CERROR("cfs_crypto_register: error %d\n", rc);
- goto cleanup_deregister;
+ goto err;
}
- lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+ lustre_insert_debugfs(lnet_table);
+ if (!IS_ERR_OR_NULL(lnet_debugfs_root))
+ lustre_insert_debugfs_links(lnet_debugfs_symlinks);
CDEBUG(D_OTHER, "portals setup OK\n");
+out:
+ libcfs_active = 1;
+ mutex_unlock(&libcfs_startup);
return 0;
- cleanup_deregister:
- misc_deregister(&libcfs_dev);
-cleanup_cpu:
+err:
+ cfs_crypto_unregister();
+ if (cfs_rehash_wq)
+ destroy_workqueue(cfs_rehash_wq);
cfs_cpu_fini();
- cleanup_debug:
libcfs_debug_cleanup();
+ mutex_unlock(&libcfs_startup);
+ return rc;
+}
+EXPORT_SYMBOL(libcfs_setup);
+
+static int libcfs_init(void)
+{
+ int rc;
+
+ rc = misc_register(&libcfs_dev);
+ if (rc)
+ CERROR("misc_register: error %d\n", rc);
+ else
+ libcfs_dev_registered = 1;
return rc;
}
@@ -579,14 +734,13 @@ static void libcfs_exit(void)
lustre_remove_debugfs();
- if (cfs_rehash_wq) {
+ if (cfs_rehash_wq)
destroy_workqueue(cfs_rehash_wq);
- cfs_rehash_wq = NULL;
- }
cfs_crypto_unregister();
- misc_deregister(&libcfs_dev);
+ if (libcfs_dev_registered)
+ misc_deregister(&libcfs_dev);
cfs_cpu_fini();
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 4affca750bc5..7ca562e156f0 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -39,9 +39,15 @@
#define DEBUG_SUBSYSTEM S_LNET
#define LUSTRE_TRACEFILE_PRIVATE
#define pr_fmt(fmt) "Lustre: " fmt
-#include "tracefile.h"
-#include <linux/libcfs/libcfs.h>
+#include <linux/ratelimit.h>
+#include <linux/highmem.h>
+#include <linux/ctype.h>
+#include <linux/kthread.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include "tracefile.h"
/* XXX move things up to the top, comment */
union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned;
@@ -114,7 +120,7 @@ static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp)
struct cfs_trace_page *tage;
/* My caller is trying to free memory */
- if (!in_interrupt() && memory_pressure_get())
+ if (!in_interrupt() && (current->flags & PF_MEMALLOC))
return NULL;
/*
@@ -192,7 +198,8 @@ cfs_trace_get_tage_try(struct cfs_trace_cpu_data *tcd, unsigned long len)
} else {
tage = cfs_tage_alloc(GFP_ATOMIC);
if (unlikely(!tage)) {
- if (!memory_pressure_get() || in_interrupt())
+ if (!(current->flags & PF_MEMALLOC) ||
+ in_interrupt())
pr_warn_ratelimited("cannot allocate a tage (%ld)\n",
tcd->tcd_cur_pages);
return NULL;
@@ -328,7 +335,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
goto console;
}
- depth = __current_nesting_level();
+ depth = 0;
known_size = strlen(file) + 1 + depth;
if (msgdata->msg_fn)
known_size += strlen(msgdata->msg_fn) + 1;
@@ -431,7 +438,7 @@ console:
if (cdls) {
if (libcfs_console_ratelimit &&
cdls->cdls_next && /* not first time ever */
- !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
+ !time_after(jiffies, cdls->cdls_next)) {
/* skipping a console message */
cdls->cdls_count++;
if (tcd)
@@ -439,9 +446,9 @@ console:
return 1;
}
- if (cfs_time_after(cfs_time_current(),
- cdls->cdls_next + libcfs_console_max_delay +
- 10 * HZ)) {
+ if (time_after(jiffies,
+ cdls->cdls_next + libcfs_console_max_delay +
+ 10 * HZ)) {
/* last timeout was a long time ago */
cdls->cdls_delay /= libcfs_console_backoff * 4;
} else {
@@ -454,7 +461,7 @@ console:
cdls->cdls_delay = libcfs_console_max_delay;
/* ensure cdls_next is never zero after it's been seen */
- cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
+ cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
}
if (tcd) {
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index a29d6eb3a785..0608240d897f 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -34,6 +34,12 @@
#ifndef __LIBCFS_TRACEFILE_H__
#define __LIBCFS_TRACEFILE_H__
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <linux/cache.h>
+#include <linux/threads.h>
+#include <linux/limits.h>
+#include <linux/smp.h>
#include <linux/libcfs/libcfs.h>
enum cfs_trace_buf_type {
@@ -49,6 +55,11 @@ enum cfs_trace_buf_type {
extern char cfs_tracefile[TRACEFILE_NAME_SIZE];
extern long long cfs_tracefile_size;
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_debug_log_upcall[1024];
+
void libcfs_run_debug_log_upcall(char *file);
int cfs_tracefile_init_arch(void);
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 90266be0132d..f9ed6977056c 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1413,9 +1413,9 @@ int lnet_lib_init(void)
memset(&the_lnet, 0, sizeof(the_lnet));
- /* refer to global cfs_cpt_table for now */
- the_lnet.ln_cpt_table = cfs_cpt_table;
- the_lnet.ln_cpt_number = cfs_cpt_number(cfs_cpt_table);
+ /* refer to global cfs_cpt_tab for now */
+ the_lnet.ln_cpt_table = cfs_cpt_tab;
+ the_lnet.ln_cpt_number = cfs_cpt_number(cfs_cpt_tab);
LASSERT(the_lnet.ln_cpt_number > 0);
if (the_lnet.ln_cpt_number > LNET_CPT_MAX) {
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 0aea268a4f1c..55ecc1998b7e 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -34,6 +34,7 @@
#define DEBUG_SUBSYSTEM S_LNET
#include <linux/nsproxy.h>
#include <net/net_namespace.h>
+#include <linux/ctype.h>
#include <linux/lnet/lib-lnet.h>
struct lnet_text_buf { /* tmp struct for parsing routes */
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c
index ea53b5cb3f72..c78e70373ab4 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -225,7 +225,7 @@ lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event *ev)
lnet_eq_wait_lock();
ev->sequence = eq->eq_enq_seq++;
- LASSERT(eq->eq_size == LOWEST_BIT_SET(eq->eq_size));
+ LASSERT(is_power_of_2(eq->eq_size));
index = ev->sequence & (eq->eq_size - 1);
eq->eq_events[index] = *ev;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index ed43b3f4b114..f8eaf8ff8d8d 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -501,7 +501,7 @@ lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp)
ni->ni_lnd->lnd_query(ni, lp->lp_nid, &last_alive);
lnet_net_lock(lp->lp_cpt);
- lp->lp_last_query = cfs_time_current();
+ lp->lp_last_query = jiffies;
if (last_alive) /* NI has updated timestamp */
lp->lp_last_alive = last_alive;
@@ -520,12 +520,11 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
* ignore the initial assumed death (see lnet_peers_start_down()).
*/
if (!lp->lp_alive && lp->lp_alive_count > 0 &&
- cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
+ time_after_eq(lp->lp_timestamp, lp->lp_last_alive))
return 0;
- deadline = cfs_time_add(lp->lp_last_alive,
- lp->lp_ni->ni_peertimeout * HZ);
- alive = cfs_time_after(deadline, now);
+ deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
+ alive = time_after(deadline, now);
/* Update obsolete lp_alive except for routers assumed to be dead
* initially, because router checker would update aliveness in this
@@ -545,7 +544,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
static int
lnet_peer_alive_locked(struct lnet_peer *lp)
{
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
if (!lnet_peer_aliveness_enabled(lp))
return -ENODEV;
@@ -561,8 +560,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
static const int lnet_queryinterval = 1;
unsigned long next_query =
- cfs_time_add(lp->lp_last_query,
- lnet_queryinterval * HZ);
+ lp->lp_last_query + lnet_queryinterval * HZ;
if (time_before(now, next_query)) {
if (lp->lp_alive)
@@ -2016,7 +2014,7 @@ LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, enum lnet_ack_req ack,
libcfs_id2str(target));
return -ENOMEM;
}
- msg->msg_vmflush = !!memory_pressure_get();
+ msg->msg_vmflush = !!(current->flags & PF_MEMALLOC);
cpt = lnet_cpt_of_cookie(mdh.cookie);
lnet_res_lock(cpt);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 1bee667802b0..9b61260155f2 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -41,7 +41,6 @@
#include <linux/syscalls.h>
#include <net/sock.h>
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
static int
diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
index c0c4723f72fd..9d06664f0c17 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -136,30 +136,37 @@ out_unlock:
}
static int
-lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
+lnet_ioctl(struct notifier_block *nb,
+ unsigned long cmd, void *vdata)
{
int rc;
+ struct libcfs_ioctl_hdr *hdr = vdata;
switch (cmd) {
case IOC_LIBCFS_CONFIGURE: {
struct libcfs_ioctl_data *data =
(struct libcfs_ioctl_data *)hdr;
- if (data->ioc_hdr.ioc_len < sizeof(*data))
- return -EINVAL;
-
- the_lnet.ln_nis_from_mod_params = data->ioc_flags;
- return lnet_configure(NULL);
+ if (data->ioc_hdr.ioc_len < sizeof(*data)) {
+ rc = -EINVAL;
+ } else {
+ the_lnet.ln_nis_from_mod_params = data->ioc_flags;
+ rc = lnet_configure(NULL);
+ }
+ break;
}
case IOC_LIBCFS_UNCONFIGURE:
- return lnet_unconfigure();
+ rc = lnet_unconfigure();
+ break;
case IOC_LIBCFS_ADD_NET:
- return lnet_dyn_configure(hdr);
+ rc = lnet_dyn_configure(hdr);
+ break;
case IOC_LIBCFS_DEL_NET:
- return lnet_dyn_unconfigure(hdr);
+ rc = lnet_dyn_unconfigure(hdr);
+ break;
default:
/*
@@ -172,11 +179,14 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
rc = LNetCtl(cmd, hdr);
LNetNIFini();
}
- return rc;
+ break;
}
+ return notifier_from_ioctl_errno(rc);
}
-static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
+static struct notifier_block lnet_ioctl_handler = {
+ .notifier_call = lnet_ioctl,
+};
static int __init lnet_init(void)
{
@@ -184,13 +194,18 @@ static int __init lnet_init(void)
mutex_init(&lnet_config_mutex);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
rc = lnet_lib_init();
if (rc) {
CERROR("lnet_lib_init: error %d\n", rc);
return rc;
}
- rc = libcfs_register_ioctl(&lnet_ioctl_handler);
+ rc = blocking_notifier_chain_register(&libcfs_ioctl_list,
+ &lnet_ioctl_handler);
LASSERT(!rc);
if (config_on_load) {
@@ -208,7 +223,8 @@ static void __exit lnet_exit(void)
{
int rc;
- rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
+ rc = blocking_notifier_chain_unregister(&libcfs_ioctl_list,
+ &lnet_ioctl_handler);
LASSERT(!rc);
lnet_lib_exit();
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index a63b7941d435..0066394b0bb0 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
rule->dr_attr = *attr;
if (attr->u.drop.da_interval) {
- rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
- rule->dr_drop_time = cfs_time_shift(
- prandom_u32_max(attr->u.drop.da_interval));
+ rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
+ rule->dr_drop_time = jiffies +
+ prandom_u32_max(attr->u.drop.da_interval) * HZ;
} else {
rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
}
@@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
if (attr->u.drop.da_rate) {
rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
} else {
- rule->dr_drop_time = cfs_time_shift(
- prandom_u32_max(attr->u.drop.da_interval));
- rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
+ rule->dr_drop_time = jiffies +
+ prandom_u32_max(attr->u.drop.da_interval) * HZ;
+ rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
}
spin_unlock(&rule->dr_lock);
}
@@ -306,12 +306,12 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
/* match this rule, check drop rate now */
spin_lock(&rule->dr_lock);
if (rule->dr_drop_time) { /* time based drop */
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
rule->dr_stat.fs_count++;
- drop = cfs_time_aftereq(now, rule->dr_drop_time);
+ drop = time_after_eq(now, rule->dr_drop_time);
if (drop) {
- if (cfs_time_after(now, rule->dr_time_base))
+ if (time_after(now, rule->dr_time_base))
rule->dr_time_base = now;
rule->dr_drop_time = rule->dr_time_base +
@@ -472,12 +472,12 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
/* match this rule, check delay rate now */
spin_lock(&rule->dl_lock);
if (rule->dl_delay_time) { /* time based delay */
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
rule->dl_stat.fs_count++;
- delay = cfs_time_aftereq(now, rule->dl_delay_time);
+ delay = time_after_eq(now, rule->dl_delay_time);
if (delay) {
- if (cfs_time_after(now, rule->dl_time_base))
+ if (time_after(now, rule->dl_time_base))
rule->dl_time_base = now;
rule->dl_delay_time = rule->dl_time_base +
@@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
list_add_tail(&msg->msg_list, &rule->dl_msg_list);
msg->msg_delay_send = round_timeout(
- cfs_time_shift(attr->u.delay.la_latency));
+ jiffies + attr->u.delay.la_latency * HZ);
if (rule->dl_msg_send == -1) {
rule->dl_msg_send = msg->msg_delay_send;
mod_timer(&rule->dl_timer, rule->dl_msg_send);
@@ -562,7 +562,7 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all,
{
struct lnet_msg *msg;
struct lnet_msg *tmp;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
if (!all && rule->dl_msg_send > now)
return;
@@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
rule->dl_attr = *attr;
if (attr->u.delay.la_interval) {
- rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
- rule->dl_delay_time = cfs_time_shift(
- prandom_u32_max(attr->u.delay.la_interval));
+ rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
+ rule->dl_delay_time = jiffies +
+ prandom_u32_max(attr->u.delay.la_interval) * HZ;
} else {
rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
}
@@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
} else {
rule->dl_delay_time =
- cfs_time_shift(prandom_u32_max(
- attr->u.delay.la_interval));
- rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
+ jiffies + prandom_u32_max(
+ attr->u.delay.la_interval) * HZ;
+ rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
}
spin_unlock(&rule->dl_lock);
}
diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c
index 3aba1421c741..0f6c3fa16c65 100644
--- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
+++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -37,7 +37,10 @@
#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/spinlock.h>
+#include <linux/slab.h>
#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_string.h>
#include <uapi/linux/lnet/nidstr.h>
/* max value for numeric network address */
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 3d4caa609c83..58294149f7b2 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -315,7 +315,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
lp->lp_alive_count = 0;
lp->lp_timestamp = 0;
lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
- lp->lp_last_alive = cfs_time_current(); /* assumes alive */
+ lp->lp_last_alive = jiffies; /* assumes alive */
lp->lp_last_query = 0; /* haven't asked NI yet */
lp->lp_ping_timestamp = 0;
lp->lp_ping_feats = LNET_PING_FEAT_INVAL;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index a3c3f4959f46..6267d5e4bbd6 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -765,7 +765,7 @@ lnet_router_checker_event(struct lnet_event *event)
* we ping alive routers to try to detect router death before
* apps get burned).
*/
- lnet_notify_locked(lp, 1, !event->status, cfs_time_current());
+ lnet_notify_locked(lp, 1, !event->status, jiffies);
/*
* The router checker will wake up very shortly and do the
@@ -976,13 +976,13 @@ static void
lnet_ping_router_locked(struct lnet_peer *rtr)
{
struct lnet_rc_data *rcd = NULL;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
int secs;
lnet_peer_addref_locked(rtr);
if (rtr->lp_ping_deadline && /* ping timed out? */
- cfs_time_after(now, rtr->lp_ping_deadline))
+ time_after(now, rtr->lp_ping_deadline))
lnet_notify_locked(rtr, 1, 0, now);
/* Run any outstanding notifications */
@@ -1010,8 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
if (secs && !rtr->lp_ping_notsent &&
- cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
- secs * HZ))) {
+ time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
int rc;
struct lnet_process_id id;
struct lnet_handle_md mdh;
@@ -1027,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
if (!rtr->lp_ping_deadline) {
rtr->lp_ping_deadline =
- cfs_time_shift(router_ping_timeout);
+ jiffies + router_ping_timeout * HZ;
}
lnet_net_unlock(rtr->lp_cpt);
@@ -1730,7 +1729,7 @@ int
lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
{
struct lnet_peer *lp = NULL;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
int cpt = lnet_cpt_of_nid(nid);
LASSERT(!in_interrupt());
@@ -1749,11 +1748,11 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
}
/* can't do predictions... */
- if (cfs_time_after(when, now)) {
+ if (time_after(when, now)) {
CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
!ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
libcfs_nid2str(nid), alive ? "up" : "down",
- cfs_duration_sec(cfs_time_sub(when, now)));
+ (when - now) / HZ);
return -EINVAL;
}
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 1a71ffebc889..ae4b7f5953a0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -20,7 +20,6 @@
#define DEBUG_SUBSYSTEM S_LNET
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
/*
@@ -324,15 +323,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
if (peer) {
lnet_nid_t nid = peer->lp_nid;
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
unsigned long deadline = peer->lp_ping_deadline;
int nrefs = peer->lp_refcount;
int nrtrrefs = peer->lp_rtr_refcount;
int alive_cnt = peer->lp_alive_count;
int alive = peer->lp_alive;
int pingsent = !peer->lp_ping_notsent;
- int last_ping = cfs_duration_sec(cfs_time_sub(now,
- peer->lp_ping_timestamp));
+ int last_ping = (now - peer->lp_ping_timestamp) / HZ;
int down_ni = 0;
struct lnet_route *rtr;
@@ -364,7 +362,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
nrefs, nrtrrefs, alive_cnt,
alive ? "up" : "down", last_ping,
pingsent,
- cfs_duration_sec(cfs_time_sub(deadline, now)),
+ (deadline - now) / HZ,
down_ni, libcfs_nid2str(nid));
LASSERT(tmpstr + tmpsiz - s > 0);
}
@@ -509,11 +507,11 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
aliveness = peer->lp_alive ? "up" : "down";
if (lnet_peer_aliveness_enabled(peer)) {
- unsigned long now = cfs_time_current();
+ unsigned long now = jiffies;
long delta;
- delta = cfs_time_sub(now, peer->lp_last_alive);
- lastalive = cfs_duration_sec(delta);
+ delta = now - peer->lp_last_alive;
+ lastalive = (delta) / HZ;
/* No need to mess up peers contents with
* arbitrarily long integers - it suffices to
@@ -901,7 +899,7 @@ static struct ctl_table lnet_table[] = {
void lnet_router_debugfs_init(void)
{
- lustre_insert_debugfs(lnet_table, NULL);
+ lustre_insert_debugfs(lnet_table);
}
void lnet_router_debugfs_fini(void)
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c
index a2d8092bdeb7..906d82d90c0c 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -37,7 +37,6 @@
* Author: Liang Zhen <liangzhen@clusterfs.com>
*/
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#include <uapi/linux/lnet/lnetst.h>
#include "console.h"
@@ -680,32 +679,34 @@ out:
}
int
-lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
+lstcon_ioctl_entry(struct notifier_block *nb,
+ unsigned long cmd, void *vdata)
{
- char *buf;
+ struct libcfs_ioctl_hdr *hdr = vdata;
+ char *buf = NULL;
struct libcfs_ioctl_data *data;
int opc;
- int rc;
+ int rc = -EINVAL;
if (cmd != IOC_LIBCFS_LNETST)
- return -EINVAL;
+ goto err;
data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr);
opc = data->ioc_u32[0];
if (data->ioc_plen1 > PAGE_SIZE)
- return -EINVAL;
+ goto err;
buf = kmalloc(data->ioc_plen1, GFP_KERNEL);
+ rc = -ENOMEM;
if (!buf)
- return -ENOMEM;
+ goto err;
/* copy in parameter */
- if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
- kfree(buf);
- return -EFAULT;
- }
+ rc = -EFAULT;
+ if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1))
+ goto err;
mutex_lock(&console_session.ses_mutex);
@@ -785,6 +786,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
break;
default:
rc = -EINVAL;
+ goto out;
}
if (copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat,
@@ -792,8 +794,8 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
rc = -EFAULT;
out:
mutex_unlock(&console_session.ses_mutex);
-
+err:
kfree(buf);
- return rc;
+ return notifier_from_ioctl_errno(rc);
}
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 6dcc966b293b..0dabade3d091 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -37,7 +37,6 @@
* Author: Liang Zhen <liang@whamcloud.com>
*/
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#include "timer.h"
#include "conrpc.h"
@@ -75,7 +74,7 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
/* not aborted */
LASSERT(!crpc->crp_status);
- crpc->crp_stamp = cfs_time_current();
+ crpc->crp_stamp = jiffies;
crpc->crp_status = rpc->crpc_status;
}
@@ -297,14 +296,14 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
if (!crpc->crp_posted || /* not posted */
crpc->crp_stamp) { /* rpc done or aborted already */
if (!crpc->crp_stamp) {
- crpc->crp_stamp = cfs_time_current();
+ crpc->crp_stamp = jiffies;
crpc->crp_status = -EINTR;
}
spin_unlock(&rpc->crpc_lock);
continue;
}
- crpc->crp_stamp = cfs_time_current();
+ crpc->crp_stamp = jiffies;
crpc->crp_status = error;
spin_unlock(&rpc->crpc_lock);
@@ -315,7 +314,7 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
continue;
nd = crpc->crp_node;
- if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+ if (time_after(nd->nd_stamp, crpc->crp_stamp))
continue;
nd->nd_stamp = crpc->crp_stamp;
@@ -404,7 +403,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
crpc->crp_unpacked = 1;
}
- if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+ if (time_after(nd->nd_stamp, crpc->crp_stamp))
return 0;
nd->nd_stamp = crpc->crp_stamp;
@@ -500,8 +499,8 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
nd = crpc->crp_node;
- dur = (long)cfs_time_sub(crpc->crp_stamp,
- (unsigned long)console_session.ses_id.ses_stamp);
+ dur = (long)(crpc->crp_stamp -
+ (unsigned long)console_session.ses_id.ses_stamp);
jiffies_to_timeval(dur, &tv);
if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h
index 374a5f31ef6f..ce2f92d04838 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -40,7 +40,6 @@
#ifndef __LST_CONRPC_H__
#define __LST_CONRPC_H__
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-types.h>
#include <uapi/linux/lnet/lnetst.h>
#include "rpc.h"
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 1acd5cb324b1..3c1c1b5997e0 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -37,7 +37,6 @@
* Author: Liang Zhen <liangzhen@clusterfs.com>
*/
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#include "console.h"
#include "conrpc.h"
@@ -98,7 +97,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
ndl->ndl_node->nd_ref = 1;
ndl->ndl_node->nd_id = id;
- ndl->ndl_node->nd_stamp = cfs_time_current();
+ ndl->ndl_node->nd_stamp = jiffies;
ndl->ndl_node->nd_state = LST_NODE_UNKNOWN;
ndl->ndl_node->nd_timeout = 0;
memset(&ndl->ndl_node->nd_ping, 0, sizeof(struct lstcon_rpc));
@@ -1701,7 +1700,7 @@ lstcon_new_session_id(struct lst_sid *sid)
LNetGetId(1, &id);
sid->ses_nid = id.nid;
- sid->ses_stamp = cfs_time_current();
+ sid->ses_stamp = jiffies;
}
int
@@ -1996,7 +1995,9 @@ static void lstcon_init_acceptor_service(void)
lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX;
}
-static DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry);
+static struct notifier_block lstcon_ioctl_handler = {
+ .notifier_call = lstcon_ioctl_entry,
+};
/* initialize console */
int
@@ -2048,7 +2049,8 @@ lstcon_console_init(void)
goto out;
}
- rc = libcfs_register_ioctl(&lstcon_ioctl_handler);
+ rc = blocking_notifier_chain_register(&libcfs_ioctl_list,
+ &lstcon_ioctl_handler);
if (!rc) {
lstcon_rpc_module_init();
@@ -2071,7 +2073,8 @@ lstcon_console_fini(void)
{
int i;
- libcfs_deregister_ioctl(&lstcon_ioctl_handler);
+ blocking_notifier_chain_unregister(&libcfs_ioctl_list,
+ &lstcon_ioctl_handler);
mutex_lock(&console_session.ses_mutex);
diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h
index 3933ed4cca93..2826205e36a1 100644
--- a/drivers/staging/lustre/lnet/selftest/console.h
+++ b/drivers/staging/lustre/lnet/selftest/console.h
@@ -40,7 +40,6 @@
#ifndef __LST_CONSOLE_H__
#define __LST_CONSOLE_H__
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-types.h>
#include <uapi/linux/lnet/lnetst.h>
#include "selftest.h"
@@ -187,7 +186,8 @@ lstcon_id2hash(struct lnet_process_id id, struct list_head *hash)
return &hash[idx];
}
-int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
+int lstcon_ioctl_entry(struct notifier_block *nb,
+ unsigned long cmd, void *vdata);
int lstcon_console_init(void);
int lstcon_console_fini(void);
int lstcon_session_match(struct lst_sid sid);
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index 0ca1e3a780ca..741af10560ad 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -272,7 +272,7 @@ sfw_init_session(struct sfw_session *sn, struct lst_sid sid,
sn->sn_id = sid;
sn->sn_features = features;
sn->sn_timeout = session_timeout;
- sn->sn_started = cfs_time_current();
+ sn->sn_started = jiffies;
timer->stt_data = sn;
timer->stt_func = sfw_session_expired;
@@ -588,7 +588,7 @@ sfw_load_test(struct sfw_test_instance *tsi)
CDEBUG(D_NET, "Reserved %d buffers for test %s\n",
nbuf * (srpc_serv_is_framework(svc) ?
- 2 : cfs_cpt_number(cfs_cpt_table)), svc->sv_name);
+ 2 : cfs_cpt_number(cfs_cpt_tab)), svc->sv_name);
return 0;
}
diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c
index 7359aa56d9b3..9ba65320f748 100644
--- a/drivers/staging/lustre/lnet/selftest/module.c
+++ b/drivers/staging/lustre/lnet/selftest/module.c
@@ -89,9 +89,13 @@ static int
lnet_selftest_init(void)
{
int nscheds;
- int rc = -ENOMEM;
+ int rc;
int i;
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
lst_serial_wq = alloc_ordered_workqueue("lst_s", 0);
if (!lst_serial_wq) {
CERROR("Failed to create serial WI scheduler for LST\n");
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
index 05466b85e1c0..8737fa96b192 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -39,7 +39,6 @@
#define LNET_ONLY
-#include <linux/libcfs/libcfs.h>
#include <linux/lnet/lib-lnet.h>
#include <linux/lnet/lib-types.h>
#include <uapi/linux/lnet/lnetst.h>
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 1b2c5fc81358..582f252b3e12 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -155,9 +155,9 @@ stt_check_timers(unsigned long *last)
spin_lock(&stt_data.stt_lock);
- while (cfs_time_aftereq(this_slot, *last)) {
+ while (time_after_eq(this_slot, *last)) {
expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
- this_slot = cfs_time_sub(this_slot, STTIMER_SLOTTIME);
+ this_slot = this_slot - STTIMER_SLOTTIME;
}
*last = now & STTIMER_SLOTTIMEMASK;
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h
index b7b8f900df8e..14569e969a31 100644
--- a/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -38,7 +38,6 @@
#define __FID_INTERNAL_H
#include <uapi/linux/lustre/lustre_idl.h>
-#include <linux/libcfs/libcfs.h>
/* Functions used internally in module. */
diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c
index 9577da33e666..ac52b378c155 100644
--- a/drivers/staging/lustre/lustre/fid/fid_lib.c
+++ b/drivers/staging/lustre/lustre/fid/fid_lib.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_FID
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <lustre_fid.h>
diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c
index 030680f37c79..c674652af03a 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -39,7 +39,6 @@
#define DEBUG_SUBSYSTEM S_FID
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <obd.h>
@@ -419,6 +418,12 @@ EXPORT_SYMBOL(client_fid_fini);
static int __init fid_init(void)
{
+ int rc;
+
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
debugfs_lustre_root,
NULL, NULL);
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index a1e5bf9f36ec..0aabf473c9bd 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -39,7 +39,6 @@
#define DEBUG_SUBSYSTEM S_FID
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <obd.h>
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 2d61ca4e51cf..a7415c9a1c28 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_FLD
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <asm/div64.h>
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h
index b5e3abaa508a..e1d6aaa5c2b4 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -59,7 +59,6 @@
#include <uapi/linux/lustre/lustre_idl.h>
-#include <linux/libcfs/libcfs.h>
#include <lustre_req_layout.h>
#include <lustre_fld.h>
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
index 068c364adda8..7b7ba93a4db6 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -39,7 +39,6 @@
#define DEBUG_SUBSYSTEM S_FLD
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <asm/div64.h>
@@ -450,6 +449,12 @@ void fld_client_flush(struct lu_client_fld *fld)
static int __init fld_init(void)
{
+ int rc;
+
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME,
debugfs_lustre_root,
NULL, NULL);
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 1a6a76110c3e..0bcfb26ef8aa 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_FLD
-#include <linux/libcfs/libcfs.h>
#include <linux/module.h>
#include <obd.h>
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device *d)
static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
{
LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
- return container_of0(d, struct cl_device, cd_lu_dev);
+ return container_of_safe(d, struct cl_device, cd_lu_dev);
}
static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d)
static inline struct cl_object *lu2cl(const struct lu_object *o)
{
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
- return container_of0(o, struct cl_object, co_lu);
+ return container_of_safe(o, struct cl_object, co_lu);
}
static inline const struct cl_object_conf *
lu2cl_conf(const struct lu_object_conf *conf)
{
- return container_of0(conf, struct cl_object_conf, coc_lu);
+ return container_of_safe(conf, struct cl_object_conf, coc_lu);
}
static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj)
static inline struct cl_device *cl_object_device(const struct cl_object *o)
{
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
- return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+ return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
}
static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
{
- return container_of0(h, struct cl_object_header, coh_lu);
+ return container_of_safe(h, struct cl_object_header, coh_lu);
}
static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 426e8f3c9809..1322ecffda13 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -43,8 +43,8 @@
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>
+#include <linux/device.h>
-#include <linux/libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_cfg.h>
#include <uapi/linux/lustre/lustre_idl.h>
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..f29bbca5af65 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -549,31 +549,7 @@ struct lu_object_header {
};
struct fld;
-
-struct lu_site_bkt_data {
- /**
- * number of object in this bucket on the lsb_lru list.
- */
- long lsb_lru_len;
- /**
- * LRU list, updated on each access to object. Protected by
- * bucket lock of lu_site::ls_obj_hash.
- *
- * "Cold" end of LRU is lu_site::ls_lru.next. Accessed object are
- * moved to the lu_site::ls_lru.prev (this is due to the non-existence
- * of list_for_each_entry_safe_reverse()).
- */
- struct list_head lsb_lru;
- /**
- * Wait-queue signaled when an object in this site is ultimately
- * destroyed (lu_object_free()). It is used by lu_object_find() to
- * wait before re-trying when object in the process of destruction is
- * found in the hash table.
- *
- * \see htable_lookup().
- */
- wait_queue_head_t lsb_marche_funebre;
-};
+struct lu_site_bkt_data;
enum {
LU_SS_CREATED = 0,
@@ -642,14 +618,8 @@ struct lu_site {
struct percpu_counter ls_lru_len_counter;
};
-static inline struct lu_site_bkt_data *
-lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid)
-{
- struct cfs_hash_bd bd;
-
- cfs_hash_bd_get(site->ls_obj_hash, fid, &bd);
- return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd);
-}
+wait_queue_head_t *
+lu_site_wq_from_fid(struct lu_site *site, struct lu_fid *fid);
static inline struct seq_server_site *lu_site2seq(const struct lu_site *s)
{
@@ -745,15 +715,15 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
static inline struct lu_object *lu_object_top(struct lu_object_header *h)
{
LASSERT(!list_empty(&h->loh_layers));
- return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
+ return list_first_entry(&h->loh_layers, struct lu_object, lo_linkage);
}
/**
* Next sub-object in the layering
*/
-static inline struct lu_object *lu_object_next(const struct lu_object *o)
+static inline const struct lu_object *lu_object_next(const struct lu_object *o)
{
- return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
+ return list_next_entry(o, lo_linkage);
}
/**
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 9f488e605083..3c6db0d632dc 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -37,6 +37,7 @@
#include <linux/fs_struct.h>
#include <linux/namei.h>
#include <linux/cred.h>
+#include <linux/module.h>
#include <lustre_patchless_compat.h>
diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h
index 100e993ab00b..886e817644d6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_disk.h
+++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
@@ -48,7 +48,6 @@
#include <asm/byteorder.h>
#include <linux/types.h>
#include <linux/backing-dev.h>
-#include <linux/libcfs/libcfs.h>
/****************** persistent mount data *********************/
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 239aa2b1268f..b3532adac31c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -362,6 +362,9 @@ struct ldlm_namespace {
/** Flag indicating if namespace is on client instead of server */
enum ldlm_side ns_client;
+ /** name of this namespace */
+ char *ns_name;
+
/** Resource hash table for namespace. */
struct cfs_hash *ns_rs_hash;
@@ -630,16 +633,6 @@ struct ldlm_lock {
*/
struct ldlm_interval *l_tree_node;
/**
- * Per export hash of locks.
- * Protected by per-bucket exp->exp_lock_hash locks.
- */
- struct hlist_node l_exp_hash;
- /**
- * Per export hash of flock locks.
- * Protected by per-bucket exp->exp_flock_hash locks.
- */
- struct hlist_node l_exp_flock_hash;
- /**
* Requested mode.
* Protected by lr_lock.
*/
@@ -888,7 +881,7 @@ static inline bool ldlm_has_layout(struct ldlm_lock *lock)
static inline char *
ldlm_ns_name(struct ldlm_namespace *ns)
{
- return ns->ns_rs_hash->hs_name;
+ return ns->ns_name;
}
static inline struct ldlm_namespace *
@@ -1200,7 +1193,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
struct ldlm_resource *parent,
const struct ldlm_res_id *,
enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
void ldlm_resource_add_lock(struct ldlm_resource *res,
struct list_head *head,
struct ldlm_lock *lock);
@@ -1227,7 +1220,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
* processing.
* @{
*/
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
/** @} ldlm_local_ast */
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 40cd168ed2ea..79ad5aae86b9 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -89,7 +89,7 @@ struct obd_export {
struct list_head exp_obd_chain;
/** work_struct for destruction of export */
struct work_struct exp_zombie_work;
- struct hlist_node exp_uuid_hash; /** uuid-export hash*/
+ struct rhash_head exp_uuid_hash; /** uuid-export hash*/
/** Obd device of this export */
struct obd_device *exp_obd;
/**
@@ -102,13 +102,6 @@ struct obd_export {
struct ptlrpc_connection *exp_connection;
/** Connection count value from last successful reconnect rpc */
__u32 exp_conn_cnt;
- /** Hash list of all ldlm locks granted on this export */
- struct cfs_hash *exp_lock_hash;
- /**
- * Hash list for Posix lock deadlock detection, added with
- * ldlm_lock::l_exp_flock_hash.
- */
- struct cfs_hash *exp_flock_hash;
struct list_head exp_outstanding_replies;
struct list_head exp_uncommitted_replies;
spinlock_t exp_uncommitted_replies_lock;
diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h
index 4055bbd24c55..f42122a4dfaa 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -40,7 +40,6 @@
*/
#include <uapi/linux/lustre/lustre_idl.h>
-#include <linux/libcfs/libcfs.h>
#include <seq_range.h>
struct lu_client_fld;
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index c48c97362cf6..3556ce8d94e8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -45,8 +45,6 @@
#include <linux/spinlock.h>
#include <linux/types.h>
-#include <linux/libcfs/libcfs.h>
-
struct portals_handle_ops {
void (*hop_addref)(void *object);
void (*hop_free)(void *object, int size);
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
index 1731048f1ff2..ac3805ead620 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -44,6 +44,7 @@
* @{
*/
+#include <linux/libcfs/libcfs.h>
#include <lustre_handles.h>
#include <uapi/linux/lustre/lustre_idl.h>
diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h
index 519e94fc089d..51e5c0e03872 100644
--- a/drivers/staging/lustre/lustre/include/lustre_intent.h
+++ b/drivers/staging/lustre/lustre/include/lustre_intent.h
@@ -34,6 +34,8 @@
#ifndef LUSTRE_INTENT_H
#define LUSTRE_INTENT_H
+#include <linux/types.h>
+
/* intent IT_XXX are defined in lustre/include/obd.h */
struct lookup_intent {
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h
index 0053eafc1c10..87748e9902a7 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -46,7 +46,6 @@
#include <linux/sched/signal.h>
#include <linux/signal.h>
#include <linux/types.h>
-#include <linux/libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <uapi/linux/lustre/lustre_ver.h>
#include <uapi/linux/lustre/lustre_cfg.h>
@@ -94,31 +93,34 @@ static inline int l_fatal_signal_pending(struct task_struct *p)
*/
#define l_wait_event_abortable(wq, condition) \
({ \
- sigset_t __old_blocked; \
+ sigset_t __new_blocked, __old_blocked; \
int __ret = 0; \
- cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked); \
+ siginitset(&__new_blocked, LUSTRE_FATAL_SIGS); \
+ sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible(wq, condition); \
- cfs_restore_sigs(&__old_blocked); \
+ sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret; \
})
#define l_wait_event_abortable_timeout(wq, condition, timeout) \
({ \
- sigset_t __old_blocked; \
+ sigset_t __new_blocked, __old_blocked; \
int __ret = 0; \
- cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked); \
+ siginitset(&__new_blocked, LUSTRE_FATAL_SIGS); \
+ sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_timeout(wq, condition, timeout);\
- cfs_restore_sigs(&__old_blocked); \
+ sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret; \
})
#define l_wait_event_abortable_exclusive(wq, condition) \
({ \
- sigset_t __old_blocked; \
+ sigset_t __new_blocked, __old_blocked; \
int __ret = 0; \
- cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked); \
+ siginitset(&__new_blocked, LUSTRE_FATAL_SIGS); \
+ sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_exclusive(wq, condition); \
- cfs_restore_sigs(&__old_blocked); \
+ sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret; \
})
#endif /* _LUSTRE_LIB_H */
diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h
index 6937546f1d46..f665556556ec 100644
--- a/drivers/staging/lustre/lustre/include/lustre_mds.h
+++ b/drivers/staging/lustre/lustre/include/lustre_mds.h
@@ -45,7 +45,6 @@
*/
#include <lustre_handles.h>
-#include <linux/libcfs/libcfs.h>
#include <lustre_lib.h>
#include <lustre_dlm.h>
#include <lustre_export.h>
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index d35ae0cda8d2..35b43a77eb18 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -67,6 +67,8 @@
#include <obd_support.h>
#include <uapi/linux/lustre/lustre_ver.h>
+#include <linux/rhashtable.h>
+
/* MD flags we _always_ use */
#define PTLRPC_MD_OPTIONS 0
@@ -286,7 +288,7 @@ struct ptlrpc_replay_async_args {
*/
struct ptlrpc_connection {
/** linkage for connections hash table */
- struct hlist_node c_hash;
+ struct rhash_head c_hash;
/** Our own lnet nid for this connection */
lnet_nid_t c_self;
/** Remote side nid for this connection */
@@ -556,7 +558,7 @@ struct ptlrpc_cli_req {
/** optional time limit for send attempts */
long cr_delay_limit;
/** time request was first queued */
- time_t cr_queued_time;
+ unsigned long cr_queued_time;
/** request sent timeval */
struct timespec64 cr_sent_tv;
/** time for request really sent out */
@@ -2253,9 +2255,8 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
{
if (req->rq_delay_limit != 0 &&
- time_before(cfs_time_add(req->rq_queued_time,
- req->rq_delay_limit * HZ),
- cfs_time_current())) {
+ time_before(req->rq_queued_time + req->rq_delay_limit * HZ,
+ jiffies)) {
return 1;
}
return 0;
diff --git a/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
index ce28ed5c1ef8..298476ea7557 100644
--- a/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_patchless_compat.h
@@ -39,6 +39,7 @@
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/hash.h>
+#include <linux/pagemap.h>
#define ll_delete_from_page_cache(page) delete_from_page_cache(page)
diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h
index c5cb07acd0da..d35bcbc98831 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -34,6 +34,8 @@
#ifndef _LUSTRE_SEC_H_
#define _LUSTRE_SEC_H_
+#include <linux/module.h>
+
/** \defgroup sptlrpc sptlrpc
*
* @{
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index f1233ca7d337..da99a0f02b6c 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -46,6 +46,8 @@
#include <lustre_intent.h>
#include <cl_object.h>
+#include <linux/rhashtable.h>
+
#define MAX_OBD_DEVICES 8192
struct osc_async_rc {
@@ -331,7 +333,7 @@ struct client_obd {
void *cl_writeback_work;
void *cl_lru_work;
/* hash tables for osc_quota_info */
- struct cfs_hash *cl_quota_hash[MAXQUOTAS];
+ struct rhashtable cl_quota_hash[MAXQUOTAS];
};
#define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
@@ -383,7 +385,7 @@ struct lov_obd {
__u32 lov_tgt_size; /* size of tgts array */
int lov_connects;
int lov_pool_count;
- struct cfs_hash *lov_pools_hash_body; /* used for key access */
+ struct rhashtable lov_pools_hash_body; /* used for key access */
struct list_head lov_pool_list; /* used for sequential access */
struct dentry *lov_pool_debugfs_entry;
enum lustre_sec_part lov_sp_me;
@@ -556,7 +558,7 @@ struct obd_device {
*/
unsigned long obd_recovery_expired:1;
/* uuid-export hash body */
- struct cfs_hash *obd_uuid_hash;
+ struct rhashtable obd_uuid_hash;
wait_queue_head_t obd_refcount_waitq;
struct list_head obd_exports;
struct list_head obd_unlinked_exports;
@@ -620,6 +622,9 @@ struct obd_device {
struct completion obd_kobj_unregister;
};
+int obd_uuid_add(struct obd_device *obd, struct obd_export *export);
+void obd_uuid_del(struct obd_device *obd, struct obd_export *export);
+
/* get/set_info keys */
#define KEY_ASYNC "async"
#define KEY_CHANGELOG_CLEAR "changelog_clear"
@@ -686,6 +691,16 @@ enum md_cli_flags {
CLI_MIGRATE = BIT(4),
};
+/**
+ * GETXATTR is not included as only a couple of fields in the reply body
+ * is filled, but not FID which is needed for common intent handling in
+ * mdc_finish_intent_lock()
+ */
+static inline bool it_has_reply_body(const struct lookup_intent *it)
+{
+ return it->it_op & (IT_OPEN | IT_UNLINK | IT_LOOKUP | IT_GETATTR);
+}
+
struct md_op_data {
struct lu_fid op_fid1; /* operation fid1 (usually parent) */
struct lu_fid op_fid2; /* operation fid2 (usually child) */
@@ -702,7 +717,7 @@ struct md_op_data {
__u32 op_suppgids[2];
__u32 op_fsuid;
__u32 op_fsgid;
- cfs_cap_t op_cap;
+ kernel_cap_t op_cap;
void *op_data;
size_t op_data_size;
@@ -897,10 +912,9 @@ struct md_ops {
struct md_open_data *, struct ptlrpc_request **);
int (*create)(struct obd_export *, struct md_op_data *,
const void *, size_t, umode_t, uid_t, gid_t,
- cfs_cap_t, __u64, struct ptlrpc_request **);
+ kernel_cap_t, __u64, struct ptlrpc_request **);
int (*enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
- const union ldlm_policy_data *,
- struct lookup_intent *, struct md_op_data *,
+ const union ldlm_policy_data *, struct md_op_data *,
struct lustre_handle *, __u64);
int (*getattr)(struct obd_export *, struct md_op_data *,
struct ptlrpc_request **);
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index f24dd74ffa09..a3b1465121e5 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -913,7 +913,7 @@ static inline int obd_destroy_export(struct obd_export *exp)
/*
* @max_age is the oldest time in jiffies that we accept using a cached data.
* If the cache is older than @max_age we will get a new value from the
- * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target. Use a value of "jiffies + HZ" to guarantee freshness.
*/
static inline int obd_statfs_async(struct obd_export *exp,
struct obd_info *oinfo,
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
- if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+ if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
} else {
CDEBUG(D_SUPER,
@@ -975,7 +975,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
/*
* @max_age is the oldest time in jiffies that we accept using a cached data.
* If the cache is older than @max_age we will get a new value from the
- * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target. Use a value of "jiffies + HZ" to guarantee freshness.
*/
static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
struct obd_statfs *osfs, __u64 max_age,
@@ -992,12 +992,12 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
obd->obd_osfs_age, max_age);
- if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+ if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
if (rc == 0) {
spin_lock(&obd->obd_osfs_lock);
memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
- obd->obd_osfs_age = cfs_time_current_64();
+ obd->obd_osfs_age = get_jiffies_64();
spin_unlock(&obd->obd_osfs_lock);
}
} else {
@@ -1226,7 +1226,7 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
int rc;
@@ -1241,7 +1241,6 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
static inline int md_enqueue(struct obd_export *exp,
struct ldlm_enqueue_info *einfo,
const union ldlm_policy_data *policy,
- struct lookup_intent *it,
struct md_op_data *op_data,
struct lustre_handle *lockh,
__u64 extra_lock_flags)
@@ -1250,7 +1249,7 @@ static inline int md_enqueue(struct obd_export *exp,
EXP_CHECK_MD_OP(exp, enqueue);
EXP_MD_COUNTER_INCREMENT(exp, enqueue);
- rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, it, op_data, lockh,
+ rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
extra_lock_flags);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 8595091b8b86..9e41633823f7 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -37,7 +37,6 @@
#include <linux/slab.h>
#include <linux/sched/signal.h>
-#include <linux/libcfs/libcfs.h>
#include <lustre_compat.h>
#include <lprocfs_status.h>
@@ -61,33 +60,6 @@ extern atomic_long_t obd_dirty_transit_pages;
extern char obd_jobid_var[];
/* Some hash init argument constants */
-#define HASH_POOLS_BKT_BITS 3
-#define HASH_POOLS_CUR_BITS 3
-#define HASH_POOLS_MAX_BITS 7
-#define HASH_UUID_BKT_BITS 5
-#define HASH_UUID_CUR_BITS 7
-#define HASH_UUID_MAX_BITS 12
-#define HASH_NID_BKT_BITS 5
-#define HASH_NID_CUR_BITS 7
-#define HASH_NID_MAX_BITS 12
-#define HASH_NID_STATS_BKT_BITS 5
-#define HASH_NID_STATS_CUR_BITS 7
-#define HASH_NID_STATS_MAX_BITS 12
-#define HASH_LQE_BKT_BITS 5
-#define HASH_LQE_CUR_BITS 7
-#define HASH_LQE_MAX_BITS 12
-#define HASH_CONN_BKT_BITS 5
-#define HASH_CONN_CUR_BITS 5
-#define HASH_CONN_MAX_BITS 15
-#define HASH_EXP_LOCK_BKT_BITS 5
-#define HASH_EXP_LOCK_CUR_BITS 7
-#define HASH_EXP_LOCK_MAX_BITS 16
-#define HASH_CL_ENV_BKT_BITS 5
-#define HASH_CL_ENV_BITS 10
-#define HASH_JOB_STATS_BKT_BITS 5
-#define HASH_JOB_STATS_CUR_BITS 7
-#define HASH_JOB_STATS_MAX_BITS 12
-
/* Timeout definitions */
#define OBD_TIMEOUT_DEFAULT 100
/* Time to wait for all clients to reconnect during recovery (hard limit) */
diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c
index 0662cec14b81..296259aa51e6 100644
--- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -32,7 +32,6 @@
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/libcfs/libcfs.h>
#include <lustre_dlm.h>
#include <lustre_lib.h>
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index 11b11b5f3216..4da23ade2bb3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -47,7 +47,6 @@
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/libcfs/libcfs.h>
#include <lustre_dlm.h>
#include <obd_support.h>
#include <obd.h>
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 411b540b96d9..94f3b1e49896 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
LDLM_DEBUG(lock, "%s(mode: %d)",
__func__, mode);
- /* Safe to not lock here, since it should be empty anyway */
- LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
-
list_del_init(&lock->l_res_link);
/* client side - set a flag to prevent sending a CANCEL */
@@ -263,15 +260,9 @@ reprocess:
lock->l_policy_data.l_flock.start =
new->l_policy_data.l_flock.end + 1;
new2->l_conn_export = lock->l_conn_export;
- if (lock->l_export) {
+ if (lock->l_export)
new2->l_export = class_export_lock_get(lock->l_export,
new2);
- if (new2->l_export->exp_lock_hash &&
- hlist_unhashed(&new2->l_exp_hash))
- cfs_hash_add(new2->l_export->exp_lock_hash,
- &new2->l_remote_handle,
- &new2->l_exp_hash);
- }
ldlm_lock_addref_internal_nolock(new2,
lock->l_granted_mode);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index 9efd26ec59dd..0aa4f234a4f4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/libcfs/libcfs.h>
#include <obd.h>
#include <obd_class.h>
#include <lustre_dlm.h>
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 95bea351d21d..a644d133063b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/libcfs/libcfs.h>
#include <lustre_intent.h>
#include <lustre_swab.h>
#include <obd_class.h>
@@ -243,7 +242,7 @@ static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
{
struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
- lock->l_last_used = cfs_time_current();
+ lock->l_last_used = jiffies;
LASSERT(list_empty(&lock->l_lru));
LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
list_add_tail(&lock->l_lru, &ns->ns_unused_list);
@@ -318,18 +317,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
}
ldlm_set_destroyed(lock);
- if (lock->l_export && lock->l_export->exp_lock_hash) {
- /* NB: it's safe to call cfs_hash_del() even lock isn't
- * in exp_lock_hash.
- */
- /* In the function below, .hs_keycmp resolves to
- * ldlm_export_lock_keycmp()
- */
- /* coverity[overrun-buffer-val] */
- cfs_hash_del(lock->l_export->exp_lock_hash,
- &lock->l_remote_handle, &lock->l_exp_hash);
- }
-
ldlm_lock_remove_from_lru(lock);
class_handle_unhash(&lock->l_handle);
@@ -419,8 +406,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
lock->l_blocking_lock = NULL;
INIT_LIST_HEAD(&lock->l_sl_mode);
INIT_LIST_HEAD(&lock->l_sl_policy);
- INIT_HLIST_NODE(&lock->l_exp_hash);
- INIT_HLIST_NODE(&lock->l_exp_flock_hash);
lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
LDLM_NSS_LOCKS);
@@ -1565,12 +1550,14 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
return ERR_CAST(res);
lock = ldlm_lock_new(res);
- if (!lock)
+ if (!lock) {
+ ldlm_resource_putref(res);
return ERR_PTR(-ENOMEM);
+ }
lock->l_req_mode = mode;
lock->l_ast_data = data;
- lock->l_pid = current_pid();
+ lock->l_pid = current->pid;
if (cbs) {
lock->l_blocking_ast = cbs->lcs_blocking;
lock->l_completion_ast = cbs->lcs_completion;
@@ -1609,6 +1596,8 @@ out:
return ERR_PTR(rc);
}
+
+
/**
* Enqueue (request) a lock.
* On the client this is called from ldlm_cli_enqueue_fini
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index c772c68e5a49..b0a29f50c7d6 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -38,7 +38,8 @@
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/libcfs/libcfs.h>
+#include <linux/kthread.h>
+#include <linux/sched/mm.h>
#include <lustre_dlm.h>
#include <obd_class.h>
#include <linux/list.h>
@@ -325,9 +326,8 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
lock_res_and_lock(lock);
if (lock->l_granted_mode == LCK_PW &&
!lock->l_readers && !lock->l_writers &&
- cfs_time_after(cfs_time_current(),
- cfs_time_add(lock->l_last_used,
- 10 * HZ))) {
+ time_after(jiffies,
+ lock->l_last_used + 10 * HZ)) {
unlock_res_and_lock(lock);
if (ldlm_bl_to_thread_lock(ns, NULL, lock))
ldlm_handle_bl_callback(ns, NULL, lock);
@@ -388,7 +388,7 @@ static inline void init_blwi(struct ldlm_bl_work_item *blwi,
init_completion(&blwi->blwi_comp);
INIT_LIST_HEAD(&blwi->blwi_head);
- if (memory_pressure_get())
+ if (current->flags & PF_MEMALLOC)
blwi->blwi_mem_pressure = 1;
blwi->blwi_ns = ns;
@@ -777,12 +777,14 @@ static int ldlm_bl_thread_need_create(struct ldlm_bl_pool *blp,
static int ldlm_bl_thread_blwi(struct ldlm_bl_pool *blp,
struct ldlm_bl_work_item *blwi)
{
+ unsigned int flags = 0;
+
if (!blwi->blwi_ns)
/* added by ldlm_cleanup() */
return LDLM_ITER_STOP;
if (blwi->blwi_mem_pressure)
- memory_pressure_set();
+ flags = memalloc_noreclaim_save();
OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_PAUSE_CANCEL2, 4);
@@ -805,7 +807,7 @@ static int ldlm_bl_thread_blwi(struct ldlm_bl_pool *blp,
blwi->blwi_lock);
}
if (blwi->blwi_mem_pressure)
- memory_pressure_clr();
+ memalloc_noreclaim_restore(flags);
if (blwi->blwi_flags & LCF_ASYNC)
kfree(blwi);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index c3c9186b74ce..cdc52eed6d85 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -62,6 +62,7 @@
#include <lustre_dlm.h>
#include <obd_class.h>
#include <obd.h>
+#include <linux/libcfs/libcfs_hash.h>
#include "ldlm_internal.h"
@@ -116,9 +117,9 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
(s64)lock->l_last_activity,
(s64)(ktime_get_real_seconds() -
lock->l_last_activity));
- if (cfs_time_after(cfs_time_current(), next_dump)) {
+ if (time_after(jiffies, next_dump)) {
last_dump = next_dump;
- next_dump = cfs_time_shift(300);
+ next_dump = jiffies + 300 * HZ;
ldlm_namespace_dump(D_DLMTRACE,
ldlm_lock_to_ns(lock));
if (last_dump == 0)
@@ -192,29 +193,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
}
/**
- * Implementation of ->l_completion_ast() for a client, that doesn't wait
- * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
- * other threads that cannot block for long.
- */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
-{
- if (flags == LDLM_FL_WAIT_NOREPROC) {
- LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
- return 0;
- }
-
- if (!(flags & LDLM_FL_BLOCKED_MASK)) {
- wake_up(&lock->l_waitq);
- return ldlm_completion_tail(lock, data);
- }
-
- LDLM_DEBUG(lock,
- "client-side enqueue returned a blocked lock, going forward");
- return 0;
-}
-EXPORT_SYMBOL(ldlm_completion_ast_async);
-
-/**
* Generic LDLM "completion" AST. This is called in several cases:
*
* - when a reply to an ENQUEUE RPC is received from the server
@@ -428,19 +406,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
cleanup_phase = 0;
lock_res_and_lock(lock);
- /* Key change rehash lock in per-export hash with new key */
- if (exp->exp_lock_hash) {
- /* In the function below, .hs_keycmp resolves to
- * ldlm_export_lock_keycmp()
- */
- /* coverity[overrun-buffer-val] */
- cfs_hash_rehash_key(exp->exp_lock_hash,
- &lock->l_remote_handle,
- &reply->lock_handle,
- &lock->l_exp_hash);
- } else {
- lock->l_remote_handle = reply->lock_handle;
- }
+ lock->l_remote_handle = reply->lock_handle;
*flags = ldlm_flags_from_wire(reply->lock_flags);
lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
@@ -1196,7 +1162,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
int unused, int added,
int count)
{
- unsigned long cur = cfs_time_current();
+ unsigned long cur = jiffies;
struct ldlm_pool *pl = &ns->ns_pool;
__u64 slv, lvf, lv;
unsigned long la;
@@ -1211,13 +1177,12 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
* Despite of the LV, It doesn't make sense to keep the lock which
* is unused for ns_max_age time.
*/
- if (cfs_time_after(cfs_time_current(),
- cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+ if (time_after(jiffies, lock->l_last_used + ns->ns_max_age))
return LDLM_POLICY_CANCEL_LOCK;
slv = ldlm_pool_get_slv(pl);
lvf = ldlm_pool_get_lvf(pl);
- la = cfs_duration_sec(cfs_time_sub(cur, lock->l_last_used));
+ la = (cur - lock->l_last_used) / HZ;
lv = lvf * la * unused;
/* Inform pool about current CLV to see it via debugfs. */
@@ -1268,8 +1233,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
int count)
{
if ((added >= count) &&
- time_before(cfs_time_current(),
- cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+ time_before(jiffies, lock->l_last_used + ns->ns_max_age))
return LDLM_POLICY_KEEP_LOCK;
return LDLM_POLICY_CANCEL_LOCK;
@@ -1415,7 +1379,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
continue;
last_use = lock->l_last_used;
- if (last_use == cfs_time_current())
+ if (last_use == jiffies)
continue;
/* Somebody is already doing CANCEL. No need for this
@@ -1907,18 +1871,7 @@ static int replay_lock_interpret(const struct lu_env *env,
/* Key change rehash lock in per-export hash with new key */
exp = req->rq_export;
- if (exp && exp->exp_lock_hash) {
- /* In the function below, .hs_keycmp resolves to
- * ldlm_export_lock_keycmp()
- */
- /* coverity[overrun-buffer-val] */
- cfs_hash_rehash_key(exp->exp_lock_hash,
- &lock->l_remote_handle,
- &reply->lock_handle,
- &lock->l_exp_hash);
- } else {
- lock->l_remote_handle = reply->lock_handle;
- }
+ lock->l_remote_handle = reply->lock_handle;
LDLM_DEBUG(lock, "replayed lock:");
ptlrpc_import_recovery_state_machine(req->rq_import);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..28cd8398d4ce 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -41,6 +41,7 @@
#include <lustre_fid.h>
#include <obd_class.h>
#include "ldlm_internal.h"
+#include <linux/libcfs/libcfs_hash.h>
struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab;
@@ -688,6 +689,9 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ns->ns_obd = obd;
ns->ns_appetite = apt;
ns->ns_client = client;
+ ns->ns_name = kstrdup(name, GFP_KERNEL);
+ if (!ns->ns_name)
+ goto out_hash;
INIT_LIST_HEAD(&ns->ns_list_chain);
INIT_LIST_HEAD(&ns->ns_unused_list);
@@ -730,6 +734,7 @@ out_sysfs:
ldlm_namespace_sysfs_unregister(ns);
ldlm_namespace_cleanup(ns, 0);
out_hash:
+ kfree(ns->ns_name);
cfs_hash_putref(ns->ns_rs_hash);
out_ns:
kfree(ns);
@@ -993,6 +998,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
ldlm_namespace_debugfs_unregister(ns);
ldlm_namespace_sysfs_unregister(ns);
cfs_hash_putref(ns->ns_rs_hash);
+ kfree(ns->ns_name);
/* Namespace \a ns should be not on list at this time, otherwise
* this will cause issues related to using freed \a ns in poold
* thread.
@@ -1195,6 +1201,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
struct ldlm_resource *res)
{
struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+ struct ldlm_namespace *ns = nsb->nsb_namespace;
if (!list_empty(&res->lr_granted)) {
ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1213,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
LBUG();
}
- cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+ cfs_hash_bd_del_locked(ns->ns_rs_hash,
bd, &res->lr_hash);
lu_ref_fini(&res->lr_reference);
+ cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+ if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+ ns->ns_lvbo->lvbo_free(res);
if (cfs_hash_bd_count_get(bd) == 0)
- ldlm_namespace_put(nsb->nsb_namespace);
+ ldlm_namespace_put(ns);
+ kmem_cache_free(ldlm_resource_slab, res);
}
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
{
struct ldlm_namespace *ns = ldlm_res_to_ns(res);
struct cfs_hash_bd bd;
@@ -1224,15 +1234,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
res, atomic_read(&res->lr_refcount) - 1);
cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
- if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
+ if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
__ldlm_resource_putref_final(&bd, res);
- cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
- if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
- ns->ns_lvbo->lvbo_free(res);
- kmem_cache_free(ldlm_resource_slab, res);
- return 1;
- }
- return 0;
}
EXPORT_SYMBOL(ldlm_resource_putref);
@@ -1319,14 +1322,14 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
- if (time_before(cfs_time_current(), ns->ns_next_dump))
+ if (time_before(jiffies, ns->ns_next_dump))
return;
cfs_hash_for_each_nolock(ns->ns_rs_hash,
ldlm_res_hash_dump,
(void *)(unsigned long)level, 0);
spin_lock(&ns->ns_lock);
- ns->ns_next_dump = cfs_time_shift(10);
+ ns->ns_next_dump = jiffies + 10 * HZ;
spin_unlock(&ns->ns_lock);
}
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index d10d27268323..688dddf3ca47 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -445,7 +445,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump,
err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode,
from_kuid(&init_user_ns, current_fsuid()),
from_kgid(&init_user_ns, current_fsgid()),
- cfs_curproc_cap_pack(), 0, &request);
+ current_cap(), 0, &request);
ll_finish_md_op_data(op_data);
err = ll_prep_inode(&inode, request, parent->i_sb, NULL);
@@ -1185,6 +1185,8 @@ lmv_out_free:
if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3)))
return -EFAULT;
+ if (lumv3.lmm_magic != LOV_USER_MAGIC_V3)
+ return -EINVAL;
}
if (is_root_inode(inode))
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index ca5faea13b7e..a77cadcd9d48 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2514,7 +2514,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
PFID(ll_inode2fid(inode)), flock.l_flock.pid, flags,
einfo.ei_mode, flock.l_flock.start, flock.l_flock.end);
- rc = md_enqueue(sbi->ll_md_exp, &einfo, &flock, NULL, op_data, &lockh,
+ rc = md_enqueue(sbi->ll_md_exp, &einfo, &flock, op_data, &lockh,
flags);
/* Restore the file lock type if not TEST lock. */
@@ -2527,7 +2527,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
if (rc2 && file_lock->fl_type != F_UNLCK) {
einfo.ei_mode = LCK_NL;
- md_enqueue(sbi->ll_md_exp, &einfo, &flock, NULL, op_data,
+ md_enqueue(sbi->ll_md_exp, &einfo, &flock, op_data,
&lockh, flags);
rc = rc2;
}
@@ -3050,7 +3050,6 @@ int ll_inode_permission(struct inode *inode, int mask)
const struct cred *old_cred = NULL;
struct cred *cred = NULL;
bool squash_id = false;
- cfs_cap_t cap;
int rc = 0;
if (mask & MAY_NOT_BLOCK)
@@ -3094,10 +3093,9 @@ int ll_inode_permission(struct inode *inode, int mask)
cred->fsuid = make_kuid(&init_user_ns, squash->rsi_uid);
cred->fsgid = make_kgid(&init_user_ns, squash->rsi_gid);
- for (cap = 0; cap < sizeof(cfs_cap_t) * 8; cap++) {
- if ((1 << cap) & CFS_CAP_FS_MASK)
- cap_lower(cred->cap_effective, cap);
- }
+ cred->cap_effective = cap_drop_nfsd_set(cred->cap_effective);
+ cred->cap_effective = cap_drop_fs_set(cred->cap_effective);
+
old_cred = override_creds(cred);
}
@@ -3474,12 +3472,7 @@ static int ll_layout_refresh_locked(struct inode *inode)
struct lookup_intent it;
struct lustre_handle lockh;
enum ldlm_mode mode;
- struct ldlm_enqueue_info einfo = {
- .ei_type = LDLM_IBITS,
- .ei_mode = LCK_CR,
- .ei_cb_bl = &ll_md_blocking_ast,
- .ei_cb_cp = &ldlm_completion_ast,
- };
+ struct ptlrpc_request *req;
int rc;
again:
@@ -3503,13 +3496,13 @@ again:
/* have to enqueue one */
memset(&it, 0, sizeof(it));
it.it_op = IT_LAYOUT;
- lockh.cookie = 0ULL;
LDLM_DEBUG_NOLOCK("%s: requeue layout lock for file " DFID "(%p)",
ll_get_fsname(inode->i_sb, NULL, 0),
PFID(&lli->lli_fid), inode);
- rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &it, op_data, &lockh, 0);
+ rc = md_intent_lock(sbi->ll_md_exp, op_data, &it, &req,
+ &ll_md_blocking_ast, 0);
ptlrpc_req_finished(it.it_request);
it.it_request = NULL;
@@ -3522,6 +3515,7 @@ again:
if (rc == 0) {
/* set lock data in case this is a new lock */
ll_set_lock_data(sbi->ll_md_exp, inode, &it, NULL);
+ lockh.cookie = it.it_lock_handle;
rc = ll_layout_lock_set(&lockh, mode, inode);
if (rc == -EAGAIN)
goto again;
diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c
index 3075358f3f08..ce0d51767da3 100644
--- a/drivers/staging/lustre/lustre/llite/glimpse.c
+++ b/drivers/staging/lustre/lustre/llite/glimpse.c
@@ -37,7 +37,6 @@
* Author: Oleg Drokin <oleg.drokin@sun.com>
*/
-#include <linux/libcfs/libcfs.h>
#include <obd_class.h>
#include <obd_support.h>
#include <obd.h>
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index df5c0c0ae703..d7ea39ce0cb2 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/libcfs/libcfs.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/mm.h>
@@ -211,12 +210,12 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
if (unlikely(atomic_read(&header->loh_ref) != 1)) {
struct lu_site *site = obj->co_lu.lo_dev->ld_site;
- struct lu_site_bkt_data *bkt;
+ wait_queue_head_t *wq;
- bkt = lu_site_bkt_from_fid(site, &header->loh_fid);
+ wq = lu_site_wq_from_fid(site, &header->loh_fid);
init_waitqueue_entry(&waiter, current);
- add_wait_queue(&bkt->lsb_marche_funebre, &waiter);
+ add_wait_queue(wq, &waiter);
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);
@@ -226,7 +225,7 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
}
set_current_state(TASK_RUNNING);
- remove_wait_queue(&bkt->lsb_marche_funebre, &waiter);
+ remove_wait_queue(wq, &waiter);
}
cl_object_put(env, obj);
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index d46bcf71b273..379d88e20cd3 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1110,7 +1110,7 @@ static inline int ll_glimpse_size(struct inode *inode)
down_read(&lli->lli_glimpse_sem);
rc = cl_glimpse_size(inode);
- lli->lli_glimpse_time = cfs_time_current();
+ lli->lli_glimpse_time = jiffies;
up_read(&lli->lli_glimpse_sem);
return rc;
}
@@ -1140,7 +1140,7 @@ dentry_may_statahead(struct inode *dir, struct dentry *dentry)
return false;
/* not the same process, don't statahead */
- if (lli->lli_opendir_pid != current_pid())
+ if (lli->lli_opendir_pid != current->pid)
return false;
/*
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e7500c53fafc..1bc0782feae3 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -41,6 +41,7 @@
#include <linux/statfs.h>
#include <linux/types.h>
#include <linux/mm.h>
+#include <linux/random.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
#include <lustre_ha.h>
@@ -257,7 +258,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
* available
*/
err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_FOR_MDT0);
if (err)
goto out_md_fid;
@@ -400,11 +401,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
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",
dt);
- goto out_md;
+ goto out_md_fid;
} else if (err) {
CERROR("%s: Cannot connect to %s: rc = %d\n",
sbi->ll_dt_exp->exp_obd->obd_name, dt, err);
- goto out_md;
+ goto out_md_fid;
}
sbi->ll_dt_exp->exp_connect_data = *data;
@@ -1675,7 +1676,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
/* Some amount of caching on the client is allowed */
rc = ll_statfs_internal(sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
0);
if (rc)
return rc;
@@ -2336,7 +2337,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
op_data->op_mod_time = ktime_get_real_seconds();
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if ((opc == LUSTRE_OPC_CREATE) && name &&
filename_is_volatile(name, namelen, &op_data->op_mds))
op_data->op_bias |= MDS_CREATE_VOLATILE;
diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index 214b07554e62..d7fb5533f707 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -152,7 +152,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
struct vvp_io *vio;
int result;
u16 refcheck;
- sigset_t set;
+ sigset_t old, new;
struct inode *inode;
struct ll_inode_info *lli;
@@ -177,14 +177,15 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
vio->u.fault.ft_vma = vma;
vio->u.fault.ft_vmpage = vmpage;
- cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM), &set);
+ siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+ sigprocmask(SIG_BLOCK, &new, &old);
inode = vvp_object_inode(io->ci_obj);
lli = ll_i2info(inode);
result = cl_io_loop(env, io);
- cfs_restore_sigs(&set);
+ sigprocmask(SIG_SETMASK, &old, NULL);
if (result == 0) {
struct inode *inode = file_inode(vma->vm_file);
@@ -328,13 +329,14 @@ static int ll_fault(struct vm_fault *vmf)
int count = 0;
bool printed = false;
int result;
- sigset_t set;
+ sigset_t old, new;
/* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite
* so that it can be killed by admin but not cause segfault by
* other signals.
*/
- cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM), &set);
+ siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+ sigprocmask(SIG_BLOCK, &new, &old);
restart:
result = ll_fault0(vmf->vma, vmf);
@@ -360,7 +362,7 @@ restart:
result = VM_FAULT_LOCKED;
}
- cfs_restore_sigs(&set);
+ sigprocmask(SIG_SETMASK, &old, NULL);
return result;
}
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index a6a1d80c711a..14172688d55f 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -223,7 +223,7 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
/* It is hack to access lde_fid for comparison with lgd_fid.
* So the input 'name' must be part of the 'lu_dirent'.
*/
- struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
+ struct lu_dirent *lde = container_of((void*)name, struct lu_dirent, lde_name);
struct ll_getname_data *lgd =
container_of(ctx, struct ll_getname_data, ctx);
struct lu_fid fid;
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 644bea2f9d37..164fe4d6b6b8 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%llu\n", osfs.os_files);
@@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
int rc;
rc = ll_statfs_internal(sbi->ll_sb, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 6c9ec462eb41..d5f6d20afe8c 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -442,11 +442,16 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
} else {
struct dentry *new = d_splice_alias(inode, de);
+ if (IS_ERR(new))
+ CDEBUG(D_DENTRY,
+ "splice inode %p as %pd gives error %lu\n",
+ inode, de, PTR_ERR(new));
if (new)
de = new;
}
- CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
- de, d_inode(de), d_count(de), de->d_flags);
+ if (!IS_ERR(de))
+ CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
+ de, d_inode(de), d_count(de), de->d_flags);
return de;
}
@@ -880,7 +885,7 @@ again:
err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
from_kuid(&init_user_ns, current_fsuid()),
from_kgid(&init_user_ns, current_fsgid()),
- cfs_curproc_cap_pack(), rdev, &request);
+ current_cap(), rdev, &request);
ll_finish_md_op_data(op_data);
if (err < 0 && err != -EREMOTE)
goto err_exit;
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c b/drivers/staging/lustre/lustre/llite/range_lock.c
index cc9565f6bfe2..008a8874118d 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.c
+++ b/drivers/staging/lustre/lustre/llite/range_lock.c
@@ -36,6 +36,7 @@
*/
#include "range_lock.h"
#include <uapi/linux/lustre/lustre_idl.h>
+#include <linux/libcfs/libcfs.h>
/**
* Initialize a range lock tree
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.h b/drivers/staging/lustre/lustre/llite/range_lock.h
index 38b2be4e378f..9ebac09160f2 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.h
+++ b/drivers/staging/lustre/lustre/llite/range_lock.h
@@ -37,7 +37,7 @@
#ifndef _RANGE_LOCK_H
#define _RANGE_LOCK_H
-#include <linux/libcfs/libcfs.h>
+#include <linux/spinlock.h>
#include <interval_tree.h>
struct range_lock {
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 155ce3cf6f60..d864f5f36d85 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
* affect the performance.
*/
if (lli->lli_glimpse_time != 0 &&
- time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
+ time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
up_write(&lli->lli_glimpse_sem);
lli->lli_agl_index = 0;
iput(inode);
@@ -535,7 +535,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
cl_agl(inode);
lli->lli_agl_index = 0;
- lli->lli_glimpse_time = cfs_time_current();
+ lli->lli_glimpse_time = jiffies;
up_write(&lli->lli_glimpse_sem);
CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
@@ -1075,7 +1075,7 @@ static int ll_statahead_thread(void *arg)
CDEBUG(D_READA, "Statahead for dir " DFID " hit ratio too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stopping statahead thread: pid %d\n",
PFID(&lli->lli_fid), sai->sai_hit,
sai->sai_miss, sai->sai_sent,
- sai->sai_replied, current_pid());
+ sai->sai_replied, current->pid);
break;
}
}
@@ -1147,7 +1147,7 @@ void ll_authorize_statahead(struct inode *dir, void *key)
*/
LASSERT(!lli->lli_opendir_pid);
lli->lli_opendir_key = key;
- lli->lli_opendir_pid = current_pid();
+ lli->lli_opendir_pid = current->pid;
lli->lli_sa_enabled = 1;
}
spin_unlock(&lli->lli_sa_lock);
@@ -1506,7 +1506,7 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
atomic_inc(&ll_i2sbi(parent->d_inode)->ll_sa_running);
CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
- current_pid(), parent);
+ current->pid, parent);
task = kthread_create(ll_statahead_thread, parent, "ll_sa_%u",
lli->lli_opendir_pid);
diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c
index 861e7a60f408..d335f29556c2 100644
--- a/drivers/staging/lustre/lustre/llite/super25.c
+++ b/drivers/staging/lustre/lustre/llite/super25.c
@@ -90,6 +90,10 @@ static int __init lustre_init(void)
BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) !=
LUSTRE_VOLATILE_HDR_LEN + 1);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
/* print an address of _any_ initialized kernel symbol from this
* module, to allow debugging with gdb that doesn't support data
* symbols from modules.
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index 987c03b058e6..31dc3c0ade01 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -38,6 +38,7 @@
#define DEBUG_SUBSYSTEM S_LLITE
+#include <linux/libcfs/libcfs_hash.h>
#include <obd.h>
#include "llite_internal.h"
#include "vvp_internal.h"
@@ -390,6 +391,13 @@ struct vvp_pgcache_id {
struct lu_object_header *vpi_obj;
};
+struct seq_private {
+ struct ll_sb_info *sbi;
+ struct lu_env *env;
+ u16 refcheck;
+ struct cl_object *clob;
+};
+
static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id)
{
BUILD_BUG_ON(sizeof(pos) != sizeof(__u64));
@@ -452,19 +460,20 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env,
return NULL;
}
-static loff_t vvp_pgcache_find(const struct lu_env *env,
- struct lu_device *dev, loff_t pos)
+static struct page *vvp_pgcache_find(const struct lu_env *env,
+ struct lu_device *dev,
+ struct cl_object **clobp, loff_t *pos)
{
struct cl_object *clob;
struct lu_site *site;
struct vvp_pgcache_id id;
site = dev->ld_site;
- vvp_pgcache_id_unpack(pos, &id);
+ vvp_pgcache_id_unpack(*pos, &id);
while (1) {
if (id.vpi_bucket >= CFS_HASH_NHLIST(site->ls_obj_hash))
- return ~0ULL;
+ return NULL;
clob = vvp_pgcache_obj(env, dev, &id);
if (clob) {
struct inode *inode = vvp_object_inode(clob);
@@ -476,20 +485,22 @@ static loff_t vvp_pgcache_find(const struct lu_env *env,
if (nr > 0) {
id.vpi_index = vmpage->index;
/* Cant support over 16T file */
- nr = !(vmpage->index > 0xffffffff);
+ if (vmpage->index <= 0xffffffff) {
+ *clobp = clob;
+ *pos = vvp_pgcache_id_pack(&id);
+ return vmpage;
+ }
put_page(vmpage);
}
lu_object_ref_del(&clob->co_lu, "dump", current);
cl_object_put(env, clob);
- if (nr > 0)
- return vvp_pgcache_id_pack(&id);
}
/* to the next object. */
++id.vpi_depth;
id.vpi_depth &= 0xf;
if (id.vpi_depth == 0 && ++id.vpi_bucket == 0)
- return ~0ULL;
+ return NULL;
id.vpi_index = 0;
}
}
@@ -531,96 +542,53 @@ static void vvp_pgcache_page_show(const struct lu_env *env,
static int vvp_pgcache_show(struct seq_file *f, void *v)
{
- loff_t pos;
- struct ll_sb_info *sbi;
- struct cl_object *clob;
- struct lu_env *env;
- struct vvp_pgcache_id id;
- u16 refcheck;
- int result;
-
- env = cl_env_get(&refcheck);
- if (!IS_ERR(env)) {
- pos = *(loff_t *)v;
- vvp_pgcache_id_unpack(pos, &id);
- sbi = f->private;
- clob = vvp_pgcache_obj(env, &sbi->ll_cl->cd_lu_dev, &id);
- if (clob) {
- struct inode *inode = vvp_object_inode(clob);
- struct cl_page *page = NULL;
- struct page *vmpage;
-
- result = find_get_pages_contig(inode->i_mapping,
- id.vpi_index, 1,
- &vmpage);
- if (result > 0) {
- lock_page(vmpage);
- page = cl_vmpage_page(vmpage, clob);
- unlock_page(vmpage);
- put_page(vmpage);
- }
-
- seq_printf(f, "%8x@" DFID ": ", id.vpi_index,
- PFID(lu_object_fid(&clob->co_lu)));
- if (page) {
- vvp_pgcache_page_show(env, f, page);
- cl_page_put(env, page);
- } else {
- seq_puts(f, "missing\n");
- }
- lu_object_ref_del(&clob->co_lu, "dump", current);
- cl_object_put(env, clob);
- } else {
- seq_printf(f, "%llx missing\n", pos);
- }
- cl_env_put(env, &refcheck);
- result = 0;
+ struct seq_private *priv = f->private;
+ struct page *vmpage = v;
+ struct cl_page *page;
+
+ seq_printf(f, "%8lx@" DFID ": ", vmpage->index,
+ PFID(lu_object_fid(&priv->clob->co_lu)));
+ lock_page(vmpage);
+ page = cl_vmpage_page(vmpage, priv->clob);
+ unlock_page(vmpage);
+ put_page(vmpage);
+
+ if (page) {
+ vvp_pgcache_page_show(priv->env, f, page);
+ cl_page_put(priv->env, page);
} else {
- result = PTR_ERR(env);
+ seq_puts(f, "missing\n");
}
- return result;
+ lu_object_ref_del(&priv->clob->co_lu, "dump", current);
+ cl_object_put(priv->env, priv->clob);
+
+ return 0;
}
static void *vvp_pgcache_start(struct seq_file *f, loff_t *pos)
{
- struct ll_sb_info *sbi;
- struct lu_env *env;
- u16 refcheck;
+ struct seq_private *priv = f->private;
+ struct page *ret;
- sbi = f->private;
+ if (priv->sbi->ll_site->ls_obj_hash->hs_cur_bits >
+ 64 - PGC_OBJ_SHIFT)
+ ret = ERR_PTR(-EFBIG);
+ else
+ ret = vvp_pgcache_find(priv->env, &priv->sbi->ll_cl->cd_lu_dev,
+ &priv->clob, pos);
- env = cl_env_get(&refcheck);
- if (!IS_ERR(env)) {
- sbi = f->private;
- if (sbi->ll_site->ls_obj_hash->hs_cur_bits >
- 64 - PGC_OBJ_SHIFT) {
- pos = ERR_PTR(-EFBIG);
- } else {
- *pos = vvp_pgcache_find(env, &sbi->ll_cl->cd_lu_dev,
- *pos);
- if (*pos == ~0ULL)
- pos = NULL;
- }
- cl_env_put(env, &refcheck);
- }
- return pos;
+ return ret;
}
static void *vvp_pgcache_next(struct seq_file *f, void *v, loff_t *pos)
{
- struct ll_sb_info *sbi;
- struct lu_env *env;
- u16 refcheck;
+ struct seq_private *priv = f->private;
+ struct page *ret;
- env = cl_env_get(&refcheck);
- if (!IS_ERR(env)) {
- sbi = f->private;
- *pos = vvp_pgcache_find(env, &sbi->ll_cl->cd_lu_dev, *pos + 1);
- if (*pos == ~0ULL)
- pos = NULL;
- cl_env_put(env, &refcheck);
- }
- return pos;
+ *pos += 1;
+ ret = vvp_pgcache_find(priv->env, &priv->sbi->ll_cl->cd_lu_dev,
+ &priv->clob, pos);
+ return ret;
}
static void vvp_pgcache_stop(struct seq_file *f, void *v)
@@ -637,23 +605,36 @@ static const struct seq_operations vvp_pgcache_ops = {
static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp)
{
- struct seq_file *seq;
- int rc;
+ struct seq_private *priv;
- rc = seq_open(filp, &vvp_pgcache_ops);
- if (rc)
- return rc;
+ priv = __seq_open_private(filp, &vvp_pgcache_ops, sizeof(*priv));
+ if (!priv)
+ return -ENOMEM;
- seq = filp->private_data;
- seq->private = inode->i_private;
+ priv->sbi = inode->i_private;
+ priv->env = cl_env_get(&priv->refcheck);
+ if (IS_ERR(priv->env)) {
+ int err = PTR_ERR(priv->env);
+ seq_release_private(inode, filp);
+ return err;
+ }
return 0;
}
+static int vvp_dump_pgcache_seq_release(struct inode *inode, struct file *file)
+{
+ struct seq_file *seq = file->private_data;
+ struct seq_private *priv = seq->private;
+
+ cl_env_put(priv->env, &priv->refcheck);
+ return seq_release_private(inode, file);
+}
+
const struct file_operations vvp_dump_pgcache_file_ops = {
.owner = THIS_MODULE,
.open = vvp_dump_pgcache_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = seq_release,
+ .release = vvp_dump_pgcache_seq_release,
};
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
index 02ea5161d635..7d3abb43584a 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
{
- return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
+ return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
}
static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
{
- return container_of0(d, struct vvp_device, vdv_cl);
+ return container_of_safe(d, struct vvp_device, vdv_cl);
}
static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
{
- return container_of0(obj, struct vvp_object, vob_cl);
+ return container_of_safe(obj, struct vvp_object, vob_cl);
}
static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
{
- return container_of0(obj, struct vvp_object, vob_cl.co_lu);
+ return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
}
static inline struct inode *vvp_object_inode(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c
index 05ad3b322a29..b2cb51c8f7f4 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_object.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_object.c
@@ -37,8 +37,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/libcfs/libcfs.h>
-
#include <obd.h>
#include "llite_internal.h"
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 2d78432963dc..1a597a640b6c 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -46,15 +46,16 @@
const struct xattr_handler *get_xattr_type(const char *name)
{
- int i = 0;
+ int i;
- while (ll_xattr_handlers[i]) {
- size_t len = strlen(ll_xattr_handlers[i]->prefix);
+ for (i = 0; ll_xattr_handlers[i]; i++) {
+ const char *prefix = xattr_prefix(ll_xattr_handlers[i]);
+ size_t prefix_len = strlen(prefix);
- if (!strncmp(ll_xattr_handlers[i]->prefix, name, len))
+ if (!strncmp(prefix, name, prefix_len))
return ll_xattr_handlers[i];
- i++;
}
+
return NULL;
}
@@ -81,20 +82,23 @@ static int xattr_type_filter(struct ll_sb_info *sbi,
return 0;
}
-static int
-ll_xattr_set_common(const struct xattr_handler *handler,
- struct dentry *dentry, struct inode *inode,
- const char *name, const void *value, size_t size,
- int flags)
+static int ll_xattr_set_common(const struct xattr_handler *handler,
+ struct dentry *dentry, struct inode *inode,
+ const char *name, const void *value, size_t size,
+ int flags)
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req = NULL;
const char *pv = value;
char *fullname;
- __u64 valid;
+ u64 valid;
int rc;
- if (flags == XATTR_REPLACE) {
+ /* When setxattr() is called with a size of 0 the value is
+ * unconditionally replaced by "". When removexattr() is
+ * called we get a NULL value and XATTR_REPLACE for flags.
+ */
+ if (!value && flags == XATTR_REPLACE) {
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);
valid = OBD_MD_FLXATTRRM;
} else {
@@ -117,11 +121,6 @@ ll_xattr_set_common(const struct xattr_handler *handler,
(handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))))
return 0;
- /* b15587: ignore security.capability xattr for now */
- if ((handler->flags == XATTR_SECURITY_T &&
- !strcmp(name, "capability")))
- return 0;
-
/* LU-549: Disable security.selinux when selinux is disabled */
if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() &&
strcmp(name, "selinux") == 0)
@@ -141,12 +140,12 @@ ll_xattr_set_common(const struct xattr_handler *handler,
return -EPERM;
}
- fullname = kasprintf(GFP_KERNEL, "%s%s\n", handler->prefix, name);
+ fullname = kasprintf(GFP_KERNEL, "%s%s", handler->prefix, name);
if (!fullname)
return -ENOMEM;
- rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
- valid, fullname, pv, size, 0, flags,
- ll_i2suppgid(inode), &req);
+
+ rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname,
+ pv, size, 0, flags, ll_i2suppgid(inode), &req);
kfree(fullname);
if (rc) {
if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) {
@@ -191,6 +190,95 @@ static int get_hsm_state(struct inode *inode, u32 *hus_states)
return rc;
}
+static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
+{
+ int rc = 0;
+
+ if (!lump)
+ return 0;
+
+ /* Attributes that are saved via getxattr will always have
+ * the stripe_offset as 0. Instead, the MDS should be
+ * allowed to pick the starting OST index. b=17846
+ */
+ if (lump->lmm_stripe_offset == 0)
+ lump->lmm_stripe_offset = -1;
+
+ /* Avoid anyone directly setting the RELEASED flag. */
+ if (lump->lmm_pattern & LOV_PATTERN_F_RELEASED) {
+ /* Only if we have a released flag check if the file
+ * was indeed archived.
+ */
+ u32 state = HS_NONE;
+
+ rc = get_hsm_state(inode, &state);
+ if (rc)
+ return rc;
+
+ if (!(state & HS_ARCHIVED)) {
+ CDEBUG(D_VFSTRACE,
+ "hus_states state = %x, pattern = %x\n",
+ state, lump->lmm_pattern);
+ /*
+ * Here the state is: real file is not
+ * archived but user is requesting to set
+ * the RELEASED flag so we mask off the
+ * released flag from the request
+ */
+ lump->lmm_pattern ^= LOV_PATTERN_F_RELEASED;
+ }
+ }
+
+ return rc;
+}
+
+static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump,
+ size_t size)
+{
+ struct inode *inode = d_inode(dentry);
+ int rc = 0;
+
+ /*
+ * It is possible to set an xattr to a "" value of zero size.
+ * For this case we are going to treat it as a removal.
+ */
+ if (!size && lump)
+ lump = NULL;
+
+ rc = ll_adjust_lum(inode, lump);
+ if (rc)
+ return rc;
+
+ if (lump && S_ISREG(inode->i_mode)) {
+ u64 it_flags = FMODE_WRITE;
+ ssize_t lum_size;
+
+ lum_size = ll_lov_user_md_size(lump);
+ if (lum_size < 0 || size < lum_size)
+ return -ERANGE;
+
+ rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags, lump,
+ lum_size);
+ /**
+ * b=10667: ignore -EEXIST.
+ * Silently eat error on setting trusted.lov/lustre.lov
+ * attribute for platforms that added the default option
+ * to copy all attributes in 'cp' command. Both rsync and
+ * tar --xattrs also will try to set LOVEA for existing
+ * files.
+ */
+ if (rc == -EEXIST)
+ rc = 0;
+ } else if (S_ISDIR(inode->i_mode)) {
+ if (size != 0 && size < sizeof(struct lov_user_md))
+ return -EINVAL;
+
+ rc = ll_dir_setstripe(inode, lump, 0);
+ }
+
+ return rc;
+}
+
static int ll_xattr_set(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value, size_t size,
@@ -202,76 +290,20 @@ static int ll_xattr_set(const struct xattr_handler *handler,
CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p), xattr %s\n",
PFID(ll_inode2fid(inode)), inode, name);
+ /* lustre/trusted.lov.xxx would be passed through xattr API */
if (!strcmp(name, "lov")) {
- struct lov_user_md *lump = (struct lov_user_md *)value;
int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR :
LPROC_LL_SETXATTR;
- int rc = 0;
ll_stats_ops_tally(ll_i2sbi(inode), op_type, 1);
- if (size != 0 && size < sizeof(struct lov_user_md))
- return -EINVAL;
-
- /*
- * It is possible to set an xattr to a "" value of zero size.
- * For this case we are going to treat it as a removal.
- */
- if (!size && lump)
- lump = NULL;
-
- /* Attributes that are saved via getxattr will always have
- * the stripe_offset as 0. Instead, the MDS should be
- * allowed to pick the starting OST index. b=17846
- */
- if (lump && lump->lmm_stripe_offset == 0)
- lump->lmm_stripe_offset = -1;
-
- /* Avoid anyone directly setting the RELEASED flag. */
- if (lump && (lump->lmm_pattern & LOV_PATTERN_F_RELEASED)) {
- /* Only if we have a released flag check if the file
- * was indeed archived.
- */
- u32 state = HS_NONE;
-
- rc = get_hsm_state(inode, &state);
- if (rc)
- return rc;
-
- if (!(state & HS_ARCHIVED)) {
- CDEBUG(D_VFSTRACE,
- "hus_states state = %x, pattern = %x\n",
- state, lump->lmm_pattern);
- /*
- * Here the state is: real file is not
- * archived but user is requesting to set
- * the RELEASED flag so we mask off the
- * released flag from the request
- */
- lump->lmm_pattern ^= LOV_PATTERN_F_RELEASED;
- }
- }
-
- if (lump && S_ISREG(inode->i_mode)) {
- __u64 it_flags = FMODE_WRITE;
- int lum_size;
-
- lum_size = ll_lov_user_md_size(lump);
- if (lum_size < 0 || size < lum_size)
- return 0; /* b=10667: ignore error */
-
- rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags,
- lump, lum_size);
- /* b=10667: rc always be 0 here for now */
- rc = 0;
- } else if (S_ISDIR(inode->i_mode)) {
- rc = ll_dir_setstripe(inode, lump, 0);
- }
-
- return rc;
-
+ return ll_setstripe_ea(dentry, (struct lov_user_md *)value,
+ size);
} else if (!strcmp(name, "lma") || !strcmp(name, "link")) {
- ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1);
+ int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR :
+ LPROC_LL_SETXATTR;
+
+ ll_stats_ops_tally(ll_i2sbi(inode), op_type, 1);
return 0;
}
@@ -279,9 +311,8 @@ static int ll_xattr_set(const struct xattr_handler *handler,
flags);
}
-int
-ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
- size_t size, __u64 valid)
+int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
+ size_t size, u64 valid)
{
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -368,9 +399,6 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
const char *name, void *buffer, size_t size)
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
-#ifdef CONFIG_FS_POSIX_ACL
- struct ll_inode_info *lli = ll_i2info(inode);
-#endif
char *fullname;
int rc;
@@ -383,10 +411,6 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
if (rc)
return rc;
- /* b15587: ignore security.capability xattr for now */
- if ((handler->flags == XATTR_SECURITY_T && !strcmp(name, "capability")))
- return -ENODATA;
-
/* LU-549: Disable security.selinux when selinux is disabled */
if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() &&
!strcmp(name, "selinux"))
@@ -398,6 +422,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
* chance that cached ACL is uptodate.
*/
if (handler->flags == XATTR_ACL_ACCESS_T) {
+ struct ll_inode_info *lli = ll_i2info(inode);
struct posix_acl *acl;
spin_lock(&lli->lli_lock);
@@ -414,9 +439,10 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
if (handler->flags == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
return -ENODATA;
#endif
- fullname = kasprintf(GFP_KERNEL, "%s%s\n", handler->prefix, name);
+ fullname = kasprintf(GFP_KERNEL, "%s%s", handler->prefix, name);
if (!fullname)
return -ENOMEM;
+
rc = ll_xattr_list(inode, fullname, handler->flags, buffer, size,
OBD_MD_FLXATTR);
kfree(fullname);
@@ -540,9 +566,10 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
OBD_MD_FLXATTRLS);
if (rc < 0)
return rc;
+
/*
* If we're being called to get the size of the xattr list
- * (buf_size == 0) then just assume that a lustre.lov xattr
+ * (size == 0) then just assume that a lustre.lov xattr
* exists.
*/
if (!size)
@@ -555,14 +582,14 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
len = strnlen(xattr_name, rem - 1) + 1;
rem -= len;
if (!xattr_type_filter(sbi, get_xattr_type(xattr_name))) {
- /* Skip OK xattr type leave it in buffer */
+ /* Skip OK xattr type, leave it in buffer. */
xattr_name += len;
continue;
}
/*
* Move up remaining xattrs in buffer
- * removing the xattr that is not OK
+ * removing the xattr that is not OK.
*/
memmove(xattr_name, xattr_name + len, rem);
rc -= len;
@@ -605,14 +632,14 @@ static const struct xattr_handler ll_security_xattr_handler = {
};
static const struct xattr_handler ll_acl_access_xattr_handler = {
- .prefix = XATTR_NAME_POSIX_ACL_ACCESS,
+ .name = XATTR_NAME_POSIX_ACL_ACCESS,
.flags = XATTR_ACL_ACCESS_T,
.get = ll_xattr_get_common,
.set = ll_xattr_set_common,
};
static const struct xattr_handler ll_acl_default_xattr_handler = {
- .prefix = XATTR_NAME_POSIX_ACL_DEFAULT,
+ .name = XATTR_NAME_POSIX_ACL_DEFAULT,
.flags = XATTR_ACL_DEFAULT_T,
.get = ll_xattr_get_common,
.set = ll_xattr_set_common,
diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c
index 4dc799d60a9f..5da69ba088c4 100644
--- a/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -121,10 +121,12 @@ static int ll_xattr_cache_add(struct list_head *cache,
xattr->xe_name = kstrdup(xattr_name, GFP_NOFS);
if (!xattr->xe_name) {
- CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
- xattr->xe_namelen);
+ CDEBUG(D_CACHE, "failed to alloc xattr name %s\n",
+ xattr_name);
goto err_name;
}
+ xattr->xe_namelen = strlen(xattr_name) + 1;
+
xattr->xe_value = kmemdup(xattr_val, xattr_val_len, GFP_NOFS);
if (!xattr->xe_value)
goto err_value;
@@ -270,12 +272,6 @@ static int ll_xattr_find_get_lock(struct inode *inode,
struct lustre_handle lockh = { 0 };
struct md_op_data *op_data;
struct ll_inode_info *lli = ll_i2info(inode);
- struct ldlm_enqueue_info einfo = {
- .ei_type = LDLM_IBITS,
- .ei_mode = it_to_lock_mode(oit),
- .ei_cb_bl = &ll_md_blocking_ast,
- .ei_cb_cp = &ldlm_completion_ast,
- };
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct obd_export *exp = sbi->ll_md_exp;
int rc;
@@ -306,8 +302,9 @@ static int ll_xattr_find_get_lock(struct inode *inode,
op_data->op_valid = OBD_MD_FLXATTR | OBD_MD_FLXATTRLS;
- rc = md_enqueue(exp, &einfo, NULL, oit, op_data, &lockh, 0);
+ rc = md_intent_lock(exp, op_data, oit, req, &ll_md_blocking_ast, 0);
ll_finish_md_op_data(op_data);
+ *req = oit->it_request;
if (rc < 0) {
CDEBUG(D_CACHE,
@@ -317,7 +314,6 @@ static int ll_xattr_find_get_lock(struct inode *inode,
return rc;
}
- *req = oit->it_request;
out:
down_write(&lli->lli_xattrs_list_rwsem);
mutex_unlock(&lli->lli_xattrs_enq_lock);
@@ -328,16 +324,15 @@ out:
/**
* Refill the xattr cache.
*
- * Fetch and cache the whole of xattrs for @inode, acquiring
- * a read or a write xattr lock depending on operation in @oit.
- * Intent is dropped on exit unless the operation is setxattr.
+ * Fetch and cache the whole of xattrs for @inode, acquiring a read lock.
*
* \retval 0 no error occurred
* \retval -EPROTO network protocol error
* \retval -ENOMEM not enough memory for the cache
*/
-static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
+static int ll_xattr_cache_refill(struct inode *inode)
{
+ struct lookup_intent oit = { .it_op = IT_GETXATTR };
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req = NULL;
const char *xdata, *xval, *xtail, *xvtail;
@@ -346,40 +341,31 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
__u32 *xsizes;
int rc, i;
- rc = ll_xattr_find_get_lock(inode, oit, &req);
+ rc = ll_xattr_find_get_lock(inode, &oit, &req);
if (rc)
- goto out_no_unlock;
+ goto err_req;
/* Do we have the data at this point? */
if (ll_xattr_cache_valid(lli)) {
ll_stats_ops_tally(sbi, LPROC_LL_GETXATTR_HITS, 1);
+ ll_intent_drop_lock(&oit);
rc = 0;
- goto out_maybe_drop;
+ goto err_req;
}
/* Matched but no cache? Cancelled on error by a parallel refill. */
if (unlikely(!req)) {
CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n");
- rc = -EIO;
- goto out_maybe_drop;
- }
-
- if (oit->it_status < 0) {
- CDEBUG(D_CACHE,
- "getxattr intent returned %d for fid " DFID "\n",
- oit->it_status, PFID(ll_inode2fid(inode)));
- rc = oit->it_status;
- /* xattr data is so large that we don't want to cache it */
- if (rc == -ERANGE)
- rc = -EAGAIN;
- goto out_destroy;
+ ll_intent_drop_lock(&oit);
+ rc = -EAGAIN;
+ goto err_unlock;
}
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (!body) {
CERROR("no MDT BODY in the refill xattr reply\n");
rc = -EPROTO;
- goto out_destroy;
+ goto err_cancel;
}
/* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
@@ -391,7 +377,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
if (!xdata || !xval || !xsizes) {
CERROR("wrong setxattr reply\n");
rc = -EPROTO;
- goto out_destroy;
+ goto err_cancel;
}
xtail = xdata + body->mbo_eadatasize;
@@ -427,7 +413,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
}
if (rc < 0) {
ll_xattr_cache_destroy_locked(lli);
- goto out_destroy;
+ goto err_cancel;
}
xdata += strlen(xdata) + 1;
xval += *xsizes;
@@ -437,28 +423,24 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
if (xdata != xtail || xval != xvtail)
CERROR("a hole in xattr data\n");
- ll_set_lock_data(sbi->ll_md_exp, inode, oit, NULL);
-
- goto out_maybe_drop;
-out_maybe_drop:
+ ll_set_lock_data(sbi->ll_md_exp, inode, &oit, NULL);
+ ll_intent_drop_lock(&oit);
- ll_intent_drop_lock(oit);
-
- if (rc != 0)
- up_write(&lli->lli_xattrs_list_rwsem);
-out_no_unlock:
ptlrpc_req_finished(req);
-
return rc;
-out_destroy:
- up_write(&lli->lli_xattrs_list_rwsem);
-
+err_cancel:
ldlm_lock_decref_and_cancel((struct lustre_handle *)
- &oit->it_lock_handle,
- oit->it_lock_mode);
+ &oit.it_lock_handle,
+ oit.it_lock_mode);
+err_unlock:
+ up_write(&lli->lli_xattrs_list_rwsem);
+err_req:
+ if (rc == -ERANGE)
+ rc = -EAGAIN;
- goto out_no_unlock;
+ ptlrpc_req_finished(req);
+ return rc;
}
/**
@@ -478,7 +460,6 @@ out_destroy:
int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer,
size_t size, __u64 valid)
{
- struct lookup_intent oit = { .it_op = IT_GETXATTR };
struct ll_inode_info *lli = ll_i2info(inode);
int rc = 0;
@@ -487,7 +468,7 @@ int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer,
down_read(&lli->lli_xattrs_list_rwsem);
if (!ll_xattr_cache_valid(lli)) {
up_read(&lli->lli_xattrs_list_rwsem);
- rc = ll_xattr_cache_refill(inode, &oit);
+ rc = ll_xattr_cache_refill(inode);
if (rc)
return rc;
downgrade_write(&lli->lli_xattrs_list_rwsem);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
index 1793c9f79b24..1e850fdbc623 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
@@ -447,6 +447,9 @@ static int lmv_intent_lookup(struct obd_export *exp,
}
}
+ if (!it_has_reply_body(it))
+ return 0;
+
/*
* MDS has returned success. Probably name has been resolved in
* remote inode. Let's check this.
@@ -483,7 +486,7 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
(int)op_data->op_namelen, op_data->op_name,
PFID(&op_data->op_fid1));
- if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT))
+ if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT | IT_GETXATTR))
rc = lmv_intent_lookup(exp, op_data, it, reqp, cb_blocking,
extra_lock_flags);
else if (it->it_op & IT_OPEN)
@@ -497,7 +500,8 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
if (it->it_lock_mode) {
lock_handle.cookie = it->it_lock_handle;
- ldlm_lock_decref(&lock_handle, it->it_lock_mode);
+ ldlm_lock_decref_and_cancel(&lock_handle,
+ it->it_lock_mode);
}
it->it_lock_handle = 0;
@@ -505,8 +509,8 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
if (it->it_remote_lock_mode) {
lock_handle.cookie = it->it_remote_lock_handle;
- ldlm_lock_decref(&lock_handle,
- it->it_remote_lock_mode);
+ ldlm_lock_decref_and_cancel(&lock_handle,
+ it->it_remote_lock_mode);
}
it->it_remote_lock_handle = 0;
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index c27c3c32188d..68a99170c424 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -60,7 +60,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
{
- return container_of0(lmv, struct obd_device, u.lmv);
+ return container_of_safe(lmv, struct obd_device, u.lmv);
}
static inline struct lmv_tgt_desc *
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index e8a9b9902c37..60cdba99e4a4 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -37,11 +37,13 @@
#include <linux/init.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
+#include <linux/file.h>
#include <asm/div64.h>
#include <linux/seq_file.h>
#include <linux/namei.h>
#include <linux/uaccess.h>
+#include <linux/libcfs/libcfs.h>
#include <obd_support.h>
#include <lustre_net.h>
#include <obd_class.h>
@@ -876,7 +878,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
return -EFAULT;
rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
0);
if (rc)
return rc;
@@ -1598,7 +1600,7 @@ lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
static int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
@@ -1652,26 +1654,24 @@ static int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
static int
lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
- const union ldlm_policy_data *policy,
- struct lookup_intent *it, struct md_op_data *op_data,
+ const union ldlm_policy_data *policy, struct md_op_data *op_data,
struct lustre_handle *lockh, __u64 extra_lock_flags)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt;
- CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID "\n",
- LL_IT2STR(it), PFID(&op_data->op_fid1));
+ CDEBUG(D_INODE, "ENQUEUE on " DFID "\n", PFID(&op_data->op_fid1));
tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
if (IS_ERR(tgt))
return PTR_ERR(tgt);
- CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n",
- LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
+ CDEBUG(D_INODE, "ENQUEUE on " DFID " -> mds #%u\n",
+ PFID(&op_data->op_fid1), tgt->ltd_idx);
- return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
- extra_lock_flags);
+ return md_enqueue(tgt->ltd_exp, einfo, policy, op_data, lockh,
+ extra_lock_flags);
}
static int
@@ -1785,7 +1785,7 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if (op_data->op_mea2) {
struct lmv_stripe_md *lsm = op_data->op_mea2;
const struct lmv_oinfo *oinfo;
@@ -1837,7 +1837,7 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if (op_data->op_cli_flags & CLI_MIGRATE) {
LASSERTF(fid_is_sane(&op_data->op_fid3), "invalid FID " DFID "\n",
@@ -2415,7 +2415,7 @@ try_next_stripe:
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
/*
* If child's fid is given, cancel unused locks for it if it is from
@@ -3110,9 +3110,14 @@ static struct md_ops lmv_md_ops = {
static int __init lmv_init(void)
{
struct lprocfs_static_vars lvars;
+ int rc;
lprocfs_lmv_init_vars(&lvars);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
return class_register_type(&lmv_obd_ops, &lmv_md_ops,
LUSTRE_LMV_NAME, NULL);
}
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index 1185eceaf497..e4f762137a4a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -43,8 +43,6 @@
#ifndef LOV_CL_INTERNAL_H
#define LOV_CL_INTERNAL_H
-#include <linux/libcfs/libcfs.h>
-
#include <obd.h>
#include <cl_object.h>
#include "lov_internal.h"
@@ -496,7 +494,7 @@ static inline struct lu_device *lov2lu_dev(struct lov_device *lov)
static inline struct lov_device *lu2lov_dev(const struct lu_device *d)
{
LINVRNT(d->ld_type == &lov_device_type);
- return container_of0(d, struct lov_device, ld_cl.cd_lu_dev);
+ return container_of(d, struct lov_device, ld_cl.cd_lu_dev);
}
static inline struct cl_device *lovsub2cl_dev(struct lovsub_device *lovsub)
@@ -512,13 +510,13 @@ static inline struct lu_device *lovsub2lu_dev(struct lovsub_device *lovsub)
static inline struct lovsub_device *lu2lovsub_dev(const struct lu_device *d)
{
LINVRNT(d->ld_type == &lovsub_device_type);
- return container_of0(d, struct lovsub_device, acid_cl.cd_lu_dev);
+ return container_of(d, struct lovsub_device, acid_cl.cd_lu_dev);
}
static inline struct lovsub_device *cl2lovsub_dev(const struct cl_device *d)
{
LINVRNT(d->cd_lu_dev.ld_type == &lovsub_device_type);
- return container_of0(d, struct lovsub_device, acid_cl);
+ return container_of(d, struct lovsub_device, acid_cl);
}
static inline struct lu_object *lov2lu(struct lov_object *lov)
@@ -534,13 +532,13 @@ static inline struct cl_object *lov2cl(struct lov_object *lov)
static inline struct lov_object *lu2lov(const struct lu_object *obj)
{
LINVRNT(lov_is_object(obj));
- return container_of0(obj, struct lov_object, lo_cl.co_lu);
+ return container_of(obj, struct lov_object, lo_cl.co_lu);
}
static inline struct lov_object *cl2lov(const struct cl_object *obj)
{
LINVRNT(lov_is_object(&obj->co_lu));
- return container_of0(obj, struct lov_object, lo_cl);
+ return container_of(obj, struct lov_object, lo_cl);
}
static inline struct lu_object *lovsub2lu(struct lovsub_object *los)
@@ -556,13 +554,13 @@ static inline struct cl_object *lovsub2cl(struct lovsub_object *los)
static inline struct lovsub_object *cl2lovsub(const struct cl_object *obj)
{
LINVRNT(lovsub_is_object(&obj->co_lu));
- return container_of0(obj, struct lovsub_object, lso_cl);
+ return container_of(obj, struct lovsub_object, lso_cl);
}
static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj)
{
LINVRNT(lovsub_is_object(obj));
- return container_of0(obj, struct lovsub_object, lso_cl.co_lu);
+ return container_of(obj, struct lovsub_object, lso_cl.co_lu);
}
static inline struct lovsub_lock *
@@ -590,14 +588,14 @@ static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice)
static inline struct lov_page *cl2lov_page(const struct cl_page_slice *slice)
{
LINVRNT(lov_is_object(&slice->cpl_obj->co_lu));
- return container_of0(slice, struct lov_page, lps_cl);
+ return container_of(slice, struct lov_page, lps_cl);
}
static inline struct lovsub_page *
cl2lovsub_page(const struct cl_page_slice *slice)
{
LINVRNT(lovsub_is_object(&slice->cpl_obj->co_lu));
- return container_of0(slice, struct lovsub_page, lsb_cl);
+ return container_of(slice, struct lovsub_page, lsb_cl);
}
static inline struct lov_io *cl2lov_io(const struct lu_env *env,
diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
index c56a971745e8..c80320ab0858 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_LOV
#include <asm/div64.h>
-#include <linux/libcfs/libcfs.h>
#include <obd_class.h>
#include <uapi/linux/lustre/lustre_idl.h>
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index a56d71c2dda2..47042f27ca90 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -149,11 +149,16 @@ struct pool_desc {
char pool_name[LOV_MAXPOOLNAME + 1];
struct ost_pool pool_obds;
atomic_t pool_refcount;
- struct hlist_node pool_hash; /* access by poolname */
- struct list_head pool_list; /* serial access */
+ struct rhash_head pool_hash; /* access by poolname */
+ union {
+ struct list_head pool_list; /* serial access */
+ struct rcu_head rcu; /* delayed free */
+ };
struct dentry *pool_debugfs_entry; /* file in debugfs */
struct obd_device *pool_lobd; /* owner */
};
+int lov_pool_hash_init(struct rhashtable *tbl);
+void lov_pool_hash_destroy(struct rhashtable *tbl);
struct lov_request {
struct obd_info rq_oi;
@@ -241,8 +246,6 @@ void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars);
/* lov_cl.c */
extern struct lu_device_type lov_device_type;
-/* pools */
-extern struct cfs_hash_ops pool_hash_operations;
/* ost_pool methods */
int lov_ost_pool_init(struct ost_pool *op, unsigned int count);
int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count);
@@ -277,7 +280,7 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
static inline struct obd_device *lov2obd(const struct lov_obd *lov)
{
- return container_of0(lov, struct obd_device, u.lov);
+ return container_of_safe(lov, struct obd_device, u.lov);
}
#endif
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c
index 3796bbb25305..006717cf7a41 100644
--- a/drivers/staging/lustre/lustre/lov/lov_merge.c
+++ b/drivers/staging/lustre/lustre/lov/lov_merge.c
@@ -33,8 +33,6 @@
#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
-
#include <obd_class.h>
#include "lov_internal.h"
@@ -56,7 +54,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
int rc = 0;
assert_spin_locked(&lsm->lsm_lock);
- LASSERT(lsm->lsm_lock_owner == current_pid());
+ LASSERT(lsm->lsm_lock_owner == current->pid);
CDEBUG(D_INODE, "MDT ID " DOSTID " initial value: s=%llu m=%llu a=%llu c=%llu b=%llu\n",
POSTID(&lsm->lsm_oi), lvb->lvb_size, lvb->lvb_mtime,
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index ec70c12e5b40..7123972d4d5b 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -39,7 +39,6 @@
*/
#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
@@ -795,15 +794,11 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
init_rwsem(&lov->lov_notify_lock);
- lov->lov_pools_hash_body = cfs_hash_create("POOLS", HASH_POOLS_CUR_BITS,
- HASH_POOLS_MAX_BITS,
- HASH_POOLS_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &pool_hash_operations,
- CFS_HASH_DEFAULT);
INIT_LIST_HEAD(&lov->lov_pool_list);
lov->lov_pool_count = 0;
+ rc = lov_pool_hash_init(&lov->lov_pools_hash_body);
+ if (rc)
+ goto out;
rc = lov_ost_pool_init(&lov->lov_packed, 0);
if (rc)
goto out;
@@ -839,7 +834,7 @@ static int lov_cleanup(struct obd_device *obd)
/* coverity[overrun-buffer-val] */
lov_pool_del(obd, pool->pool_name);
}
- cfs_hash_putref(lov->lov_pools_hash_body);
+ lov_pool_hash_destroy(&lov->lov_pools_hash_body);
lov_ost_pool_free(&lov->lov_packed);
lprocfs_obd_cleanup(obd);
@@ -1063,7 +1058,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
/* got statfs data */
rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
flags);
if (rc)
return rc;
@@ -1301,16 +1296,16 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
void lov_stripe_lock(struct lov_stripe_md *md)
__acquires(&md->lsm_lock)
{
- LASSERT(md->lsm_lock_owner != current_pid());
+ LASSERT(md->lsm_lock_owner != current->pid);
spin_lock(&md->lsm_lock);
LASSERT(md->lsm_lock_owner == 0);
- md->lsm_lock_owner = current_pid();
+ md->lsm_lock_owner = current->pid;
}
void lov_stripe_unlock(struct lov_stripe_md *md)
__releases(&md->lsm_lock)
{
- LASSERT(md->lsm_lock_owner == current_pid());
+ LASSERT(md->lsm_lock_owner == current->pid);
md->lsm_lock_owner = 0;
spin_unlock(&md->lsm_lock);
}
@@ -1407,6 +1402,10 @@ static int __init lov_init(void)
*/
CDEBUG(D_INFO, "Lustre LOV module (%p).\n", &lov_caches);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
rc = lu_kmem_init(lov_caches);
if (rc)
return rc;
diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c
index f7c69680cb7d..adc90f310fd7 100644
--- a/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -370,7 +370,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
struct cl_object *sub;
struct lov_layout_raid0 *r0;
struct lu_site *site;
- struct lu_site_bkt_data *bkt;
+ wait_queue_head_t *wq;
wait_queue_entry_t *waiter;
r0 = &lov->u.raid0;
@@ -378,7 +378,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
sub = lovsub2cl(los);
site = sub->co_lu.lo_dev->ld_site;
- bkt = lu_site_bkt_from_fid(site, &sub->co_lu.lo_header->loh_fid);
+ wq = lu_site_wq_from_fid(site, &sub->co_lu.lo_header->loh_fid);
cl_object_kill(env, sub);
/* release a reference to the sub-object and ... */
@@ -391,7 +391,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
if (r0->lo_sub[idx] == los) {
waiter = &lov_env_info(env)->lti_waiter;
init_waitqueue_entry(waiter, current);
- add_wait_queue(&bkt->lsb_marche_funebre, waiter);
+ add_wait_queue(wq, waiter);
set_current_state(TASK_UNINTERRUPTIBLE);
while (1) {
/* this wait-queue is signaled at the end of
@@ -408,7 +408,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
break;
}
}
- remove_wait_queue(&bkt->lsb_marche_funebre, waiter);
+ remove_wait_queue(wq, waiter);
}
LASSERT(!r0->lo_sub[idx]);
}
diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c
index 3e16e647b334..a5f00f6ec347 100644
--- a/drivers/staging/lustre/lustre/lov/lov_offset.c
+++ b/drivers/staging/lustre/lustre/lov/lov_offset.c
@@ -33,8 +33,6 @@
#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
-
#include <obd_class.h>
#include "lov_internal.h"
diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c
index ecd9329cd073..6d2dec9266b6 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pool.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pool.c
@@ -41,14 +41,34 @@
#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
-
#include <obd.h>
#include "lov_internal.h"
#define pool_tgt(_p, _i) \
_p->pool_lobd->u.lov.lov_tgts[_p->pool_obds.op_array[_i]]
+static u32 pool_hashfh(const void *data, u32 len, u32 seed)
+{
+ const char *pool_name = data;
+ return hashlen_hash(hashlen_string((void*)(unsigned long)seed, pool_name));
+}
+
+static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
+{
+ const struct pool_desc *pool = obj;
+ const char *pool_name = arg->key;
+ return strcmp(pool_name, pool->pool_name);
+}
+
+static const struct rhashtable_params pools_hash_params = {
+ .key_len = 1, /* actually variable */
+ .key_offset = offsetof(struct pool_desc, pool_name),
+ .head_offset = offsetof(struct pool_desc, pool_hash),
+ .hashfn = pool_hashfh,
+ .obj_cmpfn = pool_cmpfn,
+ .automatic_shrinking = true,
+};
+
static void lov_pool_getref(struct pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
@@ -59,96 +79,13 @@ void lov_pool_putref(struct pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
if (atomic_dec_and_test(&pool->pool_refcount)) {
- LASSERT(hlist_unhashed(&pool->pool_hash));
LASSERT(list_empty(&pool->pool_list));
LASSERT(!pool->pool_debugfs_entry);
lov_ost_pool_free(&pool->pool_obds);
- kfree(pool);
+ kfree_rcu(pool, rcu);
}
}
-static void lov_pool_putref_locked(struct pool_desc *pool)
-{
- CDEBUG(D_INFO, "pool %p\n", pool);
- LASSERT(atomic_read(&pool->pool_refcount) > 1);
-
- atomic_dec(&pool->pool_refcount);
-}
-
-/*
- * hash function using a Rotating Hash algorithm
- * Knuth, D. The Art of Computer Programming,
- * Volume 3: Sorting and Searching,
- * Chapter 6.4.
- * Addison Wesley, 1973
- */
-static __u32 pool_hashfn(struct cfs_hash *hash_body, const void *key,
- unsigned int mask)
-{
- int i;
- __u32 result;
- char *poolname;
-
- result = 0;
- poolname = (char *)key;
- for (i = 0; i < LOV_MAXPOOLNAME; i++) {
- if (poolname[i] == '\0')
- break;
- result = (result << 4) ^ (result >> 28) ^ poolname[i];
- }
- return (result % mask);
-}
-
-static void *pool_key(struct hlist_node *hnode)
-{
- struct pool_desc *pool;
-
- pool = hlist_entry(hnode, struct pool_desc, pool_hash);
- return pool->pool_name;
-}
-
-static int pool_hashkey_keycmp(const void *key, struct hlist_node *compared_hnode)
-{
- char *pool_name;
- struct pool_desc *pool;
-
- pool_name = (char *)key;
- pool = hlist_entry(compared_hnode, struct pool_desc, pool_hash);
- return !strncmp(pool_name, pool->pool_name, LOV_MAXPOOLNAME);
-}
-
-static void *pool_hashobject(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct pool_desc, pool_hash);
-}
-
-static void pool_hashrefcount_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct pool_desc *pool;
-
- pool = hlist_entry(hnode, struct pool_desc, pool_hash);
- lov_pool_getref(pool);
-}
-
-static void pool_hashrefcount_put_locked(struct cfs_hash *hs,
- struct hlist_node *hnode)
-{
- struct pool_desc *pool;
-
- pool = hlist_entry(hnode, struct pool_desc, pool_hash);
- lov_pool_putref_locked(pool);
-}
-
-struct cfs_hash_ops pool_hash_operations = {
- .hs_hash = pool_hashfn,
- .hs_key = pool_key,
- .hs_keycmp = pool_hashkey_keycmp,
- .hs_object = pool_hashobject,
- .hs_get = pool_hashrefcount_get,
- .hs_put_locked = pool_hashrefcount_put_locked,
-
-};
-
/*
* pool debugfs seq_file methods
*/
@@ -396,6 +333,23 @@ int lov_ost_pool_free(struct ost_pool *op)
return 0;
}
+static void
+pools_hash_exit(void *vpool, void *data)
+{
+ struct pool_desc *pool = vpool;
+ lov_pool_putref(pool);
+}
+
+int lov_pool_hash_init(struct rhashtable *tbl)
+{
+ return rhashtable_init(tbl, &pools_hash_params);
+}
+
+void lov_pool_hash_destroy(struct rhashtable *tbl)
+{
+ rhashtable_free_and_destroy(tbl, pools_hash_exit, NULL);
+}
+
int lov_pool_new(struct obd_device *obd, char *poolname)
{
struct lov_obd *lov;
@@ -421,8 +375,6 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
if (rc)
goto out_err;
- INIT_HLIST_NODE(&new_pool->pool_hash);
-
/* get ref for debugfs file */
lov_pool_getref(new_pool);
new_pool->pool_debugfs_entry = ldebugfs_add_simple(
@@ -443,11 +395,16 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
lov->lov_pool_count++;
spin_unlock(&obd->obd_dev_lock);
- /* add to find only when it fully ready */
- rc = cfs_hash_add_unique(lov->lov_pools_hash_body, poolname,
- &new_pool->pool_hash);
+ /* Add to hash table only when it is fully ready. */
+ rc = rhashtable_lookup_insert_fast(&lov->lov_pools_hash_body,
+ &new_pool->pool_hash, pools_hash_params);
if (rc) {
- rc = -EEXIST;
+ if (rc != -EEXIST)
+ /*
+ * Hide -E2BIG and -EBUSY which
+ * are not helpful.
+ */
+ rc = -ENOMEM;
goto out_err;
}
@@ -476,7 +433,13 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
lov = &obd->u.lov;
/* lookup and kill hash reference */
- pool = cfs_hash_del_key(lov->lov_pools_hash_body, poolname);
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lov->lov_pools_hash_body, poolname, pools_hash_params);
+ if (pool)
+ if (rhashtable_remove_fast(&lov->lov_pools_hash_body,
+ &pool->pool_hash, pools_hash_params) != 0)
+ pool = NULL;
+ rcu_read_unlock();
if (!pool)
return -ENOENT;
@@ -507,7 +470,11 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
lov = &obd->u.lov;
- pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname);
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lov->lov_pools_hash_body, poolname, pools_hash_params);
+ if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+ pool = NULL;
+ rcu_read_unlock();
if (!pool)
return -ENOENT;
@@ -551,7 +518,11 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
lov = &obd->u.lov;
- pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname);
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lov->lov_pools_hash_body, poolname, pools_hash_params);
+ if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+ pool = NULL;
+ rcu_read_unlock();
if (!pool)
return -ENOENT;
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 051450d67524..cb8567f20ea7 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -33,8 +33,6 @@
#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
-
#include <obd_class.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include "lov_internal.h"
@@ -160,7 +158,7 @@ static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
spin_lock(&obd->obd_osfs_lock);
memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
- obd->obd_osfs_age = cfs_time_current_64();
+ obd->obd_osfs_age = get_jiffies_64();
spin_unlock(&obd->obd_osfs_lock);
return 0;
}
@@ -277,7 +275,7 @@ static int cb_statfs_update(void *cookie, int rc)
spin_lock(&tgtobd->obd_osfs_lock);
memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
- tgtobd->obd_osfs_age = cfs_time_current_64();
+ tgtobd->obd_osfs_age = get_jiffies_64();
spin_unlock(&tgtobd->obd_osfs_lock);
out_update:
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
index e0300c34ca3a..28924e927b50 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h
+++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
@@ -50,7 +50,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
void *ea, size_t ealen);
void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode, uid_t uid,
- gid_t gid, cfs_cap_t capability, __u64 rdev);
+ gid_t gid, kernel_cap_t capability, __u64 rdev);
void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
umode_t mode, __u64 rdev, __u64 flags, const void *data,
size_t datalen);
@@ -77,8 +77,8 @@ int mdc_intent_lock(struct obd_export *exp,
int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
const union ldlm_policy_data *policy,
- struct lookup_intent *it, struct md_op_data *op_data,
- struct lustre_handle *lockh, __u64 extra_lock_flags);
+ struct md_op_data *op_data,
+ struct lustre_handle *lockh, u64 extra_lock_flags);
int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
struct list_head *cancels, enum ldlm_mode mode,
@@ -97,7 +97,7 @@ void mdc_replay_open(struct ptlrpc_request *req);
int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode, uid_t uid,
- gid_t gid, cfs_cap_t capability, __u64 rdev,
+ gid_t gid, kernel_cap_t capability, __u64 rdev,
struct ptlrpc_request **request);
int mdc_link(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request);
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
index 46eefdc09e3a..d582968987ff 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
@@ -49,7 +49,7 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
b->mbo_gid = from_kgid(&init_user_ns, current_gid());
b->mbo_fsuid = from_kuid(&init_user_ns, current_fsuid());
b->mbo_fsgid = from_kgid(&init_user_ns, current_fsgid());
- b->mbo_capability = cfs_curproc_cap_pack();
+ b->mbo_capability = current_cap().cap[0];
}
void mdc_swap_layouts_pack(struct ptlrpc_request *req,
@@ -126,7 +126,8 @@ void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff, size_t size,
/* packing of MDS records */
void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective, __u64 rdev)
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
+ __u64 rdev)
{
struct mdt_rec_create *rec;
char *tmp;
@@ -138,7 +139,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->cr_opcode = REINT_CREATE;
rec->cr_fsuid = uid;
rec->cr_fsgid = gid;
- rec->cr_cap = cap_effective;
+ rec->cr_cap = cap_effective.cap[0];
rec->cr_fid1 = op_data->op_fid1;
rec->cr_fid2 = op_data->op_fid2;
rec->cr_mode = mode;
@@ -203,7 +204,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->cr_opcode = REINT_OPEN;
rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->cr_cap = cfs_curproc_cap_pack();
+ rec->cr_cap = current_cap().cap[0];
rec->cr_fid1 = op_data->op_fid1;
rec->cr_fid2 = op_data->op_fid2;
@@ -281,7 +282,7 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
rec->sa_opcode = REINT_SETATTR;
rec->sa_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->sa_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->sa_cap = cfs_curproc_cap_pack();
+ rec->sa_cap = current_cap().cap[0];
rec->sa_suppgid = -1;
rec->sa_fid = op_data->op_fid1;
@@ -350,7 +351,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data)
REINT_RMENTRY : REINT_UNLINK;
rec->ul_fsuid = op_data->op_fsuid;
rec->ul_fsgid = op_data->op_fsgid;
- rec->ul_cap = op_data->op_cap;
+ rec->ul_cap = op_data->op_cap.cap[0];
rec->ul_mode = op_data->op_mode;
rec->ul_suppgid1 = op_data->op_suppgids[0];
rec->ul_suppgid2 = -1;
@@ -372,7 +373,7 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data)
rec->lk_opcode = REINT_LINK;
rec->lk_fsuid = op_data->op_fsuid; /* current->fsuid; */
rec->lk_fsgid = op_data->op_fsgid; /* current->fsgid; */
- rec->lk_cap = op_data->op_cap; /* current->cap_effective; */
+ rec->lk_cap = op_data->op_cap.cap[0]; /* current->cap_effective; */
rec->lk_suppgid1 = op_data->op_suppgids[0];
rec->lk_suppgid2 = op_data->op_suppgids[1];
rec->lk_fid1 = op_data->op_fid1;
@@ -423,7 +424,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->rn_opcode = REINT_RENAME;
rec->rn_fsuid = op_data->op_fsuid;
rec->rn_fsgid = op_data->op_fsgid;
- rec->rn_cap = op_data->op_cap;
+ rec->rn_cap = op_data->op_cap.cap[0];
rec->rn_suppgid1 = op_data->op_suppgids[0];
rec->rn_suppgid2 = op_data->op_suppgids[1];
rec->rn_fid1 = op_data->op_fid1;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 695ef44532cf..253a54550ba8 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -568,7 +568,7 @@ static int mdc_finish_enqueue(struct obd_export *exp,
it->it_op, it->it_disposition, it->it_status);
/* We know what to expect, so we do any byte flipping required here */
- if (it->it_op & (IT_OPEN | IT_UNLINK | IT_LOOKUP | IT_GETATTR)) {
+ if (it_has_reply_body(it)) {
struct mdt_body *body;
body = req_capsule_server_get(pill, &RMF_MDT_BODY);
@@ -688,10 +688,10 @@ static int mdc_finish_enqueue(struct obd_export *exp,
/* We always reserve enough space in the reply packet for a stripe MD, because
* we don't know in advance the file type.
*/
-int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
- const union ldlm_policy_data *policy,
- struct lookup_intent *it, struct md_op_data *op_data,
- struct lustre_handle *lockh, u64 extra_lock_flags)
+int mdc_enqueue_base(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
+ const union ldlm_policy_data *policy,
+ struct lookup_intent *it, struct md_op_data *op_data,
+ struct lustre_handle *lockh, u64 extra_lock_flags)
{
static const union ldlm_policy_data lookup_policy = {
.l_inodebits = { MDS_INODELOCK_LOOKUP }
@@ -859,6 +859,15 @@ resend:
return rc;
}
+int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
+ const union ldlm_policy_data *policy,
+ struct md_op_data *op_data,
+ struct lustre_handle *lockh, u64 extra_lock_flags)
+{
+ return mdc_enqueue_base(exp, einfo, policy, NULL,
+ op_data, lockh, extra_lock_flags);
+}
+
static int mdc_finish_intent_lock(struct obd_export *exp,
struct ptlrpc_request *request,
struct md_op_data *op_data,
@@ -866,9 +875,8 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
struct lustre_handle *lockh)
{
struct lustre_handle old_lock;
- struct mdt_body *mdt_body;
struct ldlm_lock *lock;
- int rc;
+ int rc = 0;
LASSERT(request != LP_POISON);
LASSERT(request->rq_repmsg != LP_POISON);
@@ -876,23 +884,30 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
if (it->it_op & IT_READDIR)
return 0;
+ if (it->it_op & (IT_GETXATTR | IT_LAYOUT)) {
+ if (it->it_status != 0) {
+ rc = it->it_status;
+ goto out;
+ }
+ goto matching_lock;
+ }
+
if (!it_disposition(it, DISP_IT_EXECD)) {
/* The server failed before it even started executing the
* intent, i.e. because it couldn't unpack the request.
*/
LASSERT(it->it_status != 0);
- return it->it_status;
+ rc = it->it_status;
+ goto out;
}
+
rc = it_open_error(DISP_IT_EXECD, it);
if (rc)
- return rc;
-
- mdt_body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY);
- LASSERT(mdt_body); /* mdc_enqueue checked */
+ goto out;
rc = it_open_error(DISP_LOOKUP_EXECD, it);
if (rc)
- return rc;
+ goto out;
/* keep requests around for the multiple phases of the call
* this shows the DISP_XX must guarantee we make it into the call
@@ -918,8 +933,9 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
else if (it->it_op == IT_OPEN)
LASSERT(!it_disposition(it, DISP_OPEN_CREATE));
else
- LASSERT(it->it_op & (IT_GETATTR | IT_LOOKUP | IT_LAYOUT));
+ LASSERT(it->it_op & (IT_GETATTR | IT_LOOKUP));
+matching_lock:
/* If we already have a matching lock, then cancel the new
* one. We have to set the data here instead of in
* mdc_enqueue, because we need to use the child's inode as
@@ -932,10 +948,20 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
LDLM_DEBUG(lock, "matching against this");
- LASSERTF(fid_res_name_eq(&mdt_body->mbo_fid1,
- &lock->l_resource->lr_name),
- "Lock res_id: " DLDLMRES ", fid: " DFID "\n",
- PLDLMRES(lock->l_resource), PFID(&mdt_body->mbo_fid1));
+ if (it_has_reply_body(it)) {
+ struct mdt_body *body;
+
+ body = req_capsule_server_get(&request->rq_pill,
+ &RMF_MDT_BODY);
+
+ /* mdc_enqueue checked */
+ LASSERT(body);
+ LASSERTF(fid_res_name_eq(&body->mbo_fid1,
+ &lock->l_resource->lr_name),
+ "Lock res_id: " DLDLMRES ", fid: " DFID "\n",
+ PLDLMRES(lock->l_resource),
+ PFID(&body->mbo_fid1));
+ }
LDLM_LOCK_PUT(lock);
memcpy(&old_lock, lockh, sizeof(*lockh));
@@ -948,6 +974,7 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
it->it_lock_handle = lockh->cookie;
}
}
+out:
CDEBUG(D_DENTRY,
"D_IT dentry %.*s intent: %s status %d disp %x rc %d\n",
(int)op_data->op_namelen, op_data->op_name,
@@ -1094,8 +1121,9 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
return rc;
}
}
- rc = mdc_enqueue(exp, &einfo, NULL, it, op_data, &lockh,
- extra_lock_flags);
+
+ rc = mdc_enqueue_base(exp, &einfo, NULL, it, op_data, &lockh,
+ extra_lock_flags);
if (rc < 0)
return rc;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index 488b98007558..94ab43bcbe4f 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
@@ -148,7 +148,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 8ee7b4d273b2..50709ffe6073 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -38,6 +38,9 @@
# include <linux/miscdevice.h>
# include <linux/init.h>
# include <linux/utsname.h>
+# include <linux/file.h>
+# include <linux/kthread.h>
+#include <linux/prefetch.h>
#include <lustre_errno.h>
#include <cl_object.h>
@@ -303,7 +306,7 @@ static int mdc_xattr_common(struct obd_export *exp,
rec->sx_opcode = REINT_SETXATTR;
rec->sx_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->sx_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->sx_cap = cfs_curproc_cap_pack();
+ rec->sx_cap = current_cap().cap[0];
rec->sx_suppgid1 = suppgid;
rec->sx_suppgid2 = -1;
rec->sx_fid = *fid;
@@ -2104,7 +2107,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
}
rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
0);
if (rc != 0)
goto out;
@@ -2733,6 +2736,11 @@ static struct md_ops mdc_md_ops = {
static int __init mdc_init(void)
{
struct lprocfs_static_vars lvars = { NULL };
+ int rc;
+
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
lprocfs_mdc_init_vars(&lvars);
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index 2c571c180578..9541892b67c7 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -34,7 +34,6 @@
#ifndef _MGC_INTERNAL_H
#define _MGC_INTERNAL_H
-#include <linux/libcfs/libcfs.h>
#include <lustre_lib.h>
#include <lustre_dlm.h>
#include <lustre_log.h>
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index c61cd23a96df..32df804614d3 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -39,6 +39,7 @@
#define D_MGC D_CONFIG /*|D_WARNING*/
#include <linux/module.h>
+#include <linux/random.h>
#include <lprocfs_status.h>
#include <lustre_dlm.h>
@@ -1826,6 +1827,12 @@ static struct obd_ops mgc_obd_ops = {
static int __init mgc_init(void)
{
+ int rc;
+
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
return class_register_type(&mgc_obd_ops, NULL,
LUSTRE_MGC_NAME, NULL);
}
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index ab84e011b560..fcdae6029258 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
int result = 0;
LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
- LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
LINVRNT(cl_io_invariant(io));
cl_io_for_each(scan, io) {
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 7809f6ae1809..42cce2dc5a45 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -47,13 +47,11 @@
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/libcfs/libcfs.h>
/* class_put_type() */
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_fid.h>
#include <linux/list.h>
-#include <linux/libcfs/libcfs_hash.h> /* for cfs_hash stuff */
#include <cl_object.h>
#include <lu_object.h>
#include "cl_internal.h"
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index d3b25667bc3a..916cf81c5997 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/libcfs/libcfs.h>
#include <obd_class.h>
#include <obd_support.h>
#include <linux/list.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 3e24b76f6301..d6c46858941b 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -32,7 +32,10 @@
*/
#define DEBUG_SUBSYSTEM S_CLASS
-# include <linux/atomic.h>
+
+#include <linux/atomic.h>
+#include <linux/miscdevice.h>
+#include <linux/libcfs/libcfs.h>
#include <obd_support.h>
#include <obd_class.h>
@@ -42,6 +45,7 @@
#include <linux/list.h>
#include <cl_object.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
+#include <uapi/linux/lnet/libcfs_ioctl.h>
#include "llog_internal.h"
struct obd_device *obd_devs[MAX_OBD_DEVICES];
@@ -98,7 +102,7 @@ int lustre_get_jobid(char *jobid)
/* Use process name + fsuid as jobid */
if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u",
- current_comm(),
+ current->comm,
from_kuid(&init_user_ns, current_fsuid()));
return 0;
}
@@ -447,6 +451,11 @@ static int __init obdclass_init(void)
LCONSOLE_INFO("Lustre: Build Version: " LUSTRE_VERSION_STRING "\n");
spin_lock_init(&obd_types_lock);
+
+ err = libcfs_setup();
+ if (err)
+ return err;
+
obd_zombie_impexp_init();
err = obd_init_checks();
@@ -462,7 +471,7 @@ static int __init obdclass_init(void)
err = misc_register(&obd_psdev);
if (err) {
- CERROR("cannot register %d err %d\n", OBD_DEV_MINOR, err);
+ CERROR("cannot register OBD miscdevices: err %d\n", err);
return err;
}
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 63ccbabb4c5a..af233b868742 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -713,7 +713,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
struct obd_uuid *cluuid)
{
struct obd_export *export;
- struct cfs_hash *hash = NULL;
int rc = 0;
export = kzalloc(sizeof(*export), GFP_NOFS);
@@ -721,8 +720,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
return ERR_PTR(-ENOMEM);
export->exp_conn_cnt = 0;
- export->exp_lock_hash = NULL;
- export->exp_flock_hash = NULL;
atomic_set(&export->exp_refcount, 2);
atomic_set(&export->exp_rpc_count, 0);
atomic_set(&export->exp_cb_count, 0);
@@ -742,7 +739,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
class_handle_hash(&export->exp_handle, &export_handle_ops);
spin_lock_init(&export->exp_lock);
spin_lock_init(&export->exp_rpc_lock);
- INIT_HLIST_NODE(&export->exp_uuid_hash);
spin_lock_init(&export->exp_bl_list_lock);
INIT_LIST_HEAD(&export->exp_bl_list);
INIT_WORK(&export->exp_zombie_work, obd_zombie_exp_cull);
@@ -759,44 +755,24 @@ struct obd_export *class_new_export(struct obd_device *obd,
goto exit_unlock;
}
- hash = cfs_hash_getref(obd->obd_uuid_hash);
- if (!hash) {
- rc = -ENODEV;
- goto exit_unlock;
- }
- spin_unlock(&obd->obd_dev_lock);
-
if (!obd_uuid_equals(cluuid, &obd->obd_uuid)) {
- rc = cfs_hash_add_unique(hash, cluuid, &export->exp_uuid_hash);
- if (rc != 0) {
+ rc = obd_uuid_add(obd, export);
+ if (rc) {
LCONSOLE_WARN("%s: denying duplicate export for %s, %d\n",
obd->obd_name, cluuid->uuid, rc);
- rc = -EALREADY;
- goto exit_err;
+ goto exit_unlock;
}
}
- spin_lock(&obd->obd_dev_lock);
- if (obd->obd_stopping) {
- cfs_hash_del(hash, cluuid, &export->exp_uuid_hash);
- rc = -ENODEV;
- goto exit_unlock;
- }
-
class_incref(obd, "export", export);
list_add(&export->exp_obd_chain, &export->exp_obd->obd_exports);
export->exp_obd->obd_num_exports++;
spin_unlock(&obd->obd_dev_lock);
- cfs_hash_putref(hash);
return export;
exit_unlock:
spin_unlock(&obd->obd_dev_lock);
-exit_err:
- if (hash)
- cfs_hash_putref(hash);
class_handle_unhash(&export->exp_handle);
- LASSERT(hlist_unhashed(&export->exp_uuid_hash));
obd_destroy_export(export);
kfree(export);
return ERR_PTR(rc);
@@ -809,10 +785,8 @@ void class_unlink_export(struct obd_export *exp)
spin_lock(&exp->exp_obd->obd_dev_lock);
/* delete an uuid-export hashitem from hashtables */
- if (!hlist_unhashed(&exp->exp_uuid_hash))
- cfs_hash_del(exp->exp_obd->obd_uuid_hash,
- &exp->exp_client_uuid,
- &exp->exp_uuid_hash);
+ if (exp != exp->exp_obd->obd_self_export)
+ obd_uuid_del(exp->exp_obd, exp);
list_move(&exp->exp_obd_chain, &exp->exp_obd->obd_unlinked_exports);
exp->exp_obd->obd_num_exports--;
diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
index b9bf81607bbf..63067a7f1e19 100644
--- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
+++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
@@ -39,6 +39,8 @@
#define DEBUG_SUBSYSTEM S_CLASS
#define D_KUC D_OTHER
+#include <linux/file.h>
+#include <linux/libcfs/libcfs.h>
#include <obd_support.h>
#include <lustre_kernelcomm.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 7bceee7f121e..d3196439985b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -42,7 +42,6 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
-#include <linux/major.h>
#include <linux/sched.h>
#include <linux/lp.h>
#include <linux/slab.h>
@@ -61,7 +60,6 @@
#include <linux/seq_file.h>
#include <linux/kobject.h>
-#include <linux/libcfs/libcfs.h>
#include <uapi/linux/lnet/lnetctl.h>
#include <obd_support.h>
#include <obd_class.h>
@@ -271,7 +269,7 @@ static const struct file_operations obd_psdev_fops = {
/* modules setup */
struct miscdevice obd_psdev = {
- .minor = OBD_DEV_MINOR,
+ .minor = MISC_DYNAMIC_MINOR,
.name = OBD_DEV_NAME,
.fops = &obd_psdev_fops,
};
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 693e1129f1f9..bba84eae1e19 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -44,6 +44,7 @@
#define DEBUG_SUBSYSTEM S_LOG
+#include <linux/kthread.h>
#include <llog_swab.h>
#include <lustre_log.h>
#include <obd_class.h>
@@ -385,7 +386,7 @@ out:
if (cd)
cd->lpcd_last_idx = last_called_index;
- kfree(buf);
+ kvfree(buf);
lpi->lpi_rc = rc;
return 0;
}
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
index c83b7d7f8e72..85f09aff6e83 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
@@ -41,6 +41,7 @@
#include <linux/module.h>
#include <lprocfs_status.h>
#include <obd_support.h>
+#include <linux/libcfs/libcfs.h>
void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount)
{
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 2ed350527398..eb6396add78d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
@@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%llu\n", osfs.os_files);
@@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
- cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+ get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
OBD_STATFS_NODELAY);
if (!rc)
return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 3ae16e8501c2..aa9d74e087f4 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -41,8 +41,6 @@
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/libcfs/libcfs.h>
-
#include <linux/module.h>
/* hash_long() */
@@ -56,6 +54,27 @@
#include <lu_ref.h>
#include <linux/list.h>
+struct lu_site_bkt_data {
+ /**
+ * LRU list, updated on each access to object. Protected by
+ * bucket lock of lu_site::ls_obj_hash.
+ *
+ * "Cold" end of LRU is lu_site::ls_lru.next. Accessed object are
+ * moved to the lu_site::ls_lru.prev (this is due to the non-existence
+ * of list_for_each_entry_safe_reverse()).
+ */
+ struct list_head lsb_lru;
+ /**
+ * Wait-queue signaled when an object in this site is ultimately
+ * destroyed (lu_object_free()). It is used by lu_object_find() to
+ * wait before re-trying when object in the process of destruction is
+ * found in the hash table.
+ *
+ * \see htable_lookup().
+ */
+ wait_queue_head_t lsb_marche_funebre;
+};
+
enum {
LU_CACHE_PERCENT_MAX = 50,
LU_CACHE_PERCENT_DEFAULT = 20
@@ -88,6 +107,18 @@ MODULE_PARM_DESC(lu_cache_nr, "Maximum number of objects in lu_object cache");
static void lu_object_free(const struct lu_env *env, struct lu_object *o);
static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx);
+wait_queue_head_t *
+lu_site_wq_from_fid(struct lu_site *site, struct lu_fid *fid)
+{
+ struct cfs_hash_bd bd;
+ struct lu_site_bkt_data *bkt;
+
+ cfs_hash_bd_get(site->ls_obj_hash, fid, &bd);
+ bkt = cfs_hash_bd_extra_get(site->ls_obj_hash, &bd);
+ return &bkt->lsb_marche_funebre;
+}
+EXPORT_SYMBOL(lu_site_wq_from_fid);
+
/**
* Decrease reference counter on object. If last reference is freed, return
* object to the cache, unless lu_object_is_dying(o) holds. In the latter
@@ -151,10 +182,9 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
if (!lu_object_is_dying(top)) {
LASSERT(list_empty(&top->loh_lru));
list_add_tail(&top->loh_lru, &bkt->lsb_lru);
- bkt->lsb_lru_len++;
percpu_counter_inc(&site->ls_lru_len_counter);
- CDEBUG(D_INODE, "Add %p to site lru. hash: %p, bkt: %p, lru_len: %ld\n",
- o, site->ls_obj_hash, bkt, bkt->lsb_lru_len);
+ CDEBUG(D_INODE, "Add %p to site lru. hash: %p, bkt: %p\n",
+ o, site->ls_obj_hash, bkt);
cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
return;
}
@@ -202,7 +232,6 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o)
list_del_init(&top->loh_lru);
bkt = cfs_hash_bd_extra_get(obj_hash, &bd);
- bkt->lsb_lru_len--;
percpu_counter_dec(&site->ls_lru_len_counter);
}
cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
@@ -288,7 +317,7 @@ next:
*/
static void lu_object_free(const struct lu_env *env, struct lu_object *o)
{
- struct lu_site_bkt_data *bkt;
+ wait_queue_head_t *wq;
struct lu_site *site;
struct lu_object *scan;
struct list_head *layers;
@@ -296,7 +325,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
site = o->lo_dev->ld_site;
layers = &o->lo_header->loh_layers;
- bkt = lu_site_bkt_from_fid(site, &o->lo_header->loh_fid);
+ wq = lu_site_wq_from_fid(site, &o->lo_header->loh_fid);
/*
* First call ->loo_object_delete() method to release all resources.
*/
@@ -319,13 +348,13 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
* lives as long as possible and ->loo_object_free() methods
* can look at its contents.
*/
- o = container_of0(splice.prev, struct lu_object, lo_linkage);
+ o = container_of(splice.prev, struct lu_object, lo_linkage);
list_del_init(&o->lo_linkage);
o->lo_ops->loo_object_free(env, o);
}
- if (waitqueue_active(&bkt->lsb_marche_funebre))
- wake_up_all(&bkt->lsb_marche_funebre);
+ if (waitqueue_active(wq))
+ wake_up_all(wq);
}
/**
@@ -386,7 +415,6 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
cfs_hash_bd_del_locked(s->ls_obj_hash,
&bd2, &h->loh_hash);
list_move(&h->loh_lru, &dispose);
- bkt->lsb_lru_len--;
percpu_counter_dec(&s->ls_lru_len_counter);
if (did_sth == 0)
did_sth = 1;
@@ -404,8 +432,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
* races due to the reasons described in lu_object_put().
*/
while (!list_empty(&dispose)) {
- h = container_of0(dispose.next,
- struct lu_object_header, loh_lru);
+ h = container_of(dispose.next,
+ struct lu_object_header, loh_lru);
list_del_init(&h->loh_lru);
lu_object_free(env, lu_object_top(h));
lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED);
@@ -554,16 +582,19 @@ void lu_object_print(const struct lu_env *env, void *cookie,
}
EXPORT_SYMBOL(lu_object_print);
+/*
+ * NOTE: htable_lookup() is called with the relevant
+ * hash bucket locked, but might drop and re-acquire the lock.
+ */
static struct lu_object *htable_lookup(struct lu_site *s,
struct cfs_hash_bd *bd,
const struct lu_fid *f,
- wait_queue_entry_t *waiter,
__u64 *version)
{
struct lu_site_bkt_data *bkt;
struct lu_object_header *h;
struct hlist_node *hnode;
- __u64 ver = cfs_hash_bd_version_get(bd);
+ u64 ver = cfs_hash_bd_version_get(bd);
if (*version == ver)
return ERR_PTR(-ENOENT);
@@ -579,29 +610,14 @@ static struct lu_object *htable_lookup(struct lu_site *s,
return ERR_PTR(-ENOENT);
}
- h = container_of0(hnode, struct lu_object_header, loh_hash);
- if (likely(!lu_object_is_dying(h))) {
- cfs_hash_get(s->ls_obj_hash, hnode);
- lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
- if (!list_empty(&h->loh_lru)) {
- list_del_init(&h->loh_lru);
- bkt->lsb_lru_len--;
- percpu_counter_dec(&s->ls_lru_len_counter);
- }
- return lu_object_top(h);
+ h = container_of(hnode, struct lu_object_header, loh_hash);
+ cfs_hash_get(s->ls_obj_hash, hnode);
+ lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
+ if (!list_empty(&h->loh_lru)) {
+ list_del_init(&h->loh_lru);
+ percpu_counter_dec(&s->ls_lru_len_counter);
}
-
- /*
- * Lookup found an object being destroyed this object cannot be
- * returned (to assure that references to dying objects are eventually
- * drained), and moreover, lookup has to wait until object is freed.
- */
-
- init_waitqueue_entry(waiter, current);
- add_wait_queue(&bkt->lsb_marche_funebre, waiter);
- set_current_state(TASK_UNINTERRUPTIBLE);
- lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_DEATH_RACE);
- return ERR_PTR(-EAGAIN);
+ return lu_object_top(h);
}
/**
@@ -641,37 +657,17 @@ static void lu_object_limit(const struct lu_env *env, struct lu_device *dev)
false);
}
-static struct lu_object *lu_object_new(const struct lu_env *env,
- struct lu_device *dev,
- const struct lu_fid *f,
- const struct lu_object_conf *conf)
-{
- struct lu_object *o;
- struct cfs_hash *hs;
- struct cfs_hash_bd bd;
-
- o = lu_object_alloc(env, dev, f, conf);
- if (IS_ERR(o))
- return o;
-
- hs = dev->ld_site->ls_obj_hash;
- cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
- cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
- cfs_hash_bd_unlock(hs, &bd, 1);
-
- lu_object_limit(env, dev);
-
- return o;
-}
-
/**
* Core logic of lu_object_find*() functions.
+ *
+ * Much like lu_object_find(), but top level device of object is specifically
+ * \a dev rather than top level device of the site. This interface allows
+ * objects of different "stacking" to be created within the same site.
*/
-static struct lu_object *lu_object_find_try(const struct lu_env *env,
- struct lu_device *dev,
- const struct lu_fid *f,
- const struct lu_object_conf *conf,
- wait_queue_entry_t *waiter)
+struct lu_object *lu_object_find_at(const struct lu_env *env,
+ struct lu_device *dev,
+ const struct lu_fid *f,
+ const struct lu_object_conf *conf)
{
struct lu_object *o;
struct lu_object *shadow;
@@ -697,20 +693,19 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
* It is unnecessary to perform lookup-alloc-lookup-insert, instead,
* just alloc and insert directly.
*
- * If dying object is found during index search, add @waiter to the
- * site wait-queue and return ERR_PTR(-EAGAIN).
*/
- if (conf && conf->loc_flags & LOC_F_NEW)
- return lu_object_new(env, dev, f, conf);
-
s = dev->ld_site;
hs = s->ls_obj_hash;
- cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
- o = htable_lookup(s, &bd, f, waiter, &version);
- cfs_hash_bd_unlock(hs, &bd, 1);
- if (!IS_ERR(o) || PTR_ERR(o) != -ENOENT)
- return o;
+ cfs_hash_bd_get(hs, f, &bd);
+ if (!(conf && conf->loc_flags & LOC_F_NEW)) {
+ cfs_hash_bd_lock(hs, &bd, 1);
+ o = htable_lookup(s, &bd, f, &version);
+ cfs_hash_bd_unlock(hs, &bd, 1);
+
+ if (!IS_ERR(o) || PTR_ERR(o) != -ENOENT)
+ return o;
+ }
/*
* Allocate new object. This may result in rather complicated
* operations, including fld queries, inode loading, etc.
@@ -723,7 +718,10 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
cfs_hash_bd_lock(hs, &bd, 1);
- shadow = htable_lookup(s, &bd, f, waiter, &version);
+ if (conf && conf->loc_flags & LOC_F_NEW)
+ shadow = ERR_PTR(-ENOENT);
+ else
+ shadow = htable_lookup(s, &bd, f, &version);
if (likely(PTR_ERR(shadow) == -ENOENT)) {
cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
cfs_hash_bd_unlock(hs, &bd, 1);
@@ -738,34 +736,6 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
lu_object_free(env, o);
return shadow;
}
-
-/**
- * Much like lu_object_find(), but top level device of object is specifically
- * \a dev rather than top level device of the site. This interface allows
- * objects of different "stacking" to be created within the same site.
- */
-struct lu_object *lu_object_find_at(const struct lu_env *env,
- struct lu_device *dev,
- const struct lu_fid *f,
- const struct lu_object_conf *conf)
-{
- struct lu_site_bkt_data *bkt;
- struct lu_object *obj;
- wait_queue_entry_t wait;
-
- while (1) {
- obj = lu_object_find_try(env, dev, f, conf, &wait);
- if (obj != ERR_PTR(-EAGAIN))
- return obj;
- /*
- * lu_object_find_try() already added waiter into the
- * wait queue.
- */
- schedule();
- bkt = lu_site_bkt_from_fid(dev->ld_site, (void *)f);
- remove_wait_queue(&bkt->lsb_marche_funebre, &wait);
- }
-}
EXPORT_SYMBOL(lu_object_find_at);
/**
@@ -1327,7 +1297,7 @@ enum {
static struct lu_context_key *lu_keys[LU_CONTEXT_KEY_NR] = { NULL, };
-static DEFINE_SPINLOCK(lu_keys_guard);
+static DEFINE_RWLOCK(lu_keys_guard);
static atomic_t lu_key_initing_cnt = ATOMIC_INIT(0);
/**
@@ -1351,7 +1321,7 @@ int lu_context_key_register(struct lu_context_key *key)
LASSERT(key->lct_tags != 0);
result = -ENFILE;
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
if (!lu_keys[i]) {
key->lct_index = i;
@@ -1363,7 +1333,7 @@ int lu_context_key_register(struct lu_context_key *key)
break;
}
}
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
return result;
}
EXPORT_SYMBOL(lu_context_key_register);
@@ -1396,8 +1366,8 @@ void lu_context_key_degister(struct lu_context_key *key)
lu_context_key_quiesce(key);
+ write_lock(&lu_keys_guard);
++key_set_version;
- spin_lock(&lu_keys_guard);
key_fini(&lu_shrink_env.le_ctx, key->lct_index);
/**
@@ -1405,18 +1375,18 @@ void lu_context_key_degister(struct lu_context_key *key)
* run lu_context_key::lct_fini() method.
*/
while (atomic_read(&key->lct_used) > 1) {
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
CDEBUG(D_INFO, "%s: \"%s\" %p, %d\n",
__func__, module_name(key->lct_owner),
key, atomic_read(&key->lct_used));
schedule();
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
}
if (lu_keys[key->lct_index]) {
lu_keys[key->lct_index] = NULL;
lu_ref_fini(&key->lct_reference);
}
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
LASSERTF(atomic_read(&key->lct_used) == 1,
"key has instances: %d\n",
@@ -1536,7 +1506,7 @@ void lu_context_key_quiesce(struct lu_context_key *key)
/*
* XXX memory barrier has to go here.
*/
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
key->lct_tags |= LCT_QUIESCENT;
/**
@@ -1544,27 +1514,30 @@ void lu_context_key_quiesce(struct lu_context_key *key)
* have completed.
*/
while (atomic_read(&lu_key_initing_cnt) > 0) {
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
CDEBUG(D_INFO, "%s: \"%s\" %p, %d (%d)\n",
__func__,
module_name(key->lct_owner),
key, atomic_read(&key->lct_used),
atomic_read(&lu_key_initing_cnt));
schedule();
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
}
list_for_each_entry(ctx, &lu_context_remembered, lc_remember)
key_fini(ctx, key->lct_index);
- spin_unlock(&lu_keys_guard);
+
++key_set_version;
+ write_unlock(&lu_keys_guard);
}
}
void lu_context_key_revive(struct lu_context_key *key)
{
+ write_lock(&lu_keys_guard);
key->lct_tags &= ~LCT_QUIESCENT;
++key_set_version;
+ write_unlock(&lu_keys_guard);
}
static void keys_fini(struct lu_context *ctx)
@@ -1583,6 +1556,7 @@ static void keys_fini(struct lu_context *ctx)
static int keys_fill(struct lu_context *ctx)
{
+ unsigned int pre_version;
unsigned int i;
/*
@@ -1594,10 +1568,12 @@ static int keys_fill(struct lu_context *ctx)
* An atomic_t variable is still used, in order not to reacquire the
* lock when decrementing the counter.
*/
- spin_lock(&lu_keys_guard);
+ read_lock(&lu_keys_guard);
atomic_inc(&lu_key_initing_cnt);
- spin_unlock(&lu_keys_guard);
+ pre_version = key_set_version;
+ read_unlock(&lu_keys_guard);
+refill:
LINVRNT(ctx->lc_value);
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
struct lu_context_key *key;
@@ -1638,9 +1614,17 @@ static int keys_fill(struct lu_context *ctx)
if (key->lct_exit)
ctx->lc_tags |= LCT_HAS_EXIT;
}
- ctx->lc_version = key_set_version;
}
+
+ read_lock(&lu_keys_guard);
+ if (pre_version != key_set_version) {
+ pre_version = key_set_version;
+ read_unlock(&lu_keys_guard);
+ goto refill;
+ }
+ ctx->lc_version = key_set_version;
atomic_dec(&lu_key_initing_cnt);
+ read_unlock(&lu_keys_guard);
return 0;
}
@@ -1665,9 +1649,9 @@ int lu_context_init(struct lu_context *ctx, __u32 tags)
ctx->lc_state = LCS_INITIALIZED;
ctx->lc_tags = tags;
if (tags & LCT_REMEMBER) {
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
list_add(&ctx->lc_remember, &lu_context_remembered);
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
} else {
INIT_LIST_HEAD(&ctx->lc_remember);
}
@@ -1693,10 +1677,10 @@ void lu_context_fini(struct lu_context *ctx)
keys_fini(ctx);
} else { /* could race with key degister */
- spin_lock(&lu_keys_guard);
+ write_lock(&lu_keys_guard);
keys_fini(ctx);
list_del_init(&ctx->lc_remember);
- spin_unlock(&lu_keys_guard);
+ write_unlock(&lu_keys_guard);
}
}
EXPORT_SYMBOL(lu_context_fini);
@@ -1721,10 +1705,11 @@ void lu_context_exit(struct lu_context *ctx)
LINVRNT(ctx->lc_state == LCS_ENTERED);
ctx->lc_state = LCS_LEFT;
if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value) {
+ /* could race with key quiescency */
+ if (ctx->lc_tags & LCT_REMEMBER)
+ read_lock(&lu_keys_guard);
+
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
- /* could race with key quiescency */
- if (ctx->lc_tags & LCT_REMEMBER)
- spin_lock(&lu_keys_guard);
if (ctx->lc_value[i]) {
struct lu_context_key *key;
@@ -1733,9 +1718,10 @@ void lu_context_exit(struct lu_context *ctx)
key->lct_exit(ctx,
key, ctx->lc_value[i]);
}
- if (ctx->lc_tags & LCT_REMEMBER)
- spin_unlock(&lu_keys_guard);
}
+
+ if (ctx->lc_tags & LCT_REMEMBER)
+ read_unlock(&lu_keys_guard);
}
}
EXPORT_SYMBOL(lu_context_exit);
@@ -1747,7 +1733,14 @@ EXPORT_SYMBOL(lu_context_exit);
*/
int lu_context_refill(struct lu_context *ctx)
{
- return likely(ctx->lc_version == key_set_version) ? 0 : keys_fill(ctx);
+ read_lock(&lu_keys_guard);
+ if (likely(ctx->lc_version == key_set_version)) {
+ read_unlock(&lu_keys_guard);
+ return 0;
+ }
+
+ read_unlock(&lu_keys_guard);
+ return keys_fill(ctx);
}
/**
@@ -1798,19 +1791,24 @@ struct lu_site_stats {
unsigned int lss_busy;
};
-static void lu_site_stats_get(struct cfs_hash *hs,
+static void lu_site_stats_get(const struct lu_site *s,
struct lu_site_stats *stats, int populated)
{
+ struct cfs_hash *hs = s->ls_obj_hash;
struct cfs_hash_bd bd;
unsigned int i;
+ /*
+ * percpu_counter_sum_positive() won't accept a const pointer
+ * as it does modify the struct by taking a spinlock
+ */
+ struct lu_site *s2 = (struct lu_site *)s;
+ stats->lss_busy += cfs_hash_size_get(hs) -
+ percpu_counter_sum_positive(&s2->ls_lru_len_counter);
cfs_hash_for_each_bucket(hs, &bd, i) {
- struct lu_site_bkt_data *bkt = cfs_hash_bd_extra_get(hs, &bd);
struct hlist_head *hhead;
cfs_hash_bd_lock(hs, &bd, 1);
- stats->lss_busy +=
- cfs_hash_bd_count_get(&bd) - bkt->lsb_lru_len;
stats->lss_total += cfs_hash_bd_count_get(&bd);
stats->lss_max_search = max((int)stats->lss_max_search,
cfs_hash_bd_depmax_get(&bd));
@@ -2003,7 +2001,7 @@ int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
struct lu_site_stats stats;
memset(&stats, 0, sizeof(stats));
- lu_site_stats_get(s->ls_obj_hash, &stats, 1);
+ lu_site_stats_get(s, &stats, 1);
seq_printf(m, "%d/%d %d/%ld %d %d %d %d %d %d %d\n",
stats.lss_busy,
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
index 54fc88206534..f67cb89ea0ba 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
@@ -39,8 +39,6 @@
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/libcfs/libcfs.h>
-
#include <obd.h>
#include <obd_class.h>
#include <obd_support.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index f53b1a3c342e..cdc8dc10690d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -37,6 +37,7 @@
#define DEBUG_SUBSYSTEM S_CLASS
+#include <linux/random.h>
#include <obd_support.h>
#include <lustre_handles.h>
#include <lustre_lib.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 277576b586db..ffc1814398a5 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -48,7 +48,69 @@
#include "llog_internal.h"
-static struct cfs_hash_ops uuid_hash_ops;
+/*
+ * uuid<->export lustre hash operations
+ */
+/*
+ * NOTE: It is impossible to find an export that is in failed
+ * state with this function
+ */
+static int
+uuid_keycmp(struct rhashtable_compare_arg *arg, const void *obj)
+{
+ const struct obd_uuid *uuid = arg->key;
+ const struct obd_export *exp = obj;
+
+ if (obd_uuid_equals(uuid, &exp->exp_client_uuid) &&
+ !exp->exp_failed)
+ return 0;
+ return -ESRCH;
+}
+
+static void
+uuid_export_exit(void *vexport, void *data)
+{
+ struct obd_export *exp = vexport;
+
+ class_export_put(exp);
+}
+
+static const struct rhashtable_params uuid_hash_params = {
+ .key_len = sizeof(struct obd_uuid),
+ .key_offset = offsetof(struct obd_export, exp_client_uuid),
+ .head_offset = offsetof(struct obd_export, exp_uuid_hash),
+ .obj_cmpfn = uuid_keycmp,
+ .automatic_shrinking = true,
+};
+
+int obd_uuid_add(struct obd_device *obd, struct obd_export *export)
+{
+ int rc;
+
+ rc = rhashtable_lookup_insert_fast(&obd->obd_uuid_hash,
+ &export->exp_uuid_hash,
+ uuid_hash_params);
+ if (rc == 0)
+ class_export_get(export);
+ else if (rc == -EEXIST)
+ rc = -EALREADY;
+ else
+ /* map obscure error codes to -ENOMEM */
+ rc = -ENOMEM;
+ return rc;
+}
+
+void obd_uuid_del(struct obd_device *obd, struct obd_export *export)
+{
+ int rc;
+
+ rc = rhashtable_remove_fast(&obd->obd_uuid_hash,
+ &export->exp_uuid_hash,
+ uuid_hash_params);
+
+ if (rc == 0)
+ class_export_put(export);
+}
/*********** string parsing utils *********/
@@ -269,7 +331,7 @@ static int class_attach(struct lustre_cfg *lcfg)
/* obd->obd_osfs_age must be set to a value in the distant
* past to guarantee a fresh statfs is fetched on mount.
*/
- obd->obd_osfs_age = cfs_time_shift_64(-1000);
+ obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
/* XXX belongs in setup not attach */
init_rwsem(&obd->obd_observer_link_sem);
@@ -347,26 +409,18 @@ static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
* other fns check that status, and we're not actually set up yet.
*/
obd->obd_starting = 1;
- obd->obd_uuid_hash = NULL;
spin_unlock(&obd->obd_dev_lock);
/* create an uuid-export lustre hash */
- obd->obd_uuid_hash = cfs_hash_create("UUID_HASH",
- HASH_UUID_CUR_BITS,
- HASH_UUID_MAX_BITS,
- HASH_UUID_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &uuid_hash_ops, CFS_HASH_DEFAULT);
- if (!obd->obd_uuid_hash) {
- err = -ENOMEM;
+ err = rhashtable_init(&obd->obd_uuid_hash, &uuid_hash_params);
+
+ if (err)
goto err_hash;
- }
exp = class_new_export(obd, &obd->obd_uuid);
if (IS_ERR(exp)) {
err = PTR_ERR(exp);
- goto err_hash;
+ goto err_new;
}
obd->obd_self_export = exp;
@@ -392,11 +446,9 @@ err_exp:
class_unlink_export(obd->obd_self_export);
obd->obd_self_export = NULL;
}
+err_new:
+ rhashtable_destroy(&obd->obd_uuid_hash);
err_hash:
- if (obd->obd_uuid_hash) {
- cfs_hash_putref(obd->obd_uuid_hash);
- obd->obd_uuid_hash = NULL;
- }
obd->obd_starting = 0;
CERROR("setup %s failed (%d)\n", obd->obd_name, err);
return err;
@@ -490,10 +542,7 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
obd->obd_name, err);
/* destroy an uuid-export hash body */
- if (obd->obd_uuid_hash) {
- cfs_hash_putref(obd->obd_uuid_hash);
- obd->obd_uuid_hash = NULL;
- }
+ rhashtable_free_and_destroy(&obd->obd_uuid_hash, uuid_export_exit, NULL);
class_decref(obd, "setup", obd);
obd->obd_set_up = 0;
@@ -1487,73 +1536,3 @@ out:
return rc;
}
EXPORT_SYMBOL(class_manual_cleanup);
-
-/*
- * uuid<->export lustre hash operations
- */
-
-static unsigned int
-uuid_hash(struct cfs_hash *hs, const void *key, unsigned int mask)
-{
- return cfs_hash_djb2_hash(((struct obd_uuid *)key)->uuid,
- sizeof(((struct obd_uuid *)key)->uuid), mask);
-}
-
-static void *
-uuid_key(struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_uuid_hash);
-
- return &exp->exp_client_uuid;
-}
-
-/*
- * NOTE: It is impossible to find an export that is in failed
- * state with this function
- */
-static int
-uuid_keycmp(const void *key, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- LASSERT(key);
- exp = hlist_entry(hnode, struct obd_export, exp_uuid_hash);
-
- return obd_uuid_equals(key, &exp->exp_client_uuid) &&
- !exp->exp_failed;
-}
-
-static void *
-uuid_export_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct obd_export, exp_uuid_hash);
-}
-
-static void
-uuid_export_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_uuid_hash);
- class_export_get(exp);
-}
-
-static void
-uuid_export_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_uuid_hash);
- class_export_put(exp);
-}
-
-static struct cfs_hash_ops uuid_hash_ops = {
- .hs_hash = uuid_hash,
- .hs_key = uuid_key,
- .hs_keycmp = uuid_keycmp,
- .hs_object = uuid_export_object,
- .hs_get = uuid_export_get,
- .hs_put_locked = uuid_export_put_locked,
-};
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index f5e8214ac37b..06c38fdef7ba 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -41,6 +41,7 @@
#define D_MOUNT (D_SUPER | D_CONFIG/*|D_WARNING */)
#define PRINT_CMD CDEBUG
+#include <linux/random.h>
#include <obd.h>
#include <lustre_compat.h>
#include <obd_class.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c
index 6cf7a03f048f..ec8c6dc5c9a7 100644
--- a/drivers/staging/lustre/lustre/obdclass/uuid.c
+++ b/drivers/staging/lustre/lustre/obdclass/uuid.c
@@ -35,8 +35,6 @@
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/libcfs/libcfs.h>
-
#include <obd_support.h>
#include <obd_class.h>
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 99a76db51ae0..b692e76e7108 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -32,7 +32,6 @@
*/
#define DEBUG_SUBSYSTEM S_ECHO
-#include <linux/libcfs/libcfs.h>
#include <obd.h>
#include <obd_support.h>
@@ -99,7 +98,7 @@ static int echo_client_cleanup(struct obd_device *obddev);
*/
static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
{
- return container_of0(dev, struct echo_device, ed_cl);
+ return container_of_safe(dev, struct echo_device, ed_cl);
}
static inline struct cl_device *echo_dev2cl(struct echo_device *d)
@@ -1701,10 +1700,16 @@ static void echo_client_exit(void)
static int __init obdecho_init(void)
{
+ int rc;
+
LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
LASSERT(PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
return echo_client_init();
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 459503727ce3..f26983004843 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -1290,7 +1290,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
result = cl_page_make_ready(env, page, CRT_WRITE);
if (result == 0)
- opg->ops_submit_time = cfs_time_current();
+ opg->ops_submit_time = jiffies;
return result;
}
@@ -2622,7 +2622,7 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
oap->oap_async_flags |= ASYNC_READY | ASYNC_URGENT;
spin_unlock(&oap->oap_lock);
- if (memory_pressure_get())
+ if (current->flags & PF_MEMALLOC)
ext->oe_memalloc = 1;
ext->oe_urgent = 1;
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 1449013722f6..2d3cba16ef34 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -43,8 +43,6 @@
#ifndef OSC_CL_INTERNAL_H
#define OSC_CL_INTERNAL_H
-#include <linux/libcfs/libcfs.h>
-
#include <obd.h>
/* osc_build_res_name() */
#include <cl_object.h>
@@ -460,7 +458,7 @@ static inline int osc_is_object(const struct lu_object *obj)
static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
{
LINVRNT(d->ld_type == &osc_device_type);
- return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
+ return container_of(d, struct osc_device, od_cl.cd_lu_dev);
}
static inline struct obd_export *osc_export(const struct osc_object *obj)
@@ -476,7 +474,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
static inline struct osc_object *cl2osc(const struct cl_object *obj)
{
LINVRNT(osc_is_object(&obj->co_lu));
- return container_of0(obj, struct osc_object, oo_cl);
+ return container_of(obj, struct osc_object, oo_cl);
}
static inline struct cl_object *osc2cl(const struct osc_object *obj)
@@ -509,12 +507,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
{
LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
- return container_of0(slice, struct osc_page, ops_cl);
+ return container_of(slice, struct osc_page, ops_cl);
}
static inline struct osc_page *oap2osc(struct osc_async_page *oap)
{
- return container_of0(oap, struct osc_page, ops_oap);
+ return container_of_safe(oap, struct osc_page, ops_oap);
}
static inline pgoff_t osc_index(struct osc_page *opg)
@@ -545,7 +543,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
{
LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
- return container_of0(slice, struct osc_lock, ols_cl);
+ return container_of(slice, struct osc_lock, ols_cl);
}
static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 32db150fd42e..fca020568c19 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -180,7 +180,7 @@ struct osc_device {
static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
{
- return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
+ return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
}
extern struct lu_kmem_descr osc_caches[];
@@ -188,8 +188,9 @@ extern struct lu_kmem_descr osc_caches[];
extern struct kmem_cache *osc_quota_kmem;
struct osc_quota_info {
/** linkage for quota hash table */
- struct hlist_node oqi_hash;
- u32 oqi_id;
+ struct rhash_head oqi_hash;
+ u32 oqi_id;
+ struct rcu_head rcu;
};
int osc_quota_setup(struct obd_device *obd);
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 76743faf3e6d..67734a8ed331 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -55,7 +55,7 @@
static struct osc_io *cl2osc_io(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
+ struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
LINVRNT(oio == osc_env_io(env));
return oio;
diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
index fe8ed0d0497a..d93d33dc8dc4 100644
--- a/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_OSC
-#include <linux/libcfs/libcfs.h>
/* fid_build_reg_res_name() */
#include <lustre_fid.h>
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 6baa8e2e00c9..84240181c7ea 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
static struct osc_object *lu2osc(const struct lu_object *obj)
{
LINVRNT(osc_is_object(obj));
- return container_of0(obj, struct osc_object, oo_cl.co_lu);
+ return container_of(obj, struct osc_object, oo_cl.co_lu);
}
/*****************************************************************************
@@ -300,7 +300,7 @@ drop_lock:
void osc_object_set_contended(struct osc_object *obj)
{
- obj->oo_contention_time = cfs_time_current();
+ obj->oo_contention_time = jiffies;
/* mb(); */
obj->oo_contended = 1;
}
@@ -314,7 +314,7 @@ int osc_object_is_contended(struct osc_object *obj)
{
struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
int osc_contention_time = dev->od_contention_time;
- unsigned long cur_time = cfs_time_current();
+ unsigned long cur_time = jiffies;
unsigned long retry_time;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
@@ -327,9 +327,8 @@ int osc_object_is_contended(struct osc_object *obj)
* I like copy-paste. the code is copied from
* ll_file_is_contended.
*/
- retry_time = cfs_time_add(obj->oo_contention_time,
- osc_contention_time * HZ);
- if (cfs_time_after(cur_time, retry_time)) {
+ retry_time = obj->oo_contention_time + osc_contention_time * HZ;
+ if (time_after(cur_time, retry_time)) {
osc_object_clear_contended(obj);
return 0;
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 01a930dbbf64..20c553ef3a5e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -125,7 +125,7 @@ static inline unsigned long osc_submit_duration(struct osc_page *opg)
if (opg->ops_submit_time == 0)
return 0;
- return (cfs_time_current() - opg->ops_submit_time);
+ return (jiffies - opg->ops_submit_time);
}
static int osc_page_print(const struct lu_env *env,
@@ -312,7 +312,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
oap->oap_cmd |= OBD_BRW_NOQUOTA;
}
- opg->ops_submit_time = cfs_time_current();
+ opg->ops_submit_time = jiffies;
osc_page_transfer_get(opg, "transfer\0imm");
osc_page_transfer_add(env, opg, crt);
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c
index ce1731dc604f..723ec2fb18bf 100644
--- a/drivers/staging/lustre/lustre/osc/osc_quota.c
+++ b/drivers/staging/lustre/lustre/osc/osc_quota.c
@@ -27,6 +27,13 @@
#include <obd_class.h>
#include "osc_internal.h"
+static const struct rhashtable_params quota_hash_params = {
+ .key_len = sizeof(u32),
+ .key_offset = offsetof(struct osc_quota_info, oqi_id),
+ .head_offset = offsetof(struct osc_quota_info, oqi_hash),
+ .automatic_shrinking = true,
+};
+
static inline struct osc_quota_info *osc_oqi_alloc(u32 id)
{
struct osc_quota_info *oqi;
@@ -45,9 +52,10 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[])
for (type = 0; type < MAXQUOTAS; type++) {
struct osc_quota_info *oqi;
- oqi = cfs_hash_lookup(cli->cl_quota_hash[type], &qid[type]);
+ oqi = rhashtable_lookup_fast(&cli->cl_quota_hash[type], &qid[type],
+ quota_hash_params);
if (oqi) {
- /* do not try to access oqi here, it could have been
+ /* Must not access oqi here, it could have been
* freed by osc_quota_setdq()
*/
@@ -63,6 +71,14 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[])
return QUOTA_OK;
}
+static void osc_quota_free(struct rcu_head *head)
+{
+ struct osc_quota_info *oqi = container_of(head, struct osc_quota_info, rcu);
+
+ kmem_cache_free(osc_quota_kmem, oqi);
+}
+
+
#define MD_QUOTA_FLAG(type) ((type == USRQUOTA) ? OBD_MD_FLUSRQUOTA \
: OBD_MD_FLGRPQUOTA)
#define FL_QUOTA_FLAG(type) ((type == USRQUOTA) ? OBD_FL_NO_USRQUOTA \
@@ -84,11 +100,14 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
continue;
/* lookup the ID in the per-type hash table */
- oqi = cfs_hash_lookup(cli->cl_quota_hash[type], &qid[type]);
+ rcu_read_lock();
+ oqi = rhashtable_lookup_fast(&cli->cl_quota_hash[type], &qid[type],
+ quota_hash_params);
if ((flags & FL_QUOTA_FLAG(type)) != 0) {
/* This ID is getting close to its quota limit, let's
* switch to sync I/O
*/
+ rcu_read_unlock();
if (oqi)
continue;
@@ -98,12 +117,16 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
break;
}
- rc = cfs_hash_add_unique(cli->cl_quota_hash[type],
- &qid[type], &oqi->oqi_hash);
+ rc = rhashtable_lookup_insert_fast(&cli->cl_quota_hash[type],
+ &oqi->oqi_hash, quota_hash_params);
/* race with others? */
- if (rc == -EALREADY) {
- rc = 0;
+ if (rc) {
kmem_cache_free(osc_quota_kmem, oqi);
+ if (rc != -EEXIST) {
+ rc = -ENOMEM;
+ break;
+ }
+ rc = 0;
}
CDEBUG(D_QUOTA, "%s: setdq to insert for %s %d (%d)\n",
@@ -114,14 +137,14 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
/* This ID is now off the hook, let's remove it from
* the hash table
*/
- if (!oqi)
+ if (!oqi) {
+ rcu_read_unlock();
continue;
-
- oqi = cfs_hash_del_key(cli->cl_quota_hash[type],
- &qid[type]);
- if (oqi)
- kmem_cache_free(osc_quota_kmem, oqi);
-
+ }
+ if (rhashtable_remove_fast(&cli->cl_quota_hash[type],
+ &oqi->oqi_hash, quota_hash_params) == 0)
+ call_rcu(&oqi->rcu, osc_quota_free);
+ rcu_read_unlock();
CDEBUG(D_QUOTA, "%s: setdq to remove for %s %d (%p)\n",
cli_name(cli),
type == USRQUOTA ? "user" : "group",
@@ -132,93 +155,21 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
return rc;
}
-/*
- * Hash operations for uid/gid <-> osc_quota_info
- */
-static unsigned int
-oqi_hashfn(struct cfs_hash *hs, const void *key, unsigned int mask)
-{
- return cfs_hash_u32_hash(*((__u32 *)key), mask);
-}
-
-static int
-oqi_keycmp(const void *key, struct hlist_node *hnode)
-{
- struct osc_quota_info *oqi;
- u32 uid;
-
- LASSERT(key);
- uid = *((u32 *)key);
- oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
-
- return uid == oqi->oqi_id;
-}
-
-static void *
-oqi_key(struct hlist_node *hnode)
-{
- struct osc_quota_info *oqi;
-
- oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
- return &oqi->oqi_id;
-}
-
-static void *
-oqi_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct osc_quota_info, oqi_hash);
-}
-
-static void
-oqi_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
-}
-
-static void
-oqi_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
-}
-
static void
-oqi_exit(struct cfs_hash *hs, struct hlist_node *hnode)
+oqi_exit(void *vquota, void *data)
{
- struct osc_quota_info *oqi;
-
- oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
+ struct osc_quota_info *oqi = vquota;
- kmem_cache_free(osc_quota_kmem, oqi);
+ osc_quota_free(&oqi->rcu);
}
-#define HASH_QUOTA_BKT_BITS 5
-#define HASH_QUOTA_CUR_BITS 5
-#define HASH_QUOTA_MAX_BITS 15
-
-static struct cfs_hash_ops quota_hash_ops = {
- .hs_hash = oqi_hashfn,
- .hs_keycmp = oqi_keycmp,
- .hs_key = oqi_key,
- .hs_object = oqi_object,
- .hs_get = oqi_get,
- .hs_put_locked = oqi_put_locked,
- .hs_exit = oqi_exit,
-};
-
int osc_quota_setup(struct obd_device *obd)
{
struct client_obd *cli = &obd->u.cli;
int i, type;
for (type = 0; type < MAXQUOTAS; type++) {
- cli->cl_quota_hash[type] = cfs_hash_create("QUOTA_HASH",
- HASH_QUOTA_CUR_BITS,
- HASH_QUOTA_MAX_BITS,
- HASH_QUOTA_BKT_BITS,
- 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &quota_hash_ops,
- CFS_HASH_DEFAULT);
- if (!cli->cl_quota_hash[type])
+ if (rhashtable_init(&cli->cl_quota_hash[type], &quota_hash_params) != 0)
break;
}
@@ -226,7 +177,7 @@ int osc_quota_setup(struct obd_device *obd)
return 0;
for (i = 0; i < type; i++)
- cfs_hash_putref(cli->cl_quota_hash[i]);
+ rhashtable_destroy(&cli->cl_quota_hash[i]);
return -ENOMEM;
}
@@ -237,7 +188,8 @@ int osc_quota_cleanup(struct obd_device *obd)
int type;
for (type = 0; type < MAXQUOTAS; type++)
- cfs_hash_putref(cli->cl_quota_hash[type]);
+ rhashtable_free_and_destroy(&cli->cl_quota_hash[type],
+ oqi_exit, NULL);
return 0;
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 1c2bbbf5d864..61ef6c8d7a12 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -33,7 +33,8 @@
#define DEBUG_SUBSYSTEM S_OSC
-#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_hash.h>
+#include <linux/sched/mm.h>
#include <lustre_dlm.h>
#include <lustre_net.h>
@@ -617,7 +618,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
void osc_update_next_shrink(struct client_obd *cli)
{
cli->cl_next_shrink_grant =
- cfs_time_shift(cli->cl_grant_shrink_interval);
+ jiffies + cli->cl_grant_shrink_interval * HZ;
CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
cli->cl_next_shrink_grant);
}
@@ -741,14 +742,14 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
static int osc_should_shrink_grant(struct client_obd *client)
{
- unsigned long time = cfs_time_current();
+ unsigned long time = jiffies;
unsigned long next_shrink = client->cl_next_shrink_grant;
if ((client->cl_import->imp_connect_data.ocd_connect_flags &
OBD_CONNECT_GRANT_SHRINK) == 0)
return 0;
- if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
+ if (time_after_eq(time, next_shrink - 5)) {
/* Get the current RPC size directly, instead of going via:
* cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
* Keep comment here so that it can be found by searching.
@@ -1654,7 +1655,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
struct cl_req_attr *crattr = NULL;
u64 starting_offset = OBD_OBJECT_EOF;
u64 ending_offset = 0;
- int mpflag = 0;
+ unsigned int mpflag = 0;
int mem_tight = 0;
int page_count = 0;
bool soft_sync = false;
@@ -1677,7 +1678,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
soft_sync = osc_over_unstable_soft_limit(cli);
if (mem_tight)
- mpflag = cfs_memory_pressure_get_and_set();
+ mpflag = memalloc_noreclaim_save();
pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS);
if (!pga) {
@@ -1791,7 +1792,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
out:
if (mem_tight != 0)
- cfs_memory_pressure_restore(mpflag);
+ memalloc_noreclaim_restore(mpflag);
if (rc != 0) {
LASSERT(!req);
@@ -2296,7 +2297,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
goto out;
default:
CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n",
- cmd, current_comm());
+ cmd, current->comm);
err = -ENOTTY;
goto out;
}
@@ -2831,25 +2832,24 @@ static int __init osc_init(void)
*/
CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches);
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
rc = lu_kmem_init(osc_caches);
if (rc)
return rc;
lprocfs_osc_init_vars(&lvars);
- rc = class_register_type(&osc_obd_ops, NULL,
- LUSTRE_OSC_NAME, &osc_device_type);
- if (rc)
- goto out_kmem;
-
rc = register_shrinker(&osc_cache_shrinker);
if (rc)
- goto out_type;
+ goto err;
/* This is obviously too much memory, only prevent overflow here */
if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) {
rc = -EINVAL;
- goto out_type;
+ goto err;
}
reqpool_size = osc_reqpool_mem_max << 20;
@@ -2870,14 +2870,22 @@ static int __init osc_init(void)
osc_rq_pool = ptlrpc_init_rq_pool(0, OST_MAXREQSIZE,
ptlrpc_add_rqs_to_pool);
- if (osc_rq_pool)
- return 0;
-
rc = -ENOMEM;
-out_type:
- class_unregister_type(LUSTRE_OSC_NAME);
-out_kmem:
+ if (!osc_rq_pool)
+ goto err;
+
+ rc = class_register_type(&osc_obd_ops, NULL,
+ LUSTRE_OSC_NAME, &osc_device_type);
+ if (rc)
+ goto err;
+
+ return rc;
+
+err:
+ if (osc_rq_pool)
+ ptlrpc_free_rq_pool(osc_rq_pool);
+ unregister_shrinker(&osc_cache_shrinker);
lu_kmem_fini(osc_caches);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index ca096fadb9c0..c1b82bf20f08 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -35,6 +35,8 @@
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/random.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_lib.h>
@@ -938,9 +940,9 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
struct ptlrpc_request_set *set;
int cpt;
- cpt = cfs_cpt_current(cfs_cpt_table, 0);
+ cpt = cfs_cpt_current(cfs_cpt_tab, 0);
set = kzalloc_node(sizeof(*set), GFP_NOFS,
- cfs_cpt_spread_node(cfs_cpt_table, cpt));
+ cfs_cpt_spread_node(cfs_cpt_tab, cpt));
if (!set)
return NULL;
atomic_set(&set->set_refcount, 1);
@@ -1050,7 +1052,7 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
list_add_tail(&req->rq_set_chain, &set->set_requests);
req->rq_set = set;
atomic_inc(&set->set_remaining);
- req->rq_queued_time = cfs_time_current();
+ req->rq_queued_time = jiffies;
if (req->rq_reqmsg)
lustre_msg_set_jobid(req->rq_reqmsg, NULL);
@@ -1081,7 +1083,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
spin_lock(&set->set_new_req_lock);
/* The set takes over the caller's request reference. */
req->rq_set = set;
- req->rq_queued_time = cfs_time_current();
+ req->rq_queued_time = jiffies;
list_add_tail(&req->rq_set_chain, &set->set_new_requests);
count = atomic_inc_return(&set->set_new_count);
spin_unlock(&set->set_new_req_lock);
@@ -1552,7 +1554,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
lustre_msg_set_last_xid(req->rq_reqmsg, min_xid);
- lustre_msg_set_status(req->rq_reqmsg, current_pid());
+ lustre_msg_set_status(req->rq_reqmsg, current->pid);
rc = sptlrpc_req_refresh_ctx(req, -1);
if (rc) {
@@ -1567,7 +1569,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
}
CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n",
- current_comm(),
+ current->comm,
imp->imp_obd->obd_uuid.uuid,
lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
@@ -1978,7 +1980,7 @@ interpret:
CDEBUG(req->rq_reqmsg ? D_RPCTRACE : 0,
"Completed RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n",
- current_comm(), imp->imp_obd->obd_uuid.uuid,
+ current->comm, imp->imp_obd->obd_uuid.uuid,
lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
lustre_msg_get_opc(req->rq_reqmsg));
@@ -2514,7 +2516,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
}
DEBUG_REQ(D_WARNING, request,
- "Unexpectedly long timeout receiving_reply=%d req_ulinked=%d reply_unlinked=%d",
+ "Unexpectedly long timeout receiving_reply=%d req_unlinked=%d reply_unlinked=%d",
request->rq_receiving_reply,
request->rq_req_unlinked,
request->rq_reply_unlinked);
@@ -2760,7 +2762,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
}
/* for distributed debugging */
- lustre_msg_set_status(req->rq_reqmsg, current_pid());
+ lustre_msg_set_status(req->rq_reqmsg, current->pid);
/* add a ref for the set (see comment in ptlrpc_set_add_req) */
ptlrpc_request_addref(req);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c
index dfdb4587d49d..fb35a89ca6c6 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/connection.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c
@@ -38,8 +38,41 @@
#include "ptlrpc_internal.h"
-static struct cfs_hash *conn_hash;
-static struct cfs_hash_ops conn_hash_ops;
+static struct rhashtable conn_hash;
+
+/*
+ * struct lnet_process_id may contain unassigned bytes which might not
+ * be zero, so we cannot just hash and compare bytes.
+ */
+
+static u32 lnet_process_id_hash(const void *data, u32 len, u32 seed)
+{
+ const struct lnet_process_id *lpi = data;
+
+ seed = hash_32(seed ^ lpi->pid, 32);
+ seed ^= hash_64(lpi->nid, 32);
+ return seed;
+}
+
+static int lnet_process_id_cmp(struct rhashtable_compare_arg *arg,
+ const void *obj)
+{
+ const struct lnet_process_id *lpi = arg->key;
+ const struct ptlrpc_connection *con = obj;
+
+ if (lpi->nid == con->c_peer.nid &&
+ lpi->pid == con->c_peer.pid)
+ return 0;
+ return -ESRCH;
+}
+
+static const struct rhashtable_params conn_hash_params = {
+ .key_len = 1, /* actually variable-length */
+ .key_offset = offsetof(struct ptlrpc_connection, c_peer),
+ .head_offset = offsetof(struct ptlrpc_connection, c_hash),
+ .hashfn = lnet_process_id_hash,
+ .obj_cmpfn = lnet_process_id_cmp,
+};
struct ptlrpc_connection *
ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
@@ -47,9 +80,11 @@ ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
{
struct ptlrpc_connection *conn, *conn2;
- conn = cfs_hash_lookup(conn_hash, &peer);
- if (conn)
+ conn = rhashtable_lookup_fast(&conn_hash, &peer, conn_hash_params);
+ if (conn) {
+ ptlrpc_connection_addref(conn);
goto out;
+ }
conn = kzalloc(sizeof(*conn), GFP_NOFS);
if (!conn)
@@ -57,7 +92,6 @@ ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
conn->c_peer = peer;
conn->c_self = self;
- INIT_HLIST_NODE(&conn->c_hash);
atomic_set(&conn->c_refcount, 1);
if (uuid)
obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);
@@ -65,17 +99,18 @@ ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
/*
* Add the newly created conn to the hash, on key collision we
* lost a racing addition and must destroy our newly allocated
- * connection. The object which exists in the has will be
- * returned and may be compared against out object.
- */
- /* In the function below, .hs_keycmp resolves to
- * conn_keycmp()
+ * connection. The object which exists in the hash will be
+ * returned, otherwise NULL is returned on success.
*/
- /* coverity[overrun-buffer-val] */
- conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
- if (conn != conn2) {
+ conn2 = rhashtable_lookup_get_insert_fast(&conn_hash, &conn->c_hash,
+ conn_hash_params);
+ if (conn2 != NULL) {
+ /* insertion failed */
kfree(conn);
+ if (IS_ERR(conn2))
+ return NULL;
conn = conn2;
+ ptlrpc_connection_addref(conn);
}
out:
CDEBUG(D_INFO, "conn=%p refcount %d to %s\n",
@@ -91,7 +126,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn)
if (!conn)
return rc;
- LASSERT(atomic_read(&conn->c_refcount) > 1);
+ LASSERT(atomic_read(&conn->c_refcount) > 0);
/*
* We do not remove connection from hashtable and
@@ -109,7 +144,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn)
* when ptlrpc_connection_fini()->lh_exit->conn_exit()
* path is called.
*/
- if (atomic_dec_return(&conn->c_refcount) == 1)
+ if (atomic_dec_return(&conn->c_refcount) == 0)
rc = 1;
CDEBUG(D_INFO, "PUT conn=%p refcount %d to %s\n",
@@ -130,88 +165,11 @@ ptlrpc_connection_addref(struct ptlrpc_connection *conn)
return conn;
}
-int ptlrpc_connection_init(void)
-{
- conn_hash = cfs_hash_create("CONN_HASH",
- HASH_CONN_CUR_BITS,
- HASH_CONN_MAX_BITS,
- HASH_CONN_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &conn_hash_ops, CFS_HASH_DEFAULT);
- if (!conn_hash)
- return -ENOMEM;
-
- return 0;
-}
-
-void ptlrpc_connection_fini(void)
-{
- cfs_hash_putref(conn_hash);
-}
-
-/*
- * Hash operations for net_peer<->connection
- */
-static unsigned int
-conn_hashfn(struct cfs_hash *hs, const void *key, unsigned int mask)
-{
- return cfs_hash_djb2_hash(key, sizeof(struct lnet_process_id), mask);
-}
-
-static int
-conn_keycmp(const void *key, struct hlist_node *hnode)
-{
- struct ptlrpc_connection *conn;
- const struct lnet_process_id *conn_key;
-
- LASSERT(key);
- conn_key = key;
- conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
-
- return conn_key->nid == conn->c_peer.nid &&
- conn_key->pid == conn->c_peer.pid;
-}
-
-static void *
-conn_key(struct hlist_node *hnode)
-{
- struct ptlrpc_connection *conn;
-
- conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
- return &conn->c_peer;
-}
-
-static void *
-conn_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct ptlrpc_connection, c_hash);
-}
-
static void
-conn_get(struct cfs_hash *hs, struct hlist_node *hnode)
+conn_exit(void *vconn, void *data)
{
- struct ptlrpc_connection *conn;
+ struct ptlrpc_connection *conn = vconn;
- conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
- atomic_inc(&conn->c_refcount);
-}
-
-static void
-conn_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ptlrpc_connection *conn;
-
- conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
- atomic_dec(&conn->c_refcount);
-}
-
-static void
-conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ptlrpc_connection *conn;
-
- conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
/*
* Nothing should be left. Connection user put it and
* connection also was deleted from table by this time
@@ -223,12 +181,12 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
kfree(conn);
}
-static struct cfs_hash_ops conn_hash_ops = {
- .hs_hash = conn_hashfn,
- .hs_keycmp = conn_keycmp,
- .hs_key = conn_key,
- .hs_object = conn_object,
- .hs_get = conn_get,
- .hs_put_locked = conn_put_locked,
- .hs_exit = conn_exit,
-};
+int ptlrpc_connection_init(void)
+{
+ return rhashtable_init(&conn_hash, &conn_hash_params);
+}
+
+void ptlrpc_connection_fini(void)
+{
+ rhashtable_free_and_destroy(&conn_hash, conn_exit, NULL);
+}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c
index 54f0c36dc2bd..b904524fc1c6 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
@@ -26,7 +26,9 @@
* Copyright (c) 2013, Intel Corporation.
*/
-#include <linux/libcfs/libcfs.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
#include <lustre_errno.h>
/*
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index a2c4fc3488b1..1a0f35dfab97 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -37,6 +37,7 @@
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/kthread.h>
#include <obd_support.h>
#include <lustre_ha.h>
#include <lustre_net.h>
@@ -463,7 +464,7 @@ static int import_select_connection(struct obd_import *imp)
* the last successful attempt, go with this one
*/
if ((conn->oic_last_attempt == 0) ||
- cfs_time_beforeq_64(conn->oic_last_attempt,
+ time_before_eq64(conn->oic_last_attempt,
imp->imp_last_success_conn)) {
imp_conn = conn;
tried_all = 0;
@@ -476,7 +477,7 @@ static int import_select_connection(struct obd_import *imp)
*/
if (!imp_conn)
imp_conn = conn;
- else if (cfs_time_before_64(conn->oic_last_attempt,
+ else if (time_before64(conn->oic_last_attempt,
imp_conn->oic_last_attempt))
imp_conn = conn;
}
@@ -508,7 +509,7 @@ static int import_select_connection(struct obd_import *imp)
imp->imp_obd->obd_name, at_get(at));
}
- imp_conn->oic_last_attempt = cfs_time_current_64();
+ imp_conn->oic_last_attempt = get_jiffies_64();
/* switch connection, don't mind if it's same as the current one */
ptlrpc_connection_put(imp->imp_connection);
@@ -1486,7 +1487,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
}
if (ptlrpc_import_in_recovery(imp)) {
- long timeout;
+ unsigned long timeout;
if (AT_OFF) {
if (imp->imp_server_timeout)
@@ -1501,7 +1502,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
- cfs_timeout_cap(timeout)) == 0)
+ max(timeout, 1UL)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 254488be7093..946d538121de 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -39,8 +39,6 @@
#define DEBUG_SUBSYSTEM S_LOG
-#include <linux/libcfs/libcfs.h>
-
#include <obd_class.h>
#include <lustre_log.h>
#include <lustre_net.h>
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
index bc4398b9bd1d..b871d9e40a9e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
@@ -43,8 +43,6 @@
#define DEBUG_SUBSYSTEM S_LOG
-#include <linux/libcfs/libcfs.h>
-
#include <obd_class.h>
#include <lustre_log.h>
#include <linux/list.h>
diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
index 86883abaad2c..2897afb8806c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
@@ -32,6 +32,7 @@
*/
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/sched/mm.h>
#include <obd_support.h>
#include <lustre_net.h>
#include <lustre_lib.h>
@@ -472,7 +473,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
{
int rc;
int rc2;
- int mpflag = 0;
+ unsigned int mpflag = 0;
struct ptlrpc_connection *connection;
struct lnet_handle_me reply_me_h;
struct lnet_md reply_md;
@@ -558,7 +559,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
lustre_msg_add_flags(request->rq_reqmsg, MSG_RESENT);
if (request->rq_memalloc)
- mpflag = cfs_memory_pressure_get_and_set();
+ mpflag = memalloc_noreclaim_save();
rc = sptlrpc_cli_wrap_request(request);
if (rc) {
@@ -710,7 +711,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
ptlrpc_unregister_bulk(request, 0);
out:
if (request->rq_memalloc)
- cfs_memory_pressure_restore(mpflag);
+ memalloc_noreclaim_restore(mpflag);
return rc;
}
EXPORT_SYMBOL(ptl_send_rpc);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 4847f9a90cc9..e09b86529c5d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -37,11 +37,12 @@
*/
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_cpu.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
#include <lprocfs_status.h>
-#include <linux/libcfs/libcfs.h>
#include "ptlrpc_internal.h"
/**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index 8251cbf2ad68..ff630d94dd26 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -44,9 +44,10 @@
*/
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/libcfs/libcfs.h>
+#include <linux/libcfs/libcfs_cpu.h>
#include <obd_support.h>
#include <obd_class.h>
-#include <linux/libcfs/libcfs.h>
#include "ptlrpc_internal.h"
/**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index f73463ac401f..6ac9bb570663 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -41,8 +41,6 @@
#define DEBUG_SUBSYSTEM S_RPC
-#include <linux/libcfs/libcfs.h>
-
#include <uapi/linux/lustre/lustre_fiemap.h>
#include <llog_swab.h>
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 0775b7a048bb..b3297b5ce395 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
at_get(&imp->imp_at.iat_net_latency));
time = min(time, dtime);
}
- imp->imp_next_ping = cfs_time_shift(time);
+ imp->imp_next_ping = jiffies + time * HZ;
}
static inline int imp_is_deactive(struct obd_import *imp)
@@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
static inline int ptlrpc_next_reconnect(struct obd_import *imp)
{
if (imp->imp_server_timeout)
- return cfs_time_shift(obd_timeout / 2);
+ return jiffies + obd_timeout / 2 * HZ;
else
- return cfs_time_shift(obd_timeout);
+ return jiffies + obd_timeout * HZ;
}
static long pinger_check_timeout(unsigned long time)
@@ -141,8 +141,7 @@ static long pinger_check_timeout(unsigned long time)
}
mutex_unlock(&pinger_mutex);
- return cfs_time_sub(cfs_time_add(time, timeout * HZ),
- cfs_time_current());
+ return time + timeout * HZ - jiffies;
}
static bool ir_up;
@@ -181,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
imp->imp_force_verify = 0;
- if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
+ if (time_after_eq(imp->imp_next_ping - 5, this_ping) &&
!force) {
spin_unlock(&imp->imp_lock);
return;
@@ -223,7 +222,7 @@ static DECLARE_DELAYED_WORK(ping_work, ptlrpc_pinger_main);
static void ptlrpc_pinger_main(struct work_struct *ws)
{
- unsigned long this_ping = cfs_time_current();
+ unsigned long this_ping = jiffies;
long time_to_next_wake;
struct timeout_item *item;
struct obd_import *imp;
@@ -237,9 +236,8 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
ptlrpc_pinger_process_import(imp, this_ping);
/* obd_timeout might have changed */
if (imp->imp_pingable && imp->imp_next_ping &&
- cfs_time_after(imp->imp_next_ping,
- cfs_time_add(this_ping,
- PING_INTERVAL * HZ)))
+ time_after(imp->imp_next_ping,
+ this_ping + PING_INTERVAL * HZ))
ptlrpc_update_next_ping(imp, 0);
}
mutex_unlock(&pinger_mutex);
@@ -253,10 +251,9 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
* we will SKIP the next ping at next_ping, and the
* ping will get sent 2 timeouts from now! Beware.
*/
- CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+ CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
time_to_next_wake,
- cfs_time_add(this_ping,
- PING_INTERVAL * HZ));
+ this_ping + PING_INTERVAL * HZ);
} while (time_to_next_wake <= 0);
queue_delayed_work(pinger_wq, &ping_work,
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
index 38923418669f..5c32b657b3b5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
@@ -94,6 +94,10 @@ static int __init ptlrpc_init(void)
mutex_init(&ptlrpcd_mutex);
ptlrpc_init_xid();
+ rc = libcfs_setup();
+ if (rc)
+ return rc;
+
rc = req_layout_init();
if (rc)
return rc;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index c0fa13942bd8..531005411edf 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -52,8 +52,10 @@
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/kthread.h>
#include <linux/libcfs/libcfs.h>
-
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/libcfs/libcfs_string.h>
#include <lustre_net.h>
#include <lustre_lib.h>
#include <lustre_ha.h>
@@ -175,7 +177,7 @@ ptlrpcd_select_pc(struct ptlrpc_request *req)
if (req && req->rq_send_state != LUSTRE_IMP_FULL)
return &ptlrpcd_rcv;
- cpt = cfs_cpt_current(cfs_cpt_table, 1);
+ cpt = cfs_cpt_current(cfs_cpt_tab, 1);
if (!ptlrpcds_cpt_idx)
idx = cpt;
else
@@ -387,7 +389,7 @@ static int ptlrpcd(void *arg)
int exit = 0;
unshare_fs_struct();
- if (cfs_cpt_bind(cfs_cpt_table, pc->pc_cpt) != 0)
+ if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0)
CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
/*
@@ -529,7 +531,7 @@ static int ptlrpcd_partners(struct ptlrpcd *pd, int index)
size = sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners;
pc->pc_partners = kzalloc_node(size, GFP_NOFS,
- cfs_cpt_spread_node(cfs_cpt_table,
+ cfs_cpt_spread_node(cfs_cpt_tab,
pc->pc_cpt));
if (!pc->pc_partners) {
pc->pc_npartners = 0;
@@ -675,7 +677,7 @@ static int ptlrpcd_init(void)
/*
* Determine the CPTs that ptlrpcd threads will run on.
*/
- cptable = cfs_cpt_table;
+ cptable = cfs_cpt_tab;
ncpts = cfs_cpt_number(cptable);
if (ptlrpcd_cpts) {
struct cfs_expr_list *el;
@@ -829,7 +831,7 @@ static int ptlrpcd_init(void)
size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
pd = kzalloc_node(size, GFP_NOFS,
- cfs_cpt_spread_node(cfs_cpt_table, cpt));
+ cfs_cpt_spread_node(cfs_cpt_tab, cpt));
if (!pd) {
rc = -ENOMEM;
goto out;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 3cb1e075f077..256421465bcd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2236,7 +2236,7 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset)
pud->pud_gid = from_kgid(&init_user_ns, current_gid());
pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid());
pud->pud_fsgid = from_kgid(&init_user_ns, current_fsgid());
- pud->pud_cap = cfs_curproc_cap_pack();
+ pud->pud_cap = current_cap().cap[0];
pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;
task_lock(current);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index f37364e00dfe..3fd8c746f460 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -33,12 +33,15 @@
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/kthread.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
#include <lu_object.h>
#include <uapi/linux/lnet/lnet-types.h>
#include "ptlrpc_internal.h"
+#include <linux/libcfs/libcfs_cpu.h>
+#include <linux/libcfs/libcfs_string.h>
/* The following are visible and mutable through /sys/module/ptlrpc */
int test_req_buffer_pressure;
@@ -205,7 +208,7 @@ struct ptlrpc_hr_partition {
#define HRT_STOPPING 1
struct ptlrpc_hr_service {
- /* CPU partition table, it's just cfs_cpt_table for now */
+ /* CPU partition table, it's just cfs_cpt_tab for now */
struct cfs_cpt_table *hr_cpt_table;
/** controller sleep waitq */
wait_queue_head_t hr_waitq;
@@ -336,7 +339,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
svcpt = from_timer(svcpt, t, scp_at_timer);
svcpt->scp_at_check = 1;
- svcpt->scp_at_checktime = cfs_time_current();
+ svcpt->scp_at_checktime = jiffies;
wake_up(&svcpt->scp_waitq);
}
@@ -562,7 +565,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
cptable = cconf->cc_cptable;
if (!cptable)
- cptable = cfs_cpt_table;
+ cptable = cfs_cpt_tab;
if (!conf->psc_thr.tc_cpu_affinity) {
ncpts = 1;
@@ -922,7 +925,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
if (next <= 0) {
ptlrpc_at_timer(&svcpt->scp_at_timer);
} else {
- mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
+ mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
CDEBUG(D_INFO, "armed %s at %+ds\n",
svcpt->scp_service->srv_name, next);
}
@@ -1153,7 +1156,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
spin_unlock(&svcpt->scp_at_lock);
return;
}
- delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
+ delay = jiffies - svcpt->scp_at_checktime;
svcpt->scp_at_check = 0;
if (array->paa_count == 0) {
@@ -1679,7 +1682,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
}
CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d\n",
- current_comm(),
+ current->comm,
(request->rq_export ?
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
@@ -1723,7 +1726,7 @@ put_conn:
arrived_usecs = arrived.tv_sec * USEC_PER_SEC +
arrived.tv_nsec / NSEC_PER_USEC;
CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d Request processed in %ldus (%ldus total) trans %llu rc %d/%d\n",
- current_comm(),
+ current->comm,
(request->rq_export ?
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
@@ -2018,7 +2021,7 @@ static int ptlrpc_main(void *arg)
struct lu_env *env;
int counter = 0, rc = 0;
- thread->t_pid = current_pid();
+ thread->t_pid = current->pid;
unshare_fs_struct();
/* NB: we will call cfs_cpt_bind() for all threads, because we
@@ -2516,7 +2519,7 @@ int ptlrpc_hr_init(void)
int weight;
memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr));
- ptlrpc_hr.hr_cpt_table = cfs_cpt_table;
+ ptlrpc_hr.hr_cpt_table = cfs_cpt_tab;
ptlrpc_hr.hr_partitions = cfs_percpt_alloc(ptlrpc_hr.hr_cpt_table,
sizeof(*hrp));
diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 4d7fce8731fe..4569838f27a0 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -18,6 +18,8 @@
#include <linux/idr.h>
#include "most/core.h"
+#define CHRDEV_REGION_SIZE 50
+
static struct cdev_component {
dev_t devno;
struct ida minor_id;
@@ -51,7 +53,7 @@ static inline bool ch_has_mbo(struct comp_channel *c)
return channel_has_mbo(c->iface, c->channel_id, &comp.cc) > 0;
}
-static inline bool ch_get_mbo(struct comp_channel *c, struct mbo **mbo)
+static inline struct mbo *ch_get_mbo(struct comp_channel *c, struct mbo **mbo)
{
if (!kfifo_peek(&c->fifo, mbo)) {
*mbo = most_get_mbo(c->iface, c->channel_id, &comp.cc);
@@ -242,7 +244,7 @@ static ssize_t
comp_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
{
size_t to_copy, not_copied, copied;
- struct mbo *mbo;
+ struct mbo *mbo = NULL;
struct comp_channel *c = filp->private_data;
mutex_lock(&c->io_mutex);
@@ -290,13 +292,15 @@ static __poll_t comp_poll(struct file *filp, poll_table *wait)
poll_wait(filp, &c->wq, wait);
+ mutex_lock(&c->io_mutex);
if (c->cfg->direction == MOST_CH_RX) {
- if (!kfifo_is_empty(&c->fifo))
+ if (!c->dev || !kfifo_is_empty(&c->fifo))
mask |= EPOLLIN | EPOLLRDNORM;
} else {
- if (!kfifo_is_empty(&c->fifo) || ch_has_mbo(c))
+ if (!c->dev || !kfifo_is_empty(&c->fifo) || ch_has_mbo(c))
mask |= EPOLLOUT | EPOLLWRNORM;
}
+ mutex_unlock(&c->io_mutex);
return mask;
}
@@ -513,7 +517,7 @@ static int __init mod_init(void)
spin_lock_init(&ch_list_lock);
ida_init(&comp.minor_id);
- err = alloc_chrdev_region(&comp.devno, 0, 50, "cdev");
+ err = alloc_chrdev_region(&comp.devno, 0, CHRDEV_REGION_SIZE, "cdev");
if (err < 0)
goto dest_ida;
comp.major = MAJOR(comp.devno);
@@ -523,7 +527,7 @@ static int __init mod_init(void)
return 0;
free_cdev:
- unregister_chrdev_region(comp.devno, 1);
+ unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE);
dest_ida:
ida_destroy(&comp.minor_id);
class_destroy(comp.class);
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 8f2833526f7f..f4c464625a67 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -111,8 +111,10 @@ static void most_free_mbo_coherent(struct mbo *mbo)
struct most_channel *c = mbo->context;
u16 const coherent_buf_size = c->cfg.buffer_size + c->cfg.extra_len;
- dma_free_coherent(NULL, coherent_buf_size, mbo->virt_address,
- mbo->bus_address);
+ if (c->iface->dma_free)
+ c->iface->dma_free(mbo, coherent_buf_size);
+ else
+ kfree(mbo->virt_address);
kfree(mbo);
if (atomic_sub_and_test(1, &c->mbo_ref))
complete(&c->cleanup);
@@ -420,6 +422,26 @@ static ssize_t set_packets_per_xact_store(struct device *dev,
return count;
}
+static ssize_t set_dbr_size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct most_channel *c = to_channel(dev);
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size);
+}
+
+static ssize_t set_dbr_size_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct most_channel *c = to_channel(dev);
+ int ret = kstrtou16(buf, 0, &c->cfg.dbr_size);
+
+ if (ret)
+ return ret;
+ return count;
+}
+
#define DEV_ATTR(_name) (&dev_attr_##_name.attr)
static DEVICE_ATTR_RO(available_directions);
@@ -435,6 +457,7 @@ static DEVICE_ATTR_RW(set_direction);
static DEVICE_ATTR_RW(set_datatype);
static DEVICE_ATTR_RW(set_subbuffer_size);
static DEVICE_ATTR_RW(set_packets_per_xact);
+static DEVICE_ATTR_RW(set_dbr_size);
static struct attribute *channel_attrs[] = {
DEV_ATTR(available_directions),
@@ -450,6 +473,7 @@ static struct attribute *channel_attrs[] = {
DEV_ATTR(set_datatype),
DEV_ATTR(set_subbuffer_size),
DEV_ATTR(set_packets_per_xact),
+ DEV_ATTR(set_dbr_size),
NULL,
};
@@ -952,45 +976,49 @@ static int arm_mbo_chain(struct most_channel *c, int dir,
void (*compl)(struct mbo *))
{
unsigned int i;
- int retval;
struct mbo *mbo;
+ unsigned long flags;
u32 coherent_buf_size = c->cfg.buffer_size + c->cfg.extra_len;
atomic_set(&c->mbo_nq_level, 0);
for (i = 0; i < c->cfg.num_buffers; i++) {
mbo = kzalloc(sizeof(*mbo), GFP_KERNEL);
- if (!mbo) {
- retval = i;
- goto _exit;
- }
+ if (!mbo)
+ goto flush_fifos;
+
mbo->context = c;
mbo->ifp = c->iface;
mbo->hdm_channel_id = c->channel_id;
- mbo->virt_address = dma_alloc_coherent(NULL,
- coherent_buf_size,
- &mbo->bus_address,
- GFP_KERNEL);
- if (!mbo->virt_address) {
- pr_info("WARN: No DMA coherent buffer.\n");
- retval = i;
- goto _error1;
+ if (c->iface->dma_alloc) {
+ mbo->virt_address =
+ c->iface->dma_alloc(mbo, coherent_buf_size);
+ } else {
+ mbo->virt_address =
+ kzalloc(coherent_buf_size, GFP_KERNEL);
}
+ if (!mbo->virt_address)
+ goto release_mbo;
+
mbo->complete = compl;
mbo->num_buffers_ptr = &dummy_num_buffers;
if (dir == MOST_CH_RX) {
nq_hdm_mbo(mbo);
atomic_inc(&c->mbo_nq_level);
} else {
- arm_mbo(mbo);
+ spin_lock_irqsave(&c->fifo_lock, flags);
+ list_add_tail(&mbo->list, &c->fifo);
+ spin_unlock_irqrestore(&c->fifo_lock, flags);
}
}
- return i;
+ return c->cfg.num_buffers;
-_error1:
+release_mbo:
kfree(mbo);
-_exit:
- return retval;
+
+flush_fifos:
+ flush_channel_fifos(c);
+ return 0;
}
/**
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index 884bd71fafce..64cc02f161e7 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -128,6 +128,7 @@ struct most_channel_config {
u16 extra_len;
u16 subbuffer_size;
u16 packets_per_xact;
+ u16 dbr_size;
};
/*
@@ -229,11 +230,14 @@ struct mbo {
*/
struct most_interface {
struct device dev;
+ struct device *driver_dev;
struct module *mod;
enum most_interface_type interface;
const char *description;
unsigned int num_channels;
struct most_channel_capability *channel_vector;
+ void *(*dma_alloc)(struct mbo *mbo, u32 size);
+ void (*dma_free)(struct mbo *mbo, u32 size);
int (*configure)(struct most_interface *iface, int channel_idx,
struct most_channel_config *channel_config);
int (*enqueue)(struct most_interface *iface, int channel_idx,
diff --git a/drivers/staging/most/dim2/Kconfig b/drivers/staging/most/dim2/Kconfig
index e39c4e525cac..5aeef22c3cba 100644
--- a/drivers/staging/most/dim2/Kconfig
+++ b/drivers/staging/most/dim2/Kconfig
@@ -4,7 +4,7 @@
config MOST_DIM2
tristate "DIM2"
- depends on HAS_IOMEM
+ depends on HAS_IOMEM && OF
---help---
Say Y here if you want to connect via MediaLB to network transceiver.
diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index f9bc7dea75b8..fe90a7cb56f7 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -8,6 +8,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
+#include <linux/of_platform.h>
#include <linux/printk.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -15,13 +16,13 @@
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/io.h>
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include "most/core.h"
#include "hal.h"
-#include "dim2.h"
#include "errors.h"
#include "sysfs.h"
@@ -32,11 +33,6 @@
#define MAX_BUF_SIZE_PACKET 2048
#define MAX_BUF_SIZE_STREAMING (8 * 1024)
-/* command line parameter to select clock speed */
-static char *clock_speed;
-module_param(clock_speed, charp, 0000);
-MODULE_PARM_DESC(clock_speed, "MediaLB Clock Speed");
-
/*
* The parameter representing the number of frames per sub-buffer for
* synchronous channels. Valid values: [0 .. 6].
@@ -66,6 +62,7 @@ struct hdm_channel {
char name[sizeof "caNNN"];
bool is_initialized;
struct dim_channel ch;
+ u16 *reset_dbr_size;
struct list_head pending_list; /* before dim_enqueue_buffer() */
struct list_head started_list; /* after dim_enqueue_buffer() */
enum most_channel_direction direction;
@@ -78,7 +75,6 @@ struct hdm_channel {
* @most_iface: most interface structure
* @capabilities: an array of channel capability data
* @io_base: I/O register base address
- * @clk_speed: user selectable (through command line parameter) clock speed
* @netinfo_task: thread to deliver network status
* @netinfo_waitq: waitq for the thread to sleep
* @deliver_netinfo: to identify whether network status received
@@ -93,7 +89,9 @@ struct dim2_hdm {
struct most_interface most_iface;
char name[16 + sizeof "dim2-"];
void __iomem *io_base;
- int clk_speed;
+ u8 clk_speed;
+ struct clk *clk;
+ struct clk *clk_pll;
struct task_struct *netinfo_task;
wait_queue_head_t netinfo_waitq;
int deliver_netinfo;
@@ -103,6 +101,12 @@ struct dim2_hdm {
struct medialb_bus bus;
void (*on_netinfo)(struct most_interface *most_iface,
unsigned char link_state, unsigned char *addrs);
+ void (*disable_platform)(struct platform_device *);
+};
+
+struct dim2_platform_data {
+ int (*enable)(struct platform_device *);
+ void (*disable)(struct platform_device *);
};
#define iface_to_hdm(iface) container_of(iface, struct dim2_hdm, most_iface)
@@ -156,65 +160,6 @@ void dimcb_on_error(u8 error_id, const char *error_message)
}
/**
- * startup_dim - initialize the dim2 interface
- * @pdev: platform device
- *
- * Get the value of command line parameter "clock_speed" if given or use the
- * default value, enable the clock and PLL, and initialize the dim2 interface.
- */
-static int startup_dim(struct platform_device *pdev)
-{
- struct dim2_hdm *dev = platform_get_drvdata(pdev);
- struct dim2_platform_data *pdata = pdev->dev.platform_data;
- u8 hal_ret;
-
- dev->clk_speed = -1;
-
- if (clock_speed) {
- if (!strcmp(clock_speed, "256fs"))
- dev->clk_speed = CLK_256FS;
- else if (!strcmp(clock_speed, "512fs"))
- dev->clk_speed = CLK_512FS;
- else if (!strcmp(clock_speed, "1024fs"))
- dev->clk_speed = CLK_1024FS;
- else if (!strcmp(clock_speed, "2048fs"))
- dev->clk_speed = CLK_2048FS;
- else if (!strcmp(clock_speed, "3072fs"))
- dev->clk_speed = CLK_3072FS;
- else if (!strcmp(clock_speed, "4096fs"))
- dev->clk_speed = CLK_4096FS;
- else if (!strcmp(clock_speed, "6144fs"))
- dev->clk_speed = CLK_6144FS;
- else if (!strcmp(clock_speed, "8192fs"))
- dev->clk_speed = CLK_8192FS;
- }
-
- if (dev->clk_speed == -1) {
- pr_info("Bad or missing clock speed parameter, using default value: 3072fs\n");
- dev->clk_speed = CLK_3072FS;
- } else {
- pr_info("Selected clock speed: %s\n", clock_speed);
- }
- if (pdata && pdata->init) {
- int ret = pdata->init(pdata, dev->io_base, dev->clk_speed);
-
- if (ret)
- return ret;
- }
-
- pr_info("sync: num of frames per sub-buffer: %u\n", fcnt);
- hal_ret = dim_startup(dev->io_base, dev->clk_speed, fcnt);
- if (hal_ret != DIM_NO_ERROR) {
- pr_err("dim_startup failed: %d\n", hal_ret);
- if (pdata && pdata->destroy)
- pdata->destroy(pdata);
- return -ENODEV;
- }
-
- return 0;
-}
-
-/**
* try_start_dim_transfer - try to transfer a buffer on a channel
* @hdm_ch: channel specific data
*
@@ -528,6 +473,12 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx,
if (hdm_ch->is_initialized)
return -EPERM;
+ /* do not reset if the property was set by user, see poison_channel */
+ hdm_ch->reset_dbr_size = ccfg->dbr_size ? NULL : &ccfg->dbr_size;
+
+ /* zero value is default dbr_size, see dim2 hal */
+ hdm_ch->ch.dbr_size = ccfg->dbr_size;
+
switch (ccfg->data_type) {
case MOST_CH_CONTROL:
new_size = dim_norm_ctrl_async_buffer_size(buf_size);
@@ -608,6 +559,7 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx,
dev->atx_idx = ch_idx;
spin_unlock_irqrestore(&dim_lock, flags);
+ ccfg->dbr_size = hdm_ch->ch.dbr_size;
return 0;
}
@@ -723,10 +675,64 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
complete_all_mbos(&hdm_ch->started_list);
complete_all_mbos(&hdm_ch->pending_list);
+ if (hdm_ch->reset_dbr_size)
+ *hdm_ch->reset_dbr_size = 0;
return ret;
}
+static void *dma_alloc(struct mbo *mbo, u32 size)
+{
+ struct device *dev = mbo->ifp->driver_dev;
+
+ return dma_alloc_coherent(dev, size, &mbo->bus_address, GFP_KERNEL);
+}
+
+static void dma_free(struct mbo *mbo, u32 size)
+{
+ struct device *dev = mbo->ifp->driver_dev;
+
+ dma_free_coherent(dev, size, mbo->virt_address, mbo->bus_address);
+}
+
+static const struct of_device_id dim2_of_match[];
+
+static struct {
+ const char *clock_speed;
+ u8 clk_speed;
+} clk_mt[] = {
+ { "256fs", CLK_256FS },
+ { "512fs", CLK_512FS },
+ { "1024fs", CLK_1024FS },
+ { "2048fs", CLK_2048FS },
+ { "3072fs", CLK_3072FS },
+ { "4096fs", CLK_4096FS },
+ { "6144fs", CLK_6144FS },
+ { "8192fs", CLK_8192FS },
+};
+
+/**
+ * get_dim2_clk_speed - converts string to DIM2 clock speed value
+ *
+ * @clock_speed: string in the format "{NUMBER}fs"
+ * @val: pointer to get one of the CLK_{NUMBER}FS values
+ *
+ * By success stores one of the CLK_{NUMBER}FS in the *val and returns 0,
+ * otherwise returns -EINVAL.
+ */
+static int get_dim2_clk_speed(const char *clock_speed, u8 *val)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(clk_mt); i++) {
+ if (!strcmp(clock_speed, clk_mt[i].clock_speed)) {
+ *val = clk_mt[i].clk_speed;
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+
/*
* dim2_probe - dim2 probe handler
* @pdev: platform device structure
@@ -736,11 +742,17 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
*/
static int dim2_probe(struct platform_device *pdev)
{
+ const struct dim2_platform_data *pdata;
+ const struct of_device_id *of_id;
+ const char *clock_speed;
struct dim2_hdm *dev;
struct resource *res;
int ret, i;
+ u8 hal_ret;
int irq;
+ enum { MLB_INT_IDX, AHB0_INT_IDX };
+
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
@@ -748,43 +760,77 @@ static int dim2_probe(struct platform_device *pdev)
dev->atx_idx = -1;
platform_set_drvdata(pdev, dev);
+
+ ret = of_property_read_string(pdev->dev.of_node,
+ "microchip,clock-speed", &clock_speed);
+ if (ret) {
+ dev_err(&pdev->dev, "missing dt property clock-speed\n");
+ return ret;
+ }
+
+ ret = get_dim2_clk_speed(clock_speed, &dev->clk_speed);
+ if (ret) {
+ dev_err(&pdev->dev, "bad dt property clock-speed\n");
+ return ret;
+ }
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dev->io_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dev->io_base))
return PTR_ERR(dev->io_base);
- irq = platform_get_irq(pdev, 0);
+ of_id = of_match_node(dim2_of_match, pdev->dev.of_node);
+ pdata = of_id->data;
+ ret = pdata && pdata->enable ? pdata->enable(pdev) : 0;
+ if (ret)
+ return ret;
+
+ dev->disable_platform = pdata ? pdata->disable : 0;
+
+ dev_info(&pdev->dev, "sync: num of frames per sub-buffer: %u\n", fcnt);
+ hal_ret = dim_startup(dev->io_base, dev->clk_speed, fcnt);
+ if (hal_ret != DIM_NO_ERROR) {
+ dev_err(&pdev->dev, "dim_startup failed: %d\n", hal_ret);
+ ret = -ENODEV;
+ goto err_disable_platform;
+ }
+
+ irq = platform_get_irq(pdev, AHB0_INT_IDX);
if (irq < 0) {
dev_err(&pdev->dev, "failed to get ahb0_int irq: %d\n", irq);
- return irq;
+ ret = irq;
+ goto err_shutdown_dim;
}
ret = devm_request_irq(&pdev->dev, irq, dim2_ahb_isr, 0,
"dim2_ahb0_int", dev);
if (ret) {
dev_err(&pdev->dev, "failed to request ahb0_int irq %d\n", irq);
- return ret;
+ goto err_shutdown_dim;
}
- irq = platform_get_irq(pdev, 1);
+ irq = platform_get_irq(pdev, MLB_INT_IDX);
if (irq < 0) {
dev_err(&pdev->dev, "failed to get mlb_int irq: %d\n", irq);
- return irq;
+ ret = irq;
+ goto err_shutdown_dim;
}
ret = devm_request_irq(&pdev->dev, irq, dim2_mlb_isr, 0,
"dim2_mlb_int", dev);
if (ret) {
dev_err(&pdev->dev, "failed to request mlb_int irq %d\n", irq);
- return ret;
+ goto err_shutdown_dim;
}
init_waitqueue_head(&dev->netinfo_waitq);
dev->deliver_netinfo = 0;
- dev->netinfo_task = kthread_run(&deliver_netinfo_thread, (void *)dev,
+ dev->netinfo_task = kthread_run(&deliver_netinfo_thread, dev,
"dim2_netinfo");
- if (IS_ERR(dev->netinfo_task))
- return PTR_ERR(dev->netinfo_task);
+ if (IS_ERR(dev->netinfo_task)) {
+ ret = PTR_ERR(dev->netinfo_task);
+ goto err_shutdown_dim;
+ }
for (i = 0; i < DMA_CHANNELS; i++) {
struct most_channel_capability *cap = dev->capabilities + i;
@@ -824,8 +870,11 @@ static int dim2_probe(struct platform_device *pdev)
dev->most_iface.channel_vector = dev->capabilities;
dev->most_iface.configure = configure_channel;
dev->most_iface.enqueue = enqueue;
+ dev->most_iface.dma_alloc = dma_alloc;
+ dev->most_iface.dma_free = dma_free;
dev->most_iface.poison_channel = poison_channel;
dev->most_iface.request_netinfo = request_netinfo;
+ dev->most_iface.driver_dev = &pdev->dev;
dev->dev.init_name = "dim2_state";
dev->dev.parent = &dev->most_iface.dev;
@@ -841,20 +890,17 @@ static int dim2_probe(struct platform_device *pdev)
goto err_unreg_iface;
}
- ret = startup_dim(pdev);
- if (ret) {
- dev_err(&pdev->dev, "failed to initialize DIM2\n");
- goto err_destroy_bus;
- }
-
return 0;
-err_destroy_bus:
- dim2_sysfs_destroy(&dev->dev);
err_unreg_iface:
most_deregister_interface(&dev->most_iface);
err_stop_thread:
kthread_stop(dev->netinfo_task);
+err_shutdown_dim:
+ dim_shutdown();
+err_disable_platform:
+ if (dev->disable_platform)
+ dev->disable_platform(pdev);
return ret;
}
@@ -868,48 +914,197 @@ err_stop_thread:
static int dim2_remove(struct platform_device *pdev)
{
struct dim2_hdm *dev = platform_get_drvdata(pdev);
- struct dim2_platform_data *pdata = pdev->dev.platform_data;
unsigned long flags;
+ dim2_sysfs_destroy(&dev->dev);
+ most_deregister_interface(&dev->most_iface);
+ kthread_stop(dev->netinfo_task);
+
spin_lock_irqsave(&dim_lock, flags);
dim_shutdown();
spin_unlock_irqrestore(&dim_lock, flags);
- if (pdata && pdata->destroy)
- pdata->destroy(pdata);
+ if (dev->disable_platform)
+ dev->disable_platform(pdev);
- dim2_sysfs_destroy(&dev->dev);
- most_deregister_interface(&dev->most_iface);
- kthread_stop(dev->netinfo_task);
+ return 0;
+}
+
+/* platform specific functions [[ */
+
+static int fsl_mx6_enable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+ int ret;
+
+ dev->clk = devm_clk_get(&pdev->dev, "mlb");
+ if (IS_ERR_OR_NULL(dev->clk)) {
+ dev_err(&pdev->dev, "unable to get mlb clock\n");
+ return -EFAULT;
+ }
+
+ ret = clk_prepare_enable(dev->clk);
+ if (ret) {
+ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
+ return ret;
+ }
+
+ if (dev->clk_speed >= CLK_2048FS) {
+ /* enable pll */
+ dev->clk_pll = devm_clk_get(&pdev->dev, "pll8_mlb");
+ if (IS_ERR_OR_NULL(dev->clk_pll)) {
+ dev_err(&pdev->dev, "unable to get mlb pll clock\n");
+ clk_disable_unprepare(dev->clk);
+ return -EFAULT;
+ }
+
+ writel(0x888, dev->io_base + 0x38);
+ clk_prepare_enable(dev->clk_pll);
+ }
+
+ return 0;
+}
+
+static void fsl_mx6_disable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+
+ if (dev->clk_speed >= CLK_2048FS)
+ clk_disable_unprepare(dev->clk_pll);
+
+ clk_disable_unprepare(dev->clk);
+}
+
+static int rcar_h2_enable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+ int ret;
+
+ dev->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(dev->clk)) {
+ dev_err(&pdev->dev, "cannot get clock\n");
+ return PTR_ERR(dev->clk);
+ }
- /*
- * break link to local platform_device_id struct
- * to prevent crash by unload platform device module
- */
- pdev->id_entry = NULL;
+ ret = clk_prepare_enable(dev->clk);
+ if (ret) {
+ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
+ return ret;
+ }
+
+ if (dev->clk_speed >= CLK_2048FS) {
+ /* enable MLP pll and LVDS drivers */
+ writel(0x03, dev->io_base + 0x600);
+ /* set bias */
+ writel(0x888, dev->io_base + 0x38);
+ } else {
+ /* PLL */
+ writel(0x04, dev->io_base + 0x600);
+ }
+
+
+ /* BBCR = 0b11 */
+ writel(0x03, dev->io_base + 0x500);
+ writel(0x0002FF02, dev->io_base + 0x508);
return 0;
}
-static const struct platform_device_id dim2_id[] = {
- { "medialb_dim2" },
- { }, /* Terminating entry */
+static void rcar_h2_disable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+
+ clk_disable_unprepare(dev->clk);
+
+ /* disable PLLs and LVDS drivers */
+ writel(0x0, dev->io_base + 0x600);
+}
+
+static int rcar_m3_enable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+ u32 enable_512fs = dev->clk_speed == CLK_512FS;
+ int ret;
+
+ dev->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(dev->clk)) {
+ dev_err(&pdev->dev, "cannot get clock\n");
+ return PTR_ERR(dev->clk);
+ }
+
+ ret = clk_prepare_enable(dev->clk);
+ if (ret) {
+ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
+ return ret;
+ }
+
+ /* PLL */
+ writel(0x04, dev->io_base + 0x600);
+
+ writel(enable_512fs, dev->io_base + 0x604);
+
+ /* BBCR = 0b11 */
+ writel(0x03, dev->io_base + 0x500);
+ writel(0x0002FF02, dev->io_base + 0x508);
+
+ return 0;
+}
+
+static void rcar_m3_disable(struct platform_device *pdev)
+{
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+
+ clk_disable_unprepare(dev->clk);
+
+ /* disable PLLs and LVDS drivers */
+ writel(0x0, dev->io_base + 0x600);
+}
+
+/* ]] platform specific functions */
+
+enum dim2_platforms { FSL_MX6, RCAR_H2, RCAR_M3 };
+
+static struct dim2_platform_data plat_data[] = {
+ [FSL_MX6] = { .enable = fsl_mx6_enable, .disable = fsl_mx6_disable },
+ [RCAR_H2] = { .enable = rcar_h2_enable, .disable = rcar_h2_disable },
+ [RCAR_M3] = { .enable = rcar_m3_enable, .disable = rcar_m3_disable },
+};
+
+static const struct of_device_id dim2_of_match[] = {
+ {
+ .compatible = "fsl,imx6q-mlb150",
+ .data = plat_data + FSL_MX6
+ },
+ {
+ .compatible = "renesas,mlp",
+ .data = plat_data + RCAR_H2
+ },
+ {
+ .compatible = "rcar,medialb-dim2",
+ .data = plat_data + RCAR_M3
+ },
+ {
+ .compatible = "xlnx,axi4-os62420_3pin-1.00.a",
+ },
+ {
+ .compatible = "xlnx,axi4-os62420_6pin-1.00.a",
+ },
+ {},
};
-MODULE_DEVICE_TABLE(platform, dim2_id);
+MODULE_DEVICE_TABLE(of, dim2_of_match);
static struct platform_driver dim2_driver = {
.probe = dim2_probe,
.remove = dim2_remove,
- .id_table = dim2_id,
.driver = {
.name = "hdm_dim2",
+ .of_match_table = dim2_of_match,
},
};
module_platform_driver(dim2_driver);
-MODULE_AUTHOR("Jain Roy Ambi <JainRoy.Ambi@microchip.com>");
MODULE_AUTHOR("Andrey Shvetsov <andrey.shvetsov@k2l.de>");
MODULE_DESCRIPTION("MediaLB DIM2 Hardware Dependent Module");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/most/dim2/dim2.h b/drivers/staging/most/dim2/dim2.h
deleted file mode 100644
index 6a9fc51a2eb4..000000000000
--- a/drivers/staging/most/dim2/dim2.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * dim2.h - MediaLB DIM2 HDM Header
- *
- * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
- */
-
-#ifndef DIM2_HDM_H
-#define DIM2_HDM_H
-
-struct device;
-
-/* platform dependent data for dim2 interface */
-struct dim2_platform_data {
- int (*init)(struct dim2_platform_data *pd, void __iomem *io_base,
- int clk_speed);
- void (*destroy)(struct dim2_platform_data *pd);
- void *priv;
-};
-
-#endif /* DIM2_HDM_H */
diff --git a/drivers/staging/most/dim2/hal.c b/drivers/staging/most/dim2/hal.c
index 17c04e1c5e62..699e02f83bd4 100644
--- a/drivers/staging/most/dim2/hal.c
+++ b/drivers/staging/most/dim2/hal.c
@@ -760,7 +760,8 @@ static u8 init_ctrl_async(struct dim_channel *ch, u8 type, u8 is_tx,
if (!check_channel_address(ch_address))
return DIM_INIT_ERR_CHANNEL_ADDRESS;
- ch->dbr_size = ROUND_UP_TO(hw_buffer_size, DBR_BLOCK_SIZE);
+ if (!ch->dbr_size)
+ ch->dbr_size = ROUND_UP_TO(hw_buffer_size, DBR_BLOCK_SIZE);
ch->dbr_addr = alloc_dbr(ch->dbr_size);
if (ch->dbr_addr >= DBR_SIZE)
return DIM_INIT_ERR_OUT_OF_MEMORY;
@@ -846,7 +847,8 @@ u8 dim_init_isoc(struct dim_channel *ch, u8 is_tx, u16 ch_address,
if (!check_packet_length(packet_length))
return DIM_ERR_BAD_CONFIG;
- ch->dbr_size = packet_length * ISOC_DBR_FACTOR;
+ if (!ch->dbr_size)
+ ch->dbr_size = packet_length * ISOC_DBR_FACTOR;
ch->dbr_addr = alloc_dbr(ch->dbr_size);
if (ch->dbr_addr >= DBR_SIZE)
return DIM_INIT_ERR_OUT_OF_MEMORY;
@@ -873,7 +875,8 @@ u8 dim_init_sync(struct dim_channel *ch, u8 is_tx, u16 ch_address,
if (!check_bytes_per_frame(bytes_per_frame))
return DIM_ERR_BAD_CONFIG;
- ch->dbr_size = bytes_per_frame << bd_factor;
+ if (!ch->dbr_size)
+ ch->dbr_size = bytes_per_frame << bd_factor;
ch->dbr_addr = alloc_dbr(ch->dbr_size);
if (ch->dbr_addr >= DBR_SIZE)
return DIM_INIT_ERR_OUT_OF_MEMORY;
diff --git a/drivers/staging/most/dim2/reg.h b/drivers/staging/most/dim2/reg.h
index 69cbf78239f1..4343a483017e 100644
--- a/drivers/staging/most/dim2/reg.h
+++ b/drivers/staging/most/dim2/reg.h
@@ -12,48 +12,48 @@
#include <linux/types.h>
struct dim2_regs {
- /* 0x00 */ u32 MLBC0;
- /* 0x01 */ u32 rsvd0[1];
- /* 0x02 */ u32 MLBPC0;
- /* 0x03 */ u32 MS0;
- /* 0x04 */ u32 rsvd1[1];
- /* 0x05 */ u32 MS1;
- /* 0x06 */ u32 rsvd2[2];
- /* 0x08 */ u32 MSS;
- /* 0x09 */ u32 MSD;
- /* 0x0A */ u32 rsvd3[1];
- /* 0x0B */ u32 MIEN;
- /* 0x0C */ u32 rsvd4[1];
- /* 0x0D */ u32 MLBPC2;
- /* 0x0E */ u32 MLBPC1;
- /* 0x0F */ u32 MLBC1;
- /* 0x10 */ u32 rsvd5[0x10];
- /* 0x20 */ u32 HCTL;
- /* 0x21 */ u32 rsvd6[1];
- /* 0x22 */ u32 HCMR0;
- /* 0x23 */ u32 HCMR1;
- /* 0x24 */ u32 HCER0;
- /* 0x25 */ u32 HCER1;
- /* 0x26 */ u32 HCBR0;
- /* 0x27 */ u32 HCBR1;
- /* 0x28 */ u32 rsvd7[8];
- /* 0x30 */ u32 MDAT0;
- /* 0x31 */ u32 MDAT1;
- /* 0x32 */ u32 MDAT2;
- /* 0x33 */ u32 MDAT3;
- /* 0x34 */ u32 MDWE0;
- /* 0x35 */ u32 MDWE1;
- /* 0x36 */ u32 MDWE2;
- /* 0x37 */ u32 MDWE3;
- /* 0x38 */ u32 MCTL;
- /* 0x39 */ u32 MADR;
- /* 0x3A */ u32 rsvd8[0xB6];
- /* 0xF0 */ u32 ACTL;
- /* 0xF1 */ u32 rsvd9[3];
- /* 0xF4 */ u32 ACSR0;
- /* 0xF5 */ u32 ACSR1;
- /* 0xF6 */ u32 ACMR0;
- /* 0xF7 */ u32 ACMR1;
+ u32 MLBC0; /* 0x00 */
+ u32 rsvd0[1]; /* 0x01 */
+ u32 MLBPC0; /* 0x02 */
+ u32 MS0; /* 0x03 */
+ u32 rsvd1[1]; /* 0x04 */
+ u32 MS1; /* 0x05 */
+ u32 rsvd2[2]; /* 0x06 */
+ u32 MSS; /* 0x08 */
+ u32 MSD; /* 0x09 */
+ u32 rsvd3[1]; /* 0x0A */
+ u32 MIEN; /* 0x0B */
+ u32 rsvd4[1]; /* 0x0C */
+ u32 MLBPC2; /* 0x0D */
+ u32 MLBPC1; /* 0x0E */
+ u32 MLBC1; /* 0x0F */
+ u32 rsvd5[0x10]; /* 0x10 */
+ u32 HCTL; /* 0x20 */
+ u32 rsvd6[1]; /* 0x21 */
+ u32 HCMR0; /* 0x22 */
+ u32 HCMR1; /* 0x23 */
+ u32 HCER0; /* 0x24 */
+ u32 HCER1; /* 0x25 */
+ u32 HCBR0; /* 0x26 */
+ u32 HCBR1; /* 0x27 */
+ u32 rsvd7[8]; /* 0x28 */
+ u32 MDAT0; /* 0x30 */
+ u32 MDAT1; /* 0x31 */
+ u32 MDAT2; /* 0x32 */
+ u32 MDAT3; /* 0x33 */
+ u32 MDWE0; /* 0x34 */
+ u32 MDWE1; /* 0x35 */
+ u32 MDWE2; /* 0x36 */
+ u32 MDWE3; /* 0x37 */
+ u32 MCTL; /* 0x38 */
+ u32 MADR; /* 0x39 */
+ u32 rsvd8[0xb6]; /* 0x3A */
+ u32 ACTL; /* 0xF0 */
+ u32 rsvd9[3]; /* 0xF1 */
+ u32 ACSR0; /* 0xF4 */
+ u32 ACSR1; /* 0xF5 */
+ u32 ACMR0; /* 0xF6 */
+ u32 ACMR1; /* 0xF7 */
};
#define DIM2_MASK(n) (~((~(u32)0) << (n)))
diff --git a/drivers/staging/most/i2c/i2c.c b/drivers/staging/most/i2c/i2c.c
index 141239fc9f51..4a4fc1005932 100644
--- a/drivers/staging/most/i2c/i2c.c
+++ b/drivers/staging/most/i2c/i2c.c
@@ -11,7 +11,6 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
-#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/err.h>
@@ -29,33 +28,28 @@ enum { CH_RX, CH_TX, NUM_CHANNELS };
#define list_first_mbo(ptr) \
list_first_entry(ptr, struct mbo, list)
-/* IRQ / Polling option */
-static bool polling_req;
-module_param(polling_req, bool, 0444);
-MODULE_PARM_DESC(polling_req, "Request Polling. Default = 0 (use irq)");
-
-/* Polling Rate */
-static int scan_rate = 100;
-module_param(scan_rate, int, 0644);
-MODULE_PARM_DESC(scan_rate, "Polling rate in times/sec. Default = 100");
+static unsigned int polling_rate;
+module_param(polling_rate, uint, 0644);
+MODULE_PARM_DESC(polling_rate, "Polling rate [Hz]. Default = 0 (use IRQ)");
struct hdm_i2c {
- bool is_open[NUM_CHANNELS];
- bool polling_mode;
struct most_interface most_iface;
struct most_channel_capability capabilities[NUM_CHANNELS];
struct i2c_client *client;
struct rx {
struct delayed_work dwork;
- wait_queue_head_t waitq;
struct list_head list;
- struct mutex list_mutex;
+ bool int_disabled;
+ unsigned int delay;
} rx;
char name[64];
};
#define to_hdm(iface) container_of(iface, struct hdm_i2c, most_iface)
+static irqreturn_t most_irq_handler(int, void *);
+static void pending_rx_work(struct work_struct *);
+
/**
* configure_channel - called from MOST core to configure a channel
* @iface: interface the channel belongs to
@@ -71,10 +65,11 @@ static int configure_channel(struct most_interface *most_iface,
int ch_idx,
struct most_channel_config *channel_config)
{
+ int ret;
struct hdm_i2c *dev = to_hdm(most_iface);
+ unsigned int delay, pr;
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
- BUG_ON(dev->is_open[ch_idx]);
if (channel_config->data_type != MOST_CH_CONTROL) {
pr_err("bad data type for channel %d\n", ch_idx);
@@ -86,11 +81,27 @@ static int configure_channel(struct most_interface *most_iface,
return -EPERM;
}
- if ((channel_config->direction == MOST_CH_RX) && (dev->polling_mode)) {
- schedule_delayed_work(&dev->rx.dwork,
- msecs_to_jiffies(MSEC_PER_SEC / 4));
+ if (channel_config->direction == MOST_CH_RX) {
+ if (!polling_rate) {
+ if (dev->client->irq <= 0) {
+ pr_err("bad irq: %d\n", dev->client->irq);
+ return -ENOENT;
+ }
+ dev->rx.int_disabled = false;
+ ret = request_irq(dev->client->irq, most_irq_handler, 0,
+ dev->client->name, dev);
+ if (ret) {
+ pr_err("request_irq(%d) failed: %d\n",
+ dev->client->irq, ret);
+ return ret;
+ }
+ } else {
+ delay = msecs_to_jiffies(MSEC_PER_SEC / polling_rate);
+ dev->rx.delay = delay ? delay : 1;
+ pr = MSEC_PER_SEC / jiffies_to_msecs(dev->rx.delay);
+ pr_info("polling rate is %u Hz\n", pr);
+ }
}
- dev->is_open[ch_idx] = true;
return 0;
}
@@ -113,14 +124,17 @@ static int enqueue(struct most_interface *most_iface,
int ret;
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
- BUG_ON(!dev->is_open[ch_idx]);
if (ch_idx == CH_RX) {
/* RX */
- mutex_lock(&dev->rx.list_mutex);
+ if (!polling_rate)
+ disable_irq(dev->client->irq);
+ cancel_delayed_work_sync(&dev->rx.dwork);
list_add_tail(&mbo->list, &dev->rx.list);
- mutex_unlock(&dev->rx.list_mutex);
- wake_up_interruptible(&dev->rx.waitq);
+ if (dev->rx.int_disabled || polling_rate)
+ pending_rx_work(&dev->rx.dwork.work);
+ if (!polling_rate)
+ enable_irq(dev->client->irq);
} else {
/* TX */
ret = i2c_master_send(dev->client, mbo->virt_address,
@@ -155,25 +169,20 @@ static int poison_channel(struct most_interface *most_iface,
struct mbo *mbo;
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
- BUG_ON(!dev->is_open[ch_idx]);
-
- dev->is_open[ch_idx] = false;
if (ch_idx == CH_RX) {
- mutex_lock(&dev->rx.list_mutex);
+ if (!polling_rate)
+ free_irq(dev->client->irq, dev);
+ cancel_delayed_work_sync(&dev->rx.dwork);
+
while (!list_empty(&dev->rx.list)) {
mbo = list_first_mbo(&dev->rx.list);
list_del(&mbo->list);
- mutex_unlock(&dev->rx.list_mutex);
mbo->processed_length = 0;
mbo->status = MBO_E_CLOSE;
mbo->complete(mbo);
-
- mutex_lock(&dev->rx.list_mutex);
}
- mutex_unlock(&dev->rx.list_mutex);
- wake_up_interruptible(&dev->rx.waitq);
}
return 0;
@@ -183,7 +192,7 @@ static void do_rx_work(struct hdm_i2c *dev)
{
struct mbo *mbo;
unsigned char msg[MAX_BUF_SIZE_CONTROL];
- int ret, ch_idx = CH_RX;
+ int ret;
u16 pml, data_size;
/* Read PML (2 bytes) */
@@ -206,32 +215,8 @@ static void do_rx_work(struct hdm_i2c *dev)
return;
}
- for (;;) {
- /* Conditions to wait for: poisoned channel or free buffer
- * available for reading
- */
- if (wait_event_interruptible(dev->rx.waitq,
- !dev->is_open[ch_idx] ||
- !list_empty(&dev->rx.list))) {
- pr_err("wait_event_interruptible() failed\n");
- return;
- }
-
- if (!dev->is_open[ch_idx])
- return;
-
- mutex_lock(&dev->rx.list_mutex);
-
- /* list may be empty if poison or remove is called */
- if (!list_empty(&dev->rx.list))
- break;
-
- mutex_unlock(&dev->rx.list_mutex);
- }
-
mbo = list_first_mbo(&dev->rx.list);
list_del(&mbo->list);
- mutex_unlock(&dev->rx.list_mutex);
mbo->processed_length = min(data_size, mbo->buffer_length);
memcpy(mbo->virt_address, msg, mbo->processed_length);
@@ -249,14 +234,15 @@ static void pending_rx_work(struct work_struct *work)
{
struct hdm_i2c *dev = container_of(work, struct hdm_i2c, rx.dwork.work);
+ if (list_empty(&dev->rx.list))
+ return;
+
do_rx_work(dev);
- if (dev->polling_mode) {
- if (dev->is_open[CH_RX])
- schedule_delayed_work(&dev->rx.dwork,
- msecs_to_jiffies(MSEC_PER_SEC
- / scan_rate));
+ if (polling_rate) {
+ schedule_delayed_work(&dev->rx.dwork, dev->rx.delay);
} else {
+ dev->rx.int_disabled = false;
enable_irq(dev->client->irq);
}
}
@@ -284,7 +270,7 @@ static irqreturn_t most_irq_handler(int irq, void *_dev)
struct hdm_i2c *dev = _dev;
disable_irq_nosync(irq);
-
+ dev->rx.int_disabled = true;
schedule_delayed_work(&dev->rx.dwork, 0);
return IRQ_HANDLED;
@@ -313,7 +299,6 @@ static int i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
client->adapter->nr, client->addr);
for (i = 0; i < NUM_CHANNELS; i++) {
- dev->is_open[i] = false;
dev->capabilities[i].data_type = MOST_CH_CONTROL;
dev->capabilities[i].num_buffers_packet = MAX_BUFFERS_CONTROL;
dev->capabilities[i].buffer_size_packet = MAX_BUF_SIZE_CONTROL;
@@ -332,8 +317,6 @@ static int i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
dev->most_iface.poison_channel = poison_channel;
INIT_LIST_HEAD(&dev->rx.list);
- mutex_init(&dev->rx.list_mutex);
- init_waitqueue_head(&dev->rx.waitq);
INIT_DELAYED_WORK(&dev->rx.dwork, pending_rx_work);
@@ -347,21 +330,6 @@ static int i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
return ret;
}
- dev->polling_mode = polling_req || client->irq <= 0;
- if (!dev->polling_mode) {
- pr_info("Requesting IRQ: %d\n", client->irq);
- ret = request_irq(client->irq, most_irq_handler, 0,
- client->name, dev);
- if (ret) {
- pr_info("IRQ request failed: %d, falling back to polling\n",
- ret);
- dev->polling_mode = true;
- }
- }
-
- if (dev->polling_mode)
- pr_info("Using polling at rate: %d times/sec\n", scan_rate);
-
return 0;
}
@@ -376,17 +344,8 @@ static int i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int i2c_remove(struct i2c_client *client)
{
struct hdm_i2c *dev = i2c_get_clientdata(client);
- int i;
-
- if (!dev->polling_mode)
- free_irq(client->irq, dev);
most_deregister_interface(&dev->most_iface);
-
- for (i = 0 ; i < NUM_CHANNELS; i++)
- if (dev->is_open[i])
- poison_channel(&dev->most_iface, i);
- cancel_delayed_work_sync(&dev->rx.dwork);
kfree(dev);
return 0;
@@ -410,7 +369,6 @@ static struct i2c_driver i2c_driver = {
module_i2c_driver(i2c_driver);
-MODULE_AUTHOR("Jain Roy Ambi <JainRoy.Ambi@microchip.com>");
MODULE_AUTHOR("Andrey Shvetsov <andrey.shvetsov@k2l.de>");
MODULE_DESCRIPTION("I2C Hardware Dependent Module");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 83cec21c85b8..04c18323c2ea 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -460,21 +460,68 @@ static const struct snd_pcm_ops pcm_ops = {
.mmap = snd_pcm_lib_mmap_vmalloc,
};
-static int split_arg_list(char *buf, char **card_name, char **pcm_format)
+static int split_arg_list(char *buf, char **card_name, u16 *ch_num,
+ char **sample_res)
{
+ char *num;
+ int ret;
+
*card_name = strsep(&buf, ".");
- if (!*card_name)
- return -EIO;
- *pcm_format = strsep(&buf, ".\n");
- if (!*pcm_format)
+ if (!*card_name) {
+ pr_err("Missing sound card name\n");
return -EIO;
+ }
+ num = strsep(&buf, "x");
+ if (!num)
+ goto err;
+ ret = kstrtou16(num, 0, ch_num);
+ if (ret)
+ goto err;
+ *sample_res = strsep(&buf, ".\n");
+ if (!*sample_res)
+ goto err;
return 0;
+
+err:
+ pr_err("Bad PCM format\n");
+ return -EIO;
}
+static const struct sample_resolution_info {
+ const char *sample_res;
+ int bytes;
+ u64 formats;
+} sinfo[] = {
+ { "8", 1, SNDRV_PCM_FMTBIT_S8 },
+ { "16", 2, SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE },
+ { "24", 3, SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE },
+ { "32", 4, SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE },
+};
+
static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
- char *pcm_format,
+ u16 ch_num, char *sample_res,
struct most_channel_config *cfg)
{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(sinfo); i++) {
+ if (!strcmp(sample_res, sinfo[i].sample_res))
+ goto found;
+ }
+ pr_err("Unsupported PCM format\n");
+ return -EIO;
+
+found:
+ if (!ch_num) {
+ pr_err("Bad number of channels\n");
+ return -EINVAL;
+ }
+
+ if (cfg->subbuffer_size != ch_num * sinfo[i].bytes) {
+ pr_err("Audio resolution doesn't fit subbuffer size\n");
+ return -EINVAL;
+ }
+
pcm_hw->info = MOST_PCM_INFO;
pcm_hw->rates = SNDRV_PCM_RATE_48000;
pcm_hw->rate_min = 48000;
@@ -484,54 +531,10 @@ static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
pcm_hw->period_bytes_max = cfg->buffer_size;
pcm_hw->periods_min = 1;
pcm_hw->periods_max = cfg->num_buffers;
-
- if (!strcmp(pcm_format, "1x8")) {
- if (cfg->subbuffer_size != 1)
- goto error;
- pr_info("PCM format is 8-bit mono\n");
- pcm_hw->channels_min = 1;
- pcm_hw->channels_max = 1;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S8;
- } else if (!strcmp(pcm_format, "2x16")) {
- if (cfg->subbuffer_size != 4)
- goto error;
- pr_info("PCM format is 16-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S16_BE;
- } else if (!strcmp(pcm_format, "2x24")) {
- if (cfg->subbuffer_size != 6)
- goto error;
- pr_info("PCM format is 24-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S24_3LE |
- SNDRV_PCM_FMTBIT_S24_3BE;
- } else if (!strcmp(pcm_format, "2x32")) {
- if (cfg->subbuffer_size != 8)
- goto error;
- pr_info("PCM format is 32-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S32_LE |
- SNDRV_PCM_FMTBIT_S32_BE;
- } else if (!strcmp(pcm_format, "6x16")) {
- if (cfg->subbuffer_size != 12)
- goto error;
- pr_info("PCM format is 16-bit 5.1 multi channel\n");
- pcm_hw->channels_min = 6;
- pcm_hw->channels_max = 6;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S16_BE;
- } else {
- pr_err("PCM format %s not supported\n", pcm_format);
- return -EIO;
- }
+ pcm_hw->channels_min = ch_num;
+ pcm_hw->channels_max = ch_num;
+ pcm_hw->formats = sinfo[i].formats;
return 0;
-error:
- pr_err("Audio resolution doesn't fit subbuffer size\n");
- return -EINVAL;
}
/**
@@ -558,7 +561,8 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
int ret;
int direction;
char *card_name;
- char *pcm_format;
+ u16 ch_num;
+ char *sample_res;
if (!iface)
return -EINVAL;
@@ -582,13 +586,11 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
direction = SNDRV_PCM_STREAM_CAPTURE;
}
- ret = split_arg_list(arg_list, &card_name, &pcm_format);
- if (ret < 0) {
- pr_info("PCM format missing\n");
+ ret = split_arg_list(arg_list, &card_name, &ch_num, &sample_res);
+ if (ret < 0)
return ret;
- }
- ret = snd_card_new(NULL, -1, card_name, THIS_MODULE,
+ ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE,
sizeof(*channel), &card);
if (ret < 0)
return ret;
@@ -600,7 +602,8 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
channel->id = channel_id;
init_waitqueue_head(&channel->playback_waitq);
- ret = audio_set_hw_params(&channel->pcm_hardware, pcm_format, cfg);
+ ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res,
+ cfg);
if (ret)
goto err_free_card;
diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index 31f184cfcd69..bc820f90bcb1 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -338,7 +338,6 @@ static void hdm_write_completion(struct urb *urb)
struct mbo *mbo = urb->context;
struct most_dev *mdev = to_mdev(mbo->ifp);
unsigned int channel = mbo->hdm_channel_id;
- struct device *dev = &mdev->usb_device->dev;
spinlock_t *lock = mdev->channel_lock + channel;
unsigned long flags;
@@ -354,7 +353,9 @@ static void hdm_write_completion(struct urb *urb)
mbo->status = MBO_SUCCESS;
break;
case -EPIPE:
- dev_warn(dev, "Broken OUT pipe detected\n");
+ dev_warn(&mdev->usb_device->dev,
+ "Broken pipe on ep%02x\n",
+ mdev->ep_address[channel]);
mdev->is_channel_healthy[channel] = false;
mdev->clear_work[channel].pipe = urb->pipe;
schedule_work(&mdev->clear_work[channel].ws);
@@ -507,7 +508,8 @@ static void hdm_read_completion(struct urb *urb)
}
break;
case -EPIPE:
- dev_warn(dev, "Broken IN pipe detected\n");
+ dev_warn(dev, "Broken pipe on ep%02x\n",
+ mdev->ep_address[channel]);
mdev->is_channel_healthy[channel] = false;
mdev->clear_work[channel].pipe = urb->pipe;
schedule_work(&mdev->clear_work[channel].ws);
@@ -517,7 +519,8 @@ static void hdm_read_completion(struct urb *urb)
mbo->status = MBO_E_CLOSE;
break;
case -EOVERFLOW:
- dev_warn(dev, "Babble on IN pipe detected\n");
+ dev_warn(dev, "Babble on ep%02x\n",
+ mdev->ep_address[channel]);
break;
}
}
@@ -549,7 +552,6 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
{
struct most_dev *mdev;
struct most_channel_config *conf;
- struct device *dev;
int retval = 0;
struct urb *urb;
unsigned long length;
@@ -562,14 +564,18 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
mdev = to_mdev(iface);
conf = &mdev->conf[channel];
- dev = &mdev->usb_device->dev;
- if (!mdev->usb_device)
- return -ENODEV;
+ mutex_lock(&mdev->io_mutex);
+ if (!mdev->usb_device) {
+ retval = -ENODEV;
+ goto _exit;
+ }
urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC);
- if (!urb)
- return -ENOMEM;
+ if (!urb) {
+ retval = -ENOMEM;
+ goto _exit;
+ }
if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
hdm_add_padding(mdev, channel, mbo)) {
@@ -589,7 +595,8 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
length,
hdm_write_completion,
mbo);
- if (conf->data_type != MOST_CH_ISOC)
+ if (conf->data_type != MOST_CH_ISOC &&
+ conf->data_type != MOST_CH_SYNC)
urb->transfer_flags |= URB_ZERO_PACKET;
} else {
usb_fill_bulk_urb(urb, mdev->usb_device,
@@ -606,18 +613,37 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
retval = usb_submit_urb(urb, GFP_KERNEL);
if (retval) {
- dev_err(dev, "URB submit failed with error %d.\n", retval);
+ dev_err(&mdev->usb_device->dev,
+ "URB submit failed with error %d.\n", retval);
goto _error_1;
}
- return 0;
+ goto _exit;
_error_1:
usb_unanchor_urb(urb);
_error:
usb_free_urb(urb);
+_exit:
+ mutex_unlock(&mdev->io_mutex);
return retval;
}
+static void *hdm_dma_alloc(struct mbo *mbo, u32 size)
+{
+ struct most_dev *mdev = to_mdev(mbo->ifp);
+
+ return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL,
+ &mbo->bus_address);
+}
+
+static void hdm_dma_free(struct mbo *mbo, u32 size)
+{
+ struct most_dev *mdev = to_mdev(mbo->ifp);
+
+ usb_free_coherent(mdev->usb_device, size, mbo->virt_address,
+ mbo->bus_address);
+}
+
/**
* hdm_configure_channel - receive channel configuration from core
* @iface: interface
@@ -1027,11 +1053,14 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
mdev->link_stat_timer.expires = jiffies + (2 * HZ);
mdev->iface.mod = hdm_usb_fops.owner;
+ mdev->iface.driver_dev = &interface->dev;
mdev->iface.interface = ITYPE_USB;
mdev->iface.configure = hdm_configure_channel;
mdev->iface.request_netinfo = hdm_request_netinfo;
mdev->iface.enqueue = hdm_enqueue;
mdev->iface.poison_channel = hdm_poison_channel;
+ mdev->iface.dma_alloc = hdm_dma_alloc;
+ mdev->iface.dma_free = hdm_dma_free;
mdev->iface.description = mdev->description;
mdev->iface.num_channels = num_endpoints;
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 9d7e747519d9..cf342eb58e10 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -73,8 +73,6 @@ static int comp_vdev_open(struct file *filp)
struct most_video_dev *mdev = video_drvdata(filp);
struct comp_fh *fh;
- v4l2_info(&mdev->v4l2_dev, "comp_vdev_open()\n");
-
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
break;
@@ -122,8 +120,6 @@ static int comp_vdev_close(struct file *filp)
struct most_video_dev *mdev = fh->mdev;
struct mbo *mbo, *tmp;
- v4l2_info(&mdev->v4l2_dev, "comp_vdev_close()\n");
-
/*
* We need to put MBOs back before we call most_stop_channel()
* to deallocate MBOs.
@@ -250,8 +246,6 @@ static int vidioc_querycap(struct file *file, void *priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
- v4l2_info(&mdev->v4l2_dev, "vidioc_querycap()\n");
-
strlcpy(cap->driver, "v4l2_component", sizeof(cap->driver));
strlcpy(cap->card, "MOST", sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
@@ -267,11 +261,6 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct comp_fh *fh = priv;
- struct most_video_dev *mdev = fh->mdev;
-
- v4l2_info(&mdev->v4l2_dev, "vidioc_enum_fmt_vid_cap() %d\n", f->index);
-
if (f->index)
return -EINVAL;
@@ -286,11 +275,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct comp_fh *fh = priv;
- struct most_video_dev *mdev = fh->mdev;
-
- v4l2_info(&mdev->v4l2_dev, "vidioc_g_fmt_vid_cap()\n");
-
comp_set_format_struct(f);
return 0;
}
@@ -315,11 +299,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
{
- struct comp_fh *fh = priv;
- struct most_video_dev *mdev = fh->mdev;
-
- v4l2_info(&mdev->v4l2_dev, "vidioc_g_std()\n");
-
*norm = V4L2_STD_UNKNOWN;
return 0;
}
@@ -355,8 +334,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
- v4l2_info(&mdev->v4l2_dev, "vidioc_s_input(%d)\n", index);
-
if (index >= V4L2_CMP_MAX_INPUT)
return -EINVAL;
mdev->ctrl_input = index;
@@ -435,8 +412,6 @@ static int comp_register_videodev(struct most_video_dev *mdev)
{
int ret;
- v4l2_info(&mdev->v4l2_dev, "comp_register_videodev()\n");
-
init_waitqueue_head(&mdev->wait_data);
/* allocate and fill v4l2 video struct */
@@ -465,8 +440,6 @@ static int comp_register_videodev(struct most_video_dev *mdev)
static void comp_unregister_videodev(struct most_video_dev *mdev)
{
- v4l2_info(&mdev->v4l2_dev, "comp_unregister_videodev()\n");
-
video_unregister_device(mdev->vdev);
}
@@ -485,8 +458,6 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
int ret;
struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
- pr_info("comp_probe_channel(%s)\n", name);
-
if (mdev) {
pr_err("channel already linked\n");
return -EEXIST;
@@ -531,7 +502,6 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
spin_lock_irq(&list_lock);
list_add(&mdev->list, &video_devices);
spin_unlock_irq(&list_lock);
- v4l2_info(&mdev->v4l2_dev, "comp_probe_channel() done\n");
return 0;
err_unreg:
@@ -550,8 +520,6 @@ static int comp_disconnect_channel(struct most_interface *iface,
return -ENOENT;
}
- v4l2_info(&mdev->v4l2_dev, "comp_disconnect_channel()\n");
-
spin_lock_irq(&list_lock);
list_del(&mdev->list);
spin_unlock_irq(&list_lock);
diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts
index 515c7cbdd15e..6b13d85d9d34 100644
--- a/drivers/staging/mt7621-dts/gbpc1.dts
+++ b/drivers/staging/mt7621-dts/gbpc1.dts
@@ -75,7 +75,6 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
- m25p,chunked-io = <32>;
partition@0 {
label = "u-boot";
@@ -97,7 +96,7 @@
partition@50000 {
label = "firmware";
- reg = <0x50000 0xFB0000>;
+ reg = <0x50000 0x1FB0000>;
};
};
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi
index ebcaa8b1fc81..240d396bbb89 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -64,26 +64,29 @@
#address-cells = <1>;
#size-cells = <0>;
- compatible = "mtk,mt7621-gpio";
+ compatible = "mediatek,mt7621-gpio";
reg = <0x600 0x100>;
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>;
+
gpio0: bank@0 {
reg = <0>;
- compatible = "mtk,mt7621-gpio-bank";
+ compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
gpio1: bank@1 {
reg = <1>;
- compatible = "mtk,mt7621-gpio-bank";
+ compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
gpio2: bank@2 {
reg = <2>;
- compatible = "mtk,mt7621-gpio-bank";
+ compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
@@ -429,10 +432,11 @@
0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */
>;
- interrupt-parent = <&gic>;
- interrupts = <GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH
- GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH
- GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
+ #interrupt-cells = <1>;
+ interrupt-map-mask = <0xF0000 0 0 1>;
+ interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>,
+ <0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>,
+ <0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
status = "disabled";
diff --git a/drivers/staging/mt7621-eth/ethtool.c b/drivers/staging/mt7621-eth/ethtool.c
index 38ba0c040aba..40a7d47be913 100644
--- a/drivers/staging/mt7621-eth/ethtool.c
+++ b/drivers/staging/mt7621-eth/ethtool.c
@@ -13,13 +13,35 @@
*/
#include "mtk_eth_soc.h"
+#include "ethtool.h"
-static const char mtk_gdma_str[][ETH_GSTRING_LEN] = {
-#define _FE(x...) # x,
-MTK_STAT_REG_DECLARE
-#undef _FE
+struct mtk_stat {
+ char name[ETH_GSTRING_LEN];
+ unsigned int idx;
};
+#define MTK_HW_STAT(stat) { \
+ .name = #stat, \
+ .idx = offsetof(struct mtk_hw_stats, stat) / sizeof(u64) \
+}
+
+static const struct mtk_stat mtk_ethtool_hw_stats[] = {
+ MTK_HW_STAT(tx_bytes),
+ MTK_HW_STAT(tx_packets),
+ MTK_HW_STAT(tx_skip),
+ MTK_HW_STAT(tx_collisions),
+ MTK_HW_STAT(rx_bytes),
+ MTK_HW_STAT(rx_packets),
+ MTK_HW_STAT(rx_overflow),
+ MTK_HW_STAT(rx_fcs_errors),
+ MTK_HW_STAT(rx_short_errors),
+ MTK_HW_STAT(rx_long_errors),
+ MTK_HW_STAT(rx_checksum_errors),
+ MTK_HW_STAT(rx_flow_control_packets),
+};
+
+#define MTK_HW_STATS_LEN ARRAY_SIZE(mtk_ethtool_hw_stats)
+
static int mtk_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
@@ -52,7 +74,8 @@ static int mtk_set_link_ksettings(struct net_device *dev,
mac->phy_dev = mac->hw->phy->phy[cmd->base.phy_address];
mac->phy_flags = MTK_PHY_FLAG_PORT;
} else if (mac->hw->mii_bus) {
- mac->phy_dev = mdiobus_get_phy(mac->hw->mii_bus, cmd->base.phy_address);
+ mac->phy_dev = mdiobus_get_phy(mac->hw->mii_bus,
+ cmd->base.phy_address);
if (!mac->phy_dev)
return -ENODEV;
mac->phy_flags = MTK_PHY_FLAG_ATTACH;
@@ -62,7 +85,6 @@ static int mtk_set_link_ksettings(struct net_device *dev,
}
return phy_ethtool_ksettings_set(mac->phy_dev, cmd);
-
}
static void mtk_get_drvinfo(struct net_device *dev,
@@ -75,7 +97,7 @@ static void mtk_get_drvinfo(struct net_device *dev,
strlcpy(info->bus_info, dev_name(mac->hw->dev), sizeof(info->bus_info));
if (soc->reg_table[MTK_REG_MTK_COUNTER_BASE])
- info->n_stats = ARRAY_SIZE(mtk_gdma_str);
+ info->n_stats = MTK_HW_STATS_LEN;
}
static u32 mtk_get_msglevel(struct net_device *dev)
@@ -154,9 +176,15 @@ static void mtk_get_ringparam(struct net_device *dev,
static void mtk_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
+ int i;
+
switch (stringset) {
case ETH_SS_STATS:
- memcpy(data, *mtk_gdma_str, sizeof(mtk_gdma_str));
+ for (i = 0; i < MTK_HW_STATS_LEN; i++) {
+ memcpy(data, mtk_ethtool_hw_stats[i].name,
+ ETH_GSTRING_LEN);
+ data += ETH_GSTRING_LEN;
+ }
break;
}
}
@@ -165,7 +193,7 @@ static int mtk_get_sset_count(struct net_device *dev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
- return ARRAY_SIZE(mtk_gdma_str);
+ return MTK_HW_STATS_LEN;
default:
return -EOPNOTSUPP;
}
@@ -176,7 +204,6 @@ static void mtk_get_ethtool_stats(struct net_device *dev,
{
struct mtk_mac *mac = netdev_priv(dev);
struct mtk_hw_stats *hwstats = mac->hw_stats;
- u64 *data_src, *data_dst;
unsigned int start;
int i;
@@ -188,12 +215,9 @@ static void mtk_get_ethtool_stats(struct net_device *dev,
}
do {
- data_src = &hwstats->tx_bytes;
- data_dst = data;
start = u64_stats_fetch_begin_irq(&hwstats->syncp);
-
- for (i = 0; i < ARRAY_SIZE(mtk_gdma_str); i++)
- *data_dst++ = *data_src++;
+ for (i = 0; i < MTK_HW_STATS_LEN; i++)
+ data[i] = ((u64 *)hwstats)[mtk_ethtool_hw_stats[i].idx];
} while (u64_stats_fetch_retry_irq(&hwstats->syncp, start));
}
diff --git a/drivers/staging/mt7621-eth/gsw_mt7620.h b/drivers/staging/mt7621-eth/gsw_mt7620.h
index 1766939e2101..70f7e5481952 100644
--- a/drivers/staging/mt7621-eth/gsw_mt7620.h
+++ b/drivers/staging/mt7621-eth/gsw_mt7620.h
@@ -252,8 +252,8 @@ struct mt7620_gsw {
};
/* switch register I/O wrappers */
-void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned reg);
-u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned reg);
+void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned int reg);
+u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned int reg);
/* the callback used by the driver core to bringup the switch */
int mtk_gsw_init(struct mtk_eth *eth);
diff --git a/drivers/staging/mt7621-eth/gsw_mt7621.c b/drivers/staging/mt7621-eth/gsw_mt7621.c
index ce8d7d7577c7..2c07b559bed7 100644
--- a/drivers/staging/mt7621-eth/gsw_mt7621.c
+++ b/drivers/staging/mt7621-eth/gsw_mt7621.c
@@ -24,13 +24,13 @@
#include "mtk_eth_soc.h"
#include "gsw_mt7620.h"
-void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned reg)
+void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned int reg)
{
iowrite32(val, gsw->base + reg);
}
EXPORT_SYMBOL_GPL(mtk_switch_w32);
-u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned reg)
+u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned int reg)
{
return ioread32(gsw->base + reg);
}
@@ -201,20 +201,20 @@ static void mt7621_hw_init(struct mtk_eth *eth, struct mt7620_gsw *gsw,
/* This is copied from mt7530_apply_config in libreCMC driver */
{
int i;
+
for (i = 0; i < MT7530_NUM_PORTS; i++)
mt7530_mdio_w32(gsw, REG_ESW_PORT_PCR(i), 0x00400000);
- mt7530_mdio_w32(gsw, REG_ESW_PORT_PCR(MT7530_CPU_PORT), 0x00ff0000);
+ mt7530_mdio_w32(gsw, REG_ESW_PORT_PCR(MT7530_CPU_PORT),
+ 0x00ff0000);
for (i = 0; i < MT7530_NUM_PORTS; i++)
mt7530_mdio_w32(gsw, REG_ESW_PORT_PVC(i), 0x810000c0);
-
}
/* enable irq */
mt7530_mdio_m32(gsw, 0, 3 << 16, MT7530_TOP_SIG_CTRL);
mt7530_mdio_w32(gsw, MT7530_SYS_INT_EN, 0x1f);
-
}
static const struct of_device_id mediatek_gsw_match[] = {
diff --git a/drivers/staging/mt7621-eth/mdio.c b/drivers/staging/mt7621-eth/mdio.c
index 9d713078ef90..7ad0c4141205 100644
--- a/drivers/staging/mt7621-eth/mdio.c
+++ b/drivers/staging/mt7621-eth/mdio.c
@@ -57,6 +57,7 @@ static void mtk_phy_link_adjust(struct net_device *dev)
}
}
}
+ spin_unlock_irqrestore(&eth->phy->lock, flags);
}
int mtk_connect_phy_node(struct mtk_eth *eth, struct mtk_mac *mac,
@@ -130,6 +131,7 @@ static int mtk_phy_connect(struct mtk_mac *mac)
}
} else if (eth->mii_bus) {
struct phy_device *phy;
+
phy = mdiobus_get_phy(eth->mii_bus, i);
if (phy) {
phy_init(eth, mac, phy);
@@ -160,7 +162,9 @@ static void mtk_phy_disconnect(struct mtk_mac *mac)
} else if (eth->phy->phy[i]) {
phy_disconnect(eth->phy->phy[i]);
} else if (eth->mii_bus) {
- struct phy_device *phy = mdiobus_get_phy(eth->mii_bus, i);
+ struct phy_device *phy =
+ mdiobus_get_phy(eth->mii_bus, i);
+
if (phy)
phy_detach(phy);
}
diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c
index cbc7339843a5..2c7a2e666bfb 100644
--- a/drivers/staging/mt7621-eth/mtk_eth_soc.c
+++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c
@@ -82,12 +82,12 @@ static const u16 mtk_reg_table_default[MTK_REG_COUNT] = {
static const u16 *mtk_reg_table = mtk_reg_table_default;
-void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
+void mtk_w32(struct mtk_eth *eth, u32 val, unsigned int reg)
{
__raw_writel(val, eth->base + reg);
}
-u32 mtk_r32(struct mtk_eth *eth, unsigned reg)
+u32 mtk_r32(struct mtk_eth *eth, unsigned int reg)
{
return __raw_readl(eth->base + reg);
}
@@ -315,7 +315,7 @@ static int mtk_dma_rx_alloc(struct mtk_eth *eth, struct mtk_rx_ring *ring)
ring->rx_buf_size = mtk_max_buf_size(ring->frag_size);
ring->rx_ring_size = eth->soc->dma_ring_size;
ring->rx_data = kcalloc(ring->rx_ring_size, sizeof(*ring->rx_data),
- GFP_KERNEL);
+ GFP_KERNEL);
if (!ring->rx_data)
goto no_rx_mem;
@@ -325,10 +325,10 @@ static int mtk_dma_rx_alloc(struct mtk_eth *eth, struct mtk_rx_ring *ring)
goto no_rx_mem;
}
- ring->rx_dma = dma_alloc_coherent(eth->dev,
- ring->rx_ring_size * sizeof(*ring->rx_dma),
- &ring->rx_phys,
- GFP_ATOMIC | __GFP_ZERO);
+ ring->rx_dma =
+ dma_alloc_coherent(eth->dev,
+ ring->rx_ring_size * sizeof(*ring->rx_dma),
+ &ring->rx_phys, GFP_ATOMIC | __GFP_ZERO);
if (!ring->rx_dma)
goto no_rx_mem;
@@ -768,9 +768,8 @@ err_dma:
/* the qdma core needs scratch memory to be setup */
static int mtk_init_fq_dma(struct mtk_eth *eth)
{
- unsigned int phy_ring_head, phy_ring_tail;
+ dma_addr_t dma_addr, phy_ring_head, phy_ring_tail;
int cnt = eth->soc->dma_ring_size;
- dma_addr_t dma_addr;
int i;
eth->scratch_ring = dma_alloc_coherent(eth->dev,
@@ -1195,7 +1194,6 @@ static int mtk_qdma_tx_poll(struct mtk_eth *eth, int budget, bool *tx_again)
int total = 0, done[MTK_MAX_DEVS];
unsigned int bytes[MTK_MAX_DEVS];
u32 cpu, dma;
- static int condition;
int i;
memset(done, 0, sizeof(done));
@@ -1220,10 +1218,8 @@ static int mtk_qdma_tx_poll(struct mtk_eth *eth, int budget, bool *tx_again)
tx_buf = mtk_desc_to_tx_buf(ring, desc);
skb = tx_buf->skb;
- if (!skb) {
- condition = 1;
+ if (!skb)
break;
- }
if (skb != (struct sk_buff *)DMA_DUMMY_DESC) {
bytes[mac] += skb->len;
@@ -1352,14 +1348,14 @@ static int mtk_pdma_tx_alloc(struct mtk_eth *eth)
MAX_SKB_FRAGS);
ring->tx_buf = kcalloc(ring->tx_ring_size, sizeof(*ring->tx_buf),
- GFP_KERNEL);
+ GFP_KERNEL);
if (!ring->tx_buf)
goto no_tx_mem;
- ring->tx_dma = dma_alloc_coherent(eth->dev,
- ring->tx_ring_size * sizeof(*ring->tx_dma),
- &ring->tx_phys,
- GFP_ATOMIC | __GFP_ZERO);
+ ring->tx_dma =
+ dma_alloc_coherent(eth->dev,
+ ring->tx_ring_size * sizeof(*ring->tx_dma),
+ &ring->tx_phys, GFP_ATOMIC | __GFP_ZERO);
if (!ring->tx_dma)
goto no_tx_mem;
@@ -1540,8 +1536,8 @@ static void mtk_tx_timeout(struct net_device *dev)
if (eth->soc->dma_type & MTK_PDMA) {
netif_info(eth, drv, dev, "pdma_cfg:%08x\n",
mtk_reg_r32(eth, MTK_REG_PDMA_GLO_CFG));
- netif_info(eth, drv, dev, "tx_ring=%d, "
- "base=%08x, max=%u, ctx=%u, dtx=%u, fdx=%hu, next=%hu\n",
+ netif_info(eth, drv, dev,
+ "tx_ring=%d, base=%08x, max=%u, ctx=%u, dtx=%u, fdx=%hu, next=%hu\n",
0, mtk_reg_r32(eth, MTK_REG_TX_BASE_PTR0),
mtk_reg_r32(eth, MTK_REG_TX_MAX_CNT0),
mtk_reg_r32(eth, MTK_REG_TX_CTX_IDX0),
@@ -1552,8 +1548,8 @@ static void mtk_tx_timeout(struct net_device *dev)
if (eth->soc->dma_type & MTK_QDMA) {
netif_info(eth, drv, dev, "qdma_cfg:%08x\n",
mtk_r32(eth, MTK_QDMA_GLO_CFG));
- netif_info(eth, drv, dev, "tx_ring=%d, "
- "ctx=%08x, dtx=%08x, crx=%08x, drx=%08x, free=%hu\n",
+ netif_info(eth, drv, dev,
+ "tx_ring=%d, ctx=%08x, dtx=%08x, crx=%08x, drx=%08x, free=%hu\n",
0, mtk_r32(eth, MTK_QTX_CTX_PTR),
mtk_r32(eth, MTK_QTX_DTX_PTR),
mtk_r32(eth, MTK_QTX_CRX_PTR),
@@ -2014,8 +2010,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
if (mtk_reg_table[MTK_REG_MTK_COUNTER_BASE]) {
mac->hw_stats = devm_kzalloc(eth->dev,
- sizeof(*mac->hw_stats),
- GFP_KERNEL);
+ sizeof(*mac->hw_stats),
+ GFP_KERNEL);
if (!mac->hw_stats)
return -ENOMEM;
spin_lock_init(&mac->hw_stats->stats_lock);
diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.h b/drivers/staging/mt7621-eth/mtk_eth_soc.h
index 443f88d8af65..e6ed80433f49 100644
--- a/drivers/staging/mt7621-eth/mtk_eth_soc.h
+++ b/drivers/staging/mt7621-eth/mtk_eth_soc.h
@@ -501,21 +501,7 @@ struct mtk_soc_data {
u32 has_switch:1;
};
-/* ugly macro hack to make sure hw_stats and ethtool strings are consistent */
#define MTK_STAT_OFFSET 0x40
-#define MTK_STAT_REG_DECLARE \
- _FE(tx_bytes) \
- _FE(tx_packets) \
- _FE(tx_skip) \
- _FE(tx_collisions) \
- _FE(rx_bytes) \
- _FE(rx_packets) \
- _FE(rx_overflow) \
- _FE(rx_fcs_errors) \
- _FE(rx_short_errors) \
- _FE(rx_long_errors) \
- _FE(rx_checksum_errors) \
- _FE(rx_flow_control_packets)
/* struct mtk_hw_stats - the structure that holds the traffic statistics.
* @stats_lock: make sure that stats operations are atomic
@@ -531,9 +517,18 @@ struct mtk_hw_stats {
u32 reg_offset;
struct u64_stats_sync syncp;
-#define _FE(x) u64 x;
- MTK_STAT_REG_DECLARE
-#undef _FE
+ u64 tx_bytes;
+ u64 tx_packets;
+ u64 tx_skip;
+ u64 tx_collisions;
+ u64 rx_bytes;
+ u64 rx_packets;
+ u64 rx_overflow;
+ u64 rx_fcs_errors;
+ u64 rx_short_errors;
+ u64 rx_long_errors;
+ u64 rx_checksum_errors;
+ u64 rx_flow_control_packets;
};
/* PDMA descriptor can point at 1-2 segments. This enum allows us to track how
@@ -706,8 +701,8 @@ void mtk_stats_update_mac(struct mtk_mac *mac);
void mtk_reset(struct mtk_eth *eth, u32 reset_bits);
/* register i/o wrappers */
-void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg);
-u32 mtk_r32(struct mtk_eth *eth, unsigned reg);
+void mtk_w32(struct mtk_eth *eth, u32 val, unsigned int reg);
+u32 mtk_r32(struct mtk_eth *eth, unsigned int reg);
/* default clock calibration handler */
int mtk_set_clock_cycle(struct mtk_eth *eth);
diff --git a/drivers/staging/mt7621-eth/soc_mt7621.c b/drivers/staging/mt7621-eth/soc_mt7621.c
index 743c0eed89b6..5d63b5d96f6b 100644
--- a/drivers/staging/mt7621-eth/soc_mt7621.c
+++ b/drivers/staging/mt7621-eth/soc_mt7621.c
@@ -50,7 +50,6 @@
#define GSW_REG_GDMA2_MAC_ADRL 0x1508
#define GSW_REG_GDMA2_MAC_ADRH 0x150C
-
#define MT7621_MTK_RST_GL 0x04
#define MT7620_MTK_INT_STATUS2 0x08
@@ -108,13 +107,15 @@ static void mt7621_set_mac(struct mtk_mac *mac, unsigned char *hwaddr)
spin_lock_irqsave(&mac->hw->page_lock, flags);
if (mac->id == 0) {
- mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1], GSW_REG_GDMA1_MAC_ADRH);
+ mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1],
+ GSW_REG_GDMA1_MAC_ADRH);
mtk_w32(mac->hw, (hwaddr[2] << 24) | (hwaddr[3] << 16) |
(hwaddr[4] << 8) | hwaddr[5],
GSW_REG_GDMA1_MAC_ADRL);
}
if (mac->id == 1) {
- mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1], GSW_REG_GDMA2_MAC_ADRH);
+ mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1],
+ GSW_REG_GDMA2_MAC_ADRH);
mtk_w32(mac->hw, (hwaddr[2] << 24) | (hwaddr[3] << 16) |
(hwaddr[4] << 8) | hwaddr[5],
GSW_REG_GDMA2_MAC_ADRL);
diff --git a/drivers/staging/mt7621-gpio/TODO b/drivers/staging/mt7621-gpio/TODO
index 71439054e2e4..674930a10716 100644
--- a/drivers/staging/mt7621-gpio/TODO
+++ b/drivers/staging/mt7621-gpio/TODO
@@ -1,5 +1,3 @@
-
- general code review and clean up
-- ensure device-tree requirements are documented
Cc: NeilBrown <neil@brown.name>
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 51235687ddb6..5d923a745684 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -1,15 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
* Copyright (C) 2009-2011 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2013 John Crispin <blogic@openwrt.org>
*/
#include <linux/io.h>
#include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/spinlock.h>
@@ -34,17 +31,20 @@ enum mediatek_gpio_reg {
GPIO_REG_EDGE,
};
-static void __iomem *mediatek_gpio_membase;
-static int mediatek_gpio_irq;
-static struct irq_domain *mediatek_gpio_irq_domain;
-
-static struct mtk_gc {
+struct mtk_gc {
struct gpio_chip chip;
spinlock_t lock;
int bank;
u32 rising;
u32 falling;
-} *gc_map[MTK_MAX_BANK];
+};
+
+struct mtk_data {
+ void __iomem *gpio_membase;
+ int gpio_irq;
+ struct irq_domain *gpio_irq_domain;
+ struct mtk_gc *gc_map[MTK_MAX_BANK];
+};
static inline struct mtk_gc
*to_mediatek_gpio(struct gpio_chip *chip)
@@ -59,17 +59,23 @@ static inline struct mtk_gc
static inline void
mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val)
{
- iowrite32(val, mediatek_gpio_membase + (reg * 0x10) + (rg->bank * 0x4));
+ struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip);
+ u32 offset = (reg * 0x10) + (rg->bank * 0x4);
+
+ iowrite32(val, gpio_data->gpio_membase + offset);
}
static inline u32
mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
{
- return ioread32(mediatek_gpio_membase + (reg * 0x10) + (rg->bank * 0x4));
+ struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip);
+ u32 offset = (reg * 0x10) + (rg->bank * 0x4);
+
+ return ioread32(gpio_data->gpio_membase + offset);
}
static void
-mediatek_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+mediatek_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
{
struct mtk_gc *rg = to_mediatek_gpio(chip);
@@ -77,7 +83,7 @@ mediatek_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
}
static int
-mediatek_gpio_get(struct gpio_chip *chip, unsigned offset)
+mediatek_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct mtk_gc *rg = to_mediatek_gpio(chip);
@@ -85,7 +91,7 @@ mediatek_gpio_get(struct gpio_chip *chip, unsigned offset)
}
static int
-mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
+mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
{
struct mtk_gc *rg = to_mediatek_gpio(chip);
unsigned long flags;
@@ -102,7 +108,7 @@ mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
static int
mediatek_gpio_direction_output(struct gpio_chip *chip,
- unsigned offset, int value)
+ unsigned int offset, int value)
{
struct mtk_gc *rg = to_mediatek_gpio(chip);
unsigned long flags;
@@ -119,7 +125,7 @@ mediatek_gpio_direction_output(struct gpio_chip *chip,
}
static int
-mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
struct mtk_gc *rg = to_mediatek_gpio(chip);
unsigned long flags;
@@ -129,33 +135,35 @@ mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
spin_unlock_irqrestore(&rg->lock, flags);
- if (t & BIT(offset))
- return 0;
-
- return 1;
+ return (t & BIT(offset)) ? 0 : 1;
}
static int
-mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
+mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
{
+ struct mtk_data *gpio_data = gpiochip_get_data(chip);
struct mtk_gc *rg = to_mediatek_gpio(chip);
- return irq_create_mapping(mediatek_gpio_irq_domain, pin + (rg->bank * MTK_BANK_WIDTH));
+ return irq_create_mapping(gpio_data->gpio_irq_domain,
+ pin + (rg->bank * MTK_BANK_WIDTH));
}
static int
mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank)
{
+ struct mtk_data *gpio_data = dev_get_drvdata(&pdev->dev);
const __be32 *id = of_get_property(bank, "reg", NULL);
- struct mtk_gc *rg = devm_kzalloc(&pdev->dev,
- sizeof(struct mtk_gc), GFP_KERNEL);
+ struct mtk_gc *rg;
+ int ret;
- if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
- return -ENOMEM;
+ if (!id || be32_to_cpu(*id) >= MTK_MAX_BANK)
+ return -EINVAL;
- gc_map[be32_to_cpu(*id)] = rg;
+ rg = devm_kzalloc(&pdev->dev, sizeof(struct mtk_gc), GFP_KERNEL);
+ if (!rg)
+ return -ENOMEM;
- memset(rg, 0, sizeof(struct mtk_gc));
+ gpio_data->gc_map[be32_to_cpu(*id)] = rg;
spin_lock_init(&rg->lock);
@@ -169,25 +177,33 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank)
rg->chip.get_direction = mediatek_gpio_get_direction;
rg->chip.get = mediatek_gpio_get;
rg->chip.set = mediatek_gpio_set;
- if (mediatek_gpio_irq_domain)
+ if (gpio_data->gpio_irq_domain)
rg->chip.to_irq = mediatek_gpio_to_irq;
rg->bank = be32_to_cpu(*id);
+ ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio_data);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n",
+ rg->chip.ngpio, ret);
+ return ret;
+ }
+
/* set polarity to low for all gpios */
mtk_gpio_w32(rg, GPIO_REG_POL, 0);
dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio);
- return gpiochip_add(&rg->chip);
+ return 0;
}
static void
mediatek_gpio_irq_handler(struct irq_desc *desc)
{
+ struct mtk_data *gpio_data = irq_desc_get_handler_data(desc);
int i;
for (i = 0; i < MTK_MAX_BANK; i++) {
- struct mtk_gc *rg = gc_map[i];
+ struct mtk_gc *rg = gpio_data->gc_map[i];
unsigned long pending;
int bit;
@@ -197,7 +213,8 @@ mediatek_gpio_irq_handler(struct irq_desc *desc)
pending = mtk_gpio_r32(rg, GPIO_REG_STAT);
for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) {
- u32 map = irq_find_mapping(mediatek_gpio_irq_domain, (MTK_BANK_WIDTH * i) + bit);
+ u32 map = irq_find_mapping(gpio_data->gpio_irq_domain,
+ (MTK_BANK_WIDTH * i) + bit);
generic_handle_irq(map);
mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit));
@@ -208,9 +225,10 @@ mediatek_gpio_irq_handler(struct irq_desc *desc)
static void
mediatek_gpio_irq_unmask(struct irq_data *d)
{
+ struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
int pin = d->hwirq;
- int bank = pin / 32;
- struct mtk_gc *rg = gc_map[bank];
+ int bank = pin / MTK_BANK_WIDTH;
+ struct mtk_gc *rg = gpio_data->gc_map[bank];
unsigned long flags;
u32 rise, fall;
@@ -229,9 +247,10 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
static void
mediatek_gpio_irq_mask(struct irq_data *d)
{
+ struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
int pin = d->hwirq;
- int bank = pin / 32;
- struct mtk_gc *rg = gc_map[bank];
+ int bank = pin / MTK_BANK_WIDTH;
+ struct mtk_gc *rg = gpio_data->gc_map[bank];
unsigned long flags;
u32 rise, fall;
@@ -250,9 +269,10 @@ mediatek_gpio_irq_mask(struct irq_data *d)
static int
mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
{
+ struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
int pin = d->hwirq;
- int bank = pin / 32;
- struct mtk_gc *rg = gc_map[bank];
+ int bank = pin / MTK_BANK_WIDTH;
+ struct mtk_gc *rg = gpio_data->gc_map[bank];
u32 mask = BIT(d->hwirq);
if (!rg)
@@ -287,9 +307,16 @@ static struct irq_chip mediatek_gpio_irq_chip = {
};
static int
-mediatek_gpio_gpio_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
+mediatek_gpio_gpio_map(struct irq_domain *d, unsigned int irq,
+ irq_hw_number_t hw)
{
- irq_set_chip_and_handler(irq, &mediatek_gpio_irq_chip, handle_level_irq);
+ int ret;
+
+ ret = irq_set_chip_data(irq, d->host_data);
+ if (ret < 0)
+ return ret;
+ irq_set_chip_and_handler(irq, &mediatek_gpio_irq_chip,
+ handle_level_irq);
irq_set_handler_data(irq, d);
return 0;
@@ -305,32 +332,41 @@ mediatek_gpio_probe(struct platform_device *pdev)
{
struct device_node *bank, *np = pdev->dev.of_node;
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ struct mtk_data *gpio_data;
+
+ gpio_data = devm_kzalloc(&pdev->dev, sizeof(*gpio_data), GFP_KERNEL);
+ if (!gpio_data)
+ return -ENOMEM;
- mediatek_gpio_membase = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(mediatek_gpio_membase))
- return PTR_ERR(mediatek_gpio_membase);
+ gpio_data->gpio_membase = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(gpio_data->gpio_membase))
+ return PTR_ERR(gpio_data->gpio_membase);
- mediatek_gpio_irq = irq_of_parse_and_map(np, 0);
- if (mediatek_gpio_irq) {
- mediatek_gpio_irq_domain = irq_domain_add_linear(np,
+ gpio_data->gpio_irq = irq_of_parse_and_map(np, 0);
+ if (gpio_data->gpio_irq) {
+ gpio_data->gpio_irq_domain = irq_domain_add_linear(np,
MTK_MAX_BANK * MTK_BANK_WIDTH,
- &irq_domain_ops, NULL);
- if (!mediatek_gpio_irq_domain)
+ &irq_domain_ops, gpio_data);
+ if (!gpio_data->gpio_irq_domain)
dev_err(&pdev->dev, "irq_domain_add_linear failed\n");
}
+ platform_set_drvdata(pdev, gpio_data);
+
for_each_child_of_node(np, bank)
- if (of_device_is_compatible(bank, "mtk,mt7621-gpio-bank"))
+ if (of_device_is_compatible(bank, "mediatek,mt7621-gpio-bank"))
mediatek_gpio_bank_probe(pdev, bank);
- if (mediatek_gpio_irq_domain)
- irq_set_chained_handler(mediatek_gpio_irq, mediatek_gpio_irq_handler);
+ if (gpio_data->gpio_irq_domain)
+ irq_set_chained_handler_and_data(gpio_data->gpio_irq,
+ mediatek_gpio_irq_handler,
+ gpio_data);
return 0;
}
static const struct of_device_id mediatek_gpio_match[] = {
- { .compatible = "mtk,mt7621-gpio" },
+ { .compatible = "mediatek,mt7621-gpio" },
{},
};
MODULE_DEVICE_TABLE(of, mediatek_gpio_match);
diff --git a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
new file mode 100644
index 000000000000..af640924585f
--- /dev/null
+++ b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
@@ -0,0 +1,58 @@
+Mediatek SoC GPIO controller bindings
+
+The IP core used inside these SoCs has 3 banks of 32 GPIOs each.
+The registers of all the banks are interwoven inside one single IO range.
+We load one GPIO controller instance per bank. To make this possible
+we support 2 types of nodes. The parent node defines the memory I/O range and
+has 3 children each describing a single bank. Also the GPIO controller can receive
+interrupts on any of the GPIOs, either edge or level. It then interrupts the CPU
+using GIC INT12.
+
+Required properties for the top level node:
+- compatible:
+ - "mediatek,mt7621-gpio" for Mediatek controllers
+- reg : Physical base address and length of the controller's registers
+- interrupt-parent : phandle of the parent interrupt controller.
+- interrupts = Interrupt specifier for the controllers interrupt
+
+Required properties for the GPIO bank node:
+- compatible:
+ - "mediatek,mt7621-gpio-bank" for Mediatek banks
+- #gpio-cells : Should be two.
+ - first cell is the pin number
+ - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller
+- reg : The id of the bank that the node describes.
+
+Example:
+ gpio@600 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ compatible = "mediatek,mt7621-gpio";
+ reg = <0x600 0x100>;
+
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>;
+
+ gpio0: bank@0 {
+ reg = <0>;
+ compatible = "mediatek,mt7621-gpio-bank";
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpio1: bank@1 {
+ reg = <1>;
+ compatible = "mediatek,mt7621-gpio-bank";
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpio2: bank@2 {
+ reg = <2>;
+ compatible = "mediatek,mt7621-gpio-bank";
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+ };
diff --git a/drivers/staging/mt7621-mmc/board.h b/drivers/staging/mt7621-mmc/board.h
index 33bfc7b9597a..a7d82f321b00 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -36,27 +36,10 @@
#ifndef __ARCH_ARM_MACH_BOARD_H
#define __ARCH_ARM_MACH_BOARD_H
-#include <generated/autoconf.h>
-#include <linux/pm.h>
-/* --- chhung */
-// #include <mach/mt6575.h>
-// #include <board-custom.h>
-/* end of chhung */
-
-typedef void (*sdio_irq_handler_t)(void*); /* external irq handler */
-typedef void (*pm_callback_t)(pm_message_t state, void *data);
-
#define MSDC_CD_PIN_EN (1 << 0) /* card detection pin is wired */
#define MSDC_WP_PIN_EN (1 << 1) /* write protection pin is wired */
#define MSDC_RST_PIN_EN (1 << 2) /* emmc reset pin is wired */
-#define MSDC_SDIO_IRQ (1 << 3) /* use internal sdio irq (bus) */
-#define MSDC_EXT_SDIO_IRQ (1 << 4) /* use external sdio irq */
#define MSDC_REMOVABLE (1 << 5) /* removable slot */
-#define MSDC_SYS_SUSPEND (1 << 6) /* suspended by system */
-#define MSDC_HIGHSPEED (1 << 7) /* high-speed mode support */
-#define MSDC_UHS1 (1 << 8) /* uhs-1 mode support */
-#define MSDC_DDR (1 << 9) /* ddr mode support */
-
#define MSDC_SMPL_RISING (0)
#define MSDC_SMPL_FALLING (1)
@@ -67,71 +50,14 @@ typedef void (*pm_callback_t)(pm_message_t state, void *data);
#define MSDC_WP_PIN (3)
#define MSDC_RST_PIN (4)
-enum {
- MSDC_CLKSRC_48MHZ = 0,
-// MSDC_CLKSRC_26MHZ = 0,
-// MSDC_CLKSRC_197MHZ = 1,
-// MSDC_CLKSRC_208MHZ = 2
-};
-
struct msdc_hw {
- unsigned char clk_src; /* host clock source */
- unsigned char cmd_edge; /* command latch edge */
- unsigned char data_edge; /* data latch edge */
- unsigned char clk_drv; /* clock pad driving */
- unsigned char cmd_drv; /* command pad driving */
- unsigned char dat_drv; /* data pad driving */
- unsigned long flags; /* hardware capability flags */
- unsigned long data_pins; /* data pins */
- unsigned long data_offset; /* data address offset */
-
- /* config gpio pull mode */
- void (*config_gpio_pin)(int type, int pull);
-
- /* external power control for card */
- void (*ext_power_on)(void);
- void (*ext_power_off)(void);
+ unsigned char clk_src; /* host clock source */
+ unsigned long flags; /* hardware capability flags */
- /* external sdio irq operations */
- void (*request_sdio_eirq)(sdio_irq_handler_t sdio_irq_handler, void *data);
- void (*enable_sdio_eirq)(void);
- void (*disable_sdio_eirq)(void);
-
- /* external cd irq operations */
- void (*request_cd_eirq)(sdio_irq_handler_t cd_irq_handler, void *data);
- void (*enable_cd_eirq)(void);
- void (*disable_cd_eirq)(void);
- int (*get_cd_status)(void);
-
- /* power management callback for external module */
- void (*register_pm)(pm_callback_t pm_cb, void *data);
+ /* config gpio pull mode */
+ void (*config_gpio_pin)(int type, int pull);
};
extern struct msdc_hw msdc0_hw;
-extern struct msdc_hw msdc1_hw;
-extern struct msdc_hw msdc2_hw;
-extern struct msdc_hw msdc3_hw;
-
-/*GPS driver*/
-#define GPS_FLAG_FORCE_OFF 0x0001
-struct mt3326_gps_hardware {
- int (*ext_power_on)(int);
- int (*ext_power_off)(int);
-};
-extern struct mt3326_gps_hardware mt3326_gps_hw;
-
-/* NAND driver */
-struct mt6575_nand_host_hw {
- unsigned int nfi_bus_width; /* NFI_BUS_WIDTH */
- unsigned int nfi_access_timing; /* NFI_ACCESS_TIMING */
- unsigned int nfi_cs_num; /* NFI_CS_NUM */
- unsigned int nand_sec_size; /* NAND_SECTOR_SIZE */
- unsigned int nand_sec_shift; /* NAND_SECTOR_SHIFT */
- unsigned int nand_ecc_size;
- unsigned int nand_ecc_bytes;
- unsigned int nand_ecc_mode;
-};
-extern struct mt6575_nand_host_hw mt6575_nand_hw;
#endif /* __ARCH_ARM_MACH_BOARD_H */
-
diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 4dc115b53993..d897b1216348 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -32,7 +32,7 @@
* have been modified by MediaTek Inc. All revisions are subject to any receiver's
* applicable license agreements with MediaTek Inc.
*/
-
+
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -51,272 +51,236 @@
static char cmd_buf[256];
/* for debug zone */
-unsigned int sd_debug_zone[4]={
+unsigned int sd_debug_zone[4] = {
0,
0,
0,
0
};
-/* mode select */
-u32 dma_size[4]={
- 512,
- 512,
- 512,
- 512
-};
-msdc_mode drv_mode[4]={
- MODE_SIZE_DEP, /* using DMA or not depend on the size */
- MODE_SIZE_DEP,
- MODE_SIZE_DEP,
- MODE_SIZE_DEP
-};
-
-#if defined (MT6575_SD_DEBUG)
+#if defined(MT6575_SD_DEBUG)
/* for driver profile */
#define TICKS_ONE_MS (13000)
-u32 gpt_enable = 0;
-u32 sdio_pro_enable = 0; /* make sure gpt is enabled */
-u32 sdio_pro_time = 0; /* no more than 30s */
-struct sdio_profile sdio_perfomance = {0};
+u32 gpt_enable;
+u32 sdio_pro_enable; /* make sure gpt is enabled */
+u32 sdio_pro_time; /* no more than 30s */
+struct sdio_profile sdio_perfomance = {0};
#if 0 /* --- chhung */
void msdc_init_gpt(void)
{
- GPT_CONFIG config;
-
- config.num = GPT6;
- config.mode = GPT_FREE_RUN;
- config.clkSrc = GPT_CLK_SRC_SYS;
- config.clkDiv = GPT_CLK_DIV_1; /* 13MHz GPT6 */
-
- if (GPT_Config(config) == FALSE )
- return;
-
- GPT_Start(GPT6);
+ GPT_CONFIG config;
+
+ config.num = GPT6;
+ config.mode = GPT_FREE_RUN;
+ config.clkSrc = GPT_CLK_SRC_SYS;
+ config.clkDiv = GPT_CLK_DIV_1; /* 13MHz GPT6 */
+
+ if (GPT_Config(config) == FALSE)
+ return;
+
+ GPT_Start(GPT6);
}
#endif /* end of --- */
u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32)
{
- u32 ret = 0;
-
- if (new_H32 == old_H32) {
- ret = new_L32 - old_L32;
- } else if(new_H32 == (old_H32 + 1)) {
- if (new_L32 > old_L32) {
- printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
- }
- ret = (0xffffffff - old_L32);
- ret += new_L32;
- } else {
- printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
- }
-
- return ret;
+ u32 ret = 0;
+
+ if (new_H32 == old_H32) {
+ ret = new_L32 - old_L32;
+ } else if (new_H32 == (old_H32 + 1)) {
+ if (new_L32 > old_L32)
+ printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
+ ret = (0xffffffff - old_L32);
+ ret += new_L32;
+ } else {
+ printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
+ }
+
+ return ret;
}
-void msdc_sdio_profile(struct sdio_profile* result)
+void msdc_sdio_profile(struct sdio_profile *result)
{
- struct cmd_profile* cmd;
- u32 i;
-
- printk("sdio === performance dump ===\n");
- printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
- result->total_tc, result->total_tc / TICKS_ONE_MS,
- result->total_tx_bytes, result->total_rx_bytes);
-
- /* CMD52 Dump */
- cmd = &result->cmd52_rx;
- printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
- cmd = &result->cmd52_tx;
- printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
-
- /* CMD53 Rx bytes + block mode */
- for (i=0; i<512; i++) {
- cmd = &result->cmd53_rx_byte[i];
- if (cmd->count) {
- printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
- }
- }
- for (i=0; i<100; i++) {
- cmd = &result->cmd53_rx_blk[i];
- if (cmd->count) {
- printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
- }
- }
-
- /* CMD53 Tx bytes + block mode */
- for (i=0; i<512; i++) {
- cmd = &result->cmd53_tx_byte[i];
- if (cmd->count) {
- printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
- }
- }
- for (i=0; i<100; i++) {
- cmd = &result->cmd53_tx_blk[i];
- if (cmd->count) {
- printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
- }
- }
-
- printk("sdio === performance dump done ===\n");
+ struct cmd_profile *cmd;
+ u32 i;
+
+ printk("sdio === performance dump ===\n");
+ printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
+ result->total_tc, result->total_tc / TICKS_ONE_MS,
+ result->total_tx_bytes, result->total_rx_bytes);
+
+ /* CMD52 Dump */
+ cmd = &result->cmd52_rx;
+ printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count);
+ cmd = &result->cmd52_tx;
+ printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count);
+
+ /* CMD53 Rx bytes + block mode */
+ for (i = 0; i < 512; i++) {
+ cmd = &result->cmd53_rx_byte[i];
+ if (cmd->count) {
+ printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count,
+ cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10));
+ }
+ }
+ for (i = 0; i < 100; i++) {
+ cmd = &result->cmd53_rx_blk[i];
+ if (cmd->count) {
+ printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count,
+ cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10));
+ }
+ }
+
+ /* CMD53 Tx bytes + block mode */
+ for (i = 0; i < 512; i++) {
+ cmd = &result->cmd53_tx_byte[i];
+ if (cmd->count) {
+ printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count,
+ cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10));
+ }
+ }
+ for (i = 0; i < 100; i++) {
+ cmd = &result->cmd53_tx_blk[i];
+ if (cmd->count) {
+ printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
+ cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count,
+ cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10));
+ }
+ }
+
+ printk("sdio === performance dump done ===\n");
}
//========= sdio command table ===========
void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks)
{
- struct sdio_profile* result = &sdio_perfomance;
- struct cmd_profile* cmd;
- u32 block;
-
- if (sdio_pro_enable == 0) {
- return;
- }
-
- if (opcode == 52) {
- cmd = bRx ? &result->cmd52_rx : &result->cmd52_tx;
- } else if (opcode == 53) {
- if (sizes < 512) {
- cmd = bRx ? &result->cmd53_rx_byte[sizes] : &result->cmd53_tx_byte[sizes];
- } else {
- block = sizes / 512;
- if (block >= 99) {
- printk("cmd53 error blocks\n");
- while(1);
- }
- cmd = bRx ? &result->cmd53_rx_blk[block] : &result->cmd53_tx_blk[block];
- }
- } else {
- return;
- }
-
- /* update the members */
- if (ticks > cmd->max_tc){
- cmd->max_tc = ticks;
- }
- if (cmd->min_tc == 0 || ticks < cmd->min_tc) {
- cmd->min_tc = ticks;
- }
- cmd->tot_tc += ticks;
- cmd->tot_bytes += sizes;
- cmd->count ++;
-
- if (bRx) {
- result->total_rx_bytes += sizes;
- } else {
- result->total_tx_bytes += sizes;
- }
- result->total_tc += ticks;
-
- /* dump when total_tc > 30s */
- if (result->total_tc >= sdio_pro_time * TICKS_ONE_MS * 1000) {
- msdc_sdio_profile(result);
- memset(result, 0 , sizeof(struct sdio_profile));
- }
+ struct sdio_profile *result = &sdio_perfomance;
+ struct cmd_profile *cmd;
+ u32 block;
+
+ if (sdio_pro_enable == 0)
+ return;
+
+ if (opcode == 52) {
+ cmd = bRx ? &result->cmd52_rx : &result->cmd52_tx;
+ } else if (opcode == 53) {
+ if (sizes < 512) {
+ cmd = bRx ? &result->cmd53_rx_byte[sizes] : &result->cmd53_tx_byte[sizes];
+ } else {
+ block = sizes / 512;
+ if (block >= 99) {
+ printk("cmd53 error blocks\n");
+ while (1)
+ ;
+ }
+ cmd = bRx ? &result->cmd53_rx_blk[block] : &result->cmd53_tx_blk[block];
+ }
+ } else {
+ return;
+ }
+
+ /* update the members */
+ if (ticks > cmd->max_tc)
+ cmd->max_tc = ticks;
+ if (cmd->min_tc == 0 || ticks < cmd->min_tc)
+ cmd->min_tc = ticks;
+ cmd->tot_tc += ticks;
+ cmd->tot_bytes += sizes;
+ cmd->count++;
+
+ if (bRx)
+ result->total_rx_bytes += sizes;
+ else
+ result->total_tx_bytes += sizes;
+ result->total_tc += ticks;
+
+ /* dump when total_tc > 30s */
+ if (result->total_tc >= sdio_pro_time * TICKS_ONE_MS * 1000) {
+ msdc_sdio_profile(result);
+ memset(result, 0, sizeof(struct sdio_profile));
+ }
}
//========== driver proc interface ===========
static int msdc_debug_proc_read(struct seq_file *s, void *p)
{
- seq_printf(s, "\n=========================================\n");
- seq_printf(s, "Index<0> + Id + Zone\n");
- seq_printf(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> RSP<2> CMD<1> DMA<0>\n");
- seq_printf(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set to 0x3ff\n");
+ seq_puts(s, "\n=========================================\n");
+ seq_puts(s, "Index<0> + Id + Zone\n");
+ seq_puts(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> RSP<2> CMD<1> DMA<0>\n");
+ seq_puts(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set to 0x3ff\n");
seq_printf(s, "-> MSDC[0] Zone: 0x%.8x\n", sd_debug_zone[0]);
seq_printf(s, "-> MSDC[1] Zone: 0x%.8x\n", sd_debug_zone[1]);
seq_printf(s, "-> MSDC[2] Zone: 0x%.8x\n", sd_debug_zone[2]);
seq_printf(s, "-> MSDC[3] Zone: 0x%.8x\n", sd_debug_zone[3]);
- seq_printf(s, "Index<1> + ID:4|Mode:4 + DMA_SIZE\n");
- seq_printf(s, "-> 0)PIO 1)DMA 2)SIZE\n");
- seq_printf(s, "-> echo 1 22 0x200 >msdc_bebug -> host[2] size mode, dma when >= 512\n");
- seq_printf(s, "-> MSDC[0] mode<%d> size<%d>\n", drv_mode[0], dma_size[0]);
- seq_printf(s, "-> MSDC[1] mode<%d> size<%d>\n", drv_mode[1], dma_size[1]);
- seq_printf(s, "-> MSDC[2] mode<%d> size<%d>\n", drv_mode[2], dma_size[2]);
- seq_printf(s, "-> MSDC[3] mode<%d> size<%d>\n", drv_mode[3], dma_size[3]);
-
- seq_printf(s, "Index<3> + SDIO_PROFILE + TIME\n");
- seq_printf(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 30s\n");
+ seq_puts(s, "Index<3> + SDIO_PROFILE + TIME\n");
+ seq_puts(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 30s\n");
seq_printf(s, "-> SDIO_PROFILE<%d> TIME<%ds>\n", sdio_pro_enable, sdio_pro_time);
- seq_printf(s, "=========================================\n\n");
+ seq_puts(s, "=========================================\n\n");
return 0;
}
-static ssize_t msdc_debug_proc_write(struct file *file,
- const char __user *buf, size_t count, loff_t *data)
+static ssize_t msdc_debug_proc_write(struct file *file,
+ const char __user *buf, size_t count, loff_t *data)
{
int ret;
-
- int cmd, p1, p2;
+
+ int cmd, p1, p2;
int id, zone;
- int mode, size;
-
- if (count == 0)return -1;
- if(count > 255)count = 255;
-
- ret = copy_from_user(cmd_buf, buf, count);
- if (ret < 0)return -1;
-
+ int mode, size;
+
+ if (count == 0)
+ return -1;
+ if (count > 255)
+ count = 255;
+
+ if (copy_from_user(cmd_buf, buf, count))
+ return -EFAULT;
+
cmd_buf[count] = '\0';
printk("msdc Write %s\n", cmd_buf);
sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2);
-
- if(cmd == SD_TOOL_ZONE) {
- id = p1; zone = p2; zone &= 0x3ff;
+
+ if (cmd == SD_TOOL_ZONE) {
+ id = p1;
+ zone = p2;
+ zone &= 0x3ff;
printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone);
- if(id >=0 && id<=3){
+ if (id >= 0 && id <= 3) {
sd_debug_zone[id] = zone;
- }
- else if(id == 4){
+ } else if (id == 4) {
sd_debug_zone[0] = sd_debug_zone[1] = zone;
sd_debug_zone[2] = sd_debug_zone[3] = zone;
- }
- else{
+ } else {
printk("msdc host_id error when set debug zone\n");
}
- } else if (cmd == SD_TOOL_DMA_SIZE) {
- id = p1>>4; mode = (p1&0xf); size = p2;
- if(id >=0 && id<=3){
- drv_mode[id] = mode;
- dma_size[id] = p2;
- }
- else if(id == 4){
- drv_mode[0] = drv_mode[1] = mode;
- drv_mode[2] = drv_mode[3] = mode;
- dma_size[0] = dma_size[1] = p2;
- dma_size[2] = dma_size[3] = p2;
- }
- else{
- printk("msdc host_id error when select mode\n");
- }
} else if (cmd == SD_TOOL_SDIO_PROFILE) {
if (p1 == 1) { /* enable profile */
if (gpt_enable == 0) {
// msdc_init_gpt(); /* --- by chhung */
gpt_enable = 1;
- }
+ }
sdio_pro_enable = 1;
- if (p2 == 0) p2 = 1; if (p2 >= 30) p2 = 30;
- sdio_pro_time = p2 ;
- } else if (p1 == 0) {
+ if (p2 == 0)
+ p2 = 1;
+ if (p2 >= 30)
+ p2 = 30;
+ sdio_pro_time = p2;
+ } else if (p1 == 0) {
/* todo */
sdio_pro_enable = 0;
- }
+ }
}
-
+
return count;
}
@@ -326,22 +290,17 @@ static int msdc_debug_show(struct inode *inode, struct file *file)
}
static const struct file_operations msdc_debug_fops = {
- .owner = THIS_MODULE,
- .open = msdc_debug_show,
- .read = seq_read,
- .write = msdc_debug_proc_write,
- .llseek = seq_lseek,
- .release = single_release,
+ .owner = THIS_MODULE,
+ .open = msdc_debug_show,
+ .read = seq_read,
+ .write = msdc_debug_proc_write,
+ .llseek = seq_lseek,
+ .release = single_release,
};
-int msdc_debug_proc_init(void)
-{
- struct proc_dir_entry *de = proc_create("msdc_debug", 0667, NULL, &msdc_debug_fops);
-
- if (!de || IS_ERR(de))
- printk("!! Create MSDC debug PROC fail !!\n");
-
- return 0 ;
+void msdc_debug_proc_init(void)
+{
+ proc_create("msdc_debug", 0660, NULL, &msdc_debug_fops);
}
EXPORT_SYMBOL_GPL(msdc_debug_proc_init);
#endif
diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index e58c4312933e..5a25a69b00c9 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -39,47 +39,45 @@
extern u32 sdio_pro_enable;
/* for a type command, e.g. CMD53, 2 blocks */
struct cmd_profile {
- u32 max_tc; /* Max tick count */
- u32 min_tc;
- u32 tot_tc; /* total tick count */
- u32 tot_bytes;
- u32 count; /* the counts of the command */
+ u32 max_tc; /* Max tick count */
+ u32 min_tc;
+ u32 tot_tc; /* total tick count */
+ u32 tot_bytes;
+ u32 count; /* the counts of the command */
};
/* dump when total_tc and total_bytes */
struct sdio_profile {
- u32 total_tc; /* total tick count of CMD52 and CMD53 */
- u32 total_tx_bytes; /* total bytes of CMD53 Tx */
- u32 total_rx_bytes; /* total bytes of CMD53 Rx */
-
- /*CMD52*/
- struct cmd_profile cmd52_tx;
- struct cmd_profile cmd52_rx;
-
- /*CMD53 in byte unit */
- struct cmd_profile cmd53_tx_byte[512];
- struct cmd_profile cmd53_rx_byte[512];
-
- /*CMD53 in block unit */
- struct cmd_profile cmd53_tx_blk[100];
- struct cmd_profile cmd53_rx_blk[100];
+ u32 total_tc; /* total tick count of CMD52 and CMD53 */
+ u32 total_tx_bytes; /* total bytes of CMD53 Tx */
+ u32 total_rx_bytes; /* total bytes of CMD53 Rx */
+
+ /*CMD52*/
+ struct cmd_profile cmd52_tx;
+ struct cmd_profile cmd52_rx;
+
+ /*CMD53 in byte unit */
+ struct cmd_profile cmd53_tx_byte[512];
+ struct cmd_profile cmd53_rx_byte[512];
+
+ /*CMD53 in block unit */
+ struct cmd_profile cmd53_tx_blk[100];
+ struct cmd_profile cmd53_rx_blk[100];
};
//==========================
-typedef enum {
- SD_TOOL_ZONE = 0,
- SD_TOOL_DMA_SIZE = 1,
- SD_TOOL_PM_ENABLE = 2,
- SD_TOOL_SDIO_PROFILE = 3,
-} msdc_dbg;
-
-typedef enum {
- MODE_PIO = 0,
- MODE_DMA = 1,
- MODE_SIZE_DEP = 2,
-} msdc_mode;
-extern msdc_mode drv_mode[4];
-extern u32 dma_size[4];
+enum msdc_dbg {
+ SD_TOOL_ZONE = 0,
+ SD_TOOL_DMA_SIZE = 1,
+ SD_TOOL_PM_ENABLE = 2,
+ SD_TOOL_SDIO_PROFILE = 3,
+};
+
+enum msdc_mode {
+ MODE_PIO = 0,
+ MODE_DMA = 1,
+ MODE_SIZE_DEP = 2,
+};
/* Debug message event */
#define DBG_EVT_NONE (0) /* No event */
@@ -104,9 +102,10 @@ extern unsigned int sd_debug_zone[4];
do { \
if (x) { \
printk("[BUG] %s LINE:%d FILE:%s\n", #x, __LINE__, __FILE__); \
- while(1); \
+ while (1) \
+ ; \
} \
-}while(0)
+} while (0)
#endif /* end of +++ */
#define N_MSG(evt, fmt, args...)
@@ -121,36 +120,36 @@ do { \
#define ERR_MSG(fmt, args...) \
do { \
- printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
- host->id, ##args , __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while(0);
+ printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
+ host->id, ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
+} while (0);
#if 1
-//defined CONFIG_MTK_MMC_CD_POLL
+//defined CONFIG_MTK_MMC_CD_POLL
#define INIT_MSG(fmt, args...)
-#define IRQ_MSG(fmt, args...)
+#define IRQ_MSG(fmt, args...)
#else
#define INIT_MSG(fmt, args...) \
do { \
- printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
- host->id, ##args , __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while(0);
+ printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
+ host->id, ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
+} while (0);
/* PID in ISR in not corrent */
#define IRQ_MSG(fmt, args...) \
do { \
- printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n", \
- host->id, ##args , __FUNCTION__, __LINE__); \
-} while(0);
+ printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n", \
+ host->id, ##args, __FUNCTION__, __LINE__); \
+} while (0);
#endif
-int msdc_debug_proc_init(void);
+void msdc_debug_proc_init(void);
#if 0 /* --- chhung */
void msdc_init_gpt(void);
extern void GPT_GetCounter64(UINT32 *cntL32, UINT32 *cntH32);
#endif /* end of --- */
u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32);
-void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks);
+void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks);
#endif
diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h
index e90c4f1d1df7..33fa59a019ec 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -44,7 +44,7 @@
/*--------------------------------------------------------------------------*/
/* Common Macro */
/*--------------------------------------------------------------------------*/
-#define REG_ADDR(x) ((volatile u32*)(base + OFFSET_##x))
+#define REG_ADDR(x) (base + OFFSET_##x)
/*--------------------------------------------------------------------------*/
/* Common Definition */
@@ -88,15 +88,15 @@
#define MSDC_EMMC_BOOTMODE1 (1) /* Reset CMD mode */
enum {
- RESP_NONE = 0,
- RESP_R1,
- RESP_R2,
- RESP_R3,
- RESP_R4,
- RESP_R5,
- RESP_R6,
- RESP_R7,
- RESP_R1B
+ RESP_NONE = 0,
+ RESP_R1,
+ RESP_R2,
+ RESP_R3,
+ RESP_R4,
+ RESP_R5,
+ RESP_R6,
+ RESP_R7,
+ RESP_R1B
};
/*--------------------------------------------------------------------------*/
@@ -253,7 +253,7 @@ enum {
#define MSDC_PS_CDDEBOUNCE (0xf << 12) /* RW */
#define MSDC_PS_DAT (0xff << 16) /* R */
#define MSDC_PS_CMD (0x1 << 24) /* R */
-#define MSDC_PS_WP (0x1UL<< 31) /* R */
+#define MSDC_PS_WP (0x1UL << 31) /* R */
/* MSDC_INT mask */
#define MSDC_INT_MMCIRQ (0x1 << 0) /* W1C */
@@ -294,14 +294,14 @@ enum {
/* MSDC_FIFOCS mask */
#define MSDC_FIFOCS_RXCNT (0xff << 0) /* R */
#define MSDC_FIFOCS_TXCNT (0xff << 16) /* R */
-#define MSDC_FIFOCS_CLR (0x1UL<< 31) /* RW */
+#define MSDC_FIFOCS_CLR (0x1UL << 31) /* RW */
/* SDC_CFG mask */
#define SDC_CFG_SDIOINTWKUP (0x1 << 0) /* RW */
#define SDC_CFG_INSWKUP (0x1 << 1) /* RW */
#define SDC_CFG_BUSWIDTH (0x3 << 16) /* RW */
#define SDC_CFG_SDIO (0x1 << 19) /* RW */
-#define SDC_CFG_SDIOIDE (0x1 << 20) /* RW */
+#define SDC_CFG_SDIOIDE (0x1 << 20) /* RW */
#define SDC_CFG_INTATGAP (0x1 << 21) /* RW */
#define SDC_CFG_DTOC (0xffUL << 24) /* RW */
@@ -314,7 +314,7 @@ enum {
#define SDC_CMD_RW (0x1 << 13) /* RW */
#define SDC_CMD_STOP (0x1 << 14) /* RW */
#define SDC_CMD_GOIRQ (0x1 << 15) /* RW */
-#define SDC_CMD_BLKLEN (0xfff<< 16) /* RW */
+#define SDC_CMD_BLKLEN (0xfff << 16) /* RW */
#define SDC_CMD_AUTOCMD (0x3 << 28) /* RW */
#define SDC_CMD_VOLSWTH (0x1 << 30) /* RW */
@@ -396,7 +396,7 @@ enum {
#define MSDC_PAD_CTL0_CLKSMT (0x1 << 18) /* RW */
#define MSDC_PAD_CTL0_CLKIES (0x1 << 19) /* RW */
#define MSDC_PAD_CTL0_CLKTDSEL (0xf << 20) /* RW */
-#define MSDC_PAD_CTL0_CLKRDSEL (0xffUL<< 24) /* RW */
+#define MSDC_PAD_CTL0_CLKRDSEL (0xffUL << 24) /* RW */
/* MSDC_PAD_CTL1 mask */
#define MSDC_PAD_CTL1_CMDDRVN (0x7 << 0) /* RW */
@@ -407,7 +407,7 @@ enum {
#define MSDC_PAD_CTL1_CMDSMT (0x1 << 18) /* RW */
#define MSDC_PAD_CTL1_CMDIES (0x1 << 19) /* RW */
#define MSDC_PAD_CTL1_CMDTDSEL (0xf << 20) /* RW */
-#define MSDC_PAD_CTL1_CMDRDSEL (0xffUL<< 24) /* RW */
+#define MSDC_PAD_CTL1_CMDRDSEL (0xffUL << 24) /* RW */
/* MSDC_PAD_CTL2 mask */
#define MSDC_PAD_CTL2_DATDRVN (0x7 << 0) /* RW */
@@ -418,7 +418,7 @@ enum {
#define MSDC_PAD_CTL2_DATIES (0x1 << 19) /* RW */
#define MSDC_PAD_CTL2_DATSMT (0x1 << 18) /* RW */
#define MSDC_PAD_CTL2_DATTDSEL (0xf << 20) /* RW */
-#define MSDC_PAD_CTL2_DATRDSEL (0xffUL<< 24) /* RW */
+#define MSDC_PAD_CTL2_DATRDSEL (0xffUL << 24) /* RW */
/* MSDC_PAD_TUNE mask */
#define MSDC_PAD_TUNE_DATWRDLY (0x1F << 0) /* RW */
@@ -438,564 +438,549 @@ enum {
#define MSDC_DAT_RDDLY1_D6 (0x1F << 16) /* RW */
#define MSDC_DAT_RDDLY1_D7 (0x1F << 24) /* RW */
-#define MSDC_CKGEN_MSDC_DLY_SEL (0x1F<<10)
-#define MSDC_INT_DAT_LATCH_CK_SEL (0x7<<7)
-#define MSDC_CKGEN_MSDC_CK_SEL (0x1<<6)
-#define CARD_READY_FOR_DATA (1<<8)
-#define CARD_CURRENT_STATE(x) ((x&0x00001E00)>>9)
+#define MSDC_CKGEN_MSDC_DLY_SEL (0x1F << 10)
+#define MSDC_INT_DAT_LATCH_CK_SEL (0x7 << 7)
+#define MSDC_CKGEN_MSDC_CK_SEL (0x1 << 6)
+#define CARD_READY_FOR_DATA (1 << 8)
+#define CARD_CURRENT_STATE(x) ((x & 0x00001E00) >> 9)
/*--------------------------------------------------------------------------*/
/* Descriptor Structure */
/*--------------------------------------------------------------------------*/
-typedef struct {
- u32 hwo:1; /* could be changed by hw */
- u32 bdp:1;
- u32 rsv0:6;
- u32 chksum:8;
- u32 intr:1;
- u32 rsv1:15;
- void *next;
- void *ptr;
- u32 buflen:16;
- u32 extlen:8;
- u32 rsv2:8;
- u32 arg;
- u32 blknum;
- u32 cmd;
-} gpd_t;
-
-typedef struct {
- u32 eol:1;
- u32 rsv0:7;
- u32 chksum:8;
- u32 rsv1:1;
- u32 blkpad:1;
- u32 dwpad:1;
- u32 rsv2:13;
- void *next;
- void *ptr;
- u32 buflen:16;
- u32 rsv3:16;
-} bd_t;
+struct gpd {
+ u32 hwo:1; /* could be changed by hw */
+ u32 bdp:1;
+ u32 rsv0:6;
+ u32 chksum:8;
+ u32 intr:1;
+ u32 rsv1:15;
+ void *next;
+ void *ptr;
+ u32 buflen:16;
+ u32 extlen:8;
+ u32 rsv2:8;
+ u32 arg;
+ u32 blknum;
+ u32 cmd;
+};
+
+struct bd {
+ u32 eol:1;
+ u32 rsv0:7;
+ u32 chksum:8;
+ u32 rsv1:1;
+ u32 blkpad:1;
+ u32 dwpad:1;
+ u32 rsv2:13;
+ void *next;
+ void *ptr;
+ u32 buflen:16;
+ u32 rsv3:16;
+};
/*--------------------------------------------------------------------------*/
/* Register Debugging Structure */
/*--------------------------------------------------------------------------*/
-typedef struct {
- u32 msdc:1;
- u32 ckpwn:1;
- u32 rst:1;
- u32 pio:1;
- u32 ckdrven:1;
- u32 start18v:1;
- u32 pass18v:1;
- u32 ckstb:1;
- u32 ckdiv:8;
- u32 ckmod:2;
- u32 pad:14;
-} msdc_cfg_reg;
-typedef struct {
- u32 sdr104cksel:1;
- u32 rsmpl:1;
- u32 dsmpl:1;
- u32 ddlysel:1;
- u32 ddr50ckd:1;
- u32 dsplsel:1;
- u32 pad1:10;
- u32 d0spl:1;
- u32 d1spl:1;
- u32 d2spl:1;
- u32 d3spl:1;
- u32 d4spl:1;
- u32 d5spl:1;
- u32 d6spl:1;
- u32 d7spl:1;
- u32 riscsz:1;
- u32 pad2:7;
-} msdc_iocon_reg;
-typedef struct {
- u32 cden:1;
- u32 cdsts:1;
- u32 pad1:10;
- u32 cddebounce:4;
- u32 dat:8;
- u32 cmd:1;
- u32 pad2:6;
- u32 wp:1;
-} msdc_ps_reg;
-typedef struct {
- u32 mmcirq:1;
- u32 cdsc:1;
- u32 pad1:1;
- u32 atocmdrdy:1;
- u32 atocmdtmo:1;
- u32 atocmdcrc:1;
- u32 dmaqempty:1;
- u32 sdioirq:1;
- u32 cmdrdy:1;
- u32 cmdtmo:1;
- u32 rspcrc:1;
- u32 csta:1;
- u32 xfercomp:1;
- u32 dxferdone:1;
- u32 dattmo:1;
- u32 datcrc:1;
- u32 atocmd19done:1;
- u32 pad2:15;
-} msdc_int_reg;
-typedef struct {
- u32 mmcirq:1;
- u32 cdsc:1;
- u32 pad1:1;
- u32 atocmdrdy:1;
- u32 atocmdtmo:1;
- u32 atocmdcrc:1;
- u32 dmaqempty:1;
- u32 sdioirq:1;
- u32 cmdrdy:1;
- u32 cmdtmo:1;
- u32 rspcrc:1;
- u32 csta:1;
- u32 xfercomp:1;
- u32 dxferdone:1;
- u32 dattmo:1;
- u32 datcrc:1;
- u32 atocmd19done:1;
- u32 pad2:15;
-} msdc_inten_reg;
-typedef struct {
- u32 rxcnt:8;
- u32 pad1:8;
- u32 txcnt:8;
- u32 pad2:7;
- u32 clr:1;
-} msdc_fifocs_reg;
-typedef struct {
- u32 val;
-} msdc_txdat_reg;
-typedef struct {
- u32 val;
-} msdc_rxdat_reg;
-typedef struct {
- u32 sdiowkup:1;
- u32 inswkup:1;
- u32 pad1:14;
- u32 buswidth:2;
- u32 pad2:1;
- u32 sdio:1;
- u32 sdioide:1;
- u32 intblkgap:1;
- u32 pad4:2;
- u32 dtoc:8;
-} sdc_cfg_reg;
-typedef struct {
- u32 cmd:6;
- u32 brk:1;
- u32 rsptyp:3;
- u32 pad1:1;
- u32 dtype:2;
- u32 rw:1;
- u32 stop:1;
- u32 goirq:1;
- u32 blklen:12;
- u32 atocmd:2;
- u32 volswth:1;
- u32 pad2:1;
-} sdc_cmd_reg;
-typedef struct {
- u32 arg;
-} sdc_arg_reg;
-typedef struct {
- u32 sdcbusy:1;
- u32 cmdbusy:1;
- u32 pad:29;
- u32 swrcmpl:1;
-} sdc_sts_reg;
-typedef struct {
- u32 val;
-} sdc_resp0_reg;
-typedef struct {
- u32 val;
-} sdc_resp1_reg;
-typedef struct {
- u32 val;
-} sdc_resp2_reg;
-typedef struct {
- u32 val;
-} sdc_resp3_reg;
-typedef struct {
- u32 num;
-} sdc_blknum_reg;
-typedef struct {
- u32 sts;
-} sdc_csts_reg;
-typedef struct {
- u32 sts;
-} sdc_cstsen_reg;
-typedef struct {
- u32 datcrcsts:8;
- u32 ddrcrcsts:4;
- u32 pad:20;
-} sdc_datcrcsts_reg;
-typedef struct {
- u32 bootstart:1;
- u32 bootstop:1;
- u32 bootmode:1;
- u32 pad1:9;
- u32 bootwaidly:3;
- u32 bootsupp:1;
- u32 pad2:16;
-} emmc_cfg0_reg;
-typedef struct {
- u32 bootcrctmc:16;
- u32 pad:4;
- u32 bootacktmc:12;
-} emmc_cfg1_reg;
-typedef struct {
- u32 bootcrcerr:1;
- u32 bootackerr:1;
- u32 bootdattmo:1;
- u32 bootacktmo:1;
- u32 bootupstate:1;
- u32 bootackrcv:1;
- u32 bootdatrcv:1;
- u32 pad:25;
-} emmc_sts_reg;
-typedef struct {
- u32 bootrst:1;
- u32 pad:31;
-} emmc_iocon_reg;
-typedef struct {
- u32 val;
-} msdc_acmd_resp_reg;
-typedef struct {
- u32 tunesel:4;
- u32 pad:28;
-} msdc_acmd19_trg_reg;
-typedef struct {
- u32 val;
-} msdc_acmd19_sts_reg;
-typedef struct {
- u32 addr;
-} msdc_dma_sa_reg;
-typedef struct {
- u32 addr;
-} msdc_dma_ca_reg;
-typedef struct {
- u32 start:1;
- u32 stop:1;
- u32 resume:1;
- u32 pad1:5;
- u32 mode:1;
- u32 pad2:1;
- u32 lastbuf:1;
- u32 pad3:1;
- u32 brustsz:3;
- u32 pad4:1;
- u32 xfersz:16;
-} msdc_dma_ctrl_reg;
-typedef struct {
- u32 status:1;
- u32 decsen:1;
- u32 pad1:2;
- u32 bdcsen:1;
- u32 gpdcsen:1;
- u32 pad2:26;
-} msdc_dma_cfg_reg;
-typedef struct {
- u32 sel:16;
- u32 pad2:16;
-} msdc_dbg_sel_reg;
-typedef struct {
- u32 val;
-} msdc_dbg_out_reg;
-typedef struct {
- u32 clkdrvn:3;
- u32 rsv0:1;
- u32 clkdrvp:3;
- u32 rsv1:1;
- u32 clksr:1;
- u32 rsv2:7;
- u32 clkpd:1;
- u32 clkpu:1;
- u32 clksmt:1;
- u32 clkies:1;
- u32 clktdsel:4;
- u32 clkrdsel:8;
-} msdc_pad_ctl0_reg;
-typedef struct {
- u32 cmddrvn:3;
- u32 rsv0:1;
- u32 cmddrvp:3;
- u32 rsv1:1;
- u32 cmdsr:1;
- u32 rsv2:7;
- u32 cmdpd:1;
- u32 cmdpu:1;
- u32 cmdsmt:1;
- u32 cmdies:1;
- u32 cmdtdsel:4;
- u32 cmdrdsel:8;
-} msdc_pad_ctl1_reg;
-typedef struct {
- u32 datdrvn:3;
- u32 rsv0:1;
- u32 datdrvp:3;
- u32 rsv1:1;
- u32 datsr:1;
- u32 rsv2:7;
- u32 datpd:1;
- u32 datpu:1;
- u32 datsmt:1;
- u32 daties:1;
- u32 dattdsel:4;
- u32 datrdsel:8;
-} msdc_pad_ctl2_reg;
-typedef struct {
- u32 wrrxdly:3;
- u32 pad1:5;
- u32 rdrxdly:8;
- u32 pad2:16;
-} msdc_pad_tune_reg;
-typedef struct {
- u32 dat0:5;
- u32 rsv0:3;
- u32 dat1:5;
- u32 rsv1:3;
- u32 dat2:5;
- u32 rsv2:3;
- u32 dat3:5;
- u32 rsv3:3;
-} msdc_dat_rddly0;
-typedef struct {
- u32 dat4:5;
- u32 rsv4:3;
- u32 dat5:5;
- u32 rsv5:3;
- u32 dat6:5;
- u32 rsv6:3;
- u32 dat7:5;
- u32 rsv7:3;
-} msdc_dat_rddly1;
-typedef struct {
- u32 dbg0sel:8;
- u32 dbg1sel:6;
- u32 pad1:2;
- u32 dbg2sel:6;
- u32 pad2:2;
- u32 dbg3sel:6;
- u32 pad3:2;
-} msdc_hw_dbg_reg;
-typedef struct {
- u32 val;
-} msdc_version_reg;
-typedef struct {
- u32 val;
-} msdc_eco_ver_reg;
+struct msdc_cfg_reg {
+ u32 msdc:1;
+ u32 ckpwn:1;
+ u32 rst:1;
+ u32 pio:1;
+ u32 ckdrven:1;
+ u32 start18v:1;
+ u32 pass18v:1;
+ u32 ckstb:1;
+ u32 ckdiv:8;
+ u32 ckmod:2;
+ u32 pad:14;
+};
+
+struct msdc_iocon_reg {
+ u32 sdr104cksel:1;
+ u32 rsmpl:1;
+ u32 dsmpl:1;
+ u32 ddlysel:1;
+ u32 ddr50ckd:1;
+ u32 dsplsel:1;
+ u32 pad1:10;
+ u32 d0spl:1;
+ u32 d1spl:1;
+ u32 d2spl:1;
+ u32 d3spl:1;
+ u32 d4spl:1;
+ u32 d5spl:1;
+ u32 d6spl:1;
+ u32 d7spl:1;
+ u32 riscsz:1;
+ u32 pad2:7;
+};
+
+struct msdc_ps_reg {
+ u32 cden:1;
+ u32 cdsts:1;
+ u32 pad1:10;
+ u32 cddebounce:4;
+ u32 dat:8;
+ u32 cmd:1;
+ u32 pad2:6;
+ u32 wp:1;
+};
+
+struct msdc_int_reg {
+ u32 mmcirq:1;
+ u32 cdsc:1;
+ u32 pad1:1;
+ u32 atocmdrdy:1;
+ u32 atocmdtmo:1;
+ u32 atocmdcrc:1;
+ u32 dmaqempty:1;
+ u32 sdioirq:1;
+ u32 cmdrdy:1;
+ u32 cmdtmo:1;
+ u32 rspcrc:1;
+ u32 csta:1;
+ u32 xfercomp:1;
+ u32 dxferdone:1;
+ u32 dattmo:1;
+ u32 datcrc:1;
+ u32 atocmd19done:1;
+ u32 pad2:15;
+};
+
+struct msdc_inten_reg {
+ u32 mmcirq:1;
+ u32 cdsc:1;
+ u32 pad1:1;
+ u32 atocmdrdy:1;
+ u32 atocmdtmo:1;
+ u32 atocmdcrc:1;
+ u32 dmaqempty:1;
+ u32 sdioirq:1;
+ u32 cmdrdy:1;
+ u32 cmdtmo:1;
+ u32 rspcrc:1;
+ u32 csta:1;
+ u32 xfercomp:1;
+ u32 dxferdone:1;
+ u32 dattmo:1;
+ u32 datcrc:1;
+ u32 atocmd19done:1;
+ u32 pad2:15;
+};
+
+struct msdc_fifocs_reg {
+ u32 rxcnt:8;
+ u32 pad1:8;
+ u32 txcnt:8;
+ u32 pad2:7;
+ u32 clr:1;
+};
+
+struct msdc_txdat_reg {
+ u32 val;
+};
+
+struct msdc_rxdat_reg {
+ u32 val;
+};
+
+struct sdc_cfg_reg {
+ u32 sdiowkup:1;
+ u32 inswkup:1;
+ u32 pad1:14;
+ u32 buswidth:2;
+ u32 pad2:1;
+ u32 sdio:1;
+ u32 sdioide:1;
+ u32 intblkgap:1;
+ u32 pad4:2;
+ u32 dtoc:8;
+};
+
+struct sdc_cmd_reg {
+ u32 cmd:6;
+ u32 brk:1;
+ u32 rsptyp:3;
+ u32 pad1:1;
+ u32 dtype:2;
+ u32 rw:1;
+ u32 stop:1;
+ u32 goirq:1;
+ u32 blklen:12;
+ u32 atocmd:2;
+ u32 volswth:1;
+ u32 pad2:1;
+};
+
+struct sdc_arg_reg {
+ u32 arg;
+};
+
+struct sdc_sts_reg {
+ u32 sdcbusy:1;
+ u32 cmdbusy:1;
+ u32 pad:29;
+ u32 swrcmpl:1;
+};
+
+struct sdc_resp0_reg {
+ u32 val;
+};
+
+struct sdc_resp1_reg {
+ u32 val;
+};
+
+struct sdc_resp2_reg {
+ u32 val;
+};
+
+struct sdc_resp3_reg {
+ u32 val;
+};
+
+struct sdc_blknum_reg {
+ u32 num;
+};
+
+struct sdc_csts_reg {
+ u32 sts;
+};
+
+struct sdc_cstsen_reg {
+ u32 sts;
+};
+
+struct sdc_datcrcsts_reg {
+ u32 datcrcsts:8;
+ u32 ddrcrcsts:4;
+ u32 pad:20;
+};
+
+struct emmc_cfg0_reg {
+ u32 bootstart:1;
+ u32 bootstop:1;
+ u32 bootmode:1;
+ u32 pad1:9;
+ u32 bootwaidly:3;
+ u32 bootsupp:1;
+ u32 pad2:16;
+};
+
+struct emmc_cfg1_reg {
+ u32 bootcrctmc:16;
+ u32 pad:4;
+ u32 bootacktmc:12;
+};
+
+struct emmc_sts_reg {
+ u32 bootcrcerr:1;
+ u32 bootackerr:1;
+ u32 bootdattmo:1;
+ u32 bootacktmo:1;
+ u32 bootupstate:1;
+ u32 bootackrcv:1;
+ u32 bootdatrcv:1;
+ u32 pad:25;
+};
+
+struct emmc_iocon_reg {
+ u32 bootrst:1;
+ u32 pad:31;
+};
+
+struct msdc_acmd_resp_reg {
+ u32 val;
+};
+
+struct msdc_acmd19_trg_reg {
+ u32 tunesel:4;
+ u32 pad:28;
+};
+
+struct msdc_acmd19_sts_reg {
+ u32 val;
+};
+
+struct msdc_dma_sa_reg {
+ u32 addr;
+};
+
+struct msdc_dma_ca_reg {
+ u32 addr;
+};
+
+struct msdc_dma_ctrl_reg {
+ u32 start:1;
+ u32 stop:1;
+ u32 resume:1;
+ u32 pad1:5;
+ u32 mode:1;
+ u32 pad2:1;
+ u32 lastbuf:1;
+ u32 pad3:1;
+ u32 brustsz:3;
+ u32 pad4:1;
+ u32 xfersz:16;
+};
+
+struct msdc_dma_cfg_reg {
+ u32 status:1;
+ u32 decsen:1;
+ u32 pad1:2;
+ u32 bdcsen:1;
+ u32 gpdcsen:1;
+ u32 pad2:26;
+};
+
+struct msdc_dbg_sel_reg {
+ u32 sel:16;
+ u32 pad2:16;
+};
+
+struct msdc_dbg_out_reg {
+ u32 val;
+};
+
+struct msdc_pad_ctl0_reg {
+ u32 clkdrvn:3;
+ u32 rsv0:1;
+ u32 clkdrvp:3;
+ u32 rsv1:1;
+ u32 clksr:1;
+ u32 rsv2:7;
+ u32 clkpd:1;
+ u32 clkpu:1;
+ u32 clksmt:1;
+ u32 clkies:1;
+ u32 clktdsel:4;
+ u32 clkrdsel:8;
+};
+
+struct msdc_pad_ctl1_reg {
+ u32 cmddrvn:3;
+ u32 rsv0:1;
+ u32 cmddrvp:3;
+ u32 rsv1:1;
+ u32 cmdsr:1;
+ u32 rsv2:7;
+ u32 cmdpd:1;
+ u32 cmdpu:1;
+ u32 cmdsmt:1;
+ u32 cmdies:1;
+ u32 cmdtdsel:4;
+ u32 cmdrdsel:8;
+};
+
+struct msdc_pad_ctl2_reg {
+ u32 datdrvn:3;
+ u32 rsv0:1;
+ u32 datdrvp:3;
+ u32 rsv1:1;
+ u32 datsr:1;
+ u32 rsv2:7;
+ u32 datpd:1;
+ u32 datpu:1;
+ u32 datsmt:1;
+ u32 daties:1;
+ u32 dattdsel:4;
+ u32 datrdsel:8;
+};
+
+struct msdc_pad_tune_reg {
+ u32 wrrxdly:3;
+ u32 pad1:5;
+ u32 rdrxdly:8;
+ u32 pad2:16;
+};
+
+struct msdc_dat_rddly0 {
+ u32 dat0:5;
+ u32 rsv0:3;
+ u32 dat1:5;
+ u32 rsv1:3;
+ u32 dat2:5;
+ u32 rsv2:3;
+ u32 dat3:5;
+ u32 rsv3:3;
+};
+
+struct msdc_dat_rddly1 {
+ u32 dat4:5;
+ u32 rsv4:3;
+ u32 dat5:5;
+ u32 rsv5:3;
+ u32 dat6:5;
+ u32 rsv6:3;
+ u32 dat7:5;
+ u32 rsv7:3;
+};
+
+struct msdc_hw_dbg_reg {
+ u32 dbg0sel:8;
+ u32 dbg1sel:6;
+ u32 pad1:2;
+ u32 dbg2sel:6;
+ u32 pad2:2;
+ u32 dbg3sel:6;
+ u32 pad3:2;
+};
+
+struct msdc_version_reg {
+ u32 val;
+};
+
+struct msdc_eco_ver_reg {
+ u32 val;
+};
struct msdc_regs {
- msdc_cfg_reg msdc_cfg; /* base+0x00h */
- msdc_iocon_reg msdc_iocon; /* base+0x04h */
- msdc_ps_reg msdc_ps; /* base+0x08h */
- msdc_int_reg msdc_int; /* base+0x0ch */
- msdc_inten_reg msdc_inten; /* base+0x10h */
- msdc_fifocs_reg msdc_fifocs; /* base+0x14h */
- msdc_txdat_reg msdc_txdat; /* base+0x18h */
- msdc_rxdat_reg msdc_rxdat; /* base+0x1ch */
- u32 rsv1[4];
- sdc_cfg_reg sdc_cfg; /* base+0x30h */
- sdc_cmd_reg sdc_cmd; /* base+0x34h */
- sdc_arg_reg sdc_arg; /* base+0x38h */
- sdc_sts_reg sdc_sts; /* base+0x3ch */
- sdc_resp0_reg sdc_resp0; /* base+0x40h */
- sdc_resp1_reg sdc_resp1; /* base+0x44h */
- sdc_resp2_reg sdc_resp2; /* base+0x48h */
- sdc_resp3_reg sdc_resp3; /* base+0x4ch */
- sdc_blknum_reg sdc_blknum; /* base+0x50h */
- u32 rsv2[1];
- sdc_csts_reg sdc_csts; /* base+0x58h */
- sdc_cstsen_reg sdc_cstsen; /* base+0x5ch */
- sdc_datcrcsts_reg sdc_dcrcsta; /* base+0x60h */
- u32 rsv3[3];
- emmc_cfg0_reg emmc_cfg0; /* base+0x70h */
- emmc_cfg1_reg emmc_cfg1; /* base+0x74h */
- emmc_sts_reg emmc_sts; /* base+0x78h */
- emmc_iocon_reg emmc_iocon; /* base+0x7ch */
- msdc_acmd_resp_reg acmd_resp; /* base+0x80h */
- msdc_acmd19_trg_reg acmd19_trg; /* base+0x84h */
- msdc_acmd19_sts_reg acmd19_sts; /* base+0x88h */
- u32 rsv4[1];
- msdc_dma_sa_reg dma_sa; /* base+0x90h */
- msdc_dma_ca_reg dma_ca; /* base+0x94h */
- msdc_dma_ctrl_reg dma_ctrl; /* base+0x98h */
- msdc_dma_cfg_reg dma_cfg; /* base+0x9ch */
- msdc_dbg_sel_reg dbg_sel; /* base+0xa0h */
- msdc_dbg_out_reg dbg_out; /* base+0xa4h */
- u32 rsv5[2];
- u32 patch0; /* base+0xb0h */
- u32 patch1; /* base+0xb4h */
- u32 rsv6[10];
- msdc_pad_ctl0_reg pad_ctl0; /* base+0xe0h */
- msdc_pad_ctl1_reg pad_ctl1; /* base+0xe4h */
- msdc_pad_ctl2_reg pad_ctl2; /* base+0xe8h */
- msdc_pad_tune_reg pad_tune; /* base+0xech */
- msdc_dat_rddly0 dat_rddly0; /* base+0xf0h */
- msdc_dat_rddly1 dat_rddly1; /* base+0xf4h */
- msdc_hw_dbg_reg hw_dbg; /* base+0xf8h */
- u32 rsv7[1];
- msdc_version_reg version; /* base+0x100h */
- msdc_eco_ver_reg eco_ver; /* base+0x104h */
-};
-
-struct scatterlist_ex {
- u32 cmd;
- u32 arg;
- u32 sglen;
- struct scatterlist *sg;
-};
-
-#define DMA_FLAG_NONE (0x00000000)
-#define DMA_FLAG_EN_CHKSUM (0x00000001)
-#define DMA_FLAG_PAD_BLOCK (0x00000002)
-#define DMA_FLAG_PAD_DWORD (0x00000004)
+ struct msdc_cfg_reg msdc_cfg; /* base+0x00h */
+ struct msdc_iocon_reg msdc_iocon; /* base+0x04h */
+ struct msdc_ps_reg msdc_ps; /* base+0x08h */
+ struct msdc_int_reg msdc_int; /* base+0x0ch */
+ struct msdc_inten_reg msdc_inten; /* base+0x10h */
+ struct msdc_fifocs_reg msdc_fifocs; /* base+0x14h */
+ struct msdc_txdat_reg msdc_txdat; /* base+0x18h */
+ struct msdc_rxdat_reg msdc_rxdat; /* base+0x1ch */
+ u32 rsv1[4];
+ struct sdc_cfg_reg sdc_cfg; /* base+0x30h */
+ struct sdc_cmd_reg sdc_cmd; /* base+0x34h */
+ struct sdc_arg_reg sdc_arg; /* base+0x38h */
+ struct sdc_sts_reg sdc_sts; /* base+0x3ch */
+ struct sdc_resp0_reg sdc_resp0; /* base+0x40h */
+ struct sdc_resp1_reg sdc_resp1; /* base+0x44h */
+ struct sdc_resp2_reg sdc_resp2; /* base+0x48h */
+ struct sdc_resp3_reg sdc_resp3; /* base+0x4ch */
+ struct sdc_blknum_reg sdc_blknum; /* base+0x50h */
+ u32 rsv2[1];
+ struct sdc_csts_reg sdc_csts; /* base+0x58h */
+ struct sdc_cstsen_reg sdc_cstsen; /* base+0x5ch */
+ struct sdc_datcrcsts_reg sdc_dcrcsta; /* base+0x60h */
+ u32 rsv3[3];
+ struct emmc_cfg0_reg emmc_cfg0; /* base+0x70h */
+ struct emmc_cfg1_reg emmc_cfg1; /* base+0x74h */
+ struct emmc_sts_reg emmc_sts; /* base+0x78h */
+ struct emmc_iocon_reg emmc_iocon; /* base+0x7ch */
+ struct msdc_acmd_resp_reg acmd_resp; /* base+0x80h */
+ struct msdc_acmd19_trg_reg acmd19_trg; /* base+0x84h */
+ struct msdc_acmd19_sts_reg acmd19_sts; /* base+0x88h */
+ u32 rsv4[1];
+ struct msdc_dma_sa_reg dma_sa; /* base+0x90h */
+ struct msdc_dma_ca_reg dma_ca; /* base+0x94h */
+ struct msdc_dma_ctrl_reg dma_ctrl; /* base+0x98h */
+ struct msdc_dma_cfg_reg dma_cfg; /* base+0x9ch */
+ struct msdc_dbg_sel_reg dbg_sel; /* base+0xa0h */
+ struct msdc_dbg_out_reg dbg_out; /* base+0xa4h */
+ u32 rsv5[2];
+ u32 patch0; /* base+0xb0h */
+ u32 patch1; /* base+0xb4h */
+ u32 rsv6[10];
+ struct msdc_pad_ctl0_reg pad_ctl0; /* base+0xe0h */
+ struct msdc_pad_ctl1_reg pad_ctl1; /* base+0xe4h */
+ struct msdc_pad_ctl2_reg pad_ctl2; /* base+0xe8h */
+ struct msdc_pad_tune_reg pad_tune; /* base+0xech */
+ struct msdc_dat_rddly0 dat_rddly0; /* base+0xf0h */
+ struct msdc_dat_rddly1 dat_rddly1; /* base+0xf4h */
+ struct msdc_hw_dbg_reg hw_dbg; /* base+0xf8h */
+ u32 rsv7[1];
+ struct msdc_version_reg version; /* base+0x100h */
+ struct msdc_eco_ver_reg eco_ver; /* base+0x104h */
+};
struct msdc_dma {
- u32 flags; /* flags */
- u32 xfersz; /* xfer size in bytes */
- u32 sglen; /* size of scatter list */
- u32 blklen; /* block size */
- struct scatterlist *sg; /* I/O scatter list */
- struct scatterlist_ex *esg; /* extended I/O scatter list */
- u8 mode; /* dma mode */
- u8 burstsz; /* burst size */
- u8 intr; /* dma done interrupt */
- u8 padding; /* padding */
- u32 cmd; /* enhanced mode command */
- u32 arg; /* enhanced mode arg */
- u32 rsp; /* enhanced mode command response */
- u32 autorsp; /* auto command response */
-
- gpd_t *gpd; /* pointer to gpd array */
- bd_t *bd; /* pointer to bd array */
- dma_addr_t gpd_addr; /* the physical address of gpd array */
- dma_addr_t bd_addr; /* the physical address of bd array */
- u32 used_gpd; /* the number of used gpd elements */
- u32 used_bd; /* the number of used bd elements */
-};
-
-struct msdc_host
-{
- struct msdc_hw *hw;
+ u32 sglen; /* size of scatter list */
+ struct scatterlist *sg; /* I/O scatter list */
+ u8 mode; /* dma mode */
+
+ struct gpd *gpd; /* pointer to gpd array */
+ struct bd *bd; /* pointer to bd array */
+ dma_addr_t gpd_addr; /* the physical address of gpd array */
+ dma_addr_t bd_addr; /* the physical address of bd array */
+};
- struct mmc_host *mmc; /* mmc structure */
- struct mmc_command *cmd;
- struct mmc_data *data;
- struct mmc_request *mrq;
- int cmd_rsp;
- int cmd_rsp_done;
- int cmd_r1b_done;
+struct msdc_host {
+ struct msdc_hw *hw;
- int error;
- spinlock_t lock; /* mutex */
- struct semaphore sem;
+ struct mmc_host *mmc; /* mmc structure */
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+ struct mmc_request *mrq;
+ int cmd_rsp;
- u32 blksz; /* host block size */
- u32 base; /* host base address */
- int id; /* host id */
- int pwr_ref; /* core power reference count */
+ int error;
+ spinlock_t lock; /* mutex */
+ struct semaphore sem;
- u32 xfer_size; /* total transferred size */
+ u32 blksz; /* host block size */
+ void __iomem *base; /* host base address */
+ int id; /* host id */
+ int pwr_ref; /* core power reference count */
- struct msdc_dma dma; /* dma channel */
- u32 dma_addr; /* dma transfer address */
- u32 dma_left_size; /* dma transfer left size */
- u32 dma_xfer_size; /* dma transfer size in bytes */
- int dma_xfer; /* dma transfer mode */
+ u32 xfer_size; /* total transferred size */
- u32 timeout_ns; /* data timeout ns */
- u32 timeout_clks; /* data timeout clks */
+ struct msdc_dma dma; /* dma channel */
+ u32 dma_xfer_size; /* dma transfer size in bytes */
- atomic_t abort; /* abort transfer */
+ u32 timeout_ns; /* data timeout ns */
+ u32 timeout_clks; /* data timeout clks */
- int irq; /* host interrupt */
+ int irq; /* host interrupt */
- struct tasklet_struct card_tasklet;
-#if 0
- struct work_struct card_workqueue;
-#else
- struct delayed_work card_delaywork;
-#endif
+ struct delayed_work card_delaywork;
+
+ struct completion cmd_done;
+ struct completion xfer_done;
+ struct pm_message pm_state;
+
+ u32 mclk; /* mmc subsystem clock */
+ u32 hclk; /* host clock speed */
+ u32 sclk; /* SD/MS clock speed */
+ u8 core_clkon; /* Host core clock on ? */
+ u8 card_clkon; /* Card clock on ? */
+ u8 core_power; /* core power */
+ u8 power_mode; /* host power mode */
+ u8 card_inserted; /* card inserted ? */
+ u8 suspend; /* host suspended ? */
+ u8 app_cmd; /* for app command */
+ u32 app_cmd_arg;
+};
+
+#define sdr_read8(reg) readb(reg)
+#define sdr_read32(reg) readl(reg)
+#define sdr_write8(reg, val) writeb(val, reg)
+#define sdr_write32(reg, val) writel(val, reg)
- struct completion cmd_done;
- struct completion xfer_done;
- struct pm_message pm_state;
-
- u32 mclk; /* mmc subsystem clock */
- u32 hclk; /* host clock speed */
- u32 sclk; /* SD/MS clock speed */
- u8 core_clkon; /* Host core clock on ? */
- u8 card_clkon; /* Card clock on ? */
- u8 core_power; /* core power */
- u8 power_mode; /* host power mode */
- u8 card_inserted; /* card inserted ? */
- u8 suspend; /* host suspended ? */
- u8 reserved;
- u8 app_cmd; /* for app command */
- u32 app_cmd_arg;
- u64 starttime;
-};
-
-static inline unsigned int uffs(unsigned int x)
+static inline void sdr_set_bits(void __iomem *reg, u32 bs)
{
- unsigned int r = 1;
-
- if (!x)
- return 0;
- if (!(x & 0xffff)) {
- x >>= 16;
- r += 16;
- }
- if (!(x & 0xff)) {
- x >>= 8;
- r += 8;
- }
- if (!(x & 0xf)) {
- x >>= 4;
- r += 4;
- }
- if (!(x & 3)) {
- x >>= 2;
- r += 2;
- }
- if (!(x & 1)) {
- x >>= 1;
- r += 1;
- }
- return r;
+ u32 val = readl(reg);
+
+ val |= bs;
+ writel(val, reg);
}
-#define sdr_read8(reg) __raw_readb(reg)
-#define sdr_read16(reg) __raw_readw(reg)
-#define sdr_read32(reg) __raw_readl(reg)
-#define sdr_write8(reg,val) __raw_writeb(val,reg)
-#define sdr_write16(reg,val) __raw_writew(val,reg)
-#define sdr_write32(reg,val) __raw_writel(val,reg)
-
-#define sdr_set_bits(reg,bs) ((*(volatile u32*)(reg)) |= (u32)(bs))
-#define sdr_clr_bits(reg,bs) ((*(volatile u32*)(reg)) &= ~((u32)(bs)))
-
-#define sdr_set_field(reg,field,val) \
- do { \
- volatile unsigned int tv = sdr_read32(reg); \
- tv &= ~(field); \
- tv |= ((val) << (uffs((unsigned int)field) - 1)); \
- sdr_write32(reg,tv); \
- } while(0)
-#define sdr_get_field(reg,field,val) \
- do { \
- volatile unsigned int tv = sdr_read32(reg); \
- val = ((tv & (field)) >> (uffs((unsigned int)field) - 1)); \
- } while(0)
-#endif
+static inline void sdr_clr_bits(void __iomem *reg, u32 bs)
+{
+ u32 val = readl(reg);
+
+ val &= ~bs;
+ writel(val, reg);
+}
+
+static inline void sdr_set_field(void __iomem *reg, u32 field, u32 val)
+{
+ unsigned int tv = readl(reg);
+ tv &= ~field;
+ tv |= ((val) << (ffs((unsigned int)field) - 1));
+ writel(tv, reg);
+}
+
+static inline void sdr_get_field(void __iomem *reg, u32 field, u32 *val)
+{
+ unsigned int tv = readl(reg);
+ *val = ((tv & field) >> (ffs((unsigned int)field) - 1));
+}
+
+#endif
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index a1d0173eba56..648a2dd1436e 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -34,38 +34,21 @@
*/
#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
#include <linux/spinlock.h>
-#include <linux/timer.h>
-#include <linux/ioport.h>
-#include <linux/device.h>
#include <linux/platform_device.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/blkdev.h>
-#include <linux/slab.h>
+
#include <linux/mmc/host.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/core.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <linux/mmc/sdio.h>
-#include <linux/dma-mapping.h>
-/* +++ by chhung */
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <linux/pm.h>
-#include <linux/of.h>
-
-#define MSDC_SMPL_FALLING (1)
-#define MSDC_CD_PIN_EN (1 << 0) /* card detection pin is wired */
-#define MSDC_WP_PIN_EN (1 << 1) /* write protection pin is wired */
-#define MSDC_REMOVABLE (1 << 5) /* removable slot */
-#define MSDC_SYS_SUSPEND (1 << 6) /* suspended by system */
-#define MSDC_HIGHSPEED (1 << 7)
+#include <asm/mach-ralink/ralink_regs.h>
+
+#include "board.h"
+#include "dbg.h"
+#include "mt6575_sd.h"
//#define IRQ_SDC 14 //MT7620 /*FIXME*/
#ifdef CONFIG_SOC_MT7621
@@ -77,46 +60,11 @@
#endif
#define IRQ_SDC 22 /*FIXME*/
-#include <asm/dma.h>
-/* end of +++ */
-
-
-#include <asm/mach-ralink/ralink_regs.h>
-
-#if 0 /* --- by chhung */
-#include <mach/board.h>
-#include <mach/mt6575_devs.h>
-#include <mach/mt6575_typedefs.h>
-#include <mach/mt6575_clock_manager.h>
-#include <mach/mt6575_pm_ldo.h>
-//#include <mach/mt6575_pll.h>
-//#include <mach/mt6575_gpio.h>
-//#include <mach/mt6575_gpt_sw.h>
-#include <asm/tcm.h>
-// #include <mach/mt6575_gpt.h>
-#endif /* end of --- */
-
-#include "mt6575_sd.h"
-#include "dbg.h"
-
-/* +++ by chhung */
-#include "board.h"
-/* end of +++ */
-
-#if 0 /* --- by chhung */
-#define isb() __asm__ __volatile__ ("" : : : "memory")
-#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
- : : "r" (0) : "memory")
-#define dmb() __asm__ __volatile__ ("" : : : "memory")
-#endif /* end of --- */
-
#define DRV_NAME "mtk-sd"
-#define HOST_MAX_NUM (1) /* +/- by chhung */
-
-#if defined (CONFIG_SOC_MT7620)
+#if defined(CONFIG_SOC_MT7620)
#define HOST_MAX_MCLK (48000000) /* +/- by chhung */
-#elif defined (CONFIG_SOC_MT7621)
+#elif defined(CONFIG_SOC_MT7621)
#define HOST_MAX_MCLK (50000000) /* +/- by chhung */
#endif
#define HOST_MIN_MCLK (260000)
@@ -130,14 +78,14 @@
#if 0 /* --- by chhung */
#define MSDC_CLKSRC_REG (0xf100000C)
-#define PDN_REG (0xF1000010)
+#define PDN_REG (0xF1000010)
#endif /* end of --- */
#define DEFAULT_DEBOUNCE (8) /* 8 cycles */
#define DEFAULT_DTOC (40) /* data timeout counter. 65536x40 sclk. */
-#define CMD_TIMEOUT (HZ/10) /* 100ms */
-#define DAT_TIMEOUT (HZ/2 * 5) /* 500ms x5 */
+#define CMD_TIMEOUT (HZ / 10) /* 100ms */
+#define DAT_TIMEOUT (HZ / 2 * 5) /* 500ms x5 */
#define MAX_DMA_CNT (64 * 1024 - 512) /* a single transaction for WIFI may be 50K*/
@@ -148,13 +96,7 @@
#define MAX_HW_SGMTS (MAX_BD_NUM)
#define MAX_PHY_SGMTS (MAX_BD_NUM)
#define MAX_SGMT_SZ (MAX_DMA_CNT)
-#define MAX_REQ_SZ (MAX_SGMT_SZ * 8)
-
-#ifdef MT6575_SD_DEBUG
-static struct msdc_regs *msdc_reg[HOST_MAX_NUM];
-#endif
-
-static int mtk_sw_poll;
+#define MAX_REQ_SZ (MAX_SGMT_SZ * 8)
static int cd_active_low = 1;
@@ -164,203 +106,149 @@ static int cd_active_low = 1;
//#define PERI_MSDC2_PDN (17)
//#define PERI_MSDC3_PDN (18)
-struct msdc_host *msdc_6575_host[] = {NULL,NULL,NULL,NULL};
#if 0 /* --- by chhung */
/* gate means clock power down */
-static int g_clk_gate = 0;
+static int g_clk_gate = 0;
#define msdc_gate_clock(id) \
- do { \
- g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)); \
- } while(0)
+ do { \
+ g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)); \
+ } while (0)
/* not like power down register. 1 means clock on. */
#define msdc_ungate_clock(id) \
- do { \
- g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN); \
- } while(0)
+ do { \
+ g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN); \
+ } while (0)
-// do we need sync object or not
-void msdc_clk_status(int * status)
+// do we need sync object or not
+void msdc_clk_status(int *status)
{
- *status = g_clk_gate;
+ *status = g_clk_gate;
}
#endif /* end of --- */
/* +++ by chhung */
struct msdc_hw msdc0_hw = {
.clk_src = 0,
- .cmd_edge = MSDC_SMPL_FALLING,
- .data_edge = MSDC_SMPL_FALLING,
- .clk_drv = 4,
- .cmd_drv = 4,
- .dat_drv = 4,
- .data_pins = 4,
- .data_offset = 0,
- .flags = MSDC_SYS_SUSPEND | MSDC_CD_PIN_EN | MSDC_REMOVABLE | MSDC_HIGHSPEED,
-// .flags = MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN | MSDC_REMOVABLE,
-};
-
-static struct resource mtk_sd_resources[] = {
- [0] = {
- .start = RALINK_MSDC_BASE,
- .end = RALINK_MSDC_BASE+0x3fff,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = IRQ_SDC, /*FIXME*/
- .end = IRQ_SDC, /*FIXME*/
- .flags = IORESOURCE_IRQ,
- },
+ .flags = MSDC_CD_PIN_EN | MSDC_REMOVABLE,
+// .flags = MSDC_WP_PIN_EN | MSDC_CD_PIN_EN | MSDC_REMOVABLE,
};
-static struct platform_device mtk_sd_device = {
- .name = "mtk-sd",
- .id = 0,
- .num_resources = ARRAY_SIZE(mtk_sd_resources),
- .resource = mtk_sd_resources,
-};
/* end of +++ */
static int msdc_rsp[] = {
- 0, /* RESP_NONE */
- 1, /* RESP_R1 */
- 2, /* RESP_R2 */
- 3, /* RESP_R3 */
- 4, /* RESP_R4 */
- 1, /* RESP_R5 */
- 1, /* RESP_R6 */
- 1, /* RESP_R7 */
- 7, /* RESP_R1b */
+ 0, /* RESP_NONE */
+ 1, /* RESP_R1 */
+ 2, /* RESP_R2 */
+ 3, /* RESP_R3 */
+ 4, /* RESP_R4 */
+ 1, /* RESP_R5 */
+ 1, /* RESP_R6 */
+ 1, /* RESP_R7 */
+ 7, /* RESP_R1b */
};
-/* For Inhanced DMA */
-#define msdc_init_gpd_ex(gpd,extlen,cmd,arg,blknum) \
- do { \
- ((gpd_t*)gpd)->extlen = extlen; \
- ((gpd_t*)gpd)->cmd = cmd; \
- ((gpd_t*)gpd)->arg = arg; \
- ((gpd_t*)gpd)->blknum = blknum; \
- }while(0)
-
-#define msdc_init_bd(bd, blkpad, dwpad, dptr, dlen) \
- do { \
- BUG_ON(dlen > 0xFFFFUL); \
- ((bd_t*)bd)->blkpad = blkpad; \
- ((bd_t*)bd)->dwpad = dwpad; \
- ((bd_t*)bd)->ptr = (void*)dptr; \
- ((bd_t*)bd)->buflen = dlen; \
- }while(0)
-
#define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16)
#define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
#define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v))
#define msdc_fifo_write8(v) sdr_write8(MSDC_TXDATA, (v))
#define msdc_fifo_read32() sdr_read32(MSDC_RXDATA)
-#define msdc_fifo_read8() sdr_read8(MSDC_RXDATA)
-
+#define msdc_fifo_read8() sdr_read8(MSDC_RXDATA)
#define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
-#define msdc_dma_off() sdr_set_bits(MSDC_CFG, MSDC_CFG_PIO)
-
-#define msdc_retry(expr,retry,cnt) \
- do { \
- int backup = cnt; \
- while (retry) { \
- if (!(expr)) break; \
- if (cnt-- == 0) { \
- retry--; mdelay(1); cnt = backup; \
- } \
- } \
- WARN_ON(retry == 0); \
- } while(0)
-#if 0 /* --- by chhung */
-#define msdc_reset() \
- do { \
- int retry = 3, cnt = 1000; \
- sdr_set_bits(MSDC_CFG, MSDC_CFG_RST); \
- dsb(); \
- msdc_retry(sdr_read32(MSDC_CFG) & MSDC_CFG_RST, retry, cnt); \
- } while(0)
-#else
-#define msdc_reset() \
- do { \
- int retry = 3, cnt = 1000; \
- sdr_set_bits(MSDC_CFG, MSDC_CFG_RST); \
- msdc_retry(sdr_read32(MSDC_CFG) & MSDC_CFG_RST, retry, cnt); \
- } while(0)
-#endif /* end of +/- */
+#define msdc_retry(expr, retry, cnt) \
+ do { \
+ int backup = cnt; \
+ while (retry) { \
+ if (!(expr)) \
+ break; \
+ if (cnt-- == 0) { \
+ retry--; mdelay(1); cnt = backup; \
+ } \
+ } \
+ WARN_ON(retry == 0); \
+ } while (0)
+
+static void msdc_reset_hw(struct msdc_host *host)
+{
+ void __iomem *base = host->base;
+
+ sdr_set_bits(MSDC_CFG, MSDC_CFG_RST);
+ while (sdr_read32(MSDC_CFG) & MSDC_CFG_RST)
+ cpu_relax();
+}
#define msdc_clr_int() \
- do { \
- volatile u32 val = sdr_read32(MSDC_INT); \
- sdr_write32(MSDC_INT, val); \
- } while(0)
+ do { \
+ volatile u32 val = sdr_read32(MSDC_INT); \
+ sdr_write32(MSDC_INT, val); \
+ } while (0)
#define msdc_clr_fifo() \
- do { \
- int retry = 3, cnt = 1000; \
- sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
- msdc_retry(sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \
- } while(0)
+ do { \
+ int retry = 3, cnt = 1000; \
+ sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
+ msdc_retry(sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \
+ } while (0)
#define msdc_irq_save(val) \
- do { \
- val = sdr_read32(MSDC_INTEN); \
- sdr_clr_bits(MSDC_INTEN, val); \
- } while(0)
-
+ do { \
+ val = sdr_read32(MSDC_INTEN); \
+ sdr_clr_bits(MSDC_INTEN, val); \
+ } while (0)
+
#define msdc_irq_restore(val) \
- do { \
- sdr_set_bits(MSDC_INTEN, val); \
- } while(0)
+ do { \
+ sdr_set_bits(MSDC_INTEN, val); \
+ } while (0)
/* clock source for host: global */
-#if defined (CONFIG_SOC_MT7620)
+#if defined(CONFIG_SOC_MT7620)
static u32 hclks[] = {48000000}; /* +/- by chhung */
-#elif defined (CONFIG_SOC_MT7621)
+#elif defined(CONFIG_SOC_MT7621)
static u32 hclks[] = {50000000}; /* +/- by chhung */
#endif
//============================================
// the power for msdc host controller: global
-// always keep the VMC on.
+// always keep the VMC on.
//============================================
#define msdc_vcore_on(host) \
- do { \
- INIT_MSG("[+]VMC ref. count<%d>", ++host->pwr_ref); \
- (void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD"); \
- } while (0)
+ do { \
+ INIT_MSG("[+]VMC ref. count<%d>", ++host->pwr_ref); \
+ (void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD"); \
+ } while (0)
#define msdc_vcore_off(host) \
- do { \
- INIT_MSG("[-]VMC ref. count<%d>", --host->pwr_ref); \
- (void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD"); \
- } while (0)
+ do { \
+ INIT_MSG("[-]VMC ref. count<%d>", --host->pwr_ref); \
+ (void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD"); \
+ } while (0)
//====================================
-// the vdd output for card: global
-// always keep the VMCH on.
-//====================================
+// the vdd output for card: global
+// always keep the VMCH on.
+//====================================
#define msdc_vdd_on(host) \
- do { \
- (void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"); \
- } while (0)
+ do { \
+ (void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"); \
+ } while (0)
#define msdc_vdd_off(host) \
- do { \
- (void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
- } while (0)
+ do { \
+ (void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
+ } while (0)
#define sdc_is_busy() (sdr_read32(SDC_STS) & SDC_STS_SDCBUSY)
#define sdc_is_cmd_busy() (sdr_read32(SDC_STS) & SDC_STS_CMDBUSY)
-#define sdc_send_cmd(cmd,arg) \
- do { \
- sdr_write32(SDC_ARG, (arg)); \
- sdr_write32(SDC_CMD, (cmd)); \
- } while(0)
+#define sdc_send_cmd(cmd, arg) \
+ do { \
+ sdr_write32(SDC_ARG, (arg)); \
+ sdr_write32(SDC_CMD, (cmd)); \
+ } while (0)
// can modify to read h/w register.
//#define is_card_present(h) ((sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1);
-#define is_card_present(h) (((struct msdc_host*)(h))->card_inserted)
+#define is_card_present(h) (((struct msdc_host *)(h))->card_inserted)
/* +++ by chhung */
#ifndef __ASSEMBLY__
@@ -369,2013 +257,1621 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */
#define PHYSADDR(a) ((a) & 0x1fffffff)
#endif
/* end of +++ */
-static unsigned int msdc_do_command(struct msdc_host *host,
- struct mmc_command *cmd,
- int tune,
- unsigned long timeout);
-
-static int msdc_tune_cmdrsp(struct msdc_host*host,struct mmc_command *cmd);
+static unsigned int msdc_do_command(struct msdc_host *host,
+ struct mmc_command *cmd,
+ int tune,
+ unsigned long timeout);
+
+static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd);
#ifdef MT6575_SD_DEBUG
static void msdc_dump_card_status(struct msdc_host *host, u32 status)
{
/* N_MSG is currently a no-op */
#if 0
- static char *state[] = {
- "Idle", /* 0 */
- "Ready", /* 1 */
- "Ident", /* 2 */
- "Stby", /* 3 */
- "Tran", /* 4 */
- "Data", /* 5 */
- "Rcv", /* 6 */
- "Prg", /* 7 */
- "Dis", /* 8 */
- "Reserved", /* 9 */
- "Reserved", /* 10 */
- "Reserved", /* 11 */
- "Reserved", /* 12 */
- "Reserved", /* 13 */
- "Reserved", /* 14 */
- "I/O mode", /* 15 */
- };
+ static char *state[] = {
+ "Idle", /* 0 */
+ "Ready", /* 1 */
+ "Ident", /* 2 */
+ "Stby", /* 3 */
+ "Tran", /* 4 */
+ "Data", /* 5 */
+ "Rcv", /* 6 */
+ "Prg", /* 7 */
+ "Dis", /* 8 */
+ "Reserved", /* 9 */
+ "Reserved", /* 10 */
+ "Reserved", /* 11 */
+ "Reserved", /* 12 */
+ "Reserved", /* 13 */
+ "Reserved", /* 14 */
+ "I/O mode", /* 15 */
+ };
#endif
- if (status & R1_OUT_OF_RANGE)
- N_MSG(RSP, "[CARD_STATUS] Out of Range");
- if (status & R1_ADDRESS_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Address Error");
- if (status & R1_BLOCK_LEN_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Block Len Error");
- if (status & R1_ERASE_SEQ_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Erase Seq Error");
- if (status & R1_ERASE_PARAM)
- N_MSG(RSP, "[CARD_STATUS] Erase Param");
- if (status & R1_WP_VIOLATION)
- N_MSG(RSP, "[CARD_STATUS] WP Violation");
- if (status & R1_CARD_IS_LOCKED)
- N_MSG(RSP, "[CARD_STATUS] Card is Locked");
- if (status & R1_LOCK_UNLOCK_FAILED)
- N_MSG(RSP, "[CARD_STATUS] Lock/Unlock Failed");
- if (status & R1_COM_CRC_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Command CRC Error");
- if (status & R1_ILLEGAL_COMMAND)
- N_MSG(RSP, "[CARD_STATUS] Illegal Command");
- if (status & R1_CARD_ECC_FAILED)
- N_MSG(RSP, "[CARD_STATUS] Card ECC Failed");
- if (status & R1_CC_ERROR)
- N_MSG(RSP, "[CARD_STATUS] CC Error");
- if (status & R1_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Error");
- if (status & R1_UNDERRUN)
- N_MSG(RSP, "[CARD_STATUS] Underrun");
- if (status & R1_OVERRUN)
- N_MSG(RSP, "[CARD_STATUS] Overrun");
- if (status & R1_CID_CSD_OVERWRITE)
- N_MSG(RSP, "[CARD_STATUS] CID/CSD Overwrite");
- if (status & R1_WP_ERASE_SKIP)
- N_MSG(RSP, "[CARD_STATUS] WP Eraser Skip");
- if (status & R1_CARD_ECC_DISABLED)
- N_MSG(RSP, "[CARD_STATUS] Card ECC Disabled");
- if (status & R1_ERASE_RESET)
- N_MSG(RSP, "[CARD_STATUS] Erase Reset");
- if (status & R1_READY_FOR_DATA)
- N_MSG(RSP, "[CARD_STATUS] Ready for Data");
- if (status & R1_SWITCH_ERROR)
- N_MSG(RSP, "[CARD_STATUS] Switch error");
- if (status & R1_APP_CMD)
- N_MSG(RSP, "[CARD_STATUS] App Command");
-
- N_MSG(RSP, "[CARD_STATUS] '%s' State", state[R1_CURRENT_STATE(status)]);
+ if (status & R1_OUT_OF_RANGE)
+ N_MSG(RSP, "[CARD_STATUS] Out of Range");
+ if (status & R1_ADDRESS_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Address Error");
+ if (status & R1_BLOCK_LEN_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Block Len Error");
+ if (status & R1_ERASE_SEQ_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Erase Seq Error");
+ if (status & R1_ERASE_PARAM)
+ N_MSG(RSP, "[CARD_STATUS] Erase Param");
+ if (status & R1_WP_VIOLATION)
+ N_MSG(RSP, "[CARD_STATUS] WP Violation");
+ if (status & R1_CARD_IS_LOCKED)
+ N_MSG(RSP, "[CARD_STATUS] Card is Locked");
+ if (status & R1_LOCK_UNLOCK_FAILED)
+ N_MSG(RSP, "[CARD_STATUS] Lock/Unlock Failed");
+ if (status & R1_COM_CRC_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Command CRC Error");
+ if (status & R1_ILLEGAL_COMMAND)
+ N_MSG(RSP, "[CARD_STATUS] Illegal Command");
+ if (status & R1_CARD_ECC_FAILED)
+ N_MSG(RSP, "[CARD_STATUS] Card ECC Failed");
+ if (status & R1_CC_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] CC Error");
+ if (status & R1_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Error");
+ if (status & R1_UNDERRUN)
+ N_MSG(RSP, "[CARD_STATUS] Underrun");
+ if (status & R1_OVERRUN)
+ N_MSG(RSP, "[CARD_STATUS] Overrun");
+ if (status & R1_CID_CSD_OVERWRITE)
+ N_MSG(RSP, "[CARD_STATUS] CID/CSD Overwrite");
+ if (status & R1_WP_ERASE_SKIP)
+ N_MSG(RSP, "[CARD_STATUS] WP Eraser Skip");
+ if (status & R1_CARD_ECC_DISABLED)
+ N_MSG(RSP, "[CARD_STATUS] Card ECC Disabled");
+ if (status & R1_ERASE_RESET)
+ N_MSG(RSP, "[CARD_STATUS] Erase Reset");
+ if (status & R1_READY_FOR_DATA)
+ N_MSG(RSP, "[CARD_STATUS] Ready for Data");
+ if (status & R1_SWITCH_ERROR)
+ N_MSG(RSP, "[CARD_STATUS] Switch error");
+ if (status & R1_APP_CMD)
+ N_MSG(RSP, "[CARD_STATUS] App Command");
+
+ N_MSG(RSP, "[CARD_STATUS] '%s' State", state[R1_CURRENT_STATE(status)]);
}
static void msdc_dump_ocr_reg(struct msdc_host *host, u32 resp)
{
- if (resp & (1 << 7))
- N_MSG(RSP, "[OCR] Low Voltage Range");
- if (resp & (1 << 15))
- N_MSG(RSP, "[OCR] 2.7-2.8 volt");
- if (resp & (1 << 16))
- N_MSG(RSP, "[OCR] 2.8-2.9 volt");
- if (resp & (1 << 17))
- N_MSG(RSP, "[OCR] 2.9-3.0 volt");
- if (resp & (1 << 18))
- N_MSG(RSP, "[OCR] 3.0-3.1 volt");
- if (resp & (1 << 19))
- N_MSG(RSP, "[OCR] 3.1-3.2 volt");
- if (resp & (1 << 20))
- N_MSG(RSP, "[OCR] 3.2-3.3 volt");
- if (resp & (1 << 21))
- N_MSG(RSP, "[OCR] 3.3-3.4 volt");
- if (resp & (1 << 22))
- N_MSG(RSP, "[OCR] 3.4-3.5 volt");
- if (resp & (1 << 23))
- N_MSG(RSP, "[OCR] 3.5-3.6 volt");
- if (resp & (1 << 24))
- N_MSG(RSP, "[OCR] Switching to 1.8V Accepted (S18A)");
- if (resp & (1 << 30))
- N_MSG(RSP, "[OCR] Card Capacity Status (CCS)");
- if (resp & (1 << 31))
- N_MSG(RSP, "[OCR] Card Power Up Status (Idle)");
- else
- N_MSG(RSP, "[OCR] Card Power Up Status (Busy)");
+ if (resp & (1 << 7))
+ N_MSG(RSP, "[OCR] Low Voltage Range");
+ if (resp & (1 << 15))
+ N_MSG(RSP, "[OCR] 2.7-2.8 volt");
+ if (resp & (1 << 16))
+ N_MSG(RSP, "[OCR] 2.8-2.9 volt");
+ if (resp & (1 << 17))
+ N_MSG(RSP, "[OCR] 2.9-3.0 volt");
+ if (resp & (1 << 18))
+ N_MSG(RSP, "[OCR] 3.0-3.1 volt");
+ if (resp & (1 << 19))
+ N_MSG(RSP, "[OCR] 3.1-3.2 volt");
+ if (resp & (1 << 20))
+ N_MSG(RSP, "[OCR] 3.2-3.3 volt");
+ if (resp & (1 << 21))
+ N_MSG(RSP, "[OCR] 3.3-3.4 volt");
+ if (resp & (1 << 22))
+ N_MSG(RSP, "[OCR] 3.4-3.5 volt");
+ if (resp & (1 << 23))
+ N_MSG(RSP, "[OCR] 3.5-3.6 volt");
+ if (resp & (1 << 24))
+ N_MSG(RSP, "[OCR] Switching to 1.8V Accepted (S18A)");
+ if (resp & (1 << 30))
+ N_MSG(RSP, "[OCR] Card Capacity Status (CCS)");
+ if (resp & (1 << 31))
+ N_MSG(RSP, "[OCR] Card Power Up Status (Idle)");
+ else
+ N_MSG(RSP, "[OCR] Card Power Up Status (Busy)");
}
static void msdc_dump_rca_resp(struct msdc_host *host, u32 resp)
{
- u32 status = (((resp >> 15) & 0x1) << 23) |
- (((resp >> 14) & 0x1) << 22) |
- (((resp >> 13) & 0x1) << 19) |
- (resp & 0x1fff);
-
- N_MSG(RSP, "[RCA] 0x%.4x", resp >> 16);
- msdc_dump_card_status(host, status);
+ u32 status = (((resp >> 15) & 0x1) << 23) |
+ (((resp >> 14) & 0x1) << 22) |
+ (((resp >> 13) & 0x1) << 19) |
+ (resp & 0x1fff);
+
+ N_MSG(RSP, "[RCA] 0x%.4x", resp >> 16);
+ msdc_dump_card_status(host, status);
}
static void msdc_dump_io_resp(struct msdc_host *host, u32 resp)
{
- u32 flags = (resp >> 8) & 0xFF;
+ u32 flags = (resp >> 8) & 0xFF;
#if 0
- char *state[] = {"DIS", "CMD", "TRN", "RFU"};
+ char *state[] = {"DIS", "CMD", "TRN", "RFU"};
#endif
- if (flags & (1 << 7))
- N_MSG(RSP, "[IO] COM_CRC_ERR");
- if (flags & (1 << 6))
- N_MSG(RSP, "[IO] Illgal command");
- if (flags & (1 << 3))
- N_MSG(RSP, "[IO] Error");
- if (flags & (1 << 2))
- N_MSG(RSP, "[IO] RFU");
- if (flags & (1 << 1))
- N_MSG(RSP, "[IO] Function number error");
- if (flags & (1 << 0))
- N_MSG(RSP, "[IO] Out of range");
-
- N_MSG(RSP, "[IO] State: %s, Data:0x%x", state[(resp >> 12) & 0x3], resp & 0xFF);
+ if (flags & (1 << 7))
+ N_MSG(RSP, "[IO] COM_CRC_ERR");
+ if (flags & (1 << 6))
+ N_MSG(RSP, "[IO] Illegal command");
+ if (flags & (1 << 3))
+ N_MSG(RSP, "[IO] Error");
+ if (flags & (1 << 2))
+ N_MSG(RSP, "[IO] RFU");
+ if (flags & (1 << 1))
+ N_MSG(RSP, "[IO] Function number error");
+ if (flags & (1 << 0))
+ N_MSG(RSP, "[IO] Out of range");
+
+ N_MSG(RSP, "[IO] State: %s, Data:0x%x", state[(resp >> 12) & 0x3], resp & 0xFF);
}
#endif
static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
{
- u32 base = host->base;
- u32 timeout, clk_ns;
-
- host->timeout_ns = ns;
- host->timeout_clks = clks;
-
- clk_ns = 1000000000UL / host->sclk;
- timeout = ns / clk_ns + clks;
- timeout = timeout >> 16; /* in 65536 sclk cycle unit */
- timeout = timeout > 1 ? timeout - 1 : 0;
- timeout = timeout > 255 ? 255 : timeout;
-
- sdr_set_field(SDC_CFG, SDC_CFG_DTOC, timeout);
-
- N_MSG(OPS, "Set read data timeout: %dns %dclks -> %d x 65536 cycles",
- ns, clks, timeout + 1);
-}
-
-/* msdc_eirq_sdio() will be called when EIRQ(for WIFI) */
-static void msdc_eirq_sdio(void *data)
-{
- struct msdc_host *host = (struct msdc_host *)data;
+ void __iomem *base = host->base;
+ u32 timeout, clk_ns;
- N_MSG(INT, "SDIO EINT");
+ host->timeout_ns = ns;
+ host->timeout_clks = clks;
- mmc_signal_sdio_irq(host->mmc);
-}
+ clk_ns = 1000000000UL / host->sclk;
+ timeout = ns / clk_ns + clks;
+ timeout = timeout >> 16; /* in 65536 sclk cycle unit */
+ timeout = timeout > 1 ? timeout - 1 : 0;
+ timeout = timeout > 255 ? 255 : timeout;
-/* msdc_eirq_cd will not be used! We not using EINT for card detection. */
-static void msdc_eirq_cd(void *data)
-{
- struct msdc_host *host = (struct msdc_host *)data;
+ sdr_set_field(SDC_CFG, SDC_CFG_DTOC, timeout);
- N_MSG(INT, "CD EINT");
-
-#if 0
- tasklet_hi_schedule(&host->card_tasklet);
-#else
- schedule_delayed_work(&host->card_delaywork, HZ);
-#endif
+ N_MSG(OPS, "Set read data timeout: %dns %dclks -> %d x 65536 cycles",
+ ns, clks, timeout + 1);
}
-#if 0
-static void msdc_tasklet_card(unsigned long arg)
-{
- struct msdc_host *host = (struct msdc_host *)arg;
-#else
static void msdc_tasklet_card(struct work_struct *work)
{
- struct msdc_host *host = (struct msdc_host *)container_of(work,
- struct msdc_host, card_delaywork.work);
-#endif
- struct msdc_hw *hw = host->hw;
- u32 base = host->base;
- u32 inserted;
- u32 status = 0;
+ struct msdc_host *host = (struct msdc_host *)container_of(work,
+ struct msdc_host, card_delaywork.work);
+ void __iomem *base = host->base;
+ u32 inserted;
+ u32 status = 0;
//u32 change = 0;
- spin_lock(&host->lock);
+ spin_lock(&host->lock);
- if (hw->get_cd_status) { // NULL
- inserted = hw->get_cd_status();
- } else {
- status = sdr_read32(MSDC_PS);
- if (cd_active_low)
+ status = sdr_read32(MSDC_PS);
+ if (cd_active_low)
inserted = (status & MSDC_PS_CDSTS) ? 0 : 1;
else
- inserted = (status & MSDC_PS_CDSTS) ? 1 : 0;
- }
+ inserted = (status & MSDC_PS_CDSTS) ? 1 : 0;
#if 0
- change = host->card_inserted ^ inserted;
- host->card_inserted = inserted;
-
- if (change && !host->suspend) {
- if (inserted) {
- host->mmc->f_max = HOST_MAX_MCLK; // work around
- }
- mmc_detect_change(host->mmc, msecs_to_jiffies(20));
- }
+ change = host->card_inserted ^ inserted;
+ host->card_inserted = inserted;
+
+ if (change && !host->suspend) {
+ if (inserted)
+ host->mmc->f_max = HOST_MAX_MCLK; // work around
+ mmc_detect_change(host->mmc, msecs_to_jiffies(20));
+ }
#else /* Make sure: handle the last interrupt */
- host->card_inserted = inserted;
-
- if (!host->suspend) {
- host->mmc->f_max = HOST_MAX_MCLK;
- mmc_detect_change(host->mmc, msecs_to_jiffies(20));
- }
-
- IRQ_MSG("card found<%s>", inserted ? "inserted" : "removed");
+ host->card_inserted = inserted;
+
+ if (!host->suspend) {
+ host->mmc->f_max = HOST_MAX_MCLK;
+ mmc_detect_change(host->mmc, msecs_to_jiffies(20));
+ }
+
+ IRQ_MSG("card found<%s>", inserted ? "inserted" : "removed");
#endif
- spin_unlock(&host->lock);
+ spin_unlock(&host->lock);
}
#if 0 /* --- by chhung */
/* For E2 only */
static u8 clk_src_bit[4] = {
- 0, 3, 5, 7
+ 0, 3, 5, 7
};
-static void msdc_select_clksrc(struct msdc_host* host, unsigned char clksrc)
+static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc)
{
- u32 val;
- u32 base = host->base;
-
- BUG_ON(clksrc > 3);
- INIT_MSG("set clock source to <%d>", clksrc);
-
- val = sdr_read32(MSDC_CLKSRC_REG);
- if (sdr_read32(MSDC_ECO_VER) >= 4) {
- val &= ~(0x3 << clk_src_bit[host->id]);
- val |= clksrc << clk_src_bit[host->id];
- } else {
- val &= ~0x3; val |= clksrc;
- }
- sdr_write32(MSDC_CLKSRC_REG, val);
-
- host->hclk = hclks[clksrc];
- host->hw->clk_src = clksrc;
+ u32 val;
+ void __iomem *base = host->base;
+
+ BUG_ON(clksrc > 3);
+ INIT_MSG("set clock source to <%d>", clksrc);
+
+ val = sdr_read32(MSDC_CLKSRC_REG);
+ if (sdr_read32(MSDC_ECO_VER) >= 4) {
+ val &= ~(0x3 << clk_src_bit[host->id]);
+ val |= clksrc << clk_src_bit[host->id];
+ } else {
+ val &= ~0x3; val |= clksrc;
+ }
+ sdr_write32(MSDC_CLKSRC_REG, val);
+
+ host->hclk = hclks[clksrc];
+ host->hw->clk_src = clksrc;
}
#endif /* end of --- */
static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz)
{
- //struct msdc_hw *hw = host->hw;
- u32 base = host->base;
- u32 mode;
- u32 flags;
- u32 div;
- u32 sclk;
- u32 hclk = host->hclk;
- //u8 clksrc = hw->clk_src;
-
- if (!hz) { // set mmc system clock to 0 ?
- //ERR_MSG("set mclk to 0!!!");
- msdc_reset();
- return;
- }
-
- msdc_irq_save(flags);
-
-#if defined (CONFIG_MT7621_FPGA) || defined (CONFIG_MT7628_FPGA)
- mode = 0x0; /* use divisor */
- if (hz >= (hclk >> 1)) {
- div = 0; /* mean div = 1/2 */
- sclk = hclk >> 1; /* sclk = clk / 2 */
- } else {
- div = (hclk + ((hz << 2) - 1)) / (hz << 2);
- sclk = (hclk >> 2) / div;
- }
-#else
- if (ddr) {
- mode = 0x2; /* ddr mode and use divisor */
- if (hz >= (hclk >> 2)) {
- div = 1; /* mean div = 1/4 */
- sclk = hclk >> 2; /* sclk = clk / 4 */
- } else {
- div = (hclk + ((hz << 2) - 1)) / (hz << 2);
- sclk = (hclk >> 2) / div;
- }
- } else if (hz >= hclk) { /* bug fix */
- mode = 0x1; /* no divisor and divisor is ignored */
- div = 0;
- sclk = hclk;
- } else {
- mode = 0x0; /* use divisor */
- if (hz >= (hclk >> 1)) {
- div = 0; /* mean div = 1/2 */
- sclk = hclk >> 1; /* sclk = clk / 2 */
- } else {
- div = (hclk + ((hz << 2) - 1)) / (hz << 2);
- sclk = (hclk >> 2) / div;
- }
- }
-#endif
- /* set clock mode and divisor */
- sdr_set_field(MSDC_CFG, MSDC_CFG_CKMOD, mode);
- sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div);
-
- /* wait clock stable */
- while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB));
-
- host->sclk = sclk;
- host->mclk = hz;
- msdc_set_timeout(host, host->timeout_ns, host->timeout_clks); // need?
-
- INIT_MSG("================");
- INIT_MSG("!!! Set<%dKHz> Source<%dKHz> -> sclk<%dKHz>", hz/1000, hclk/1000, sclk/1000);
- INIT_MSG("================");
-
- msdc_irq_restore(flags);
+ //struct msdc_hw *hw = host->hw;
+ void __iomem *base = host->base;
+ u32 mode;
+ u32 flags;
+ u32 div;
+ u32 sclk;
+ u32 hclk = host->hclk;
+ //u8 clksrc = hw->clk_src;
+
+ if (!hz) { // set mmc system clock to 0 ?
+ //ERR_MSG("set mclk to 0!!!");
+ msdc_reset_hw(host);
+ return;
+ }
+
+ msdc_irq_save(flags);
+
+ if (ddr) {
+ mode = 0x2; /* ddr mode and use divisor */
+ if (hz >= (hclk >> 2)) {
+ div = 1; /* mean div = 1/4 */
+ sclk = hclk >> 2; /* sclk = clk / 4 */
+ } else {
+ div = (hclk + ((hz << 2) - 1)) / (hz << 2);
+ sclk = (hclk >> 2) / div;
+ }
+ } else if (hz >= hclk) { /* bug fix */
+ mode = 0x1; /* no divisor and divisor is ignored */
+ div = 0;
+ sclk = hclk;
+ } else {
+ mode = 0x0; /* use divisor */
+ if (hz >= (hclk >> 1)) {
+ div = 0; /* mean div = 1/2 */
+ sclk = hclk >> 1; /* sclk = clk / 2 */
+ } else {
+ div = (hclk + ((hz << 2) - 1)) / (hz << 2);
+ sclk = (hclk >> 2) / div;
+ }
+ }
+
+ /* set clock mode and divisor */
+ sdr_set_field(MSDC_CFG, MSDC_CFG_CKMOD, mode);
+ sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div);
+
+ /* wait clock stable */
+ while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB))
+ cpu_relax();
+
+ host->sclk = sclk;
+ host->mclk = hz;
+ msdc_set_timeout(host, host->timeout_ns, host->timeout_clks); // need?
+
+ INIT_MSG("================");
+ INIT_MSG("!!! Set<%dKHz> Source<%dKHz> -> sclk<%dKHz>", hz / 1000, hclk / 1000, sclk / 1000);
+ INIT_MSG("================");
+
+ msdc_irq_restore(flags);
}
/* Fix me. when need to abort */
static void msdc_abort_data(struct msdc_host *host)
{
- u32 base = host->base;
- struct mmc_command *stop = host->mrq->stop;
-
- ERR_MSG("Need to Abort. dma<%d>", host->dma_xfer);
-
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
-
- // need to check FIFO count 0 ?
-
- if (stop) { /* try to stop, but may not success */
- ERR_MSG("stop when abort CMD<%d>", stop->opcode);
- (void)msdc_do_command(host, stop, 0, CMD_TIMEOUT);
- }
-
- //if (host->mclk >= 25000000) {
- // msdc_set_mclk(host, 0, host->mclk >> 1);
- //}
+ void __iomem *base = host->base;
+ struct mmc_command *stop = host->mrq->stop;
+
+ ERR_MSG("Need to Abort.");
+
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+ msdc_clr_int();
+
+ // need to check FIFO count 0 ?
+
+ if (stop) { /* try to stop, but may not success */
+ ERR_MSG("stop when abort CMD<%d>", stop->opcode);
+ (void)msdc_do_command(host, stop, 0, CMD_TIMEOUT);
+ }
+
+ //if (host->mclk >= 25000000) {
+ // msdc_set_mclk(host, 0, host->mclk >> 1);
+ //}
}
#if 0 /* --- by chhung */
static void msdc_pin_config(struct msdc_host *host, int mode)
{
- struct msdc_hw *hw = host->hw;
- u32 base = host->base;
- int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN;
-
- /* Config WP pin */
- if (hw->flags & MSDC_WP_PIN_EN) {
- if (hw->config_gpio_pin) /* NULL */
- hw->config_gpio_pin(MSDC_WP_PIN, pull);
- }
-
- switch (mode) {
- case MSDC_PIN_PULL_UP:
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 1); /* Check & FIXME */
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 1);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 1);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0);
- break;
- case MSDC_PIN_PULL_DOWN:
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 1); /* Check & FIXME */
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 1);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 1);
- break;
- case MSDC_PIN_PULL_NONE:
- default:
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */
- //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0);
- break;
- }
-
- N_MSG(CFG, "Pins mode(%d), down(%d), up(%d)",
- mode, MSDC_PIN_PULL_DOWN, MSDC_PIN_PULL_UP);
+ struct msdc_hw *hw = host->hw;
+ void __iomem *base = host->base;
+ int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN;
+
+ /* Config WP pin */
+ if (hw->flags & MSDC_WP_PIN_EN) {
+ if (hw->config_gpio_pin) /* NULL */
+ hw->config_gpio_pin(MSDC_WP_PIN, pull);
+ }
+
+ switch (mode) {
+ case MSDC_PIN_PULL_UP:
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 1); /* Check & FIXME */
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 1);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 1);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0);
+ break;
+ case MSDC_PIN_PULL_DOWN:
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 1); /* Check & FIXME */
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 1);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 1);
+ break;
+ case MSDC_PIN_PULL_NONE:
+ default:
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */
+ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0);
+ break;
+ }
+
+ N_MSG(CFG, "Pins mode(%d), down(%d), up(%d)",
+ mode, MSDC_PIN_PULL_DOWN, MSDC_PIN_PULL_UP);
}
void msdc_pin_reset(struct msdc_host *host, int mode)
{
- struct msdc_hw *hw = (struct msdc_hw *)host->hw;
- u32 base = host->base;
- int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN;
-
- /* Config reset pin */
- if (hw->flags & MSDC_RST_PIN_EN) {
- if (hw->config_gpio_pin) /* NULL */
- hw->config_gpio_pin(MSDC_RST_PIN, pull);
-
- if (mode == MSDC_PIN_PULL_UP) {
- sdr_clr_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST);
- } else {
- sdr_set_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST);
- }
- }
+ struct msdc_hw *hw = (struct msdc_hw *)host->hw;
+ void __iomem *base = host->base;
+ int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN;
+
+ /* Config reset pin */
+ if (hw->flags & MSDC_RST_PIN_EN) {
+ if (hw->config_gpio_pin) /* NULL */
+ hw->config_gpio_pin(MSDC_RST_PIN, pull);
+
+ if (mode == MSDC_PIN_PULL_UP)
+ sdr_clr_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST);
+ else
+ sdr_set_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST);
+ }
}
static void msdc_core_power(struct msdc_host *host, int on)
{
- N_MSG(CFG, "Turn %s %s power (copower: %d -> %d)",
- on ? "on" : "off", "core", host->core_power, on);
-
- if (on && host->core_power == 0) {
- msdc_vcore_on(host);
- host->core_power = 1;
- msleep(1);
- } else if (!on && host->core_power == 1) {
- msdc_vcore_off(host);
- host->core_power = 0;
- msleep(1);
- }
+ N_MSG(CFG, "Turn %s %s power (copower: %d -> %d)",
+ on ? "on" : "off", "core", host->core_power, on);
+
+ if (on && host->core_power == 0) {
+ msdc_vcore_on(host);
+ host->core_power = 1;
+ msleep(1);
+ } else if (!on && host->core_power == 1) {
+ msdc_vcore_off(host);
+ host->core_power = 0;
+ msleep(1);
+ }
}
static void msdc_host_power(struct msdc_host *host, int on)
{
- N_MSG(CFG, "Turn %s %s power ", on ? "on" : "off", "host");
-
- if (on) {
- //msdc_core_power(host, 1); // need do card detection.
- msdc_pin_reset(host, MSDC_PIN_PULL_UP);
- } else {
- msdc_pin_reset(host, MSDC_PIN_PULL_DOWN);
- //msdc_core_power(host, 0);
- }
+ N_MSG(CFG, "Turn %s %s power ", on ? "on" : "off", "host");
+
+ if (on) {
+ //msdc_core_power(host, 1); // need do card detection.
+ msdc_pin_reset(host, MSDC_PIN_PULL_UP);
+ } else {
+ msdc_pin_reset(host, MSDC_PIN_PULL_DOWN);
+ //msdc_core_power(host, 0);
+ }
}
static void msdc_card_power(struct msdc_host *host, int on)
{
- N_MSG(CFG, "Turn %s %s power ", on ? "on" : "off", "card");
-
- if (on) {
- msdc_pin_config(host, MSDC_PIN_PULL_UP);
- if (host->hw->ext_power_on) {
- host->hw->ext_power_on();
- } else {
- //msdc_vdd_on(host); // need todo card detection.
- }
- msleep(1);
- } else {
- if (host->hw->ext_power_off) {
- host->hw->ext_power_off();
- } else {
- //msdc_vdd_off(host);
- }
- msdc_pin_config(host, MSDC_PIN_PULL_DOWN);
- msleep(1);
- }
+ N_MSG(CFG, "Turn %s %s power ", on ? "on" : "off", "card");
+
+ if (on) {
+ msdc_pin_config(host, MSDC_PIN_PULL_UP);
+ //msdc_vdd_on(host); // need todo card detection.
+ msleep(1);
+ } else {
+ //msdc_vdd_off(host);
+ msdc_pin_config(host, MSDC_PIN_PULL_DOWN);
+ msleep(1);
+ }
}
static void msdc_set_power_mode(struct msdc_host *host, u8 mode)
{
- N_MSG(CFG, "Set power mode(%d)", mode);
-
- if (host->power_mode == MMC_POWER_OFF && mode != MMC_POWER_OFF) {
- msdc_host_power(host, 1);
- msdc_card_power(host, 1);
- } else if (host->power_mode != MMC_POWER_OFF && mode == MMC_POWER_OFF) {
- msdc_card_power(host, 0);
- msdc_host_power(host, 0);
- }
- host->power_mode = mode;
+ N_MSG(CFG, "Set power mode(%d)", mode);
+
+ if (host->power_mode == MMC_POWER_OFF && mode != MMC_POWER_OFF) {
+ msdc_host_power(host, 1);
+ msdc_card_power(host, 1);
+ } else if (host->power_mode != MMC_POWER_OFF && mode == MMC_POWER_OFF) {
+ msdc_card_power(host, 0);
+ msdc_host_power(host, 0);
+ }
+ host->power_mode = mode;
}
#endif /* end of --- */
#ifdef CONFIG_PM
/*
- register as callback function of WIFI(combo_sdio_register_pm) .
- can called by msdc_drv_suspend/resume too.
+ register as callback function of WIFI(combo_sdio_register_pm) .
+ can called by msdc_drv_suspend/resume too.
*/
static void msdc_pm(pm_message_t state, void *data)
{
- struct msdc_host *host = (struct msdc_host *)data;
- int evt = state.event;
-
- if (evt == PM_EVENT_USER_RESUME || evt == PM_EVENT_USER_SUSPEND) {
- INIT_MSG("USR_%s: suspend<%d> power<%d>",
- evt == PM_EVENT_USER_RESUME ? "EVENT_USER_RESUME" : "EVENT_USER_SUSPEND",
- host->suspend, host->power_mode);
- }
-
- if (evt == PM_EVENT_SUSPEND || evt == PM_EVENT_USER_SUSPEND) {
- if (host->suspend) /* already suspend */ /* default 0*/
- return;
-
- /* for memory card. already power off by mmc */
- if (evt == PM_EVENT_SUSPEND && host->power_mode == MMC_POWER_OFF)
- return;
-
- host->suspend = 1;
- host->pm_state = state; /* default PMSG_RESUME */
-
- INIT_MSG("%s Suspend", evt == PM_EVENT_SUSPEND ? "PM" : "USR");
- if(host->hw->flags & MSDC_SYS_SUSPEND) /* set for card */
- (void)mmc_suspend_host(host->mmc);
- else {
- // host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; /* just for double confirm */ /* --- by chhung */
- mmc_remove_host(host->mmc);
- }
- } else if (evt == PM_EVENT_RESUME || evt == PM_EVENT_USER_RESUME) {
- if (!host->suspend){
- //ERR_MSG("warning: already resume");
- return;
- }
-
- /* No PM resume when USR suspend */
- if (evt == PM_EVENT_RESUME && host->pm_state.event == PM_EVENT_USER_SUSPEND) {
- ERR_MSG("PM Resume when in USR Suspend"); /* won't happen. */
- return;
- }
-
- host->suspend = 0;
- host->pm_state = state;
-
- INIT_MSG("%s Resume", evt == PM_EVENT_RESUME ? "PM" : "USR");
- if(host->hw->flags & MSDC_SYS_SUSPEND) { /* will not set for WIFI */
- (void)mmc_resume_host(host->mmc);
- }
- else {
- // host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; /* --- by chhung */
- mmc_add_host(host->mmc);
- }
- }
+ struct msdc_host *host = (struct msdc_host *)data;
+ int evt = state.event;
+
+ if (evt == PM_EVENT_USER_RESUME || evt == PM_EVENT_USER_SUSPEND) {
+ INIT_MSG("USR_%s: suspend<%d> power<%d>",
+ evt == PM_EVENT_USER_RESUME ? "EVENT_USER_RESUME" : "EVENT_USER_SUSPEND",
+ host->suspend, host->power_mode);
+ }
+
+ if (evt == PM_EVENT_SUSPEND || evt == PM_EVENT_USER_SUSPEND) {
+ if (host->suspend) /* already suspend */ /* default 0*/
+ return;
+
+ /* for memory card. already power off by mmc */
+ if (evt == PM_EVENT_SUSPEND && host->power_mode == MMC_POWER_OFF)
+ return;
+
+ host->suspend = 1;
+ host->pm_state = state; /* default PMSG_RESUME */
+
+ } else if (evt == PM_EVENT_RESUME || evt == PM_EVENT_USER_RESUME) {
+ if (!host->suspend) {
+ //ERR_MSG("warning: already resume");
+ return;
+ }
+
+ /* No PM resume when USR suspend */
+ if (evt == PM_EVENT_RESUME && host->pm_state.event == PM_EVENT_USER_SUSPEND) {
+ ERR_MSG("PM Resume when in USR Suspend"); /* won't happen. */
+ return;
+ }
+
+ host->suspend = 0;
+ host->pm_state = state;
+
+ }
}
#endif
/*--------------------------------------------------------------------------*/
/* mmc_host_ops members */
/*--------------------------------------------------------------------------*/
-static unsigned int msdc_command_start(struct msdc_host *host,
- struct mmc_command *cmd,
- int tune, /* not used */
- unsigned long timeout)
+static unsigned int msdc_command_start(struct msdc_host *host,
+ struct mmc_command *cmd,
+ int tune, /* not used */
+ unsigned long timeout)
{
- u32 base = host->base;
- u32 opcode = cmd->opcode;
- u32 rawcmd;
- u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO |
- MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
- MSDC_INT_ACMD19_DONE;
-
- u32 resp;
- unsigned long tmo;
-
- /* Protocol layer does not provide response type, but our hardware needs
- * to know exact type, not just size!
- */
- if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND)
- resp = RESP_R3;
- else if (opcode == MMC_SET_RELATIVE_ADDR || opcode == SD_SEND_RELATIVE_ADDR)
- resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
- else if (opcode == MMC_FAST_IO)
- resp = RESP_R4;
- else if (opcode == MMC_GO_IRQ_STATE)
- resp = RESP_R5;
- else if (opcode == MMC_SELECT_CARD)
- resp = (cmd->arg != 0) ? RESP_R1B : RESP_NONE;
- else if (opcode == SD_IO_RW_DIRECT || opcode == SD_IO_RW_EXTENDED)
- resp = RESP_R1; /* SDIO workaround. */
- else if (opcode == SD_SEND_IF_COND && (mmc_cmd_type(cmd) == MMC_CMD_BCR))
- resp = RESP_R1;
- else {
- switch (mmc_resp_type(cmd)) {
- case MMC_RSP_R1:
- resp = RESP_R1;
- break;
- case MMC_RSP_R1B:
- resp = RESP_R1B;
- break;
- case MMC_RSP_R2:
- resp = RESP_R2;
- break;
- case MMC_RSP_R3:
- resp = RESP_R3;
- break;
- case MMC_RSP_NONE:
- default:
- resp = RESP_NONE;
- break;
- }
- }
-
- cmd->error = 0;
- /* rawcmd :
- * vol_swt << 30 | auto_cmd << 28 | blklen << 16 | go_irq << 15 |
- * stop << 14 | rw << 13 | dtype << 11 | rsptyp << 7 | brk << 6 | opcode
- */
- rawcmd = opcode | msdc_rsp[resp] << 7 | host->blksz << 16;
-
- if (opcode == MMC_READ_MULTIPLE_BLOCK) {
- rawcmd |= (2 << 11);
- } else if (opcode == MMC_READ_SINGLE_BLOCK) {
- rawcmd |= (1 << 11);
- } else if (opcode == MMC_WRITE_MULTIPLE_BLOCK) {
- rawcmd |= ((2 << 11) | (1 << 13));
- } else if (opcode == MMC_WRITE_BLOCK) {
- rawcmd |= ((1 << 11) | (1 << 13));
- } else if (opcode == SD_IO_RW_EXTENDED) {
- if (cmd->data->flags & MMC_DATA_WRITE)
- rawcmd |= (1 << 13);
- if (cmd->data->blocks > 1)
- rawcmd |= (2 << 11);
- else
- rawcmd |= (1 << 11);
- } else if (opcode == SD_IO_RW_DIRECT && cmd->flags == (unsigned int)-1) {
- rawcmd |= (1 << 14);
- } else if ((opcode == SD_APP_SEND_SCR) ||
- (opcode == SD_APP_SEND_NUM_WR_BLKS) ||
- (opcode == SD_SWITCH && (mmc_cmd_type(cmd) == MMC_CMD_ADTC)) ||
- (opcode == SD_APP_SD_STATUS && (mmc_cmd_type(cmd) == MMC_CMD_ADTC)) ||
- (opcode == MMC_SEND_EXT_CSD && (mmc_cmd_type(cmd) == MMC_CMD_ADTC))) {
- rawcmd |= (1 << 11);
- } else if (opcode == MMC_STOP_TRANSMISSION) {
- rawcmd |= (1 << 14);
- rawcmd &= ~(0x0FFF << 16);
- }
-
- N_MSG(CMD, "CMD<%d><0x%.8x> Arg<0x%.8x>", opcode , rawcmd, cmd->arg);
-
- tmo = jiffies + timeout;
-
- if (opcode == MMC_SEND_STATUS) {
- for (;;) {
- if (!sdc_is_cmd_busy())
- break;
-
- if (time_after(jiffies, tmo)) {
- ERR_MSG("XXX cmd_busy timeout: before CMD<%d>", opcode);
- cmd->error = (unsigned int)-ETIMEDOUT;
- msdc_reset();
- goto end;
- }
- }
- }else {
- for (;;) {
- if (!sdc_is_busy())
- break;
- if (time_after(jiffies, tmo)) {
- ERR_MSG("XXX sdc_busy timeout: before CMD<%d>", opcode);
- cmd->error = (unsigned int)-ETIMEDOUT;
- msdc_reset();
- goto end;
- }
- }
- }
-
- //BUG_ON(in_interrupt());
- host->cmd = cmd;
- host->cmd_rsp = resp;
-
- init_completion(&host->cmd_done);
-
- sdr_set_bits(MSDC_INTEN, wints);
- sdc_send_cmd(rawcmd, cmd->arg);
-
-end:
- return cmd->error;
+ void __iomem *base = host->base;
+ u32 opcode = cmd->opcode;
+ u32 rawcmd;
+ u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO |
+ MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
+ MSDC_INT_ACMD19_DONE;
+
+ u32 resp;
+ unsigned long tmo;
+
+ /* Protocol layer does not provide response type, but our hardware needs
+ * to know exact type, not just size!
+ */
+ if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND) {
+ resp = RESP_R3;
+ } else if (opcode == MMC_SET_RELATIVE_ADDR) {
+ resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
+ } else if (opcode == MMC_FAST_IO) {
+ resp = RESP_R4;
+ } else if (opcode == MMC_GO_IRQ_STATE) {
+ resp = RESP_R5;
+ } else if (opcode == MMC_SELECT_CARD) {
+ resp = (cmd->arg != 0) ? RESP_R1B : RESP_NONE;
+ } else if (opcode == SD_IO_RW_DIRECT || opcode == SD_IO_RW_EXTENDED) {
+ resp = RESP_R1; /* SDIO workaround. */
+ } else if (opcode == SD_SEND_IF_COND && (mmc_cmd_type(cmd) == MMC_CMD_BCR)) {
+ resp = RESP_R1;
+ } else {
+ switch (mmc_resp_type(cmd)) {
+ case MMC_RSP_R1:
+ resp = RESP_R1;
+ break;
+ case MMC_RSP_R1B:
+ resp = RESP_R1B;
+ break;
+ case MMC_RSP_R2:
+ resp = RESP_R2;
+ break;
+ case MMC_RSP_R3:
+ resp = RESP_R3;
+ break;
+ case MMC_RSP_NONE:
+ default:
+ resp = RESP_NONE;
+ break;
+ }
+ }
+
+ cmd->error = 0;
+ /* rawcmd :
+ * vol_swt << 30 | auto_cmd << 28 | blklen << 16 | go_irq << 15 |
+ * stop << 14 | rw << 13 | dtype << 11 | rsptyp << 7 | brk << 6 | opcode
+ */
+ rawcmd = opcode | msdc_rsp[resp] << 7 | host->blksz << 16;
+
+ if (opcode == MMC_READ_MULTIPLE_BLOCK) {
+ rawcmd |= (2 << 11);
+ } else if (opcode == MMC_READ_SINGLE_BLOCK) {
+ rawcmd |= (1 << 11);
+ } else if (opcode == MMC_WRITE_MULTIPLE_BLOCK) {
+ rawcmd |= ((2 << 11) | (1 << 13));
+ } else if (opcode == MMC_WRITE_BLOCK) {
+ rawcmd |= ((1 << 11) | (1 << 13));
+ } else if (opcode == SD_IO_RW_EXTENDED) {
+ if (cmd->data->flags & MMC_DATA_WRITE)
+ rawcmd |= (1 << 13);
+ if (cmd->data->blocks > 1)
+ rawcmd |= (2 << 11);
+ else
+ rawcmd |= (1 << 11);
+ } else if (opcode == SD_IO_RW_DIRECT && cmd->flags == (unsigned int)-1) {
+ rawcmd |= (1 << 14);
+ } else if ((opcode == SD_APP_SEND_SCR) ||
+ (opcode == SD_APP_SEND_NUM_WR_BLKS) ||
+ (opcode == SD_SWITCH && (mmc_cmd_type(cmd) == MMC_CMD_ADTC)) ||
+ (opcode == SD_APP_SD_STATUS && (mmc_cmd_type(cmd) == MMC_CMD_ADTC)) ||
+ (opcode == MMC_SEND_EXT_CSD && (mmc_cmd_type(cmd) == MMC_CMD_ADTC))) {
+ rawcmd |= (1 << 11);
+ } else if (opcode == MMC_STOP_TRANSMISSION) {
+ rawcmd |= (1 << 14);
+ rawcmd &= ~(0x0FFF << 16);
+ }
+
+ N_MSG(CMD, "CMD<%d><0x%.8x> Arg<0x%.8x>", opcode, rawcmd, cmd->arg);
+
+ tmo = jiffies + timeout;
+
+ if (opcode == MMC_SEND_STATUS) {
+ for (;;) {
+ if (!sdc_is_cmd_busy())
+ break;
+
+ if (time_after(jiffies, tmo)) {
+ ERR_MSG("XXX cmd_busy timeout: before CMD<%d>", opcode);
+ cmd->error = -ETIMEDOUT;
+ msdc_reset_hw(host);
+ goto end;
+ }
+ }
+ } else {
+ for (;;) {
+ if (!sdc_is_busy())
+ break;
+ if (time_after(jiffies, tmo)) {
+ ERR_MSG("XXX sdc_busy timeout: before CMD<%d>", opcode);
+ cmd->error = -ETIMEDOUT;
+ msdc_reset_hw(host);
+ goto end;
+ }
+ }
+ }
+
+ //BUG_ON(in_interrupt());
+ host->cmd = cmd;
+ host->cmd_rsp = resp;
+
+ init_completion(&host->cmd_done);
+
+ sdr_set_bits(MSDC_INTEN, wints);
+ sdc_send_cmd(rawcmd, cmd->arg);
+
+end:
+ return cmd->error;
}
-static unsigned int msdc_command_resp(struct msdc_host *host,
- struct mmc_command *cmd,
- int tune,
- unsigned long timeout)
+static unsigned int msdc_command_resp(struct msdc_host *host,
+ struct mmc_command *cmd,
+ int tune,
+ unsigned long timeout)
+ __must_hold(&host->lock)
{
- u32 base = host->base;
- u32 opcode = cmd->opcode;
- //u32 rawcmd;
- u32 resp;
- u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO |
- MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
- MSDC_INT_ACMD19_DONE;
-
- resp = host->cmd_rsp;
-
- BUG_ON(in_interrupt());
- //init_completion(&host->cmd_done);
- //sdr_set_bits(MSDC_INTEN, wints);
-
- spin_unlock(&host->lock);
- if(!wait_for_completion_timeout(&host->cmd_done, 10*timeout)){
- ERR_MSG("XXX CMD<%d> wait_for_completion timeout ARG<0x%.8x>", opcode, cmd->arg);
- cmd->error = (unsigned int)-ETIMEDOUT;
- msdc_reset();
- }
- spin_lock(&host->lock);
-
- sdr_clr_bits(MSDC_INTEN, wints);
- host->cmd = NULL;
+ void __iomem *base = host->base;
+ u32 opcode = cmd->opcode;
+ //u32 rawcmd;
+ u32 resp;
+ u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO |
+ MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
+ MSDC_INT_ACMD19_DONE;
+
+ resp = host->cmd_rsp;
+
+ BUG_ON(in_interrupt());
+ //init_completion(&host->cmd_done);
+ //sdr_set_bits(MSDC_INTEN, wints);
+
+ spin_unlock(&host->lock);
+ if (!wait_for_completion_timeout(&host->cmd_done, 10 * timeout)) {
+ ERR_MSG("XXX CMD<%d> wait_for_completion timeout ARG<0x%.8x>", opcode, cmd->arg);
+ cmd->error = -ETIMEDOUT;
+ msdc_reset_hw(host);
+ }
+ spin_lock(&host->lock);
+
+ sdr_clr_bits(MSDC_INTEN, wints);
+ host->cmd = NULL;
//end:
#ifdef MT6575_SD_DEBUG
- switch (resp) {
- case RESP_NONE:
- N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)", opcode, cmd->error, resp);
- break;
- case RESP_R2:
- N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)= %.8x %.8x %.8x %.8x",
- opcode, cmd->error, resp, cmd->resp[0], cmd->resp[1],
- cmd->resp[2], cmd->resp[3]);
- break;
- default: /* Response types 1, 3, 4, 5, 6, 7(1b) */
- N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)= 0x%.8x",
- opcode, cmd->error, resp, cmd->resp[0]);
- if (cmd->error == 0) {
- switch (resp) {
- case RESP_R1:
- case RESP_R1B:
- msdc_dump_card_status(host, cmd->resp[0]);
- break;
- case RESP_R3:
- msdc_dump_ocr_reg(host, cmd->resp[0]);
- break;
- case RESP_R5:
- msdc_dump_io_resp(host, cmd->resp[0]);
- break;
- case RESP_R6:
- msdc_dump_rca_resp(host, cmd->resp[0]);
- break;
- }
- }
- break;
- }
+ switch (resp) {
+ case RESP_NONE:
+ N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)", opcode, cmd->error, resp);
+ break;
+ case RESP_R2:
+ N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)= %.8x %.8x %.8x %.8x",
+ opcode, cmd->error, resp, cmd->resp[0], cmd->resp[1],
+ cmd->resp[2], cmd->resp[3]);
+ break;
+ default: /* Response types 1, 3, 4, 5, 6, 7(1b) */
+ N_MSG(RSP, "CMD_RSP(%d): %d RSP(%d)= 0x%.8x",
+ opcode, cmd->error, resp, cmd->resp[0]);
+ if (cmd->error == 0) {
+ switch (resp) {
+ case RESP_R1:
+ case RESP_R1B:
+ msdc_dump_card_status(host, cmd->resp[0]);
+ break;
+ case RESP_R3:
+ msdc_dump_ocr_reg(host, cmd->resp[0]);
+ break;
+ case RESP_R5:
+ msdc_dump_io_resp(host, cmd->resp[0]);
+ break;
+ case RESP_R6:
+ msdc_dump_rca_resp(host, cmd->resp[0]);
+ break;
+ }
+ }
+ break;
+ }
#endif
- /* do we need to save card's RCA when SD_SEND_RELATIVE_ADDR */
-
- if (!tune) {
- return cmd->error;
- }
-
- /* memory card CRC */
- if(host->hw->flags & MSDC_REMOVABLE && cmd->error == (unsigned int)(-EIO) ) {
- if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */
- msdc_abort_data(host);
- } else {
- /* do basic: reset*/
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
- }
- cmd->error = msdc_tune_cmdrsp(host,cmd);
- }
-
- // check DAT0
- /* if (resp == RESP_R1B) {
- while ((sdr_read32(MSDC_PS) & 0x10000) != 0x10000);
- } */
- /* CMD12 Error Handle */
-
- return cmd->error;
-}
-
-static unsigned int msdc_do_command(struct msdc_host *host,
- struct mmc_command *cmd,
- int tune,
- unsigned long timeout)
-{
- if (msdc_command_start(host, cmd, tune, timeout))
- goto end;
+ /* do we need to save card's RCA when SD_SEND_RELATIVE_ADDR */
+
+ if (!tune)
+ return cmd->error;
+
+ /* memory card CRC */
+ if (host->hw->flags & MSDC_REMOVABLE && cmd->error == -EIO) {
+ if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */
+ msdc_abort_data(host);
+ } else {
+ /* do basic: reset*/
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+ msdc_clr_int();
+ }
+ cmd->error = msdc_tune_cmdrsp(host, cmd);
+ }
- if (msdc_command_resp(host, cmd, tune, timeout))
- goto end;
-
-end:
+ // check DAT0
+ /* if (resp == RESP_R1B) {
+ while ((sdr_read32(MSDC_PS) & 0x10000) != 0x10000);
+ } */
+ /* CMD12 Error Handle */
- N_MSG(CMD, " return<%d> resp<0x%.8x>", cmd->error, cmd->resp[0]);
- return cmd->error;
-}
-
-/* The abort condition when PIO read/write
- tmo:
-*/
-static int msdc_pio_abort(struct msdc_host *host, struct mmc_data *data, unsigned long tmo)
-{
- int ret = 0;
- u32 base = host->base;
-
- if (atomic_read(&host->abort)) {
- ret = 1;
- }
-
- if (time_after(jiffies, tmo)) {
- data->error = (unsigned int)-ETIMEDOUT;
- ERR_MSG("XXX PIO Data Timeout: CMD<%d>", host->mrq->cmd->opcode);
- ret = 1;
- }
-
- if(ret) {
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
- ERR_MSG("msdc pio find abort");
- }
- return ret;
+ return cmd->error;
}
-/*
- Need to add a timeout, or WDT timeout, system reboot.
-*/
-// pio mode data read/write
-static int msdc_pio_read(struct msdc_host *host, struct mmc_data *data)
+static unsigned int msdc_do_command(struct msdc_host *host,
+ struct mmc_command *cmd,
+ int tune,
+ unsigned long timeout)
{
- struct scatterlist *sg = data->sg;
- u32 base = host->base;
- u32 num = data->sg_len;
- u32 *ptr;
- u8 *u8ptr;
- u32 left = 0;
- u32 count, size = 0;
- u32 wints = MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR ;
- unsigned long tmo = jiffies + DAT_TIMEOUT;
-
- sdr_set_bits(MSDC_INTEN, wints);
- while (num) {
- left = sg_dma_len(sg);
- ptr = sg_virt(sg);
- while (left) {
- if ((left >= MSDC_FIFO_THD) && (msdc_rxfifocnt() >= MSDC_FIFO_THD)) {
- count = MSDC_FIFO_THD >> 2;
- do {
- *ptr++ = msdc_fifo_read32();
- } while (--count);
- left -= MSDC_FIFO_THD;
- } else if ((left < MSDC_FIFO_THD) && msdc_rxfifocnt() >= left) {
- while (left > 3) {
- *ptr++ = msdc_fifo_read32();
- left -= 4;
- }
-
- u8ptr = (u8 *)ptr;
- while(left) {
- * u8ptr++ = msdc_fifo_read8();
- left--;
- }
- }
-
- if (msdc_pio_abort(host, data, tmo)) {
- goto end;
- }
- }
- size += sg_dma_len(sg);
- sg = sg_next(sg); num--;
- }
+ if (msdc_command_start(host, cmd, tune, timeout))
+ goto end;
+
+ if (msdc_command_resp(host, cmd, tune, timeout))
+ goto end;
+
end:
- data->bytes_xfered += size;
- N_MSG(FIO, " PIO Read<%d>bytes", size);
-
- sdr_clr_bits(MSDC_INTEN, wints);
- if(data->error) ERR_MSG("read pio data->error<%d> left<%d> size<%d>", data->error, left, size);
- return data->error;
-}
-/* please make sure won't using PIO when size >= 512
- which means, memory card block read/write won't using pio
- then don't need to handle the CMD12 when data error.
-*/
-static int msdc_pio_write(struct msdc_host* host, struct mmc_data *data)
-{
- u32 base = host->base;
- struct scatterlist *sg = data->sg;
- u32 num = data->sg_len;
- u32 *ptr;
- u8 *u8ptr;
- u32 left;
- u32 count, size = 0;
- u32 wints = MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR ;
- unsigned long tmo = jiffies + DAT_TIMEOUT;
-
- sdr_set_bits(MSDC_INTEN, wints);
- while (num) {
- left = sg_dma_len(sg);
- ptr = sg_virt(sg);
-
- while (left) {
- if (left >= MSDC_FIFO_SZ && msdc_txfifocnt() == 0) {
- count = MSDC_FIFO_SZ >> 2;
- do {
- msdc_fifo_write32(*ptr); ptr++;
- } while (--count);
- left -= MSDC_FIFO_SZ;
- } else if (left < MSDC_FIFO_SZ && msdc_txfifocnt() == 0) {
- while (left > 3) {
- msdc_fifo_write32(*ptr); ptr++;
- left -= 4;
- }
-
- u8ptr = (u8*)ptr;
- while(left){
- msdc_fifo_write8(*u8ptr); u8ptr++;
- left--;
- }
- }
-
- if (msdc_pio_abort(host, data, tmo)) {
- goto end;
- }
- }
- size += sg_dma_len(sg);
- sg = sg_next(sg); num--;
- }
-end:
- data->bytes_xfered += size;
- N_MSG(FIO, " PIO Write<%d>bytes", size);
- if(data->error) ERR_MSG("write pio data->error<%d>", data->error);
-
- sdr_clr_bits(MSDC_INTEN, wints);
- return data->error;
+ N_MSG(CMD, " return<%d> resp<0x%.8x>", cmd->error, cmd->resp[0]);
+ return cmd->error;
}
#if 0 /* --- by chhung */
-// DMA resume / start / stop
+// DMA resume / start / stop
static void msdc_dma_resume(struct msdc_host *host)
{
- u32 base = host->base;
+ void __iomem *base = host->base;
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_RESUME, 1);
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_RESUME, 1);
- N_MSG(DMA, "DMA resume");
+ N_MSG(DMA, "DMA resume");
}
#endif /* end of --- */
static void msdc_dma_start(struct msdc_host *host)
{
- u32 base = host->base;
- u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR ;
-
- sdr_set_bits(MSDC_INTEN, wints);
- //dsb(); /* --- by chhung */
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_START, 1);
-
- N_MSG(DMA, "DMA start");
+ void __iomem *base = host->base;
+ u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR;
+
+ sdr_set_bits(MSDC_INTEN, wints);
+ //dsb(); /* --- by chhung */
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_START, 1);
+
+ N_MSG(DMA, "DMA start");
}
static void msdc_dma_stop(struct msdc_host *host)
{
- u32 base = host->base;
- //u32 retries=500;
- u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR ;
-
- N_MSG(DMA, "DMA status: 0x%.8x",sdr_read32(MSDC_DMA_CFG));
- //while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS);
+ void __iomem *base = host->base;
+ //u32 retries=500;
+ u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR;
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1);
- while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS);
+ N_MSG(DMA, "DMA status: 0x%.8x", sdr_read32(MSDC_DMA_CFG));
+ //while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS);
- //dsb(); /* --- by chhung */
- sdr_clr_bits(MSDC_INTEN, wints); /* Not just xfer_comp */
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1);
+ while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS)
+ ;
- N_MSG(DMA, "DMA stop");
-}
+ //dsb(); /* --- by chhung */
+ sdr_clr_bits(MSDC_INTEN, wints); /* Not just xfer_comp */
-#if 0 /* --- by chhung */
-/* dump a gpd list */
-static void msdc_dma_dump(struct msdc_host *host, struct msdc_dma *dma)
-{
- gpd_t *gpd = dma->gpd;
- bd_t *bd = dma->bd;
- bd_t *ptr;
- int i = 0;
- int p_to_v;
-
- if (dma->mode != MSDC_MODE_DMA_DESC) {
- return;
- }
-
- ERR_MSG("try to dump gpd and bd");
-
- /* dump gpd */
- ERR_MSG(".gpd<0x%.8x> gpd_phy<0x%.8x>", (int)gpd, (int)dma->gpd_addr);
- ERR_MSG("...hwo <%d>", gpd->hwo );
- ERR_MSG("...bdp <%d>", gpd->bdp );
- ERR_MSG("...chksum<0x%.8x>", gpd->chksum );
- //ERR_MSG("...intr <0x%.8x>", gpd->intr );
- ERR_MSG("...next <0x%.8x>", (int)gpd->next );
- ERR_MSG("...ptr <0x%.8x>", (int)gpd->ptr );
- ERR_MSG("...buflen<0x%.8x>", gpd->buflen );
- //ERR_MSG("...extlen<0x%.8x>", gpd->extlen );
- //ERR_MSG("...arg <0x%.8x>", gpd->arg );
- //ERR_MSG("...blknum<0x%.8x>", gpd->blknum );
- //ERR_MSG("...cmd <0x%.8x>", gpd->cmd );
-
- /* dump bd */
- ERR_MSG(".bd<0x%.8x> bd_phy<0x%.8x> gpd_ptr<0x%.8x>", (int)bd, (int)dma->bd_addr, (int)gpd->ptr);
- ptr = bd;
- p_to_v = ((u32)bd - (u32)dma->bd_addr);
- while (1) {
- ERR_MSG(".bd[%d]", i); i++;
- ERR_MSG("...eol <%d>", ptr->eol );
- ERR_MSG("...chksum<0x%.8x>", ptr->chksum );
- //ERR_MSG("...blkpad<0x%.8x>", ptr->blkpad );
- //ERR_MSG("...dwpad <0x%.8x>", ptr->dwpad );
- ERR_MSG("...next <0x%.8x>", (int)ptr->next );
- ERR_MSG("...ptr <0x%.8x>", (int)ptr->ptr );
- ERR_MSG("...buflen<0x%.8x>", (int)ptr->buflen );
-
- if (ptr->eol == 1) {
- break;
- }
-
- /* find the next bd, virtual address of ptr->next */
- /* don't need to enable when use malloc */
- //BUG_ON( (ptr->next + p_to_v)!=(ptr+1) );
- //ERR_MSG(".next bd<0x%.8x><0x%.8x>", (ptr->next + p_to_v), (ptr+1));
- ptr++;
- }
-
- ERR_MSG("dump gpd and bd finished");
+ N_MSG(DMA, "DMA stop");
}
-#endif /* end of --- */
/* calc checksum */
static u8 msdc_dma_calcs(u8 *buf, u32 len)
{
- u32 i, sum = 0;
- for (i = 0; i < len; i++) {
- sum += buf[i];
- }
- return 0xFF - (u8)sum;
+ u32 i, sum = 0;
+
+ for (i = 0; i < len; i++)
+ sum += buf[i];
+ return 0xFF - (u8)sum;
}
/* gpd bd setup + dma registers */
-static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
+static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
{
- u32 base = host->base;
- u32 sglen = dma->sglen;
- //u32 i, j, num, bdlen, arg, xfersz;
- u32 j, num, bdlen;
- u8 blkpad, dwpad, chksum;
- struct scatterlist *sg = dma->sg;
- gpd_t *gpd;
- bd_t *bd;
-
- switch (dma->mode) {
- case MSDC_MODE_DMA_BASIC:
- BUG_ON(dma->xfersz > 65535);
- BUG_ON(dma->sglen != 1);
- sdr_write32(MSDC_DMA_SA, PHYSADDR(sg_dma_address(sg)));
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1);
+ void __iomem *base = host->base;
+ //u32 i, j, num, bdlen, arg, xfersz;
+ u32 j, num;
+ struct scatterlist *sg;
+ struct gpd *gpd;
+ struct bd *bd;
+
+ switch (dma->mode) {
+ case MSDC_MODE_DMA_BASIC:
+ BUG_ON(host->xfer_size > 65535);
+ BUG_ON(dma->sglen != 1);
+ sdr_write32(MSDC_DMA_SA, PHYSADDR(sg_dma_address(sg)));
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1);
//#if defined (CONFIG_RALINK_MT7620)
- if (ralink_soc == MT762X_SOC_MT7620A)
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, sg_dma_len(sg));
+ if (ralink_soc == MT762X_SOC_MT7620A)
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, sg_dma_len(sg));
//#elif defined (CONFIG_RALINK_MT7621) || defined (CONFIG_RALINK_MT7628)
- else
- sdr_write32((volatile u32*)(RALINK_MSDC_BASE+0xa8), sg_dma_len(sg));
+ else
+ sdr_write32((void __iomem *)(RALINK_MSDC_BASE + 0xa8), sg_dma_len(sg));
//#endif
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, dma->burstsz);
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 0);
- break;
- case MSDC_MODE_DMA_DESC:
- blkpad = (dma->flags & DMA_FLAG_PAD_BLOCK) ? 1 : 0;
- dwpad = (dma->flags & DMA_FLAG_PAD_DWORD) ? 1 : 0;
- chksum = (dma->flags & DMA_FLAG_EN_CHKSUM) ? 1 : 0;
-
- /* calculate the required number of gpd */
- num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
- BUG_ON(num !=1 );
-
- gpd = dma->gpd;
- bd = dma->bd;
- bdlen = sglen;
-
- /* modify gpd*/
- //gpd->intr = 0;
- gpd->hwo = 1; /* hw will clear it */
- gpd->bdp = 1;
- gpd->chksum = 0; /* need to clear first. */
- gpd->chksum = (chksum ? msdc_dma_calcs((u8 *)gpd, 16) : 0);
-
- /* modify bd*/
- for (j = 0; j < bdlen; j++) {
- msdc_init_bd(&bd[j], blkpad, dwpad, sg_dma_address(sg), sg_dma_len(sg));
- if(j == bdlen - 1) {
- bd[j].eol = 1; /* the last bd */
- } else {
- bd[j].eol = 0;
- }
- bd[j].chksum = 0; /* checksume need to clear first */
- bd[j].chksum = (chksum ? msdc_dma_calcs((u8 *)(&bd[j]), 16) : 0);
- sg++;
- }
-
- dma->used_gpd += 2;
- dma->used_bd += bdlen;
-
- sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, chksum);
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, dma->burstsz);
- sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1);
-
- sdr_write32(MSDC_DMA_SA, PHYSADDR((u32)dma->gpd_addr));
- break;
-
- default:
- break;
- }
-
- N_MSG(DMA, "DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL));
- N_MSG(DMA, "DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG));
- N_MSG(DMA, "DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA));
-
- return 0;
-}
-
-static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma,
- struct scatterlist *sg, unsigned int sglen)
-{
- BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
-
- dma->sg = sg;
- dma->flags = DMA_FLAG_EN_CHKSUM;
- //dma->flags = DMA_FLAG_NONE; /* CHECKME */
- dma->sglen = sglen;
- dma->xfersz = host->xfer_size;
- dma->burstsz = MSDC_BRUST_64B;
-
- if (sglen == 1 && sg_dma_len(sg) <= MAX_DMA_CNT)
- dma->mode = MSDC_MODE_DMA_BASIC;
- else
- dma->mode = MSDC_MODE_DMA_DESC;
-
- N_MSG(DMA, "DMA mode<%d> sglen<%d> xfersz<%d>", dma->mode, dma->sglen, dma->xfersz);
-
- msdc_dma_config(host, dma);
-
- /*if (dma->mode == MSDC_MODE_DMA_DESC) {
- //msdc_dma_dump(host, dma);
- } */
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
+ MSDC_BRUST_64B);
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 0);
+ break;
+ case MSDC_MODE_DMA_DESC:
+
+ /* calculate the required number of gpd */
+ num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
+ BUG_ON(num != 1);
+
+ gpd = dma->gpd;
+ bd = dma->bd;
+
+ /* modify gpd*/
+ //gpd->intr = 0;
+ gpd->hwo = 1; /* hw will clear it */
+ gpd->bdp = 1;
+ gpd->chksum = 0; /* need to clear first. */
+ gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16);
+
+ /* modify bd*/
+ for_each_sg(dma->sg, sg, dma->sglen, j) {
+ bd[j].blkpad = 0;
+ bd[j].dwpad = 0;
+ bd[j].ptr = (void *)sg_dma_address(sg);
+ bd[j].buflen = sg_dma_len(sg);
+
+ if (j == dma->sglen - 1)
+ bd[j].eol = 1; /* the last bd */
+ else
+ bd[j].eol = 0;
+
+ bd[j].chksum = 0; /* checksume need to clear first */
+ bd[j].chksum = msdc_dma_calcs((u8 *)(&bd[j]), 16);
+ }
+
+ sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1);
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
+ MSDC_BRUST_64B);
+ sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1);
+
+ sdr_write32(MSDC_DMA_SA, PHYSADDR((u32)dma->gpd_addr));
+ break;
+
+ default:
+ break;
+ }
+
+ N_MSG(DMA, "DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL));
+ N_MSG(DMA, "DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG));
+ N_MSG(DMA, "DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA));
+
}
-/* set block number before send command */
-static void msdc_set_blknum(struct msdc_host *host, u32 blknum)
+static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma,
+ struct scatterlist *sg, unsigned int sglen)
{
- u32 base = host->base;
+ BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
- sdr_write32(SDC_BLK_NUM, blknum);
+ dma->sg = sg;
+ dma->sglen = sglen;
+
+ dma->mode = MSDC_MODE_DMA_DESC;
+
+ N_MSG(DMA, "DMA mode<%d> sglen<%d> xfersz<%d>", dma->mode, dma->sglen,
+ host->xfer_size);
+
+ msdc_dma_config(host, dma);
}
-static int msdc_do_request(struct mmc_host*mmc, struct mmc_request*mrq)
+static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
+ __must_hold(&host->lock)
{
- struct msdc_host *host = mmc_priv(mmc);
- struct mmc_command *cmd;
- struct mmc_data *data;
- u32 base = host->base;
- //u32 intsts = 0;
- unsigned int left=0;
- int dma = 0, read = 1, dir = DMA_FROM_DEVICE, send_type=0;
-
- #define SND_DAT 0
- #define SND_CMD 1
-
- BUG_ON(mmc == NULL);
- BUG_ON(mrq == NULL);
-
- host->error = 0;
- atomic_set(&host->abort, 0);
-
- cmd = mrq->cmd;
- data = mrq->cmd->data;
-
+ struct msdc_host *host = mmc_priv(mmc);
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+ void __iomem *base = host->base;
+ //u32 intsts = 0;
+ int read = 1, send_type = 0;
+
+#define SND_DAT 0
+#define SND_CMD 1
+
+ BUG_ON(mmc == NULL);
+ BUG_ON(mrq == NULL);
+
+ host->error = 0;
+
+ cmd = mrq->cmd;
+ data = mrq->cmd->data;
+
#if 0 /* --- by chhung */
- //if(host->id ==1){
- N_MSG(OPS, "enable clock!");
- msdc_ungate_clock(host->id);
- //}
+ //if(host->id ==1){
+ N_MSG(OPS, "enable clock!");
+ msdc_ungate_clock(host->id);
+ //}
#endif /* end of --- */
-
- if (!data) {
- send_type=SND_CMD;
- if (msdc_do_command(host, cmd, 1, CMD_TIMEOUT) != 0) {
- goto done;
- }
- } else {
- BUG_ON(data->blksz > HOST_MAX_BLKSZ);
- send_type=SND_DAT;
-
- data->error = 0;
- read = data->flags & MMC_DATA_READ ? 1 : 0;
- host->data = data;
- host->xfer_size = data->blocks * data->blksz;
- host->blksz = data->blksz;
-
- /* deside the transfer mode */
- if (drv_mode[host->id] == MODE_PIO) {
- host->dma_xfer = dma = 0;
- } else if (drv_mode[host->id] == MODE_DMA) {
- host->dma_xfer = dma = 1;
- } else if (drv_mode[host->id] == MODE_SIZE_DEP) {
- host->dma_xfer = dma = ((host->xfer_size >= dma_size[host->id]) ? 1 : 0);
- }
-
- if (read) {
- if ((host->timeout_ns != data->timeout_ns) ||
- (host->timeout_clks != data->timeout_clks)) {
- msdc_set_timeout(host, data->timeout_ns, data->timeout_clks);
- }
- }
-
- msdc_set_blknum(host, data->blocks);
- //msdc_clr_fifo(); /* no need */
-
- if (dma) {
- msdc_dma_on(); /* enable DMA mode first!! */
- init_completion(&host->xfer_done);
-
- /* start the command first*/
- if (msdc_command_start(host, cmd, 1, CMD_TIMEOUT) != 0)
- goto done;
-
- dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
- (void)dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, dir);
- msdc_dma_setup(host, &host->dma, data->sg, data->sg_len);
-
- /* then wait command done */
- if (msdc_command_resp(host, cmd, 1, CMD_TIMEOUT) != 0)
- goto done;
-
- /* for read, the data coming too fast, then CRC error
- start DMA no business with CRC. */
- //init_completion(&host->xfer_done);
- msdc_dma_start(host);
-
- spin_unlock(&host->lock);
- if(!wait_for_completion_timeout(&host->xfer_done, DAT_TIMEOUT)){
- ERR_MSG("XXX CMD<%d> wait xfer_done<%d> timeout!!", cmd->opcode, data->blocks * data->blksz);
- ERR_MSG(" DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA));
- ERR_MSG(" DMA_CA = 0x%x", sdr_read32(MSDC_DMA_CA));
- ERR_MSG(" DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL));
- ERR_MSG(" DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG));
- data->error = (unsigned int)-ETIMEDOUT;
-
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
- }
- spin_lock(&host->lock);
- msdc_dma_stop(host);
- } else {
- /* Firstly: send command */
- if (msdc_do_command(host, cmd, 1, CMD_TIMEOUT) != 0) {
- goto done;
- }
-
- /* Secondly: pio data phase */
- if (read) {
- if (msdc_pio_read(host, data)){
- goto done;
- }
- } else {
- if (msdc_pio_write(host, data)) {
- goto done;
- }
- }
-
- /* For write case: make sure contents in fifo flushed to device */
- if (!read) {
- while (1) {
- left=msdc_txfifocnt();
- if (left == 0) {
- break;
- }
- if (msdc_pio_abort(host, data, jiffies + DAT_TIMEOUT)) {
- break;
- /* Fix me: what about if data error, when stop ? how to? */
- }
- }
- } else {
- /* Fix me: read case: need to check CRC error */
- }
-
- /* For write case: SDCBUSY and Xfer_Comp will assert when DAT0 not busy.
- For read case : SDCBUSY and Xfer_Comp will assert when last byte read out from FIFO.
- */
-
- /* try not to wait xfer_comp interrupt.
- the next command will check SDC_BUSY.
- SDC_BUSY means xfer_comp assert
- */
-
- } // PIO mode
-
- /* Last: stop transfer */
- if (data->stop){
- if (msdc_do_command(host, data->stop, 0, CMD_TIMEOUT) != 0) {
- goto done;
- }
- }
- }
+
+ if (!data) {
+ send_type = SND_CMD;
+ if (msdc_do_command(host, cmd, 1, CMD_TIMEOUT) != 0)
+ goto done;
+ } else {
+ BUG_ON(data->blksz > HOST_MAX_BLKSZ);
+ send_type = SND_DAT;
+
+ data->error = 0;
+ read = data->flags & MMC_DATA_READ ? 1 : 0;
+ host->data = data;
+ host->xfer_size = data->blocks * data->blksz;
+ host->blksz = data->blksz;
+
+ if (read) {
+ if ((host->timeout_ns != data->timeout_ns) ||
+ (host->timeout_clks != data->timeout_clks)) {
+ msdc_set_timeout(host, data->timeout_ns, data->timeout_clks);
+ }
+ }
+
+ sdr_write32(SDC_BLK_NUM, data->blocks);
+ //msdc_clr_fifo(); /* no need */
+
+ msdc_dma_on(); /* enable DMA mode first!! */
+ init_completion(&host->xfer_done);
+
+ /* start the command first*/
+ if (msdc_command_start(host, cmd, 1, CMD_TIMEOUT) != 0)
+ goto done;
+
+ data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg,
+ data->sg_len,
+ mmc_get_dma_dir(data));
+ msdc_dma_setup(host, &host->dma, data->sg,
+ data->sg_count);
+
+ /* then wait command done */
+ if (msdc_command_resp(host, cmd, 1, CMD_TIMEOUT) != 0)
+ goto done;
+
+ /* for read, the data coming too fast, then CRC error
+ start DMA no business with CRC. */
+ //init_completion(&host->xfer_done);
+ msdc_dma_start(host);
+
+ spin_unlock(&host->lock);
+ if (!wait_for_completion_timeout(&host->xfer_done, DAT_TIMEOUT)) {
+ ERR_MSG("XXX CMD<%d> wait xfer_done<%d> timeout!!", cmd->opcode, data->blocks * data->blksz);
+ ERR_MSG(" DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA));
+ ERR_MSG(" DMA_CA = 0x%x", sdr_read32(MSDC_DMA_CA));
+ ERR_MSG(" DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL));
+ ERR_MSG(" DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG));
+ data->error = -ETIMEDOUT;
+
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+ msdc_clr_int();
+ }
+ spin_lock(&host->lock);
+ msdc_dma_stop(host);
+
+ /* Last: stop transfer */
+ if (data->stop) {
+ if (msdc_do_command(host, data->stop, 0, CMD_TIMEOUT) != 0)
+ goto done;
+ }
+ }
done:
- if (data != NULL) {
- host->data = NULL;
- host->dma_xfer = 0;
- if (dma != 0) {
- msdc_dma_off();
- host->dma.used_bd = 0;
- host->dma.used_gpd = 0;
- dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, dir);
- }
- host->blksz = 0;
-
+ if (data != NULL) {
+ host->data = NULL;
+ dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len,
+ mmc_get_dma_dir(data));
+ host->blksz = 0;
+
#if 0 // don't stop twice!
- if(host->hw->flags & MSDC_REMOVABLE && data->error) {
- msdc_abort_data(host);
- /* reset in IRQ, stop command has issued. -> No need */
- }
-#endif
+ if (host->hw->flags & MSDC_REMOVABLE && data->error) {
+ msdc_abort_data(host);
+ /* reset in IRQ, stop command has issued. -> No need */
+ }
+#endif
- N_MSG(OPS, "CMD<%d> data<%s %s> blksz<%d> block<%d> error<%d>",cmd->opcode, (dma? "dma":"pio"),
- (read ? "read ":"write") ,data->blksz, data->blocks, data->error);
- }
+ N_MSG(OPS, "CMD<%d> data<%s %s> blksz<%d> block<%d> error<%d>", cmd->opcode, (dma ? "dma" : "pio"),
+ (read ? "read " : "write"), data->blksz, data->blocks, data->error);
+ }
#if 0 /* --- by chhung */
-#if 1
- //if(host->id==1) {
- if(send_type==SND_CMD) {
- if(cmd->opcode == MMC_SEND_STATUS) {
- if((cmd->resp[0] & CARD_READY_FOR_DATA) ||(CARD_CURRENT_STATE(cmd->resp[0]) != 7)){
- N_MSG(OPS,"disable clock, CMD13 IDLE");
- msdc_gate_clock(host->id);
- }
- } else {
- N_MSG(OPS,"disable clock, CMD<%d>", cmd->opcode);
- msdc_gate_clock(host->id);
- }
- } else {
- if(read) {
- N_MSG(OPS,"disable clock!!! Read CMD<%d>",cmd->opcode);
- msdc_gate_clock(host->id);
- }
- }
- //}
+#if 1
+ //if(host->id==1) {
+ if (send_type == SND_CMD) {
+ if (cmd->opcode == MMC_SEND_STATUS) {
+ if ((cmd->resp[0] & CARD_READY_FOR_DATA) || (CARD_CURRENT_STATE(cmd->resp[0]) != 7)) {
+ N_MSG(OPS, "disable clock, CMD13 IDLE");
+ msdc_gate_clock(host->id);
+ }
+ } else {
+ N_MSG(OPS, "disable clock, CMD<%d>", cmd->opcode);
+ msdc_gate_clock(host->id);
+ }
+ } else {
+ if (read) {
+ N_MSG(OPS, "disable clock!!! Read CMD<%d>", cmd->opcode);
+ msdc_gate_clock(host->id);
+ }
+ }
+ //}
#else
- msdc_gate_clock(host->id);
+ msdc_gate_clock(host->id);
#endif
#endif /* end of --- */
-
- if (mrq->cmd->error) host->error = 0x001;
- if (mrq->data && mrq->data->error) host->error |= 0x010;
- if (mrq->stop && mrq->stop->error) host->error |= 0x100;
- //if (host->error) ERR_MSG("host->error<%d>", host->error);
+ if (mrq->cmd->error)
+ host->error = 0x001;
+ if (mrq->data && mrq->data->error)
+ host->error |= 0x010;
+ if (mrq->stop && mrq->stop->error)
+ host->error |= 0x100;
+
+ //if (host->error) ERR_MSG("host->error<%d>", host->error);
- return host->error;
+ return host->error;
}
static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host)
{
- struct mmc_command cmd;
- struct mmc_request mrq;
- u32 err;
-
- memset(&cmd, 0, sizeof(struct mmc_command));
- cmd.opcode = MMC_APP_CMD;
-#if 0 /* bug: we meet mmc->card is null when ACMD6 */
- cmd.arg = mmc->card->rca << 16;
-#else
- cmd.arg = host->app_cmd_arg;
-#endif
- cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
-
- memset(&mrq, 0, sizeof(struct mmc_request));
- mrq.cmd = &cmd; cmd.mrq = &mrq;
- cmd.data = NULL;
-
- err = msdc_do_command(host, &cmd, 0, CMD_TIMEOUT);
- return err;
+ struct mmc_command cmd;
+ struct mmc_request mrq;
+ u32 err;
+
+ memset(&cmd, 0, sizeof(struct mmc_command));
+ cmd.opcode = MMC_APP_CMD;
+#if 0 /* bug: we meet mmc->card is null when ACMD6 */
+ cmd.arg = mmc->card->rca << 16;
+#else
+ cmd.arg = host->app_cmd_arg;
+#endif
+ cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
+
+ memset(&mrq, 0, sizeof(struct mmc_request));
+ mrq.cmd = &cmd; cmd.mrq = &mrq;
+ cmd.data = NULL;
+
+ err = msdc_do_command(host, &cmd, 0, CMD_TIMEOUT);
+ return err;
}
-static int msdc_tune_cmdrsp(struct msdc_host*host, struct mmc_command *cmd)
+static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd)
{
- int result = -1;
- u32 base = host->base;
- u32 rsmpl, cur_rsmpl, orig_rsmpl;
- u32 rrdly, cur_rrdly = 0xffffffff, orig_rrdly;
- u32 skip = 1;
-
- /* ==== don't support 3.0 now ====
- 1: R_SMPL[1]
- 2: PAD_CMD_RESP_RXDLY[26:22]
- ==========================*/
-
- // save the previous tune result
- sdr_get_field(MSDC_IOCON, MSDC_IOCON_RSPL, orig_rsmpl);
- sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, orig_rrdly);
-
- rrdly = 0;
- do {
- for (rsmpl = 0; rsmpl < 2; rsmpl++) {
- /* Lv1: R_SMPL[1] */
- cur_rsmpl = (orig_rsmpl + rsmpl) % 2;
- if (skip == 1) {
- skip = 0;
- continue;
- }
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL, cur_rsmpl);
-
- if (host->app_cmd) {
- result = msdc_app_cmd(host->mmc, host);
- if (result) {
- ERR_MSG("TUNE_CMD app_cmd<%d> failed: RESP_RXDLY<%d>,R_SMPL<%d>",
- host->mrq->cmd->opcode, cur_rrdly, cur_rsmpl);
- continue;
- }
- }
- result = msdc_do_command(host, cmd, 0, CMD_TIMEOUT); // not tune.
- ERR_MSG("TUNE_CMD<%d> %s PAD_CMD_RESP_RXDLY[26:22]<%d> R_SMPL[1]<%d>", cmd->opcode,
- (result == 0) ? "PASS" : "FAIL", cur_rrdly, cur_rsmpl);
-
- if (result == 0) {
- return 0;
- }
- if (result != (unsigned int)(-EIO)) {
- ERR_MSG("TUNE_CMD<%d> Error<%d> not -EIO", cmd->opcode, result);
- return result;
- }
-
- /* should be EIO */
- if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */
- msdc_abort_data(host);
- }
- }
-
- /* Lv2: PAD_CMD_RESP_RXDLY[26:22] */
- cur_rrdly = (orig_rrdly + rrdly + 1) % 32;
- sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, cur_rrdly);
- }while (++rrdly < 32);
-
- return result;
+ int result = -1;
+ void __iomem *base = host->base;
+ u32 rsmpl, cur_rsmpl, orig_rsmpl;
+ u32 rrdly, cur_rrdly = 0xffffffff, orig_rrdly;
+ u32 skip = 1;
+
+ /* ==== don't support 3.0 now ====
+ 1: R_SMPL[1]
+ 2: PAD_CMD_RESP_RXDLY[26:22]
+ ==========================*/
+
+ // save the previous tune result
+ sdr_get_field(MSDC_IOCON, MSDC_IOCON_RSPL, &orig_rsmpl);
+ sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, &orig_rrdly);
+
+ rrdly = 0;
+ do {
+ for (rsmpl = 0; rsmpl < 2; rsmpl++) {
+ /* Lv1: R_SMPL[1] */
+ cur_rsmpl = (orig_rsmpl + rsmpl) % 2;
+ if (skip == 1) {
+ skip = 0;
+ continue;
+ }
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL, cur_rsmpl);
+
+ if (host->app_cmd) {
+ result = msdc_app_cmd(host->mmc, host);
+ if (result) {
+ ERR_MSG("TUNE_CMD app_cmd<%d> failed: RESP_RXDLY<%d>,R_SMPL<%d>",
+ host->mrq->cmd->opcode, cur_rrdly, cur_rsmpl);
+ continue;
+ }
+ }
+ result = msdc_do_command(host, cmd, 0, CMD_TIMEOUT); // not tune.
+ ERR_MSG("TUNE_CMD<%d> %s PAD_CMD_RESP_RXDLY[26:22]<%d> R_SMPL[1]<%d>", cmd->opcode,
+ (result == 0) ? "PASS" : "FAIL", cur_rrdly, cur_rsmpl);
+
+ if (result == 0)
+ return 0;
+ if (result != -EIO) {
+ ERR_MSG("TUNE_CMD<%d> Error<%d> not -EIO", cmd->opcode, result);
+ return result;
+ }
+
+ /* should be EIO */
+ if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */
+ msdc_abort_data(host);
+ }
+ }
+
+ /* Lv2: PAD_CMD_RESP_RXDLY[26:22] */
+ cur_rrdly = (orig_rrdly + rrdly + 1) % 32;
+ sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, cur_rrdly);
+ } while (++rrdly < 32);
+
+ return result;
}
/* Support SD2.0 Only */
static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq)
{
- struct msdc_host *host = mmc_priv(mmc);
- u32 base = host->base;
- u32 ddr=0;
- u32 dcrc=0;
- u32 rxdly, cur_rxdly0, cur_rxdly1;
- u32 dsmpl, cur_dsmpl, orig_dsmpl;
- u32 cur_dat0, cur_dat1, cur_dat2, cur_dat3;
- u32 cur_dat4, cur_dat5, cur_dat6, cur_dat7;
- u32 orig_dat0, orig_dat1, orig_dat2, orig_dat3;
- u32 orig_dat4, orig_dat5, orig_dat6, orig_dat7;
- int result = -1;
- u32 skip = 1;
-
- sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, orig_dsmpl);
-
- /* Tune Method 2. */
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1);
-
- rxdly = 0;
- do {
- for (dsmpl = 0; dsmpl < 2; dsmpl++) {
- cur_dsmpl = (orig_dsmpl + dsmpl) % 2;
- if (skip == 1) {
- skip = 0;
- continue;
- }
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl);
-
- if (host->app_cmd) {
- result = msdc_app_cmd(host->mmc, host);
- if (result) {
- ERR_MSG("TUNE_BREAD app_cmd<%d> failed", host->mrq->cmd->opcode);
- continue;
- }
- }
- result = msdc_do_request(mmc,mrq);
-
- sdr_get_field(SDC_DCRC_STS, SDC_DCRC_STS_POS|SDC_DCRC_STS_NEG, dcrc); /* RO */
- if (!ddr) dcrc &= ~SDC_DCRC_STS_NEG;
- ERR_MSG("TUNE_BREAD<%s> dcrc<0x%x> DATRDDLY0/1<0x%x><0x%x> dsmpl<0x%x>",
- (result == 0 && dcrc == 0) ? "PASS" : "FAIL", dcrc,
- sdr_read32(MSDC_DAT_RDDLY0), sdr_read32(MSDC_DAT_RDDLY1), cur_dsmpl);
-
- /* Fix me: result is 0, but dcrc is still exist */
- if (result == 0 && dcrc == 0) {
- goto done;
- } else {
- /* there is a case: command timeout, and data phase not processed */
- if (mrq->data->error != 0 && mrq->data->error != (unsigned int)(-EIO)) {
- ERR_MSG("TUNE_READ: result<0x%x> cmd_error<%d> data_error<%d>",
- result, mrq->cmd->error, mrq->data->error);
- goto done;
- }
- }
- }
-
- cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0);
- cur_rxdly1 = sdr_read32(MSDC_DAT_RDDLY1);
-
- /* E1 ECO. YD: Reverse */
- if (sdr_read32(MSDC_ECO_VER) >= 4) {
- orig_dat0 = (cur_rxdly0 >> 24) & 0x1F;
- orig_dat1 = (cur_rxdly0 >> 16) & 0x1F;
- orig_dat2 = (cur_rxdly0 >> 8) & 0x1F;
- orig_dat3 = (cur_rxdly0 >> 0) & 0x1F;
- orig_dat4 = (cur_rxdly1 >> 24) & 0x1F;
- orig_dat5 = (cur_rxdly1 >> 16) & 0x1F;
- orig_dat6 = (cur_rxdly1 >> 8) & 0x1F;
- orig_dat7 = (cur_rxdly1 >> 0) & 0x1F;
- } else {
- orig_dat0 = (cur_rxdly0 >> 0) & 0x1F;
- orig_dat1 = (cur_rxdly0 >> 8) & 0x1F;
- orig_dat2 = (cur_rxdly0 >> 16) & 0x1F;
- orig_dat3 = (cur_rxdly0 >> 24) & 0x1F;
- orig_dat4 = (cur_rxdly1 >> 0) & 0x1F;
- orig_dat5 = (cur_rxdly1 >> 8) & 0x1F;
- orig_dat6 = (cur_rxdly1 >> 16) & 0x1F;
- orig_dat7 = (cur_rxdly1 >> 24) & 0x1F;
- }
-
- if (ddr) {
- cur_dat0 = (dcrc & (1 << 0) || dcrc & (1 << 8)) ? ((orig_dat0 + 1) % 32) : orig_dat0;
- cur_dat1 = (dcrc & (1 << 1) || dcrc & (1 << 9)) ? ((orig_dat1 + 1) % 32) : orig_dat1;
- cur_dat2 = (dcrc & (1 << 2) || dcrc & (1 << 10)) ? ((orig_dat2 + 1) % 32) : orig_dat2;
- cur_dat3 = (dcrc & (1 << 3) || dcrc & (1 << 11)) ? ((orig_dat3 + 1) % 32) : orig_dat3;
- } else {
- cur_dat0 = (dcrc & (1 << 0)) ? ((orig_dat0 + 1) % 32) : orig_dat0;
- cur_dat1 = (dcrc & (1 << 1)) ? ((orig_dat1 + 1) % 32) : orig_dat1;
- cur_dat2 = (dcrc & (1 << 2)) ? ((orig_dat2 + 1) % 32) : orig_dat2;
- cur_dat3 = (dcrc & (1 << 3)) ? ((orig_dat3 + 1) % 32) : orig_dat3;
- }
- cur_dat4 = (dcrc & (1 << 4)) ? ((orig_dat4 + 1) % 32) : orig_dat4;
- cur_dat5 = (dcrc & (1 << 5)) ? ((orig_dat5 + 1) % 32) : orig_dat5;
- cur_dat6 = (dcrc & (1 << 6)) ? ((orig_dat6 + 1) % 32) : orig_dat6;
- cur_dat7 = (dcrc & (1 << 7)) ? ((orig_dat7 + 1) % 32) : orig_dat7;
-
- cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0);
- cur_rxdly1 = (cur_dat4 << 24) | (cur_dat5 << 16) | (cur_dat6 << 8) | (cur_dat7 << 0);
-
- sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
- sdr_write32(MSDC_DAT_RDDLY1, cur_rxdly1);
-
- } while (++rxdly < 32);
-
+ struct msdc_host *host = mmc_priv(mmc);
+ void __iomem *base = host->base;
+ u32 ddr = 0;
+ u32 dcrc = 0;
+ u32 rxdly, cur_rxdly0, cur_rxdly1;
+ u32 dsmpl, cur_dsmpl, orig_dsmpl;
+ u32 cur_dat0, cur_dat1, cur_dat2, cur_dat3;
+ u32 cur_dat4, cur_dat5, cur_dat6, cur_dat7;
+ u32 orig_dat0, orig_dat1, orig_dat2, orig_dat3;
+ u32 orig_dat4, orig_dat5, orig_dat6, orig_dat7;
+ int result = -1;
+ u32 skip = 1;
+
+ sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl);
+
+ /* Tune Method 2. */
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1);
+
+ rxdly = 0;
+ do {
+ for (dsmpl = 0; dsmpl < 2; dsmpl++) {
+ cur_dsmpl = (orig_dsmpl + dsmpl) % 2;
+ if (skip == 1) {
+ skip = 0;
+ continue;
+ }
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl);
+
+ if (host->app_cmd) {
+ result = msdc_app_cmd(host->mmc, host);
+ if (result) {
+ ERR_MSG("TUNE_BREAD app_cmd<%d> failed", host->mrq->cmd->opcode);
+ continue;
+ }
+ }
+ result = msdc_do_request(mmc, mrq);
+
+ sdr_get_field(SDC_DCRC_STS,
+ SDC_DCRC_STS_POS | SDC_DCRC_STS_NEG,
+ &dcrc); /* RO */
+ if (!ddr)
+ dcrc &= ~SDC_DCRC_STS_NEG;
+ ERR_MSG("TUNE_BREAD<%s> dcrc<0x%x> DATRDDLY0/1<0x%x><0x%x> dsmpl<0x%x>",
+ (result == 0 && dcrc == 0) ? "PASS" : "FAIL", dcrc,
+ sdr_read32(MSDC_DAT_RDDLY0), sdr_read32(MSDC_DAT_RDDLY1), cur_dsmpl);
+
+ /* Fix me: result is 0, but dcrc is still exist */
+ if (result == 0 && dcrc == 0) {
+ goto done;
+ } else {
+ /* there is a case: command timeout, and data phase not processed */
+ if (mrq->data->error != 0 &&
+ mrq->data->error != -EIO) {
+ ERR_MSG("TUNE_READ: result<0x%x> cmd_error<%d> data_error<%d>",
+ result, mrq->cmd->error, mrq->data->error);
+ goto done;
+ }
+ }
+ }
+
+ cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0);
+ cur_rxdly1 = sdr_read32(MSDC_DAT_RDDLY1);
+
+ /* E1 ECO. YD: Reverse */
+ if (sdr_read32(MSDC_ECO_VER) >= 4) {
+ orig_dat0 = (cur_rxdly0 >> 24) & 0x1F;
+ orig_dat1 = (cur_rxdly0 >> 16) & 0x1F;
+ orig_dat2 = (cur_rxdly0 >> 8) & 0x1F;
+ orig_dat3 = (cur_rxdly0 >> 0) & 0x1F;
+ orig_dat4 = (cur_rxdly1 >> 24) & 0x1F;
+ orig_dat5 = (cur_rxdly1 >> 16) & 0x1F;
+ orig_dat6 = (cur_rxdly1 >> 8) & 0x1F;
+ orig_dat7 = (cur_rxdly1 >> 0) & 0x1F;
+ } else {
+ orig_dat0 = (cur_rxdly0 >> 0) & 0x1F;
+ orig_dat1 = (cur_rxdly0 >> 8) & 0x1F;
+ orig_dat2 = (cur_rxdly0 >> 16) & 0x1F;
+ orig_dat3 = (cur_rxdly0 >> 24) & 0x1F;
+ orig_dat4 = (cur_rxdly1 >> 0) & 0x1F;
+ orig_dat5 = (cur_rxdly1 >> 8) & 0x1F;
+ orig_dat6 = (cur_rxdly1 >> 16) & 0x1F;
+ orig_dat7 = (cur_rxdly1 >> 24) & 0x1F;
+ }
+
+ if (ddr) {
+ cur_dat0 = (dcrc & (1 << 0) || dcrc & (1 << 8)) ? ((orig_dat0 + 1) % 32) : orig_dat0;
+ cur_dat1 = (dcrc & (1 << 1) || dcrc & (1 << 9)) ? ((orig_dat1 + 1) % 32) : orig_dat1;
+ cur_dat2 = (dcrc & (1 << 2) || dcrc & (1 << 10)) ? ((orig_dat2 + 1) % 32) : orig_dat2;
+ cur_dat3 = (dcrc & (1 << 3) || dcrc & (1 << 11)) ? ((orig_dat3 + 1) % 32) : orig_dat3;
+ } else {
+ cur_dat0 = (dcrc & (1 << 0)) ? ((orig_dat0 + 1) % 32) : orig_dat0;
+ cur_dat1 = (dcrc & (1 << 1)) ? ((orig_dat1 + 1) % 32) : orig_dat1;
+ cur_dat2 = (dcrc & (1 << 2)) ? ((orig_dat2 + 1) % 32) : orig_dat2;
+ cur_dat3 = (dcrc & (1 << 3)) ? ((orig_dat3 + 1) % 32) : orig_dat3;
+ }
+ cur_dat4 = (dcrc & (1 << 4)) ? ((orig_dat4 + 1) % 32) : orig_dat4;
+ cur_dat5 = (dcrc & (1 << 5)) ? ((orig_dat5 + 1) % 32) : orig_dat5;
+ cur_dat6 = (dcrc & (1 << 6)) ? ((orig_dat6 + 1) % 32) : orig_dat6;
+ cur_dat7 = (dcrc & (1 << 7)) ? ((orig_dat7 + 1) % 32) : orig_dat7;
+
+ cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0);
+ cur_rxdly1 = (cur_dat4 << 24) | (cur_dat5 << 16) | (cur_dat6 << 8) | (cur_dat7 << 0);
+
+ sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
+ sdr_write32(MSDC_DAT_RDDLY1, cur_rxdly1);
+
+ } while (++rxdly < 32);
+
done:
- return result;
+ return result;
}
-static int msdc_tune_bwrite(struct mmc_host *mmc,struct mmc_request *mrq)
+static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq)
{
- struct msdc_host *host = mmc_priv(mmc);
- u32 base = host->base;
-
- u32 wrrdly, cur_wrrdly = 0xffffffff, orig_wrrdly;
- u32 dsmpl, cur_dsmpl, orig_dsmpl;
- u32 rxdly, cur_rxdly0;
- u32 orig_dat0, orig_dat1, orig_dat2, orig_dat3;
- u32 cur_dat0, cur_dat1, cur_dat2, cur_dat3;
- int result = -1;
- u32 skip = 1;
-
- // MSDC_IOCON_DDR50CKD need to check. [Fix me]
-
- sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, orig_wrrdly);
- sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, orig_dsmpl );
-
- /* Tune Method 2. just DAT0 */
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1);
- cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0);
-
- /* E1 ECO. YD: Reverse */
- if (sdr_read32(MSDC_ECO_VER) >= 4) {
- orig_dat0 = (cur_rxdly0 >> 24) & 0x1F;
- orig_dat1 = (cur_rxdly0 >> 16) & 0x1F;
- orig_dat2 = (cur_rxdly0 >> 8) & 0x1F;
- orig_dat3 = (cur_rxdly0 >> 0) & 0x1F;
- } else {
- orig_dat0 = (cur_rxdly0 >> 0) & 0x1F;
- orig_dat1 = (cur_rxdly0 >> 8) & 0x1F;
- orig_dat2 = (cur_rxdly0 >> 16) & 0x1F;
- orig_dat3 = (cur_rxdly0 >> 24) & 0x1F;
- }
-
- rxdly = 0;
- do {
- wrrdly = 0;
- do {
- for (dsmpl = 0; dsmpl < 2; dsmpl++) {
- cur_dsmpl = (orig_dsmpl + dsmpl) % 2;
- if (skip == 1) {
- skip = 0;
- continue;
- }
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl);
-
- if (host->app_cmd) {
- result = msdc_app_cmd(host->mmc, host);
- if (result) {
- ERR_MSG("TUNE_BWRITE app_cmd<%d> failed", host->mrq->cmd->opcode);
- continue;
- }
- }
- result = msdc_do_request(mmc,mrq);
-
- ERR_MSG("TUNE_BWRITE<%s> DSPL<%d> DATWRDLY<%d> MSDC_DAT_RDDLY0<0x%x>",
- result == 0 ? "PASS" : "FAIL",
- cur_dsmpl, cur_wrrdly, cur_rxdly0);
-
- if (result == 0) {
- goto done;
- }
- else {
- /* there is a case: command timeout, and data phase not processed */
- if (mrq->data->error != (unsigned int)(-EIO)) {
- ERR_MSG("TUNE_READ: result<0x%x> cmd_error<%d> data_error<%d>",
- result, mrq->cmd->error, mrq->data->error);
- goto done;
- }
- }
- }
- cur_wrrdly = (orig_wrrdly + wrrdly + 1) % 32;
- sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, cur_wrrdly);
- } while (++wrrdly < 32);
-
- cur_dat0 = (orig_dat0 + rxdly) % 32; /* only adjust bit-1 for crc */
- cur_dat1 = orig_dat1;
- cur_dat2 = orig_dat2;
- cur_dat3 = orig_dat3;
-
- cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0);
- sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
- } while (++rxdly < 32);
+ struct msdc_host *host = mmc_priv(mmc);
+ void __iomem *base = host->base;
+
+ u32 wrrdly, cur_wrrdly = 0xffffffff, orig_wrrdly;
+ u32 dsmpl, cur_dsmpl, orig_dsmpl;
+ u32 rxdly, cur_rxdly0;
+ u32 orig_dat0, orig_dat1, orig_dat2, orig_dat3;
+ u32 cur_dat0, cur_dat1, cur_dat2, cur_dat3;
+ int result = -1;
+ u32 skip = 1;
+
+ // MSDC_IOCON_DDR50CKD need to check. [Fix me]
+
+ sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, &orig_wrrdly);
+ sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl);
+
+ /* Tune Method 2. just DAT0 */
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1);
+ cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0);
+
+ /* E1 ECO. YD: Reverse */
+ if (sdr_read32(MSDC_ECO_VER) >= 4) {
+ orig_dat0 = (cur_rxdly0 >> 24) & 0x1F;
+ orig_dat1 = (cur_rxdly0 >> 16) & 0x1F;
+ orig_dat2 = (cur_rxdly0 >> 8) & 0x1F;
+ orig_dat3 = (cur_rxdly0 >> 0) & 0x1F;
+ } else {
+ orig_dat0 = (cur_rxdly0 >> 0) & 0x1F;
+ orig_dat1 = (cur_rxdly0 >> 8) & 0x1F;
+ orig_dat2 = (cur_rxdly0 >> 16) & 0x1F;
+ orig_dat3 = (cur_rxdly0 >> 24) & 0x1F;
+ }
+
+ rxdly = 0;
+ do {
+ wrrdly = 0;
+ do {
+ for (dsmpl = 0; dsmpl < 2; dsmpl++) {
+ cur_dsmpl = (orig_dsmpl + dsmpl) % 2;
+ if (skip == 1) {
+ skip = 0;
+ continue;
+ }
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl);
+
+ if (host->app_cmd) {
+ result = msdc_app_cmd(host->mmc, host);
+ if (result) {
+ ERR_MSG("TUNE_BWRITE app_cmd<%d> failed", host->mrq->cmd->opcode);
+ continue;
+ }
+ }
+ result = msdc_do_request(mmc, mrq);
+
+ ERR_MSG("TUNE_BWRITE<%s> DSPL<%d> DATWRDLY<%d> MSDC_DAT_RDDLY0<0x%x>",
+ result == 0 ? "PASS" : "FAIL",
+ cur_dsmpl, cur_wrrdly, cur_rxdly0);
+
+ if (result == 0) {
+ goto done;
+ } else {
+ /* there is a case: command timeout, and data phase not processed */
+ if (mrq->data->error != -EIO) {
+ ERR_MSG("TUNE_READ: result<0x%x> cmd_error<%d> data_error<%d>",
+ result, mrq->cmd->error, mrq->data->error);
+ goto done;
+ }
+ }
+ }
+ cur_wrrdly = (orig_wrrdly + wrrdly + 1) % 32;
+ sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, cur_wrrdly);
+ } while (++wrrdly < 32);
+
+ cur_dat0 = (orig_dat0 + rxdly) % 32; /* only adjust bit-1 for crc */
+ cur_dat1 = orig_dat1;
+ cur_dat2 = orig_dat2;
+ cur_dat3 = orig_dat3;
+
+ cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0);
+ sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
+ } while (++rxdly < 32);
done:
- return result;
+ return result;
}
static int msdc_get_card_status(struct mmc_host *mmc, struct msdc_host *host, u32 *status)
{
- struct mmc_command cmd;
- struct mmc_request mrq;
- u32 err;
-
- memset(&cmd, 0, sizeof(struct mmc_command));
- cmd.opcode = MMC_SEND_STATUS;
- if (mmc->card) {
- cmd.arg = mmc->card->rca << 16;
- } else {
- ERR_MSG("cmd13 mmc card is null");
- cmd.arg = host->app_cmd_arg;
- }
- cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
-
- memset(&mrq, 0, sizeof(struct mmc_request));
- mrq.cmd = &cmd; cmd.mrq = &mrq;
- cmd.data = NULL;
-
- err = msdc_do_command(host, &cmd, 1, CMD_TIMEOUT);
-
- if (status) {
- *status = cmd.resp[0];
- }
-
- return err;
+ struct mmc_command cmd;
+ struct mmc_request mrq;
+ u32 err;
+
+ memset(&cmd, 0, sizeof(struct mmc_command));
+ cmd.opcode = MMC_SEND_STATUS;
+ if (mmc->card) {
+ cmd.arg = mmc->card->rca << 16;
+ } else {
+ ERR_MSG("cmd13 mmc card is null");
+ cmd.arg = host->app_cmd_arg;
+ }
+ cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
+
+ memset(&mrq, 0, sizeof(struct mmc_request));
+ mrq.cmd = &cmd; cmd.mrq = &mrq;
+ cmd.data = NULL;
+
+ err = msdc_do_command(host, &cmd, 1, CMD_TIMEOUT);
+
+ if (status)
+ *status = cmd.resp[0];
+
+ return err;
}
static int msdc_check_busy(struct mmc_host *mmc, struct msdc_host *host)
{
- u32 err = 0;
- u32 status = 0;
-
- do {
- err = msdc_get_card_status(mmc, host, &status);
- if (err) return err;
- /* need cmd12? */
- ERR_MSG("cmd<13> resp<0x%x>", status);
- } while (R1_CURRENT_STATE(status) == 7);
-
- return err;
+ u32 err = 0;
+ u32 status = 0;
+
+ do {
+ err = msdc_get_card_status(mmc, host, &status);
+ if (err)
+ return err;
+ /* need cmd12? */
+ ERR_MSG("cmd<13> resp<0x%x>", status);
+ } while (R1_CURRENT_STATE(status) == 7);
+
+ return err;
}
/* failed when msdc_do_request */
static int msdc_tune_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
- struct msdc_host *host = mmc_priv(mmc);
- struct mmc_command *cmd;
- struct mmc_data *data;
- //u32 base = host->base;
- int ret=0, read;
-
- cmd = mrq->cmd;
- data = mrq->cmd->data;
-
- read = data->flags & MMC_DATA_READ ? 1 : 0;
-
- if (read) {
- if (data->error == (unsigned int)(-EIO)) {
- ret = msdc_tune_bread(mmc,mrq);
- }
- } else {
- ret = msdc_check_busy(mmc, host);
- if (ret){
- ERR_MSG("XXX cmd13 wait program done failed");
- return ret;
- }
- /* CRC and TO */
- /* Fix me: don't care card status? */
- ret = msdc_tune_bwrite(mmc,mrq);
- }
-
- return ret;
+ struct msdc_host *host = mmc_priv(mmc);
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+ //u32 base = host->base;
+ int ret = 0, read;
+
+ cmd = mrq->cmd;
+ data = mrq->cmd->data;
+
+ read = data->flags & MMC_DATA_READ ? 1 : 0;
+
+ if (read) {
+ if (data->error == -EIO)
+ ret = msdc_tune_bread(mmc, mrq);
+ } else {
+ ret = msdc_check_busy(mmc, host);
+ if (ret) {
+ ERR_MSG("XXX cmd13 wait program done failed");
+ return ret;
+ }
+ /* CRC and TO */
+ /* Fix me: don't care card status? */
+ ret = msdc_tune_bwrite(mmc, mrq);
+ }
+
+ return ret;
}
/* ops.request */
-static void msdc_ops_request(struct mmc_host *mmc,struct mmc_request *mrq)
-{
- struct msdc_host *host = mmc_priv(mmc);
+static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+ struct msdc_host *host = mmc_priv(mmc);
- //=== for sdio profile ===
+ //=== for sdio profile ===
#if 0 /* --- by chhung */
- u32 old_H32, old_L32, new_H32, new_L32;
- u32 ticks = 0, opcode = 0, sizes = 0, bRx = 0;
+ u32 old_H32, old_L32, new_H32, new_L32;
+ u32 ticks = 0, opcode = 0, sizes = 0, bRx = 0;
#endif /* end of --- */
-
- if(host->mrq){
- ERR_MSG("XXX host->mrq<0x%.8x>", (int)host->mrq);
- BUG();
- }
-
- if (!is_card_present(host) || host->power_mode == MMC_POWER_OFF) {
- ERR_MSG("cmd<%d> card<%d> power<%d>", mrq->cmd->opcode, is_card_present(host), host->power_mode);
- mrq->cmd->error = (unsigned int)-ENOMEDIUM;
-
-#if 1
- mrq->done(mrq); // call done directly.
-#else
- mrq->cmd->retries = 0; // please don't retry.
- mmc_request_done(mmc, mrq);
-#endif
- return;
- }
-
- /* start to process */
- spin_lock(&host->lock);
+ WARN_ON(host->mrq);
+
+ /* start to process */
+ spin_lock(&host->lock);
#if 0 /* --- by chhung */
- if (sdio_pro_enable) { //=== for sdio profile ===
- if (mrq->cmd->opcode == 52 || mrq->cmd->opcode == 53) {
- GPT_GetCounter64(&old_L32, &old_H32);
- }
- }
+ if (sdio_pro_enable) { //=== for sdio profile ===
+ if (mrq->cmd->opcode == 52 || mrq->cmd->opcode == 53)
+ GPT_GetCounter64(&old_L32, &old_H32);
+ }
#endif /* end of --- */
-
- host->mrq = mrq;
-
- if (msdc_do_request(mmc,mrq)) {
- if(host->hw->flags & MSDC_REMOVABLE && ralink_soc == MT762X_SOC_MT7621AT && mrq->data && mrq->data->error) {
- msdc_tune_request(mmc,mrq);
- }
- }
-
- /* ==== when request done, check if app_cmd ==== */
- if (mrq->cmd->opcode == MMC_APP_CMD) {
- host->app_cmd = 1;
- host->app_cmd_arg = mrq->cmd->arg; /* save the RCA */
- } else {
- host->app_cmd = 0;
- //host->app_cmd_arg = 0;
- }
-
- host->mrq = NULL;
+
+ host->mrq = mrq;
+
+ if (msdc_do_request(mmc, mrq)) {
+ if (host->hw->flags & MSDC_REMOVABLE && ralink_soc == MT762X_SOC_MT7621AT && mrq->data && mrq->data->error)
+ msdc_tune_request(mmc, mrq);
+ }
+
+ /* ==== when request done, check if app_cmd ==== */
+ if (mrq->cmd->opcode == MMC_APP_CMD) {
+ host->app_cmd = 1;
+ host->app_cmd_arg = mrq->cmd->arg; /* save the RCA */
+ } else {
+ host->app_cmd = 0;
+ //host->app_cmd_arg = 0;
+ }
+
+ host->mrq = NULL;
#if 0 /* --- by chhung */
- //=== for sdio profile ===
- if (sdio_pro_enable) {
- if (mrq->cmd->opcode == 52 || mrq->cmd->opcode == 53) {
- GPT_GetCounter64(&new_L32, &new_H32);
- ticks = msdc_time_calc(old_L32, old_H32, new_L32, new_H32);
-
- opcode = mrq->cmd->opcode;
- if (mrq->cmd->data) {
- sizes = mrq->cmd->data->blocks * mrq->cmd->data->blksz;
- bRx = mrq->cmd->data->flags & MMC_DATA_READ ? 1 : 0 ;
- } else {
- bRx = mrq->cmd->arg & 0x80000000 ? 1 : 0;
- }
-
- if (!mrq->cmd->error) {
- msdc_performance(opcode, sizes, bRx, ticks);
- }
- }
- }
+ //=== for sdio profile ===
+ if (sdio_pro_enable) {
+ if (mrq->cmd->opcode == 52 || mrq->cmd->opcode == 53) {
+ GPT_GetCounter64(&new_L32, &new_H32);
+ ticks = msdc_time_calc(old_L32, old_H32, new_L32, new_H32);
+
+ opcode = mrq->cmd->opcode;
+ if (mrq->cmd->data) {
+ sizes = mrq->cmd->data->blocks * mrq->cmd->data->blksz;
+ bRx = mrq->cmd->data->flags & MMC_DATA_READ ? 1 : 0;
+ } else {
+ bRx = mrq->cmd->arg & 0x80000000 ? 1 : 0;
+ }
+
+ if (!mrq->cmd->error)
+ msdc_performance(opcode, sizes, bRx, ticks);
+ }
+ }
#endif /* end of --- */
- spin_unlock(&host->lock);
-
- mmc_request_done(mmc, mrq);
-
- return;
+ spin_unlock(&host->lock);
+
+ mmc_request_done(mmc, mrq);
+
+ return;
}
/* called by ops.set_ios */
static void msdc_set_buswidth(struct msdc_host *host, u32 width)
{
- u32 base = host->base;
- u32 val = sdr_read32(SDC_CFG);
-
- val &= ~SDC_CFG_BUSWIDTH;
-
- switch (width) {
- default:
- case MMC_BUS_WIDTH_1:
- width = 1;
- val |= (MSDC_BUS_1BITS << 16);
- break;
- case MMC_BUS_WIDTH_4:
- val |= (MSDC_BUS_4BITS << 16);
- break;
- case MMC_BUS_WIDTH_8:
- val |= (MSDC_BUS_8BITS << 16);
- break;
- }
-
- sdr_write32(SDC_CFG, val);
-
- N_MSG(CFG, "Bus Width = %d", width);
+ void __iomem *base = host->base;
+ u32 val = sdr_read32(SDC_CFG);
+
+ val &= ~SDC_CFG_BUSWIDTH;
+
+ switch (width) {
+ default:
+ case MMC_BUS_WIDTH_1:
+ width = 1;
+ val |= (MSDC_BUS_1BITS << 16);
+ break;
+ case MMC_BUS_WIDTH_4:
+ val |= (MSDC_BUS_4BITS << 16);
+ break;
+ case MMC_BUS_WIDTH_8:
+ val |= (MSDC_BUS_8BITS << 16);
+ break;
+ }
+
+ sdr_write32(SDC_CFG, val);
+
+ N_MSG(CFG, "Bus Width = %d", width);
}
/* ops.set_ios */
static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
- struct msdc_host *host = mmc_priv(mmc);
- struct msdc_hw *hw=host->hw;
- u32 base = host->base;
- u32 ddr = 0;
+ struct msdc_host *host = mmc_priv(mmc);
+ void __iomem *base = host->base;
+ u32 ddr = 0;
#ifdef MT6575_SD_DEBUG
- static char *vdd[] = {
- "1.50v", "1.55v", "1.60v", "1.65v", "1.70v", "1.80v", "1.90v",
- "2.00v", "2.10v", "2.20v", "2.30v", "2.40v", "2.50v", "2.60v",
- "2.70v", "2.80v", "2.90v", "3.00v", "3.10v", "3.20v", "3.30v",
- "3.40v", "3.50v", "3.60v"
- };
- static char *power_mode[] = {
- "OFF", "UP", "ON"
- };
- static char *bus_mode[] = {
- "UNKNOWN", "OPENDRAIN", "PUSHPULL"
- };
- static char *timing[] = {
- "LEGACY", "MMC_HS", "SD_HS"
- };
-
- printk("SET_IOS: CLK(%dkHz), BUS(%s), BW(%u), PWR(%s), VDD(%s), TIMING(%s)",
- ios->clock / 1000, bus_mode[ios->bus_mode],
- (ios->bus_width == MMC_BUS_WIDTH_4) ? 4 : 1,
- power_mode[ios->power_mode], vdd[ios->vdd], timing[ios->timing]);
+ static char *vdd[] = {
+ "1.50v", "1.55v", "1.60v", "1.65v", "1.70v", "1.80v", "1.90v",
+ "2.00v", "2.10v", "2.20v", "2.30v", "2.40v", "2.50v", "2.60v",
+ "2.70v", "2.80v", "2.90v", "3.00v", "3.10v", "3.20v", "3.30v",
+ "3.40v", "3.50v", "3.60v"
+ };
+ static char *power_mode[] = {
+ "OFF", "UP", "ON"
+ };
+ static char *bus_mode[] = {
+ "UNKNOWN", "OPENDRAIN", "PUSHPULL"
+ };
+ static char *timing[] = {
+ "LEGACY", "MMC_HS", "SD_HS"
+ };
+
+ printk("SET_IOS: CLK(%dkHz), BUS(%s), BW(%u), PWR(%s), VDD(%s), TIMING(%s)",
+ ios->clock / 1000, bus_mode[ios->bus_mode],
+ (ios->bus_width == MMC_BUS_WIDTH_4) ? 4 : 1,
+ power_mode[ios->power_mode], vdd[ios->vdd], timing[ios->timing]);
#endif
- msdc_set_buswidth(host, ios->bus_width);
-
- /* Power control ??? */
- switch (ios->power_mode) {
- case MMC_POWER_OFF:
- case MMC_POWER_UP:
- // msdc_set_power_mode(host, ios->power_mode); /* --- by chhung */
- break;
- case MMC_POWER_ON:
- host->power_mode = MMC_POWER_ON;
- break;
- default:
- break;
- }
-
- /* Clock control */
- if (host->mclk != ios->clock) {
- if(ios->clock > 25000000) {
- //if (!(host->hw->flags & MSDC_REMOVABLE)) {
- INIT_MSG("SD data latch edge<%d>", hw->data_edge);
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL, hw->cmd_edge);
- sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, hw->data_edge);
- //} /* for tuning debug */
- } else { /* default value */
- sdr_write32(MSDC_IOCON, 0x00000000);
- // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000);
- sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward
- sdr_write32(MSDC_DAT_RDDLY1, 0x00000000);
- // sdr_write32(MSDC_PAD_TUNE, 0x00000000);
- sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward
- }
- msdc_set_mclk(host, ddr, ios->clock);
- }
+ msdc_set_buswidth(host, ios->bus_width);
+
+ /* Power control ??? */
+ switch (ios->power_mode) {
+ case MMC_POWER_OFF:
+ case MMC_POWER_UP:
+ // msdc_set_power_mode(host, ios->power_mode); /* --- by chhung */
+ break;
+ case MMC_POWER_ON:
+ host->power_mode = MMC_POWER_ON;
+ break;
+ default:
+ break;
+ }
+
+ /* Clock control */
+ if (host->mclk != ios->clock) {
+ if (ios->clock > 25000000) {
+ //if (!(host->hw->flags & MSDC_REMOVABLE)) {
+ INIT_MSG("SD data latch edge<%d>", MSDC_SMPL_FALLING);
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL,
+ MSDC_SMPL_FALLING);
+ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL,
+ MSDC_SMPL_FALLING);
+ //} /* for tuning debug */
+ } else { /* default value */
+ sdr_write32(MSDC_IOCON, 0x00000000);
+ // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000);
+ sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward
+ sdr_write32(MSDC_DAT_RDDLY1, 0x00000000);
+ // sdr_write32(MSDC_PAD_TUNE, 0x00000000);
+ sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward
+ }
+ msdc_set_mclk(host, ddr, ios->clock);
+ }
}
/* ops.get_ro */
static int msdc_ops_get_ro(struct mmc_host *mmc)
{
- struct msdc_host *host = mmc_priv(mmc);
- u32 base = host->base;
- unsigned long flags;
- int ro = 0;
-
- if (host->hw->flags & MSDC_WP_PIN_EN) { /* set for card */
- spin_lock_irqsave(&host->lock, flags);
- ro = (sdr_read32(MSDC_PS) >> 31);
- spin_unlock_irqrestore(&host->lock, flags);
- }
- return ro;
+ struct msdc_host *host = mmc_priv(mmc);
+ void __iomem *base = host->base;
+ unsigned long flags;
+ int ro = 0;
+
+ if (host->hw->flags & MSDC_WP_PIN_EN) { /* set for card */
+ spin_lock_irqsave(&host->lock, flags);
+ ro = (sdr_read32(MSDC_PS) >> 31);
+ spin_unlock_irqrestore(&host->lock, flags);
+ }
+ return ro;
}
/* ops.get_cd */
static int msdc_ops_get_cd(struct mmc_host *mmc)
{
- struct msdc_host *host = mmc_priv(mmc);
- u32 base = host->base;
- unsigned long flags;
- int present = 1;
-
- /* for sdio, MSDC_REMOVABLE not set, always return 1 */
- if (!(host->hw->flags & MSDC_REMOVABLE)) {
- /* For sdio, read H/W always get<1>, but may timeout some times */
+ struct msdc_host *host = mmc_priv(mmc);
+ void __iomem *base = host->base;
+ unsigned long flags;
+ int present = 1;
+
+ /* for sdio, MSDC_REMOVABLE not set, always return 1 */
+ if (!(host->hw->flags & MSDC_REMOVABLE)) {
+ /* For sdio, read H/W always get<1>, but may timeout some times */
#if 1
- host->card_inserted = 1;
- return 1;
+ host->card_inserted = 1;
+ return 1;
#else
- host->card_inserted = (host->pm_state.event == PM_EVENT_USER_RESUME) ? 1 : 0;
- INIT_MSG("sdio ops_get_cd<%d>", host->card_inserted);
- return host->card_inserted;
+ host->card_inserted = (host->pm_state.event == PM_EVENT_USER_RESUME) ? 1 : 0;
+ INIT_MSG("sdio ops_get_cd<%d>", host->card_inserted);
+ return host->card_inserted;
#endif
- }
+ }
- /* MSDC_CD_PIN_EN set for card */
- if (host->hw->flags & MSDC_CD_PIN_EN) {
- spin_lock_irqsave(&host->lock, flags);
-#if 0
- present = host->card_inserted; /* why not read from H/W: Fix me*/
+ /* MSDC_CD_PIN_EN set for card */
+ if (host->hw->flags & MSDC_CD_PIN_EN) {
+ spin_lock_irqsave(&host->lock, flags);
+#if 0
+ present = host->card_inserted; /* why not read from H/W: Fix me*/
#else
- // CD
- if (cd_active_low)
- present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1;
- else
- present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0;
- host->card_inserted = present;
-#endif
- spin_unlock_irqrestore(&host->lock, flags);
- } else {
- present = 0; /* TODO? Check DAT3 pins for card detection */
- }
-
- INIT_MSG("ops_get_cd return<%d>", present);
- return present;
-}
+ // CD
+ if (cd_active_low)
+ present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1;
+ else
+ present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0;
+ host->card_inserted = present;
+#endif
+ spin_unlock_irqrestore(&host->lock, flags);
+ } else {
+ present = 0; /* TODO? Check DAT3 pins for card detection */
+ }
-/* ops.enable_sdio_irq */
-static void msdc_ops_enable_sdio_irq(struct mmc_host *mmc, int enable)
-{
- struct msdc_host *host = mmc_priv(mmc);
- struct msdc_hw *hw = host->hw;
- u32 base = host->base;
- u32 tmp;
-
- if (hw->flags & MSDC_EXT_SDIO_IRQ) { /* yes for sdio */
- if (enable) {
- hw->enable_sdio_eirq(); /* combo_sdio_enable_eirq */
- } else {
- hw->disable_sdio_eirq(); /* combo_sdio_disable_eirq */
- }
- } else {
- ERR_MSG("XXX "); /* so never enter here */
- tmp = sdr_read32(SDC_CFG);
- /* FIXME. Need to interrupt gap detection */
- if (enable) {
- tmp |= (SDC_CFG_SDIOIDE | SDC_CFG_SDIOINTWKUP);
- } else {
- tmp &= ~(SDC_CFG_SDIOIDE | SDC_CFG_SDIOINTWKUP);
- }
- sdr_write32(SDC_CFG, tmp);
- }
+ INIT_MSG("ops_get_cd return<%d>", present);
+ return present;
}
static struct mmc_host_ops mt_msdc_ops = {
- .request = msdc_ops_request,
- .set_ios = msdc_ops_set_ios,
- .get_ro = msdc_ops_get_ro,
- .get_cd = msdc_ops_get_cd,
- .enable_sdio_irq = msdc_ops_enable_sdio_irq,
+ .request = msdc_ops_request,
+ .set_ios = msdc_ops_set_ios,
+ .get_ro = msdc_ops_get_ro,
+ .get_cd = msdc_ops_get_cd,
};
/*--------------------------------------------------------------------------*/
@@ -2383,150 +1879,135 @@ static struct mmc_host_ops mt_msdc_ops = {
/*--------------------------------------------------------------------------*/
static irqreturn_t msdc_irq(int irq, void *dev_id)
{
- struct msdc_host *host = (struct msdc_host *)dev_id;
- struct mmc_data *data = host->data;
- struct mmc_command *cmd = host->cmd;
- u32 base = host->base;
-
- u32 cmdsts = MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | MSDC_INT_CMDRDY |
- MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | MSDC_INT_ACMDRDY |
- MSDC_INT_ACMD19_DONE;
- u32 datsts = MSDC_INT_DATCRCERR |MSDC_INT_DATTMO;
-
- u32 intsts = sdr_read32(MSDC_INT);
- u32 inten = sdr_read32(MSDC_INTEN); inten &= intsts;
-
- sdr_write32(MSDC_INT, intsts); /* clear interrupts */
- /* MSG will cause fatal error */
-
- /* card change interrupt */
- if (intsts & MSDC_INT_CDSC){
- if (mtk_sw_poll)
- return IRQ_HANDLED;
- IRQ_MSG("MSDC_INT_CDSC irq<0x%.8x>", intsts);
-#if 0 /* ---/+++ by chhung: fix slot mechanical bounce issue */
- tasklet_hi_schedule(&host->card_tasklet);
-#else
- schedule_delayed_work(&host->card_delaywork, HZ);
-#endif
- /* tuning when plug card ? */
- }
-
- /* sdio interrupt */
- if (intsts & MSDC_INT_SDIOIRQ){
- IRQ_MSG("XXX MSDC_INT_SDIOIRQ"); /* seems not sdio irq */
- //mmc_signal_sdio_irq(host->mmc);
- }
-
- /* transfer complete interrupt */
- if (data != NULL) {
- if (inten & MSDC_INT_XFER_COMPL) {
- data->bytes_xfered = host->dma.xfersz;
- complete(&host->xfer_done);
- }
-
- if (intsts & datsts) {
- /* do basic reset, or stop command will sdc_busy */
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
- atomic_set(&host->abort, 1); /* For PIO mode exit */
-
- if (intsts & MSDC_INT_DATTMO){
- IRQ_MSG("XXX CMD<%d> MSDC_INT_DATTMO", host->mrq->cmd->opcode);
- data->error = (unsigned int)-ETIMEDOUT;
- }
- else if (intsts & MSDC_INT_DATCRCERR){
- IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, sdr_read32(SDC_DCRC_STS));
- data->error = (unsigned int)-EIO;
- }
-
- //if(sdr_read32(MSDC_INTEN) & MSDC_INT_XFER_COMPL) {
- if (host->dma_xfer) {
- complete(&host->xfer_done); /* Read CRC come fast, XFER_COMPL not enabled */
- } /* PIO mode can't do complete, because not init */
- }
- }
-
- /* command interrupts */
- if ((cmd != NULL) && (intsts & cmdsts)) {
- if ((intsts & MSDC_INT_CMDRDY) || (intsts & MSDC_INT_ACMDRDY) ||
- (intsts & MSDC_INT_ACMD19_DONE)) {
- u32 *rsp = &cmd->resp[0];
-
- switch (host->cmd_rsp) {
- case RESP_NONE:
- break;
- case RESP_R2:
- *rsp++ = sdr_read32(SDC_RESP3); *rsp++ = sdr_read32(SDC_RESP2);
- *rsp++ = sdr_read32(SDC_RESP1); *rsp++ = sdr_read32(SDC_RESP0);
- break;
- default: /* Response types 1, 3, 4, 5, 6, 7(1b) */
- if ((intsts & MSDC_INT_ACMDRDY) || (intsts & MSDC_INT_ACMD19_DONE)) {
- *rsp = sdr_read32(SDC_ACMD_RESP);
- } else {
- *rsp = sdr_read32(SDC_RESP0);
- }
- break;
- }
- } else if ((intsts & MSDC_INT_RSPCRCERR) || (intsts & MSDC_INT_ACMDCRCERR)) {
- if(intsts & MSDC_INT_ACMDCRCERR){
- IRQ_MSG("XXX CMD<%d> MSDC_INT_ACMDCRCERR",cmd->opcode);
- }
- else {
- IRQ_MSG("XXX CMD<%d> MSDC_INT_RSPCRCERR",cmd->opcode);
- }
- cmd->error = (unsigned int)-EIO;
- } else if ((intsts & MSDC_INT_CMDTMO) || (intsts & MSDC_INT_ACMDTMO)) {
- if(intsts & MSDC_INT_ACMDTMO){
- IRQ_MSG("XXX CMD<%d> MSDC_INT_ACMDTMO",cmd->opcode);
- }
- else {
- IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO",cmd->opcode);
- }
- cmd->error = (unsigned int)-ETIMEDOUT;
- msdc_reset();
- msdc_clr_fifo();
- msdc_clr_int();
- }
- complete(&host->cmd_done);
- }
-
- /* mmc irq interrupts */
- if (intsts & MSDC_INT_MMCIRQ) {
- printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, sdr_read32(SDC_CSTS));
- }
-
+ struct msdc_host *host = (struct msdc_host *)dev_id;
+ struct mmc_data *data = host->data;
+ struct mmc_command *cmd = host->cmd;
+ void __iomem *base = host->base;
+
+ u32 cmdsts = MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | MSDC_INT_CMDRDY |
+ MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | MSDC_INT_ACMDRDY |
+ MSDC_INT_ACMD19_DONE;
+ u32 datsts = MSDC_INT_DATCRCERR | MSDC_INT_DATTMO;
+
+ u32 intsts = sdr_read32(MSDC_INT);
+ u32 inten = sdr_read32(MSDC_INTEN); inten &= intsts;
+
+ sdr_write32(MSDC_INT, intsts); /* clear interrupts */
+ /* MSG will cause fatal error */
+
+ /* card change interrupt */
+ if (intsts & MSDC_INT_CDSC) {
+ if (host->mmc->caps & MMC_CAP_NEEDS_POLL)
+ return IRQ_HANDLED;
+ IRQ_MSG("MSDC_INT_CDSC irq<0x%.8x>", intsts);
+ schedule_delayed_work(&host->card_delaywork, HZ);
+ /* tuning when plug card ? */
+ }
+
+ /* sdio interrupt */
+ if (intsts & MSDC_INT_SDIOIRQ) {
+ IRQ_MSG("XXX MSDC_INT_SDIOIRQ"); /* seems not sdio irq */
+ //mmc_signal_sdio_irq(host->mmc);
+ }
+
+ /* transfer complete interrupt */
+ if (data != NULL) {
+ if (inten & MSDC_INT_XFER_COMPL) {
+ data->bytes_xfered = host->xfer_size;
+ complete(&host->xfer_done);
+ }
+
+ if (intsts & datsts) {
+ /* do basic reset, or stop command will sdc_busy */
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+ msdc_clr_int();
+
+ if (intsts & MSDC_INT_DATTMO) {
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_DATTMO", host->mrq->cmd->opcode);
+ data->error = -ETIMEDOUT;
+ } else if (intsts & MSDC_INT_DATCRCERR) {
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, sdr_read32(SDC_DCRC_STS));
+ data->error = -EIO;
+ }
+
+ //if(sdr_read32(MSDC_INTEN) & MSDC_INT_XFER_COMPL) {
+ complete(&host->xfer_done); /* Read CRC come fast, XFER_COMPL not enabled */
+ }
+ }
+
+ /* command interrupts */
+ if ((cmd != NULL) && (intsts & cmdsts)) {
+ if ((intsts & MSDC_INT_CMDRDY) || (intsts & MSDC_INT_ACMDRDY) ||
+ (intsts & MSDC_INT_ACMD19_DONE)) {
+ u32 *rsp = &cmd->resp[0];
+
+ switch (host->cmd_rsp) {
+ case RESP_NONE:
+ break;
+ case RESP_R2:
+ *rsp++ = sdr_read32(SDC_RESP3); *rsp++ = sdr_read32(SDC_RESP2);
+ *rsp++ = sdr_read32(SDC_RESP1); *rsp++ = sdr_read32(SDC_RESP0);
+ break;
+ default: /* Response types 1, 3, 4, 5, 6, 7(1b) */
+ if ((intsts & MSDC_INT_ACMDRDY) || (intsts & MSDC_INT_ACMD19_DONE))
+ *rsp = sdr_read32(SDC_ACMD_RESP);
+ else
+ *rsp = sdr_read32(SDC_RESP0);
+ break;
+ }
+ } else if ((intsts & MSDC_INT_RSPCRCERR) || (intsts & MSDC_INT_ACMDCRCERR)) {
+ if (intsts & MSDC_INT_ACMDCRCERR)
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_ACMDCRCERR", cmd->opcode);
+ else
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_RSPCRCERR", cmd->opcode);
+ cmd->error = -EIO;
+ } else if ((intsts & MSDC_INT_CMDTMO) || (intsts & MSDC_INT_ACMDTMO)) {
+ if (intsts & MSDC_INT_ACMDTMO)
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_ACMDTMO", cmd->opcode);
+ else
+ IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", cmd->opcode);
+ cmd->error = -ETIMEDOUT;
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+ msdc_clr_int();
+ }
+ complete(&host->cmd_done);
+ }
+
+ /* mmc irq interrupts */
+ if (intsts & MSDC_INT_MMCIRQ)
+ printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, sdr_read32(SDC_CSTS));
+
#ifdef MT6575_SD_DEBUG
- {
+ {
/* msdc_int_reg *int_reg = (msdc_int_reg*)&intsts;*/
- N_MSG(INT, "IRQ_EVT(0x%x): MMCIRQ(%d) CDSC(%d), ACRDY(%d), ACTMO(%d), ACCRE(%d) AC19DN(%d)",
- intsts,
- int_reg->mmcirq,
- int_reg->cdsc,
- int_reg->atocmdrdy,
- int_reg->atocmdtmo,
- int_reg->atocmdcrc,
- int_reg->atocmd19done);
- N_MSG(INT, "IRQ_EVT(0x%x): SDIO(%d) CMDRDY(%d), CMDTMO(%d), RSPCRC(%d), CSTA(%d)",
- intsts,
- int_reg->sdioirq,
- int_reg->cmdrdy,
- int_reg->cmdtmo,
- int_reg->rspcrc,
- int_reg->csta);
- N_MSG(INT, "IRQ_EVT(0x%x): XFCMP(%d) DXDONE(%d), DATTMO(%d), DATCRC(%d), DMAEMP(%d)",
- intsts,
- int_reg->xfercomp,
- int_reg->dxferdone,
- int_reg->dattmo,
- int_reg->datcrc,
- int_reg->dmaqempty);
-
- }
+ N_MSG(INT, "IRQ_EVT(0x%x): MMCIRQ(%d) CDSC(%d), ACRDY(%d), ACTMO(%d), ACCRE(%d) AC19DN(%d)",
+ intsts,
+ int_reg->mmcirq,
+ int_reg->cdsc,
+ int_reg->atocmdrdy,
+ int_reg->atocmdtmo,
+ int_reg->atocmdcrc,
+ int_reg->atocmd19done);
+ N_MSG(INT, "IRQ_EVT(0x%x): SDIO(%d) CMDRDY(%d), CMDTMO(%d), RSPCRC(%d), CSTA(%d)",
+ intsts,
+ int_reg->sdioirq,
+ int_reg->cmdrdy,
+ int_reg->cmdtmo,
+ int_reg->rspcrc,
+ int_reg->csta);
+ N_MSG(INT, "IRQ_EVT(0x%x): XFCMP(%d) DXDONE(%d), DATTMO(%d), DATCRC(%d), DMAEMP(%d)",
+ intsts,
+ int_reg->xfercomp,
+ int_reg->dxferdone,
+ int_reg->dattmo,
+ int_reg->datcrc,
+ int_reg->dmaqempty);
+ }
#endif
-
- return IRQ_HANDLED;
+
+ return IRQ_HANDLED;
}
/*--------------------------------------------------------------------------*/
@@ -2536,450 +2017,386 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
static void msdc_enable_cd_irq(struct msdc_host *host, int enable)
{
struct msdc_hw *hw = host->hw;
- u32 base = host->base;
+ void __iomem *base = host->base;
/* for sdio, not set */
if ((hw->flags & MSDC_CD_PIN_EN) == 0) {
/* Pull down card detection pin since it is not avaiable */
/*
- if (hw->config_gpio_pin)
- hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN);
- */
+ if (hw->config_gpio_pin)
+ hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN);
+ */
sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
sdr_clr_bits(MSDC_INTEN, MSDC_INTEN_CDSC);
sdr_clr_bits(SDC_CFG, SDC_CFG_INSWKUP);
return;
}
- N_MSG(CFG, "CD IRQ Eanable(%d)", enable);
+ N_MSG(CFG, "CD IRQ Enable(%d)", enable);
if (enable) {
- if (hw->enable_cd_eirq) { /* not set, never enter */
- hw->enable_cd_eirq();
- } else {
- /* card detection circuit relies on the core power so that the core power
- * shouldn't be turned off. Here adds a reference count to keep
- * the core power alive.
- */
- //msdc_vcore_on(host); //did in msdc_init_hw()
-
- if (hw->config_gpio_pin) /* NULL */
- hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_UP);
-
- sdr_set_field(MSDC_PS, MSDC_PS_CDDEBOUNCE, DEFAULT_DEBOUNCE);
- sdr_set_bits(MSDC_PS, MSDC_PS_CDEN);
- sdr_set_bits(MSDC_INTEN, MSDC_INTEN_CDSC);
- sdr_set_bits(SDC_CFG, SDC_CFG_INSWKUP); /* not in document! Fix me */
- }
- } else {
- if (hw->disable_cd_eirq) {
- hw->disable_cd_eirq();
- } else {
- if (hw->config_gpio_pin) /* NULL */
- hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN);
-
- sdr_clr_bits(SDC_CFG, SDC_CFG_INSWKUP);
- sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
- sdr_clr_bits(MSDC_INTEN, MSDC_INTEN_CDSC);
-
- /* Here decreases a reference count to core power since card
- * detection circuit is shutdown.
- */
- //msdc_vcore_off(host);
- }
- }
+ /* card detection circuit relies on the core power so that the core power
+ * shouldn't be turned off. Here adds a reference count to keep
+ * the core power alive.
+ */
+ //msdc_vcore_on(host); //did in msdc_init_hw()
+
+ if (hw->config_gpio_pin) /* NULL */
+ hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_UP);
+
+ sdr_set_field(MSDC_PS, MSDC_PS_CDDEBOUNCE, DEFAULT_DEBOUNCE);
+ sdr_set_bits(MSDC_PS, MSDC_PS_CDEN);
+ sdr_set_bits(MSDC_INTEN, MSDC_INTEN_CDSC);
+ sdr_set_bits(SDC_CFG, SDC_CFG_INSWKUP); /* not in document! Fix me */
+ } else {
+ if (hw->config_gpio_pin) /* NULL */
+ hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN);
+
+ sdr_clr_bits(SDC_CFG, SDC_CFG_INSWKUP);
+ sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
+ sdr_clr_bits(MSDC_INTEN, MSDC_INTEN_CDSC);
+
+ /* Here decreases a reference count to core power since card
+ * detection circuit is shutdown.
+ */
+ //msdc_vcore_off(host);
+ }
}
/* called by msdc_drv_probe */
static void msdc_init_hw(struct msdc_host *host)
{
- u32 base = host->base;
- struct msdc_hw *hw = host->hw;
-
-#ifdef MT6575_SD_DEBUG
- msdc_reg[host->id] = (struct msdc_regs *)host->base;
-#endif
+ void __iomem *base = host->base;
- /* Power on */
+ /* Power on */
#if 0 /* --- by chhung */
- msdc_vcore_on(host);
- msdc_pin_reset(host, MSDC_PIN_PULL_UP);
- msdc_select_clksrc(host, hw->clk_src);
- enable_clock(PERI_MSDC0_PDN + host->id, "SD");
- msdc_vdd_on(host);
+ msdc_vcore_on(host);
+ msdc_pin_reset(host, MSDC_PIN_PULL_UP);
+ msdc_select_clksrc(host, hw->clk_src);
+ enable_clock(PERI_MSDC0_PDN + host->id, "SD");
+ msdc_vdd_on(host);
#endif /* end of --- */
- /* Configure to MMC/SD mode */
- sdr_set_field(MSDC_CFG, MSDC_CFG_MODE, MSDC_SDMMC);
-
- /* Reset */
- msdc_reset();
- msdc_clr_fifo();
-
- /* Disable card detection */
- sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
-
- /* Disable and clear all interrupts */
- sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN));
- sdr_write32(MSDC_INT, sdr_read32(MSDC_INT));
-
+ /* Configure to MMC/SD mode */
+ sdr_set_field(MSDC_CFG, MSDC_CFG_MODE, MSDC_SDMMC);
+
+ /* Reset */
+ msdc_reset_hw(host);
+ msdc_clr_fifo();
+
+ /* Disable card detection */
+ sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
+
+ /* Disable and clear all interrupts */
+ sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN));
+ sdr_write32(MSDC_INT, sdr_read32(MSDC_INT));
+
#if 1
/* reset tuning parameter */
- sdr_write32(MSDC_PAD_CTL0, 0x00090000);
- sdr_write32(MSDC_PAD_CTL1, 0x000A0000);
- sdr_write32(MSDC_PAD_CTL2, 0x000A0000);
- // sdr_write32(MSDC_PAD_TUNE, 0x00000000);
- sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward
- // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000);
- sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward
- sdr_write32(MSDC_DAT_RDDLY1, 0x00000000);
- sdr_write32(MSDC_IOCON, 0x00000000);
+ sdr_write32(MSDC_PAD_CTL0, 0x00090000);
+ sdr_write32(MSDC_PAD_CTL1, 0x000A0000);
+ sdr_write32(MSDC_PAD_CTL2, 0x000A0000);
+ // sdr_write32(MSDC_PAD_TUNE, 0x00000000);
+ sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward
+ // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000);
+ sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward
+ sdr_write32(MSDC_DAT_RDDLY1, 0x00000000);
+ sdr_write32(MSDC_IOCON, 0x00000000);
#if 0 // use MT7620 default value: 0x403c004f
- sdr_write32(MSDC_PATCH_BIT0, 0x003C000F); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/
+ sdr_write32(MSDC_PATCH_BIT0, 0x003C000F); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/
+#endif
+
+ if (sdr_read32(MSDC_ECO_VER) >= 4) {
+ if (host->id == 1) {
+ sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_WRDAT_CRCS, 1);
+ sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMD_RSP, 1);
+
+ /* internal clock: latch read data */
+ sdr_set_bits(MSDC_PATCH_BIT0, MSDC_PATCH_BIT_CKGEN_CK);
+ }
+ }
#endif
- if (sdr_read32(MSDC_ECO_VER) >= 4) {
- if (host->id == 1) {
- sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_WRDAT_CRCS, 1);
- sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMD_RSP, 1);
-
- /* internal clock: latch read data */
- sdr_set_bits(MSDC_PATCH_BIT0, MSDC_PATCH_BIT_CKGEN_CK);
- }
- }
-#endif
-
- /* for safety, should clear SDC_CFG.SDIO_INT_DET_EN & set SDC_CFG.SDIO in
- pre-loader,uboot,kernel drivers. and SDC_CFG.SDIO_INT_DET_EN will be only
- set when kernel driver wants to use SDIO bus interrupt */
- /* Configure to enable SDIO mode. it's must otherwise sdio cmd5 failed */
- sdr_set_bits(SDC_CFG, SDC_CFG_SDIO);
-
- /* disable detect SDIO device interupt function */
- sdr_clr_bits(SDC_CFG, SDC_CFG_SDIOIDE);
-
- /* eneable SMT for glitch filter */
- sdr_set_bits(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKSMT);
- sdr_set_bits(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDSMT);
- sdr_set_bits(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATSMT);
+ /* for safety, should clear SDC_CFG.SDIO_INT_DET_EN & set SDC_CFG.SDIO in
+ pre-loader,uboot,kernel drivers. and SDC_CFG.SDIO_INT_DET_EN will be only
+ set when kernel driver wants to use SDIO bus interrupt */
+ /* Configure to enable SDIO mode. it's must otherwise sdio cmd5 failed */
+ sdr_set_bits(SDC_CFG, SDC_CFG_SDIO);
+
+ /* disable detect SDIO device interupt function */
+ sdr_clr_bits(SDC_CFG, SDC_CFG_SDIOIDE);
+
+ /* eneable SMT for glitch filter */
+ sdr_set_bits(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKSMT);
+ sdr_set_bits(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDSMT);
+ sdr_set_bits(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATSMT);
#if 1
- /* set clk, cmd, dat pad driving */
- sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, hw->clk_drv);
- sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, hw->clk_drv);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, hw->cmd_drv);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, hw->cmd_drv);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, hw->dat_drv);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, hw->dat_drv);
-#else
- sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 0);
- sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 0);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 0);
- sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 0);
- sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 0);
+ /* set clk, cmd, dat pad driving */
+ sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 4);
+ sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 4);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 4);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 4);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 4);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 4);
+#else
+ sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 0);
+ sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 0);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 0);
+ sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 0);
+ sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 0);
#endif
- /* set sampling edge */
+ /* set sampling edge */
- /* write crc timeout detection */
- sdr_set_field(MSDC_PATCH_BIT0, 1 << 30, 1);
+ /* write crc timeout detection */
+ sdr_set_field(MSDC_PATCH_BIT0, 1 << 30, 1);
- /* Configure to default data timeout */
- sdr_set_field(SDC_CFG, SDC_CFG_DTOC, DEFAULT_DTOC);
+ /* Configure to default data timeout */
+ sdr_set_field(SDC_CFG, SDC_CFG_DTOC, DEFAULT_DTOC);
- msdc_set_buswidth(host, MMC_BUS_WIDTH_1);
+ msdc_set_buswidth(host, MMC_BUS_WIDTH_1);
- N_MSG(FUC, "init hardware done!");
+ N_MSG(FUC, "init hardware done!");
}
/* called by msdc_drv_remove */
static void msdc_deinit_hw(struct msdc_host *host)
{
- u32 base = host->base;
+ void __iomem *base = host->base;
- /* Disable and clear all interrupts */
- sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN));
- sdr_write32(MSDC_INT, sdr_read32(MSDC_INT));
+ /* Disable and clear all interrupts */
+ sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN));
+ sdr_write32(MSDC_INT, sdr_read32(MSDC_INT));
- /* Disable card detection */
- msdc_enable_cd_irq(host, 0);
- // msdc_set_power_mode(host, MMC_POWER_OFF); /* make sure power down */ /* --- by chhung */
+ /* Disable card detection */
+ msdc_enable_cd_irq(host, 0);
+ // msdc_set_power_mode(host, MMC_POWER_OFF); /* make sure power down */ /* --- by chhung */
}
/* init gpd and bd list in msdc_drv_probe */
static void msdc_init_gpd_bd(struct msdc_host *host, struct msdc_dma *dma)
{
- gpd_t *gpd = dma->gpd;
- bd_t *bd = dma->bd;
- bd_t *ptr, *prev;
-
- /* we just support one gpd */
- int bdlen = MAX_BD_PER_GPD;
-
- /* init the 2 gpd */
- memset(gpd, 0, sizeof(gpd_t) * 2);
- //gpd->next = (void *)virt_to_phys(gpd + 1); /* pointer to a null gpd, bug! kmalloc <-> virt_to_phys */
- //gpd->next = (dma->gpd_addr + 1); /* bug */
- gpd->next = (void *)((u32)dma->gpd_addr + sizeof(gpd_t));
-
- //gpd->intr = 0;
- gpd->bdp = 1; /* hwo, cs, bd pointer */
- //gpd->ptr = (void*)virt_to_phys(bd);
- gpd->ptr = (void *)dma->bd_addr; /* physical address */
-
- memset(bd, 0, sizeof(bd_t) * bdlen);
- ptr = bd + bdlen - 1;
- //ptr->eol = 1; /* 0 or 1 [Fix me]*/
- //ptr->next = 0;
-
- while (ptr != bd) {
- prev = ptr - 1;
- prev->next = (void *)(dma->bd_addr + sizeof(bd_t) *(ptr - bd));
- ptr = prev;
- }
+ struct gpd *gpd = dma->gpd;
+ struct bd *bd = dma->bd;
+ int i;
+
+ /* we just support one gpd, but gpd->next must be set for desc
+ * DMA. That's why we alloc 2 gpd structurs.
+ */
+
+ memset(gpd, 0, sizeof(struct gpd) * 2);
+
+ gpd->bdp = 1; /* hwo, cs, bd pointer */
+ gpd->ptr = (void *)dma->bd_addr; /* physical address */
+ gpd->next = (void *)((u32)dma->gpd_addr + sizeof(struct gpd));
+
+ memset(bd, 0, sizeof(struct bd) * MAX_BD_NUM);
+ for (i = 0; i < (MAX_BD_NUM - 1); i++)
+ bd[i].next = (void *)(dma->bd_addr + sizeof(*bd) * (i + 1));
}
static int msdc_drv_probe(struct platform_device *pdev)
{
- struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- __iomem void *base;
- struct mmc_host *mmc;
- struct resource *mem;
- struct msdc_host *host;
- struct msdc_hw *hw;
- int ret, irq;
-
- pdev->dev.platform_data = &msdc0_hw;
-
- if (of_property_read_bool(pdev->dev.of_node, "mtk,wp-en"))
- msdc0_hw.flags |= MSDC_WP_PIN_EN;
-
- /* Allocate MMC host for this device */
- mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
- if (!mmc) return -ENOMEM;
-
- hw = (struct msdc_hw*)pdev->dev.platform_data;
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- irq = platform_get_irq(pdev, 0);
-
- //BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */
-
- base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(base))
- return PTR_ERR(base);
-
- /* Set host parameters to mmc */
- mmc->ops = &mt_msdc_ops;
- mmc->f_min = HOST_MIN_MCLK;
- mmc->f_max = HOST_MAX_MCLK;
- mmc->ocr_avail = MSDC_OCR_AVAIL;
-
- /* For sd card: MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN | MSDC_REMOVABLE | MSDC_HIGHSPEED,
- For sdio : MSDC_EXT_SDIO_IRQ | MSDC_HIGHSPEED */
- if (hw->flags & MSDC_HIGHSPEED) {
- mmc->caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
- }
- if (hw->data_pins == 4) { /* current data_pins are all 4*/
- mmc->caps |= MMC_CAP_4_BIT_DATA;
- } else if (hw->data_pins == 8) {
- mmc->caps |= MMC_CAP_8_BIT_DATA;
- }
- if ((hw->flags & MSDC_SDIO_IRQ) || (hw->flags & MSDC_EXT_SDIO_IRQ))
- mmc->caps |= MMC_CAP_SDIO_IRQ; /* yes for sdio */
+ struct resource *res;
+ __iomem void *base;
+ struct mmc_host *mmc;
+ struct msdc_host *host;
+ struct msdc_hw *hw;
+ int ret;
+
+ hw = &msdc0_hw;
+
+ if (of_property_read_bool(pdev->dev.of_node, "mtk,wp-en"))
+ msdc0_hw.flags |= MSDC_WP_PIN_EN;
+
+ /* Allocate MMC host for this device */
+ mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
+ if (!mmc)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(base)) {
+ ret = PTR_ERR(base);
+ goto host_free;
+ }
+
+ /* Set host parameters to mmc */
+ mmc->ops = &mt_msdc_ops;
+ mmc->f_min = HOST_MIN_MCLK;
+ mmc->f_max = HOST_MAX_MCLK;
+ mmc->ocr_avail = MSDC_OCR_AVAIL;
+
+ mmc->caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
+
+ //TODO: read this as bus-width from dt (via mmc_of_parse)
+ mmc->caps |= MMC_CAP_4_BIT_DATA;
cd_active_low = !of_property_read_bool(pdev->dev.of_node, "mediatek,cd-high");
- mtk_sw_poll = of_property_read_bool(pdev->dev.of_node, "mediatek,cd-poll");
- if (mtk_sw_poll)
+ if (of_property_read_bool(pdev->dev.of_node, "mediatek,cd-poll"))
mmc->caps |= MMC_CAP_NEEDS_POLL;
- /* MMC core transfer sizes tunable parameters */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(3,10,0)
- mmc->max_segs = MAX_HW_SGMTS;
-#else
- mmc->max_hw_segs = MAX_HW_SGMTS;
- mmc->max_phys_segs = MAX_PHY_SGMTS;
-#endif
- mmc->max_seg_size = MAX_SGMT_SZ;
- mmc->max_blk_size = HOST_MAX_BLKSZ;
- mmc->max_req_size = MAX_REQ_SZ;
- mmc->max_blk_count = mmc->max_req_size;
-
- host = mmc_priv(mmc);
- host->hw = hw;
- host->mmc = mmc;
- host->id = pdev->id;
- if (host->id < 0 || host->id >= 4)
- host->id = 0;
- host->error = 0;
- host->irq = irq;
- host->base = (unsigned long) base;
- host->mclk = 0; /* mclk: the request clock of mmc sub-system */
- host->hclk = hclks[hw->clk_src]; /* hclk: clock of clock source to msdc controller */
- host->sclk = 0; /* sclk: the really clock after divition */
- host->pm_state = PMSG_RESUME;
- host->suspend = 0;
- host->core_clkon = 0;
- host->card_clkon = 0;
- host->core_power = 0;
- host->power_mode = MMC_POWER_OFF;
-// host->card_inserted = hw->flags & MSDC_REMOVABLE ? 0 : 1;
- host->timeout_ns = 0;
- host->timeout_clks = DEFAULT_DTOC * 65536;
-
- host->mrq = NULL;
- //init_MUTEX(&host->sem); /* we don't need to support multiple threads access */
-
- host->dma.used_gpd = 0;
- host->dma.used_bd = 0;
- mmc_dev(mmc)->dma_mask = NULL;
-
- /* using dma_alloc_coherent*/ /* todo: using 1, for all 4 slots */
- host->dma.gpd = dma_alloc_coherent(NULL, MAX_GPD_NUM * sizeof(gpd_t), &host->dma.gpd_addr, GFP_KERNEL);
- host->dma.bd = dma_alloc_coherent(NULL, MAX_BD_NUM * sizeof(bd_t), &host->dma.bd_addr, GFP_KERNEL);
- BUG_ON((!host->dma.gpd) || (!host->dma.bd));
- msdc_init_gpd_bd(host, &host->dma);
- /*for emmc*/
- msdc_6575_host[pdev->id] = host;
-
-#if 0
- tasklet_init(&host->card_tasklet, msdc_tasklet_card, (ulong)host);
-#else
- INIT_DELAYED_WORK(&host->card_delaywork, msdc_tasklet_card);
-#endif
- spin_lock_init(&host->lock);
- msdc_init_hw(host);
-
- if (ralink_soc == MT762X_SOC_MT7621AT)
- ret = request_irq((unsigned int)irq, msdc_irq, 0, dev_name(&pdev->dev), host);
- else
- ret = request_irq((unsigned int)irq, msdc_irq, IRQF_TRIGGER_LOW, dev_name(&pdev->dev), host);
-
- if (ret) goto release;
- // mt65xx_irq_unmask(irq); /* --- by chhung */
-
- if (hw->flags & MSDC_CD_PIN_EN) { /* not set for sdio */
- if (hw->request_cd_eirq) { /* not set for MT6575 */
- hw->request_cd_eirq(msdc_eirq_cd, (void*)host); /* msdc_eirq_cd will not be used! */
- }
- }
-
- if (hw->request_sdio_eirq) /* set to combo_sdio_request_eirq() for WIFI */
- hw->request_sdio_eirq(msdc_eirq_sdio, (void*)host); /* msdc_eirq_sdio() will be called when EIRQ */
-
- if (hw->register_pm) {/* yes for sdio */
-#ifdef CONFIG_PM
- hw->register_pm(msdc_pm, (void*)host); /* combo_sdio_register_pm() */
-#endif
- if(hw->flags & MSDC_SYS_SUSPEND) { /* will not set for WIFI */
- ERR_MSG("MSDC_SYS_SUSPEND and register_pm both set");
- }
- //mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; /* pm not controlled by system but by client. */ /* --- by chhung */
- }
-
- platform_set_drvdata(pdev, mmc);
-
- ret = mmc_add_host(mmc);
- if (ret) goto free_irq;
-
- /* Config card detection pin and enable interrupts */
- if (hw->flags & MSDC_CD_PIN_EN) { /* set for card */
- msdc_enable_cd_irq(host, 1);
- } else {
- msdc_enable_cd_irq(host, 0);
- }
-
- return 0;
-
-free_irq:
- free_irq(irq, host);
-release:
- platform_set_drvdata(pdev, NULL);
- msdc_deinit_hw(host);
-
-#if 0
- tasklet_kill(&host->card_tasklet);
-#else
- cancel_delayed_work_sync(&host->card_delaywork);
-#endif
+ /* MMC core transfer sizes tunable parameters */
+ mmc->max_segs = MAX_HW_SGMTS;
+
+ mmc->max_seg_size = MAX_SGMT_SZ;
+ mmc->max_blk_size = HOST_MAX_BLKSZ;
+ mmc->max_req_size = MAX_REQ_SZ;
+ mmc->max_blk_count = mmc->max_req_size;
+
+ host = mmc_priv(mmc);
+ host->hw = hw;
+ host->mmc = mmc;
+ host->id = pdev->id;
+ if (host->id < 0 || host->id >= 4)
+ host->id = 0;
+ host->error = 0;
+
+ host->irq = platform_get_irq(pdev, 0);
+ if (host->irq < 0) {
+ ret = -EINVAL;
+ goto host_free;
+ }
- if (mem)
- release_mem_region(mem->start, mem->end - mem->start + 1);
+ host->base = base;
+ host->mclk = 0; /* mclk: the request clock of mmc sub-system */
+ host->hclk = hclks[hw->clk_src]; /* hclk: clock of clock source to msdc controller */
+ host->sclk = 0; /* sclk: the really clock after divition */
+ host->pm_state = PMSG_RESUME;
+ host->suspend = 0;
+ host->core_clkon = 0;
+ host->card_clkon = 0;
+ host->core_power = 0;
+ host->power_mode = MMC_POWER_OFF;
+// host->card_inserted = hw->flags & MSDC_REMOVABLE ? 0 : 1;
+ host->timeout_ns = 0;
+ host->timeout_clks = DEFAULT_DTOC * 65536;
+
+ host->mrq = NULL;
+ //init_MUTEX(&host->sem); /* we don't need to support multiple threads access */
+
+ mmc_dev(mmc)->dma_mask = NULL;
+
+ /* using dma_alloc_coherent*/ /* todo: using 1, for all 4 slots */
+ host->dma.gpd = dma_alloc_coherent(&pdev->dev,
+ MAX_GPD_NUM * sizeof(struct gpd),
+ &host->dma.gpd_addr, GFP_KERNEL);
+ host->dma.bd = dma_alloc_coherent(&pdev->dev,
+ MAX_BD_NUM * sizeof(struct bd),
+ &host->dma.bd_addr, GFP_KERNEL);
+ if (!host->dma.gpd || !host->dma.bd) {
+ ret = -ENOMEM;
+ goto release_mem;
+ }
+ msdc_init_gpd_bd(host, &host->dma);
+
+ INIT_DELAYED_WORK(&host->card_delaywork, msdc_tasklet_card);
+ spin_lock_init(&host->lock);
+ msdc_init_hw(host);
+
+ /* TODO check weather flags 0 is correct, the mtk-sd driver uses
+ * IRQF_TRIGGER_LOW | IRQF_ONESHOT for flags
+ *
+ * for flags 0 the trigger polarity is determined by the
+ * device tree, but not the oneshot flag, but maybe it is also
+ * not needed because the soc could be oneshot safe.
+ */
+ ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq, 0, pdev->name,
+ host);
+ if (ret)
+ goto release;
+
+ platform_set_drvdata(pdev, mmc);
+
+ ret = mmc_add_host(mmc);
+ if (ret)
+ goto release;
+
+ /* Config card detection pin and enable interrupts */
+ if (hw->flags & MSDC_CD_PIN_EN) { /* set for card */
+ msdc_enable_cd_irq(host, 1);
+ } else {
+ msdc_enable_cd_irq(host, 0);
+ }
- mmc_free_host(mmc);
+ return 0;
- return ret;
+release:
+ platform_set_drvdata(pdev, NULL);
+ msdc_deinit_hw(host);
+ cancel_delayed_work_sync(&host->card_delaywork);
+
+release_mem:
+ if (host->dma.gpd)
+ dma_free_coherent(&pdev->dev, MAX_GPD_NUM * sizeof(struct gpd),
+ host->dma.gpd, host->dma.gpd_addr);
+ if (host->dma.bd)
+ dma_free_coherent(&pdev->dev, MAX_BD_NUM * sizeof(struct bd),
+ host->dma.bd, host->dma.bd_addr);
+host_free:
+ mmc_free_host(mmc);
+
+ return ret;
}
/* 4 device share one driver, using "drvdata" to show difference */
static int msdc_drv_remove(struct platform_device *pdev)
{
- struct mmc_host *mmc;
- struct msdc_host *host;
- struct resource *mem;
+ struct mmc_host *mmc;
+ struct msdc_host *host;
- mmc = platform_get_drvdata(pdev);
- BUG_ON(!mmc);
-
- host = mmc_priv(mmc);
- BUG_ON(!host);
+ mmc = platform_get_drvdata(pdev);
+ BUG_ON(!mmc);
- ERR_MSG("removed !!!");
+ host = mmc_priv(mmc);
+ BUG_ON(!host);
- platform_set_drvdata(pdev, NULL);
- mmc_remove_host(host->mmc);
- msdc_deinit_hw(host);
+ ERR_MSG("removed !!!");
-#if 0
- tasklet_kill(&host->card_tasklet);
-#else
- cancel_delayed_work_sync(&host->card_delaywork);
-#endif
- free_irq(host->irq, host);
+ platform_set_drvdata(pdev, NULL);
+ mmc_remove_host(host->mmc);
+ msdc_deinit_hw(host);
- dma_free_coherent(NULL, MAX_GPD_NUM * sizeof(gpd_t), host->dma.gpd, host->dma.gpd_addr);
- dma_free_coherent(NULL, MAX_BD_NUM * sizeof(bd_t), host->dma.bd, host->dma.bd_addr);
+ cancel_delayed_work_sync(&host->card_delaywork);
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ dma_free_coherent(&pdev->dev, MAX_GPD_NUM * sizeof(struct gpd),
+ host->dma.gpd, host->dma.gpd_addr);
+ dma_free_coherent(&pdev->dev, MAX_BD_NUM * sizeof(struct bd),
+ host->dma.bd, host->dma.bd_addr);
- if (mem)
- release_mem_region(mem->start, mem->end - mem->start + 1);
+ mmc_free_host(host->mmc);
- mmc_free_host(host->mmc);
-
- return 0;
+ return 0;
}
/* Fix me: Power Flow */
#ifdef CONFIG_PM
+
+static void msdc_drv_pm(struct platform_device *pdev, pm_message_t state)
+{
+ struct mmc_host *mmc = platform_get_drvdata(pdev);
+ if (mmc) {
+ struct msdc_host *host = mmc_priv(mmc);
+ msdc_pm(state, (void *)host);
+ }
+}
+
static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t state)
{
- int ret = 0;
- struct mmc_host *mmc = platform_get_drvdata(pdev);
- struct msdc_host *host = mmc_priv(mmc);
-
- if (mmc && state.event == PM_EVENT_SUSPEND && (host->hw->flags & MSDC_SYS_SUSPEND)) { /* will set for card */
- msdc_pm(state, (void*)host);
- }
-
- return ret;
+ if (state.event == PM_EVENT_SUSPEND)
+ msdc_drv_pm(pdev, state);
+ return 0;
}
static int msdc_drv_resume(struct platform_device *pdev)
{
- int ret = 0;
- struct mmc_host *mmc = platform_get_drvdata(pdev);
- struct msdc_host *host = mmc_priv(mmc);
- struct pm_message state;
-
- state.event = PM_EVENT_RESUME;
- if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND)) {/* will set for card */
- msdc_pm(state, (void*)host);
- }
-
- /* This mean WIFI not controller by PM */
-
- return ret;
+ struct pm_message state;
+
+ state.event = PM_EVENT_RESUME;
+ msdc_drv_pm(pdev, state);
+ return 0;
}
#endif
@@ -2990,17 +2407,16 @@ static const struct of_device_id mt7620_sdhci_match[] = {
MODULE_DEVICE_TABLE(of, mt7620_sdhci_match);
static struct platform_driver mt_msdc_driver = {
- .probe = msdc_drv_probe,
- .remove = msdc_drv_remove,
+ .probe = msdc_drv_probe,
+ .remove = msdc_drv_remove,
#ifdef CONFIG_PM
- .suspend = msdc_drv_suspend,
- .resume = msdc_drv_resume,
+ .suspend = msdc_drv_suspend,
+ .resume = msdc_drv_resume,
#endif
- .driver = {
- .name = DRV_NAME,
- .owner = THIS_MODULE,
- .of_match_table = mt7620_sdhci_match,
- },
+ .driver = {
+ .name = DRV_NAME,
+ .of_match_table = mt7620_sdhci_match,
+ },
};
/*--------------------------------------------------------------------------*/
@@ -3008,61 +2424,29 @@ static struct platform_driver mt_msdc_driver = {
/*--------------------------------------------------------------------------*/
static int __init mt_msdc_init(void)
{
- int ret;
-/* +++ by chhung */
- u32 reg;
-
-#if defined (CONFIG_MTD_ANY_RALINK)
- extern int ra_check_flash_type(void);
- if(ra_check_flash_type() == 2) { /* NAND */
- printk("%s: !!!!! SDXC Module Initialize Fail !!!!!", __func__);
- return 0;
- }
-#endif
- printk("MTK MSDC device init.\n");
- mtk_sd_device.dev.platform_data = &msdc0_hw;
-if (ralink_soc == MT762X_SOC_MT7620A || ralink_soc == MT762X_SOC_MT7621AT) {
-//#if defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621)
- reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<18);
-//#if defined (CONFIG_RALINK_MT7620)
- if (ralink_soc == MT762X_SOC_MT7620A)
- reg |= 0x1<<18;
-//#endif
-} else {
-//#elif defined (CONFIG_RALINK_MT7628)
- /* TODO: maybe omitted when RAether already toggle AGPIO_CFG */
- reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c));
- reg |= 0x1e << 16;
- sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c), reg);
-
- reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<10);
-#if defined (CONFIG_MTK_MMC_EMMC_8BIT)
- reg |= 0x3<<26 | 0x3<<28 | 0x3<<30;
- msdc0_hw.data_pins = 8,
-#endif
-//#endif
-}
- sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60), reg);
- //platform_device_register(&mtk_sd_device);
-/* end of +++ */
-
- ret = platform_driver_register(&mt_msdc_driver);
- if (ret) {
- printk(KERN_ERR DRV_NAME ": Can't register driver");
- return ret;
- }
- printk(KERN_INFO DRV_NAME ": MediaTek MT6575 MSDC Driver\n");
+ int ret;
+ u32 reg;
+
+ // Set the pins for sdxc to sdxc mode
+ //FIXME: this should be done by pinctl and not by the sd driver
+ reg = sdr_read32((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18);
+ sdr_write32((void __iomem *)(RALINK_SYSCTL_BASE + 0x60), reg);
+
+ ret = platform_driver_register(&mt_msdc_driver);
+ if (ret) {
+ printk(KERN_ERR DRV_NAME ": Can't register driver");
+ return ret;
+ }
-#if defined (MT6575_SD_DEBUG)
- msdc_debug_proc_init();
+#if defined(MT6575_SD_DEBUG)
+ msdc_debug_proc_init();
#endif
- return 0;
+ return 0;
}
static void __exit mt_msdc_exit(void)
{
-// platform_device_unregister(&mtk_sd_device);
- platform_driver_unregister(&mt_msdc_driver);
+ platform_driver_unregister(&mt_msdc_driver);
}
module_init(mt_msdc_init);
@@ -3070,5 +2454,3 @@ module_exit(mt_msdc_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MediaTek MT6575 SD/MMC Card Driver");
MODULE_AUTHOR("Infinity Chen <infinity.chen@mediatek.com>");
-
-EXPORT_SYMBOL(msdc_6575_host);
diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
index 1fa41eb8a87f..edd95013faf3 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -56,112 +56,99 @@
#include <ralink_regs.h>
-extern void pcie_phy_init(void);
-extern void chk_phy_pll(void);
-
/*
* These functions and structures provide the BIOS scan and mapping of the PCI
* devices.
*/
-#define CONFIG_PCIE_PORT0
-#define CONFIG_PCIE_PORT1
-#define CONFIG_PCIE_PORT2
-#define RALINK_PCIE0_CLK_EN (1<<24)
-#define RALINK_PCIE1_CLK_EN (1<<25)
-#define RALINK_PCIE2_CLK_EN (1<<26)
-
-#define RALINK_PCI_CONFIG_ADDR 0x20
-#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
-#define SURFBOARDINT_PCIE0 11 /* PCIE0 */
-#define RALINK_INT_PCIE0 SURFBOARDINT_PCIE0
-#define RALINK_INT_PCIE1 SURFBOARDINT_PCIE1
-#define RALINK_INT_PCIE2 SURFBOARDINT_PCIE2
-#define SURFBOARDINT_PCIE1 31 /* PCIE1 */
-#define SURFBOARDINT_PCIE2 32 /* PCIE2 */
-#define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x0028)
-#define RALINK_PCI_IOBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x002C)
-#define RALINK_PCIE0_RST (1<<24)
-#define RALINK_PCIE1_RST (1<<25)
-#define RALINK_PCIE2_RST (1<<26)
-#define RALINK_SYSCTL_BASE 0xBE000000
-
-#define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x0000)
-#define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x000C)
-#define RALINK_PCI_BASE 0xBE140000
-
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RT6855_PCIE0_OFFSET 0x2000
-#define RT6855_PCIE1_OFFSET 0x3000
-#define RT6855_PCIE2_OFFSET 0x4000
-
-#define RALINK_PCI0_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0010)
-#define RALINK_PCI0_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0018)
-#define RALINK_PCI0_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0030)
-#define RALINK_PCI0_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0034)
-#define RALINK_PCI0_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0038)
-#define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0050)
-#define RALINK_PCI0_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0060)
-#define RALINK_PCI0_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0064)
-
-#define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0010)
-#define RALINK_PCI1_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0018)
-#define RALINK_PCI1_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0030)
-#define RALINK_PCI1_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0034)
-#define RALINK_PCI1_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0038)
-#define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0050)
-#define RALINK_PCI1_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0060)
-#define RALINK_PCI1_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0064)
-
-#define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0010)
-#define RALINK_PCI2_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0018)
-#define RALINK_PCI2_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0030)
-#define RALINK_PCI2_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0034)
-#define RALINK_PCI2_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0038)
-#define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0050)
-#define RALINK_PCI2_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0060)
-#define RALINK_PCI2_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0064)
-
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RALINK_PCIEPHY_P2_CTL_OFFSET (RALINK_PCI_BASE + 0xA000)
-
-
-#define MV_WRITE(ofs, data) \
- *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
-#define MV_READ(ofs, data) \
- *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-#define MV_READ_DATA(ofs) \
- le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-
-#define MV_WRITE_16(ofs, data) \
- *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
-#define MV_READ_16(ofs, data) \
- *(data) = le16_to_cpu(*(volatile u16 *)(RALINK_PCI_BASE+(ofs)))
-
-#define MV_WRITE_8(ofs, data) \
- *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) = data
-#define MV_READ_8(ofs, data) \
- *(data) = *(volatile u8 *)(RALINK_PCI_BASE+(ofs))
-
-
-
-#define RALINK_PCI_MM_MAP_BASE 0x60000000
-#define RALINK_PCI_IO_MAP_BASE 0x1e160000
+#define RALINK_PCIE0_CLK_EN (1<<24)
+#define RALINK_PCIE1_CLK_EN (1<<25)
+#define RALINK_PCIE2_CLK_EN (1<<26)
+
+#define RALINK_PCI_CONFIG_ADDR 0x20
+#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
+#define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x0028)
+#define RALINK_PCI_IOBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x002C)
+#define RALINK_PCIE0_RST (1<<24)
+#define RALINK_PCIE1_RST (1<<25)
+#define RALINK_PCIE2_RST (1<<26)
+#define RALINK_SYSCTL_BASE 0xBE000000
+
+#define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x0000)
+#define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x000C)
+#define RALINK_PCI_BASE 0xBE140000
+
+#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
+#define RT6855_PCIE0_OFFSET 0x2000
+#define RT6855_PCIE1_OFFSET 0x3000
+#define RT6855_PCIE2_OFFSET 0x4000
+
+#define RALINK_PCI0_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0010)
+#define RALINK_PCI0_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0018)
+#define RALINK_PCI0_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0030)
+#define RALINK_PCI0_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0034)
+#define RALINK_PCI0_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0038)
+#define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0050)
+#define RALINK_PCI0_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0060)
+#define RALINK_PCI0_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0064)
+
+#define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0010)
+#define RALINK_PCI1_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0018)
+#define RALINK_PCI1_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0030)
+#define RALINK_PCI1_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0034)
+#define RALINK_PCI1_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0038)
+#define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0050)
+#define RALINK_PCI1_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0060)
+#define RALINK_PCI1_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0064)
+
+#define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0010)
+#define RALINK_PCI2_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0018)
+#define RALINK_PCI2_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0030)
+#define RALINK_PCI2_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0034)
+#define RALINK_PCI2_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0038)
+#define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0050)
+#define RALINK_PCI2_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0060)
+#define RALINK_PCI2_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0064)
+
+#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
+#define RALINK_PCIEPHY_P2_CTL_OFFSET (RALINK_PCI_BASE + 0xA000)
+
+#define MV_WRITE(ofs, data) \
+ *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
+#define MV_READ(ofs, data) \
+ *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
+#define MV_READ_DATA(ofs) \
+ le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
+
+#define MV_WRITE_16(ofs, data) \
+ *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
+#define MV_READ_16(ofs, data) \
+ *(data) = le16_to_cpu(*(volatile u16 *)(RALINK_PCI_BASE+(ofs)))
+
+#define MV_WRITE_8(ofs, data) \
+ *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) = data
+#define MV_READ_8(ofs, data) \
+ *(data) = *(volatile u8 *)(RALINK_PCI_BASE+(ofs))
+
+#define RALINK_PCI_MM_MAP_BASE 0x60000000
+#define RALINK_PCI_IO_MAP_BASE 0x1e160000
#define RALINK_SYSTEM_CONTROL_BASE 0xbe000000
-#define GPIO_PERST
-#define ASSERT_SYSRST_PCIE(val) do { \
- if (*(unsigned int *)(0xbe00000c) == 0x00030101) \
- RALINK_RSTCTRL |= val; \
- else \
- RALINK_RSTCTRL &= ~val; \
- } while(0)
-#define DEASSERT_SYSRST_PCIE(val) do { \
- if (*(unsigned int *)(0xbe00000c) == 0x00030101) \
- RALINK_RSTCTRL &= ~val; \
- else \
- RALINK_RSTCTRL |= val; \
- } while(0)
+
+#define ASSERT_SYSRST_PCIE(val) \
+ do { \
+ if (*(unsigned int *)(0xbe00000c) == 0x00030101) \
+ RALINK_RSTCTRL |= val; \
+ else \
+ RALINK_RSTCTRL &= ~val; \
+ } while(0)
+#define DEASSERT_SYSRST_PCIE(val) \
+ do { \
+ if (*(unsigned int *)(0xbe00000c) == 0x00030101) \
+ RALINK_RSTCTRL &= ~val; \
+ else \
+ RALINK_RSTCTRL |= val; \
+ } while(0)
#define RALINK_SYSCFG1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x14)
#define RALINK_CLKCFG1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x30)
#define RALINK_RSTCTRL *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x34)
@@ -281,7 +268,6 @@ write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
return PCIBIOS_SUCCESSFUL;
}
-
static int
pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val)
{
@@ -309,30 +295,16 @@ pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u
}
struct pci_ops mt7621_pci_ops= {
- .read = pci_config_read,
+ .read = pci_config_read,
.write = pci_config_write,
};
-static struct resource mt7621_res_pci_mem1 = {
- .name = "PCI MEM1",
- .start = RALINK_PCI_MM_MAP_BASE,
- .end = (u32)((RALINK_PCI_MM_MAP_BASE + (unsigned char *)0x0fffffff)),
- .flags = IORESOURCE_MEM,
-};
-static struct resource mt7621_res_pci_io1 = {
- .name = "PCI I/O1",
- .start = RALINK_PCI_IO_MAP_BASE,
- .end = (u32)((RALINK_PCI_IO_MAP_BASE + (unsigned char *)0x0ffff)),
- .flags = IORESOURCE_IO,
-};
-
+static struct resource mt7621_res_pci_mem1;
+static struct resource mt7621_res_pci_io1;
static struct pci_controller mt7621_controller = {
.pci_ops = &mt7621_pci_ops,
.mem_resource = &mt7621_res_pci_mem1,
.io_resource = &mt7621_res_pci_io1,
- .mem_offset = 0x00000000UL,
- .io_offset = 0x00000000UL,
- .io_map_base = 0xa0000000,
};
static void
@@ -341,10 +313,10 @@ read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned l
unsigned int address_reg, data_reg, address;
address_reg = RALINK_PCI_CONFIG_ADDR;
- data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+ data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
address = (((reg & 0xF00)>>8)<<24) | (bus << 16) | (dev << 11) | (func << 8) | (reg & 0xfc) | 0x80000000 ;
- MV_WRITE(address_reg, address);
- MV_READ(data_reg, val);
+ MV_WRITE(address_reg, address);
+ MV_READ(data_reg, val);
return;
}
@@ -361,74 +333,17 @@ write_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned
return;
}
-
int
pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
{
u16 cmd;
u32 val;
- int irq = 0;
-
- if ((dev->bus->number == 0) && (slot == 0)) {
- write_config(0, 0, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
- read_config(0, 0, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val);
- printk("BAR0 at slot 0 = %x\n", val);
- printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
- } else if((dev->bus->number == 0) && (slot == 0x1)) {
- write_config(0, 1, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
- read_config(0, 1, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val);
- printk("BAR0 at slot 1 = %x\n", val);
- printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
- } else if((dev->bus->number == 0) && (slot == 0x2)) {
- write_config(0, 2, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
- read_config(0, 2, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val);
- printk("BAR0 at slot 2 = %x\n", val);
- printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
- } else if ((dev->bus->number == 1) && (slot == 0x0)) {
- switch (pcie_link_status) {
- case 2:
- case 6:
- irq = RALINK_INT_PCIE1;
- break;
- case 4:
- irq = RALINK_INT_PCIE2;
- break;
- default:
- irq = RALINK_INT_PCIE0;
- }
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else if ((dev->bus->number == 2) && (slot == 0x0)) {
- switch (pcie_link_status) {
- case 5:
- case 6:
- irq = RALINK_INT_PCIE2;
- break;
- default:
- irq = RALINK_INT_PCIE1;
- }
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else if ((dev->bus->number == 2) && (slot == 0x1)) {
- switch (pcie_link_status) {
- case 5:
- case 6:
- irq = RALINK_INT_PCIE2;
- break;
- default:
- irq = RALINK_INT_PCIE1;
- }
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else if ((dev->bus->number ==3) && (slot == 0x0)) {
- irq = RALINK_INT_PCIE2;
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else if ((dev->bus->number ==3) && (slot == 0x1)) {
- irq = RALINK_INT_PCIE2;
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else if ((dev->bus->number ==3) && (slot == 0x2)) {
- irq = RALINK_INT_PCIE2;
- printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq);
- } else {
- printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
- return 0;
+ int irq;
+
+ if (dev->bus->number == 0) {
+ write_config(0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
+ read_config(0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val);
+ printk("BAR0 at slot %d = %x\n", slot, val);
}
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14); //configure cache line size 0x14
@@ -436,46 +351,32 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
pci_read_config_word(dev, PCI_COMMAND, &cmd);
cmd = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
pci_write_config_word(dev, PCI_COMMAND, cmd);
+
+ irq = of_irq_parse_and_map_pci(dev, slot, pin);
+
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-#ifdef CONFIG_DTB_GNUBEE1
- /*
- * 'irq' here is a hwirq, but a virq is needed. Until we know how and where
- * to convert one to the other, we have this hack for the GNUBEE1
- */
- return irq == 11 ? 22 : irq;
-#else
return irq;
-#endif
}
void
set_pcie_phy(u32 *addr, int start_b, int bits, int val)
{
-// printk("0x%p:", addr);
-// printk(" %x", *addr);
*(unsigned int *)(addr) &= ~(((1<<bits) - 1)<<start_b);
*(unsigned int *)(addr) |= val << start_b;
-// printk(" -> %x\n", *addr);
}
void
bypass_pipe_rst(void)
{
-#if defined (CONFIG_PCIE_PORT0)
/* PCIe Port 0 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c), 12, 1, 0x01); // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4]
-#endif
-#if defined (CONFIG_PCIE_PORT1)
/* PCIe Port 1 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c), 12, 1, 0x01); // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4]
-#endif
-#if defined (CONFIG_PCIE_PORT2)
/* PCIe Port 2 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c), 12, 1, 0x01); // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4]
-#endif
}
void
@@ -484,82 +385,79 @@ set_phy_for_ssc(void)
unsigned long reg = (*(volatile u32 *)(RALINK_SYSCTL_BASE + 0x10));
reg = (reg >> 6) & 0x7;
-#if defined (CONFIG_PCIE_PORT0) || defined (CONFIG_PCIE_PORT1)
/* Set PCIe Port0 & Port1 PHY to disable SSC */
/* Debug Xtal Type */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable
- if(reg <= 5 && reg >= 3) { // 40MHz Xtal
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable
+ if(reg <= 5 && reg >= 3) { // 40MHz Xtal
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
printk("***** Xtal 40MHz *****\n");
} else { // 25MHz | 20MHz Xtal
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
- if (reg >= 6) {
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
+ if (reg >= 6) {
printk("***** Xtal 25MHz *****\n");
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode)
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode)
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial
} else {
printk("***** Xtal 20MHz *****\n");
}
}
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN
- if(reg <= 5 && reg >= 3) { // 40MHz Xtal
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN
+ if(reg <= 5 && reg >= 3) { // 40MHz Xtal
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv
}
/* Enable PHY and disable force mode */
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x01); // rg_pe1_phy_en //Port 1 enable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 1 disable control
-#endif
-#if defined (CONFIG_PCIE_PORT2)
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x01); // rg_pe1_phy_en //Port 1 enable
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 1 disable control
+
/* Set PCIe Port2 PHY to disable SSC */
/* Debug Xtal Type */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable
- if(reg <= 5 && reg >= 3) { // 40MHz Xtal
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable
+ if(reg <= 5 && reg >= 3) { // 40MHz Xtal
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
} else { // 25MHz | 20MHz Xtal
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
- if (reg >= 6) { // 25MHz Xtal
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode)
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode)
+ if (reg >= 6) { // 25MHz Xtal
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode)
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial
}
}
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN
- if(reg <= 5 && reg >= 3) { // 40MHz Xtal
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN
+ if(reg <= 5 && reg >= 3) { // 40MHz Xtal
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv
}
/* Enable PHY and disable force mode */
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable
- set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control
-#endif
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable
+ set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control
}
void setup_cm_memory_region(struct resource *mem_resource)
@@ -567,15 +465,15 @@ void setup_cm_memory_region(struct resource *mem_resource)
resource_size_t mask;
if (mips_cps_numiocu(0)) {
/* FIXME: hardware doesn't accept mask values with 1s after
- 0s (e.g. 0xffef), so it would be great to warn if that's
- about to happen */
+ * 0s (e.g. 0xffef), so it would be great to warn if that's
+ * about to happen */
mask = ~(mem_resource->end - mem_resource->start);
write_gcr_reg1_base(mem_resource->start);
write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0);
printk("PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n",
- (unsigned long long)read_gcr_reg1_base(),
- (unsigned long long)read_gcr_reg1_mask());
+ (unsigned long long)read_gcr_reg1_base(),
+ (unsigned long long)read_gcr_reg1_mask());
}
}
@@ -588,18 +486,12 @@ static int mt7621_pci_probe(struct platform_device *pdev)
ioport_resource.start= 0;
ioport_resource.end = ~0;
-#if defined (CONFIG_PCIE_PORT0)
val = RALINK_PCIE0_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT1)
val |= RALINK_PCIE1_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT2)
val |= RALINK_PCIE2_RST;
-#endif
+
ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST | RALINK_PCIE1_RST | RALINK_PCIE2_RST);
- printk("pull PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
-#if defined GPIO_PERST /* add GPIO control instead of PERST_N */ /*chhung*/
+
*(unsigned int *)(0xbe000060) &= ~(0x3<<10 | 0x3<<3);
*(unsigned int *)(0xbe000060) |= 0x1<<10 | 0x1<<3;
mdelay(100);
@@ -608,38 +500,25 @@ static int mt7621_pci_probe(struct platform_device *pdev)
*(unsigned int *)(0xbe000620) &= ~(0x1<<19 | 0x1<<8 | 0x1<<7); // clear DATA
mdelay(100);
-#else
- *(unsigned int *)(0xbe000060) &= ~0x00000c00;
-#endif
-#if defined (CONFIG_PCIE_PORT0)
+
val = RALINK_PCIE0_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT1)
val |= RALINK_PCIE1_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT2)
val |= RALINK_PCIE2_RST;
-#endif
+
DEASSERT_SYSRST_PCIE(val);
- printk("release PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
if ((*(unsigned int *)(0xbe00000c)&0xFFFF) == 0x0101) // MT7621 E2
bypass_pipe_rst();
set_phy_for_ssc();
- printk("release PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
-#if defined (CONFIG_PCIE_PORT0)
read_config(0, 0, 0, 0x70c, &val);
printk("Port 0 N_FTS = %x\n", (unsigned int)val);
-#endif
-#if defined (CONFIG_PCIE_PORT1)
+
read_config(0, 1, 0, 0x70c, &val);
printk("Port 1 N_FTS = %x\n", (unsigned int)val);
-#endif
-#if defined (CONFIG_PCIE_PORT2)
+
read_config(0, 2, 0, 0x70c, &val);
printk("Port 2 N_FTS = %x\n", (unsigned int)val);
-#endif
RALINK_RSTCTRL = (RALINK_RSTCTRL | RALINK_PCIE_RST);
RALINK_SYSCFG1 &= ~(0x30);
@@ -650,19 +529,11 @@ static int mt7621_pci_probe(struct platform_device *pdev)
RALINK_PCIE_CLK_GEN |= 0x80000000;
mdelay(50);
RALINK_RSTCTRL = (RALINK_RSTCTRL & ~RALINK_PCIE_RST);
-
-#if defined GPIO_PERST /* add GPIO control instead of PERST_N */ /*chhung*/
+ /* Use GPIO control instead of PERST_N */
*(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // set DATA
- mdelay(100);
-#else
- RALINK_PCI_PCICFG_ADDR &= ~(1<<1); //de-assert PERST
-#endif
- mdelay(500);
-
+ mdelay(1000);
- mdelay(500);
-#if defined (CONFIG_PCIE_PORT0)
if(( RALINK_PCI0_STATUS & 0x1) == 0)
{
printk("PCIE0 no card, disable it(RST&CLK)\n");
@@ -673,8 +544,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status |= 1<<0;
RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt
}
-#endif
-#if defined (CONFIG_PCIE_PORT1)
+
if(( RALINK_PCI1_STATUS & 0x1) == 0)
{
printk("PCIE1 no card, disable it(RST&CLK)\n");
@@ -685,8 +555,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status |= 1<<1;
RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt
}
-#endif
-#if defined (CONFIG_PCIE_PORT2)
+
if (( RALINK_PCI2_STATUS & 0x1) == 0) {
printk("PCIE2 no card, disable it(RST&CLK)\n");
ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST);
@@ -696,7 +565,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status |= 1<<2;
RALINK_PCI_PCIMSK_ADDR |= (1<<22); // enable pcie2 interrupt
}
-#endif
+
if (pcie_link_status == 0)
return 0;
@@ -736,18 +605,15 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
RALINK_PCI_PCICFG_ADDR |= 0x1 << 24; //port2
break;
}
- printk(" -> %x\n", RALINK_PCI_PCICFG_ADDR);
- //printk(" RALINK_PCI_ARBCTL = %x\n", RALINK_PCI_ARBCTL);
/*
ioport_resource.start = mt7621_res_pci_io1.start;
- ioport_resource.end = mt7621_res_pci_io1.end;
+ ioport_resource.end = mt7621_res_pci_io1.end;
*/
RALINK_PCI_MEMBASE = 0xffffffff; //RALINK_PCI_MM_MAP_BASE;
RALINK_PCI_IOBASE = RALINK_PCI_IO_MAP_BASE;
-#if defined (CONFIG_PCIE_PORT0)
//PCIe0
if((pcie_link_status & 0x1) != 0) {
RALINK_PCI0_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE
@@ -755,8 +621,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
RALINK_PCI0_CLASS = 0x06040001;
printk("PCIE0 enabled\n");
}
-#endif
-#if defined (CONFIG_PCIE_PORT1)
+
//PCIe1
if ((pcie_link_status & 0x2) != 0) {
RALINK_PCI1_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE
@@ -764,8 +629,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
RALINK_PCI1_CLASS = 0x06040001;
printk("PCIE1 enabled\n");
}
-#endif
-#if defined (CONFIG_PCIE_PORT2)
+
//PCIe2
if ((pcie_link_status & 0x4) != 0) {
RALINK_PCI2_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE
@@ -773,14 +637,11 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
RALINK_PCI2_CLASS = 0x06040001;
printk("PCIE2 enabled\n");
}
-#endif
-
switch(pcie_link_status) {
case 7:
read_config(0, 2, 0, 0x4, &val);
write_config(0, 2, 0, 0x4, val|0x4);
- // write_config(0, 1, 0, 0x4, val|0x7);
read_config(0, 2, 0, 0x70c, &val);
val &= ~(0xff)<<8;
val |= 0x50<<8;
@@ -790,7 +651,6 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
case 6:
read_config(0, 1, 0, 0x4, &val);
write_config(0, 1, 0, 0x4, val|0x4);
- // write_config(0, 1, 0, 0x4, val|0x7);
read_config(0, 1, 0, 0x70c, &val);
val &= ~(0xff)<<8;
val |= 0x50<<8;
@@ -798,7 +658,6 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num
default:
read_config(0, 0, 0, 0x4, &val);
write_config(0, 0, 0, 0x4, val|0x4); //bus master enable
- // write_config(0, 0, 0, 0x4, val|0x7); //bus master enable
read_config(0, 0, 0, 0x70c, &val);
val &= ~(0xff)<<8;
val |= 0x50<<8;
@@ -827,7 +686,6 @@ static struct platform_driver mt7621_pci_driver = {
.probe = mt7621_pci_probe,
.driver = {
.name = "mt7621-pci",
- .owner = THIS_MODULE,
.of_match_table = of_match_ptr(mt7621_pci_ids),
},
};
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index 3d2d1c2a006f..2d9ab2620b82 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -459,7 +459,6 @@ static struct platform_driver rt2880_pinmux_driver = {
.probe = rt2880_pinmux_probe,
.driver = {
.name = "rt2880-pinmux",
- .owner = THIS_MODULE,
.of_match_table = rt2880_pinmux_match,
},
};
diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c
index d95e0b32f1f0..37f299080410 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -65,7 +65,6 @@ struct mt7621_spi {
unsigned int sys_freq;
unsigned int speed;
struct clk *clk;
- spinlock_t lock;
struct mt7621_spi_ops *ops;
};
@@ -395,7 +394,6 @@ static int mt7621_spi_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct spi_master *master;
struct mt7621_spi *rs;
- unsigned long flags;
void __iomem *base;
struct resource *r;
int status = 0;
@@ -447,7 +445,6 @@ static int mt7621_spi_probe(struct platform_device *pdev)
rs->sys_freq = clk_get_rate(rs->clk);
rs->ops = ops;
dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq);
- spin_lock_irqsave(&rs->lock, flags);
device_reset(&pdev->dev);
@@ -475,7 +472,6 @@ MODULE_ALIAS("platform:" DRIVER_NAME);
static struct platform_driver mt7621_spi_driver = {
.driver = {
.name = DRIVER_NAME,
- .owner = THIS_MODULE,
.of_match_table = mt7621_spi_match,
},
.probe = mt7621_spi_probe,
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 52054a528723..08027a36e0bc 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -17,12 +17,11 @@
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/list.h>
#include <linux/mfd/core.h>
#include <linux/mutex.h>
@@ -236,8 +235,8 @@ static size_t nvec_msg_size(struct nvec_msg *msg)
static void nvec_gpio_set_value(struct nvec_chip *nvec, int value)
{
dev_dbg(nvec->dev, "GPIO changed from %u to %u\n",
- gpio_get_value(nvec->gpio), value);
- gpio_set_value(nvec->gpio, value);
+ gpiod_get_value(nvec->gpiod), value);
+ gpiod_set_value(nvec->gpiod, value);
}
/**
@@ -761,31 +760,11 @@ static void nvec_power_off(void)
nvec_write_async(nvec_power_handle, ap_pwr_down, 2);
}
-/*
- * Parse common device tree data
- */
-static int nvec_i2c_parse_dt_pdata(struct nvec_chip *nvec)
-{
- nvec->gpio = of_get_named_gpio(nvec->dev->of_node, "request-gpios", 0);
-
- if (nvec->gpio < 0) {
- dev_err(nvec->dev, "no gpio specified");
- return -ENODEV;
- }
-
- if (of_property_read_u32(nvec->dev->of_node, "slave-addr",
- &nvec->i2c_addr)) {
- dev_err(nvec->dev, "no i2c address specified");
- return -ENODEV;
- }
-
- return 0;
-}
-
static int tegra_nvec_probe(struct platform_device *pdev)
{
int err, ret;
struct clk *i2c_clk;
+ struct device *dev = &pdev->dev;
struct nvec_chip *nvec;
struct nvec_msg *msg;
struct resource *res;
@@ -794,42 +773,43 @@ static int tegra_nvec_probe(struct platform_device *pdev)
unmute_speakers[] = { NVEC_OEM0, 0x10, 0x59, 0x95 },
enable_event[7] = { NVEC_SYS, CNF_EVENT_REPORTING, true };
- if (!pdev->dev.of_node) {
- dev_err(&pdev->dev, "must be instantiated using device tree\n");
+ if (!dev->of_node) {
+ dev_err(dev, "must be instantiated using device tree\n");
return -ENODEV;
}
- nvec = devm_kzalloc(&pdev->dev, sizeof(struct nvec_chip), GFP_KERNEL);
+ nvec = devm_kzalloc(dev, sizeof(struct nvec_chip), GFP_KERNEL);
if (!nvec)
return -ENOMEM;
platform_set_drvdata(pdev, nvec);
- nvec->dev = &pdev->dev;
+ nvec->dev = dev;
- err = nvec_i2c_parse_dt_pdata(nvec);
- if (err < 0)
- return err;
+ if (of_property_read_u32(dev->of_node, "slave-addr", &nvec->i2c_addr)) {
+ dev_err(dev, "no i2c address specified");
+ return -ENODEV;
+ }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- base = devm_ioremap_resource(&pdev->dev, res);
+ base = devm_ioremap_resource(dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
nvec->irq = platform_get_irq(pdev, 0);
if (nvec->irq < 0) {
- dev_err(&pdev->dev, "no irq resource?\n");
+ dev_err(dev, "no irq resource?\n");
return -ENODEV;
}
- i2c_clk = devm_clk_get(&pdev->dev, "div-clk");
+ i2c_clk = devm_clk_get(dev, "div-clk");
if (IS_ERR(i2c_clk)) {
- dev_err(nvec->dev, "failed to get controller clock\n");
+ dev_err(dev, "failed to get controller clock\n");
return -ENODEV;
}
- nvec->rst = devm_reset_control_get_exclusive(&pdev->dev, "i2c");
+ nvec->rst = devm_reset_control_get_exclusive(dev, "i2c");
if (IS_ERR(nvec->rst)) {
- dev_err(nvec->dev, "failed to get controller reset\n");
+ dev_err(dev, "failed to get controller reset\n");
return PTR_ERR(nvec->rst);
}
@@ -849,17 +829,16 @@ static int tegra_nvec_probe(struct platform_device *pdev)
INIT_WORK(&nvec->rx_work, nvec_dispatch);
INIT_WORK(&nvec->tx_work, nvec_request_master);
- err = devm_gpio_request_one(&pdev->dev, nvec->gpio, GPIOF_OUT_INIT_HIGH,
- "nvec gpio");
- if (err < 0) {
- dev_err(nvec->dev, "couldn't request gpio\n");
- return -ENODEV;
+ nvec->gpiod = devm_gpiod_get(dev, "request", GPIOD_OUT_HIGH);
+ if (IS_ERR(nvec->gpiod)) {
+ dev_err(dev, "couldn't request gpio\n");
+ return PTR_ERR(nvec->gpiod);
}
- err = devm_request_irq(&pdev->dev, nvec->irq, nvec_interrupt, 0,
+ err = devm_request_irq(dev, nvec->irq, nvec_interrupt, 0,
"nvec", nvec);
if (err) {
- dev_err(nvec->dev, "couldn't request irq\n");
+ dev_err(dev, "couldn't request irq\n");
return -ENODEV;
}
disable_irq(nvec->irq);
@@ -879,7 +858,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
err = nvec_write_sync(nvec, get_firmware_version, 2, &msg);
if (!err) {
- dev_warn(nvec->dev,
+ dev_warn(dev,
"ec firmware version %02x.%02x.%02x / %02x\n",
msg->data[4], msg->data[5],
msg->data[6], msg->data[7]);
@@ -887,10 +866,10 @@ static int tegra_nvec_probe(struct platform_device *pdev)
nvec_msg_free(nvec, msg);
}
- ret = mfd_add_devices(nvec->dev, 0, nvec_devices,
+ ret = mfd_add_devices(dev, 0, nvec_devices,
ARRAY_SIZE(nvec_devices), NULL, 0, NULL);
if (ret)
- dev_err(nvec->dev, "error adding subdevices\n");
+ dev_err(dev, "error adding subdevices\n");
/* unmute speakers? */
nvec_write_async(nvec, unmute_speakers, 4);
@@ -925,8 +904,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
static int nvec_suspend(struct device *dev)
{
int err;
- struct platform_device *pdev = to_platform_device(dev);
- struct nvec_chip *nvec = platform_get_drvdata(pdev);
+ struct nvec_chip *nvec = dev_get_drvdata(dev);
struct nvec_msg *msg;
char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND };
@@ -946,8 +924,7 @@ static int nvec_suspend(struct device *dev)
static int nvec_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct nvec_chip *nvec = platform_get_drvdata(pdev);
+ struct nvec_chip *nvec = dev_get_drvdata(dev);
dev_dbg(nvec->dev, "resuming\n");
tegra_init_i2c_slave(nvec);
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
index 25efcdfa4f20..80c0353f141c 100644
--- a/drivers/staging/nvec/nvec.h
+++ b/drivers/staging/nvec/nvec.h
@@ -132,7 +132,7 @@ struct nvec_msg {
*/
struct nvec_chip {
struct device *dev;
- int gpio;
+ struct gpio_desc *gpiod;
int irq;
u32 i2c_addr;
void __iomem *base;
diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO
index 61c2e65ac354..665a0b061719 100644
--- a/drivers/staging/olpc_dcon/TODO
+++ b/drivers/staging/olpc_dcon/TODO
@@ -1,6 +1,10 @@
TODO:
- see if vx855 gpio API can be made similar enough to cs5535 so we can
share more code
+ - convert all uses of the old GPIO API from <linux/gpio.h> to the
+ GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
+ lines from device tree, ACPI or board files, board files should
+ use <linux/gpio/machine.h>
- allow simultaneous XO-1 and XO-1.5 support
Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
diff --git a/drivers/staging/pi433/Documentation/devicetree/pi433.txt b/drivers/staging/pi433/Documentation/devicetree/pi433.txt
index 9ff217fbcbbd..a810548c5857 100644
--- a/drivers/staging/pi433/Documentation/devicetree/pi433.txt
+++ b/drivers/staging/pi433/Documentation/devicetree/pi433.txt
@@ -46,10 +46,10 @@ It consists of the three gpio pins and an spi interface (here chip select 0)
For Raspbian users only
=======================
-Since Raspbian supports device tree overlays, you may use and overlay, instead
+Since Raspbian supports device tree overlays, you may use an overlay instead
of editing your boards device tree.
-For using the overlay, you need to compile the file pi433-overlay.dts you can
-find aside to this documentation.
+To use the overlay, you need to compile the file pi433-overlay.dts which can
+be found alongside this documentation.
The file needs to be compiled - either manually or by integration in your kernel
source tree. For a manual compile, you may use a command line like the following:
'linux/scripts/dtc/dtc -@ -I dts -O dtb -o pi433.dtbo pi433-overlay.dts'
diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt
index d0b7000faafc..21cffdb86ecf 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -8,11 +8,11 @@ Introduction
This driver is for controlling pi433, a radio module for the Raspberry Pi
(www.pi433.de). It supports transmission and reception. It can be opened
by multiple applications for transmission and reception. While transmit
-jobs were queued and process automatically in the background, the first
+jobs are queued and processed automatically in the background, the first
application asking for reception will block out all other applications
until something gets received terminates the read request.
The driver supports on the fly reloading of the hardware fifo of the rf
-chip, thus enabling for much longer telegrams then hardware fifo size.
+chip, thus enabling for much longer telegrams than the hardware fifo size.
Discription of driver operation
===============================
@@ -46,10 +46,10 @@ configuration set is written to the rf module and it gets set into receiving mod
Now the driver is waiting, that a predefined RSSI level (signal strength at the
receiver) is reached. Until this hasn't happened, the reception can be
interrupted by the transmission thread at any time to insert a transmission cycle.
-As soon as the predefined RSSI level is meat, a receiving cycle starts. Similar
+As soon as the predefined RSSI level is met, a receiving cycle starts. Similar
as described for the transmission cycle the read out of the hardware fifo is done
dynamically. Upon each hardware fifo threshold interrupt, a portion of data gets
-read. So also for reception it is possible to receive more data then the hardware
+read. So also for reception it is possible to receive more data than the hardware
fifo can hold.
@@ -225,7 +225,7 @@ rf params:
isn't found, telegram will be internally discarded
optionOff - sync detection is disabled.
enable_length_byte
- optionOn - First byte of payload will be used as length byte,
+ optionOn - First byte of payload will be used as a length byte,
regardless of the amount of bytes that were requested
by the read request.
optionOff - Number of bytes to be read will be set according to
diff --git a/drivers/staging/pi433/Kconfig b/drivers/staging/pi433/Kconfig
index 87c2ee192cca..c7340129dd4c 100644
--- a/drivers/staging/pi433/Kconfig
+++ b/drivers/staging/pi433/Kconfig
@@ -1,7 +1,7 @@
config PI433
tristate "Pi433 - a 433MHz radio module for Raspberry Pi"
depends on SPI
- ---help---
+ help
This option allows you to enable support for the radio module Pi433.
Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..b061f77dda41 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
- struct mutex tx_fifo_lock; // TODO: check, whether necessary or obsolete
+ struct mutex tx_fifo_lock; /* serialize userspace writers */
struct task_struct *tx_task_struct;
wait_queue_head_t tx_wait_queue;
u8 free_in_fifo;
@@ -589,19 +589,19 @@ pi433_tx_thread(void *data)
* - size of message
* - message
*/
- mutex_lock(&device->tx_fifo_lock);
-
retval = kfifo_out(&device->tx_fifo, &tx_cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
- dev_dbg(device->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
- mutex_unlock(&device->tx_fifo_lock);
+ dev_dbg(device->dev,
+ "reading tx_cfg from fifo failed: got %d byte(s), expected %d",
+ retval, (unsigned int)sizeof(tx_cfg));
continue;
}
retval = kfifo_out(&device->tx_fifo, &size, sizeof(size_t));
if (retval != sizeof(size_t)) {
- dev_dbg(device->dev, "reading msg size from fifo failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
- mutex_unlock(&device->tx_fifo_lock);
+ dev_dbg(device->dev,
+ "reading msg size from fifo failed: got %d, expected %d",
+ retval, (unsigned int)sizeof(size_t));
continue;
}
@@ -623,7 +623,11 @@ pi433_tx_thread(void *data)
/* add length byte, if requested */
if (tx_cfg.enable_length_byte == OPTION_ON)
- device->buffer[position++] = size - 1; /* according to spec length byte itself must be excluded from the length calculation */
+ /*
+ * according to spec, length byte itself must be
+ * excluded from the length calculation
+ */
+ device->buffer[position++] = size - 1;
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
@@ -634,7 +638,6 @@ pi433_tx_thread(void *data)
sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
- mutex_unlock(&device->tx_fifo_lock);
/* if rx is active, we need to interrupt the waiting for
* incoming telegrams, to be able to send something.
@@ -818,7 +821,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance *instance;
struct pi433_device *device;
int retval;
- unsigned int copied;
+ unsigned int required, available, copied;
instance = filp->private_data;
device = instance->device;
@@ -833,6 +836,16 @@ pi433_write(struct file *filp, const char __user *buf,
* - message
*/
mutex_lock(&device->tx_fifo_lock);
+
+ required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+ available = kfifo_avail(&device->tx_fifo);
+ if (required > available) {
+ dev_dbg(device->dev, "write to fifo failed: %d bytes required but %d available",
+ required, available);
+ mutex_unlock(&device->tx_fifo_lock);
+ return -EAGAIN;
+ }
+
retval = kfifo_in(&device->tx_fifo, &instance->tx_cfg,
sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -855,8 +868,8 @@ pi433_write(struct file *filp, const char __user *buf,
return copied;
abort:
- dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
- kfifo_reset(&device->tx_fifo); // TODO: maybe find a solution, not to discard already stored, valid entries
+ dev_warn(device->dev,
+ "write to fifo failed, non recoverable: 0x%x", retval);
mutex_unlock(&device->tx_fifo_lock);
return -EAGAIN;
}
@@ -1042,7 +1055,7 @@ static int setup_gpio(struct pi433_device *device)
/* configure irq */
device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
if (device->irq_num[i] < 0) {
- device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc *)device->irq_num[i];
+ device->gpiod[i] = ERR_PTR(-EINVAL);
return device->irq_num[i];
}
retval = request_irq(device->irq_num[i],
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 5b0554823263..90280e9b006d 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -97,7 +97,8 @@ static int rf69_clear_bit(struct spi_device *spi, u8 reg, u8 mask)
return rf69_write_reg(spi, reg, tmp);
}
-static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, u8 mask, u8 value)
+static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg,
+ u8 mask, u8 value)
{
u8 tmp;
@@ -112,15 +113,20 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
{
switch (mode) {
case transmit:
- return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
+ return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+ OPMODE_MODE_TRANSMIT);
case receive:
- return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_RECEIVE);
+ return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+ OPMODE_MODE_RECEIVE);
case synthesizer:
- return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SYNTHESIZER);
+ return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+ OPMODE_MODE_SYNTHESIZER);
case standby:
- return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_STANDBY);
+ return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+ OPMODE_MODE_STANDBY);
case mode_sleep:
- return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SLEEP);
+ return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+ OPMODE_MODE_SLEEP);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -133,16 +139,21 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
{
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE, data_mode);
+ return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE,
+ data_mode);
}
int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
{
switch (modulation) {
case OOK:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_TYPE,
+ DATAMODUL_MODULATION_TYPE_OOK);
case FSK:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_TYPE,
+ DATAMODUL_MODULATION_TYPE_FSK);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -172,13 +183,21 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
case FSK:
switch (mod_shaping) {
case SHAPING_OFF:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_1_0:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_1_0);
case SHAPING_0_5:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_5);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_0_5);
case SHAPING_0_3:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_3);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_0_3);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -186,11 +205,17 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
case OOK:
switch (mod_shaping) {
case SHAPING_OFF:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_BR:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_BR);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_BR);
case SHAPING_2BR:
- return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_2BR);
+ return rf69_read_mod_write(spi, REG_DATAMODUL,
+ MASK_DATAMODUL_MODULATION_SHAPE,
+ DATAMODUL_MODULATION_SHAPE_2BR);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -342,7 +367,8 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 power_level)
}
// write value
- return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER, power_level);
+ return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER,
+ power_level);
}
int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
@@ -386,7 +412,8 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
}
}
-int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance antenna_impedance)
+int rf69_set_antenna_impedance(struct spi_device *spi,
+ enum antenna_impedance antenna_impedance)
{
switch (antenna_impedance) {
case fifty_ohm:
@@ -403,19 +430,26 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain)
{
switch (lna_gain) {
case automatic:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_AUTO);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_AUTO);
case max:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX);
case max_minus_6:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_6);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX_MINUS_6);
case max_minus_12:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_12);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX_MINUS_12);
case max_minus_24:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_24);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX_MINUS_24);
case max_minus_36:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_36);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX_MINUS_36);
case max_minus_48:
- return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_48);
+ return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN,
+ LNA_GAIN_MAX_MINUS_48);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -466,35 +500,55 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg,
return rf69_write_reg(spi, reg, bandwidth);
}
-int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 exponent)
+int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse,
+ u8 exponent)
{
return rf69_set_bandwidth_intern(spi, REG_RXBW, mantisse, exponent);
}
-int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse mantisse, u8 exponent)
+int rf69_set_bandwidth_during_afc(struct spi_device *spi,
+ enum mantisse mantisse,
+ u8 exponent)
{
return rf69_set_bandwidth_intern(spi, REG_AFCBW, mantisse, exponent);
}
-int rf69_set_ook_threshold_dec(struct spi_device *spi, enum threshold_decrement threshold_decrement)
+int rf69_set_ook_threshold_dec(struct spi_device *spi,
+ enum threshold_decrement threshold_decrement)
{
switch (threshold_decrement) {
case dec_every8th:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_8TH);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_EVERY_8TH);
case dec_every4th:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_4TH);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_EVERY_4TH);
case dec_every2nd:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_2ND);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_EVERY_2ND);
case dec_once:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_ONCE);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_ONCE);
case dec_twice:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_TWICE);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_TWICE);
case dec_4times:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_4_TIMES);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_4_TIMES);
case dec_8times:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_8_TIMES);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_8_TIMES);
case dec_16times:
- return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_16_TIMES);
+ return rf69_read_mod_write(spi, REG_OOKPEAK,
+ MASK_OOKPEAK_THRESDEC,
+ OOKPEAK_THRESHDEC_16_TIMES);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -620,13 +674,16 @@ int rf69_disable_sync(struct spi_device *spi)
return rf69_clear_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_SYNC_ON);
}
-int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifo_fill_condition fifo_fill_condition)
+int rf69_set_fifo_fill_condition(struct spi_device *spi,
+ enum fifo_fill_condition fifo_fill_condition)
{
switch (fifo_fill_condition) {
case always:
- return rf69_set_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
+ return rf69_set_bit(spi, REG_SYNC_CONFIG,
+ MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
case after_sync_interrupt:
- return rf69_clear_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
+ return rf69_clear_bit(spi, REG_SYNC_CONFIG,
+ MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -642,7 +699,9 @@ int rf69_set_sync_size(struct spi_device *spi, u8 sync_size)
}
// write value
- return rf69_read_mod_write(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_SYNC_SIZE, (sync_size << 3));
+ return rf69_read_mod_write(spi, REG_SYNC_CONFIG,
+ MASK_SYNC_CONFIG_SYNC_SIZE,
+ (sync_size << 3));
}
int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8])
@@ -661,13 +720,16 @@ int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8])
return retval;
}
-int rf69_set_packet_format(struct spi_device *spi, enum packet_format packet_format)
+int rf69_set_packet_format(struct spi_device *spi,
+ enum packet_format packet_format)
{
switch (packet_format) {
case packet_length_var:
- return rf69_set_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
+ return rf69_set_bit(spi, REG_PACKETCONFIG1,
+ MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
case packet_length_fix:
- return rf69_clear_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
+ return rf69_clear_bit(spi, REG_PACKETCONFIG1,
+ MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -684,15 +746,22 @@ int rf69_disable_crc(struct spi_device *spi)
return rf69_clear_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_CRC_ON);
}
-int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering address_filtering)
+int rf69_set_address_filtering(struct spi_device *spi,
+ enum address_filtering address_filtering)
{
switch (address_filtering) {
case filtering_off:
- return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF);
+ return rf69_read_mod_write(spi, REG_PACKETCONFIG1,
+ MASK_PACKETCONFIG1_ADDRESSFILTERING,
+ PACKETCONFIG1_ADDRESSFILTERING_OFF);
case node_address:
- return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODE);
+ return rf69_read_mod_write(spi, REG_PACKETCONFIG1,
+ MASK_PACKETCONFIG1_ADDRESSFILTERING,
+ PACKETCONFIG1_ADDRESSFILTERING_NODE);
case node_or_broadcast_address:
- return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST);
+ return rf69_read_mod_write(spi, REG_PACKETCONFIG1,
+ MASK_PACKETCONFIG1_ADDRESSFILTERING,
+ PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -714,13 +783,16 @@ int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address)
return rf69_write_reg(spi, REG_BROADCASTADRS, broadcast_address);
}
-int rf69_set_tx_start_condition(struct spi_device *spi, enum tx_start_condition tx_start_condition)
+int rf69_set_tx_start_condition(struct spi_device *spi,
+ enum tx_start_condition tx_start_condition)
{
switch (tx_start_condition) {
case fifo_level:
- return rf69_clear_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART);
+ return rf69_clear_bit(spi, REG_FIFO_THRESH,
+ MASK_FIFO_THRESH_TXSTART);
case fifo_not_empty:
- return rf69_set_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART);
+ return rf69_set_bit(spi, REG_FIFO_THRESH,
+ MASK_FIFO_THRESH_TXSTART);
default:
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
@@ -738,7 +810,9 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold)
}
/* write value */
- retval = rf69_read_mod_write(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_VALUE, threshold);
+ retval = rf69_read_mod_write(spi, REG_FIFO_THRESH,
+ MASK_FIFO_THRESH_VALUE,
+ threshold);
if (retval)
return retval;
@@ -775,7 +849,8 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
int retval;
if (size > FIFO_SIZE) {
- dev_dbg(&spi->dev, "read fifo: passed in buffer bigger then internal buffer\n");
+ dev_dbg(&spi->dev,
+ "read fifo: passed in buffer bigger then internal buffer\n");
return -EMSGSIZE;
}
@@ -807,7 +882,8 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
u8 local_buffer[FIFO_SIZE + 1];
if (size > FIFO_SIZE) {
- dev_dbg(&spi->dev, "read fifo: passed in buffer bigger then internal buffer\n");
+ dev_dbg(&spi->dev,
+ "read fifo: passed in buffer bigger then internal buffer\n");
return -EMSGSIZE;
}
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index b9f6850e3316..c131ffbdc2db 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -28,7 +28,8 @@
int rf69_set_mode(struct spi_device *spi, enum mode mode);
int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
-int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping mod_shaping);
+int rf69_set_modulation_shaping(struct spi_device *spi,
+ enum mod_shaping mod_shaping);
int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
int rf69_set_deviation(struct spi_device *spi, u32 deviation);
int rf69_set_frequency(struct spi_device *spi, u32 frequency);
@@ -36,28 +37,37 @@ int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask);
int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
-int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance antenna_impedance);
+int rf69_set_antenna_impedance(struct spi_device *spi,
+ enum antenna_impedance antenna_impedance);
int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain);
-int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 exponent);
-int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse mantisse, u8 exponent);
-int rf69_set_ook_threshold_dec(struct spi_device *spi, enum threshold_decrement threshold_decrement);
+int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse,
+ u8 exponent);
+int rf69_set_bandwidth_during_afc(struct spi_device *spi,
+ enum mantisse mantisse,
+ u8 exponent);
+int rf69_set_ook_threshold_dec(struct spi_device *spi,
+ enum threshold_decrement threshold_decrement);
int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value);
bool rf69_get_flag(struct spi_device *spi, enum flag flag);
int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
int rf69_enable_sync(struct spi_device *spi);
int rf69_disable_sync(struct spi_device *spi);
-int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifo_fill_condition fifo_fill_condition);
+int rf69_set_fifo_fill_condition(struct spi_device *spi,
+ enum fifo_fill_condition fifo_fill_condition);
int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);
int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]);
-int rf69_set_packet_format(struct spi_device *spi, enum packet_format packet_format);
+int rf69_set_packet_format(struct spi_device *spi,
+ enum packet_format packet_format);
int rf69_enable_crc(struct spi_device *spi);
int rf69_disable_crc(struct spi_device *spi);
-int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering address_filtering);
+int rf69_set_address_filtering(struct spi_device *spi,
+ enum address_filtering address_filtering);
int rf69_set_payload_length(struct spi_device *spi, u8 payload_length);
int rf69_set_node_address(struct spi_device *spi, u8 node_address);
int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address);
-int rf69_set_tx_start_condition(struct spi_device *spi, enum tx_start_condition tx_start_condition);
+int rf69_set_tx_start_condition(struct spi_device *spi,
+ enum tx_start_condition tx_start_condition);
int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold);
int rf69_set_dagc(struct spi_device *spi, enum dagc dagc);
diff --git a/drivers/staging/rtl8188eu/TODO b/drivers/staging/rtl8188eu/TODO
index ce60f07b9977..7581e25f231d 100644
--- a/drivers/staging/rtl8188eu/TODO
+++ b/drivers/staging/rtl8188eu/TODO
@@ -9,11 +9,6 @@ TODO:
- merge Realtek's bugfixes and new features into the driver
- switch to use LIB80211
- switch to use MAC80211
-- figure out what to do with this code in rtw_recv_indicatepkt():
- rcu_read_lock();
- rcu_dereference(padapter->pnetdev->rx_handler_data);
- rcu_read_unlock();
- Perhaps delete it, perhaps assign to some local variable.
Please send any patches to Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
and Larry Finger <Larry.Finger@lwfinger.net>.
diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
index bda4ab879f58..7ec53a9dfa27 100644
--- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
@@ -121,10 +121,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter,
}
}
- rcu_read_lock();
- rcu_dereference(padapter->pnetdev->rx_handler_data);
- rcu_read_unlock();
-
skb->ip_summed = CHECKSUM_NONE;
skb->dev = padapter->pnetdev;
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
diff --git a/drivers/staging/rtl8192e/dot11d.c b/drivers/staging/rtl8192e/dot11d.c
index 88f89d77b511..a1c096124683 100644
--- a/drivers/staging/rtl8192e/dot11d.c
+++ b/drivers/staging/rtl8192e/dot11d.c
@@ -50,7 +50,7 @@ void dot11d_init(struct rtllib_device *ieee)
pDot11dInfo->State = DOT11D_STATE_NONE;
pDot11dInfo->CountryIeLen = 0;
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
+ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
RESET_CIE_WATCHDOG(ieee);
}
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index fc88d47dea43..d314b2f602e4 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -578,7 +578,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
.seq_ctl = 0,
.qos_ctl = 0
};
- int qos_actived = ieee->current_network.qos_data.active;
+ int qos_activated = ieee->current_network.qos_data.active;
u8 dest[ETH_ALEN];
u8 src[ETH_ALEN];
struct lib80211_crypt_data *crypt = NULL;
@@ -684,7 +684,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
else
fc = RTLLIB_FTYPE_DATA;
- if (qos_actived)
+ if (qos_activated)
fc |= RTLLIB_STYPE_QOS_DATA;
else
fc |= RTLLIB_STYPE_DATA;
@@ -727,7 +727,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
qos_ctl = 0;
}
- if (qos_actived) {
+ if (qos_activated) {
hdr_len = RTLLIB_3ADDR_LEN + 2;
/* in case we are a client verify acm is not set for this ac */
@@ -788,7 +788,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
txb->encrypted = encrypt;
txb->payload_size = cpu_to_le16(bytes);
- if (qos_actived)
+ if (qos_activated)
txb->queue_index = UP2AC(skb->priority);
else
txb->queue_index = WME_AC_BE;
@@ -797,7 +797,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
skb_frag = txb->fragments[i];
tcb_desc = (struct cb_desc *)(skb_frag->cb +
MAX_DEV_ADDR_SIZE);
- if (qos_actived) {
+ if (qos_activated) {
skb_frag->priority = skb->priority;
tcb_desc->queue_index = UP2AC(skb->priority);
} else {
@@ -831,7 +831,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
/* The last fragment has the remaining length */
bytes = bytes_last_frag;
}
- if ((qos_actived) && (!bIsMulticast)) {
+ if ((qos_activated) && (!bIsMulticast)) {
frag_hdr->seq_ctl =
cpu_to_le16(rtllib_query_seqnum(ieee, skb_frag,
header.addr1));
@@ -866,7 +866,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
skb_put(skb_frag, 4);
}
- if ((qos_actived) && (!bIsMulticast)) {
+ if ((qos_activated) && (!bIsMulticast)) {
if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF)
ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0;
else
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index a4b40422e5bd..041f1b123888 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -66,7 +66,7 @@ static void *ieee80211_ccmp_init(int key_idx)
{
struct ieee80211_ccmp_data *priv;
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
goto fail;
priv->key_idx = key_idx;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
index 60ecfec71112..a7efaae4e25a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
@@ -66,7 +66,7 @@ static void *ieee80211_tkip_init(int key_idx)
{
struct ieee80211_tkip_data *priv;
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
goto fail;
priv->key_idx = key_idx;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
index 7ba4b07aa842..b9f86be9e52b 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
@@ -41,7 +41,7 @@ static void *prism2_wep_init(int keyidx)
{
struct prism2_wep_data *priv;
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return NULL;
priv->key_idx = keyidx;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 25c186a8bde3..21874e78d8a1 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2684,7 +2684,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
for(i = 0; i < 5; i++) {
ieee->seq_ctrl[i] = 0;
}
- ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
+ ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_KERNEL);
if (!ieee->pDot11dInfo)
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n");
//added for AP roaming
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
index bf7b7122d042..6952dab6ec80 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
@@ -8,7 +8,7 @@ u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0
u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
u16 MCS_DATA_RATE[2][2][77] =
- { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
+ { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260,
39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
@@ -67,7 +67,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
pHTInfo->bRegBW40MHz = 1;
// CCK rate support in 40MHz channel
- if(pHTInfo->bRegBW40MHz)
+ if (pHTInfo->bRegBW40MHz)
pHTInfo->bRegSuppCCK = 1;
else
pHTInfo->bRegSuppCCK = true;
@@ -83,7 +83,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
// MIMO Power Save
pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
- if(pHTInfo->SelfMimoPs == 2)
+ if (pHTInfo->SelfMimoPs == 2)
pHTInfo->SelfMimoPs = 3;
// 8190 only. Assign rate operation mode to firmware
ieee->bTxDisableRateFallBack = 0;
@@ -128,7 +128,7 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString )
static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
PHT_CAPABILITY_ELE pCapELE;
- if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
+ if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
{
//EWC IE
IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
@@ -165,7 +165,7 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
PHT_INFORMATION_ELE pHTInfoEle;
- if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
+ if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
{
// Not EWC IE
IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
@@ -225,13 +225,13 @@ static bool IsHTHalfNmode40Bandwidth(struct ieee80211_device *ieee)
bool retValue = false;
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if(!pHTInfo->bCurrentHTSupport) // wireless is n mode
+ if (!pHTInfo->bCurrentHTSupport) // wireless is n mode
retValue = false;
- else if(!pHTInfo->bRegBW40MHz) // station supports 40 bw
+ else if (!pHTInfo->bRegBW40MHz) // station supports 40 bw
retValue = false;
- else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
+ else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
retValue = false;
- else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
+ else if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
retValue = true;
else
retValue = false;
@@ -244,20 +244,20 @@ static bool IsHTHalfNmodeSGI(struct ieee80211_device *ieee, bool is40MHz)
bool retValue = false;
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if(!pHTInfo->bCurrentHTSupport) // wireless is n mode
+ if (!pHTInfo->bCurrentHTSupport) // wireless is n mode
retValue = false;
- else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
+ else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
retValue = false;
- else if(is40MHz) // ap support 40 bw
+ else if (is40MHz) // ap support 40 bw
{
- if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
+ if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
retValue = true;
else
retValue = false;
}
else
{
- if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
+ if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
retValue = true;
else
retValue = false;
@@ -301,11 +301,11 @@ u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate)
u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate)
{
//PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
+ u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c};
u8 is40MHz = 0;
u8 isShortGI = 0;
- if(nDataRate < 12)
+ if (nDataRate < 12)
{
return CCKOFDMRate[nDataRate];
}
@@ -318,21 +318,21 @@ u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate)
// nDataRate = nDataRate - 12;
}
- else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
+ else if (nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
{
is40MHz = 1;
isShortGI = 0;
//nDataRate = nDataRate - 28;
}
- else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
+ else if (nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
{
is40MHz = 0;
isShortGI = 1;
//nDataRate = nDataRate - 44;
}
- else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
+ else if (nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
{
is40MHz = 1;
isShortGI = 1;
@@ -349,20 +349,20 @@ bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee)
{
bool retValue = false;
struct ieee80211_network *net = &ieee->current_network;
- if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
- (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
- (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
- (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
- (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
- (net->ralink_cap_exist))
+ if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
+ (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
+ (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
+ (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
+ (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
+ (net->ralink_cap_exist))
retValue = true;
- else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
- (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
- (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
- (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ||
- (net->broadcom_cap_exist))
- retValue = true;
- else if(net->bssht.bdRT2RTAggregation)
+ else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ||
+ (net->broadcom_cap_exist))
+ retValue = true;
+ else if (net->bssht.bdRT2RTAggregation)
retValue = true;
else
retValue = false;
@@ -381,25 +381,25 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee)
{
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
struct ieee80211_network *net = &ieee->current_network;
- if(net->bssht.bdRT2RTAggregation)
+ if (net->bssht.bdRT2RTAggregation)
pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
- else if(net->broadcom_cap_exist)
+ else if (net->broadcom_cap_exist)
pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
- else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
+ else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
(memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
(memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
(memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) )
pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
- else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
+ else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
(memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
(memcmp(net->bssid, PCI_RALINK, 3)==0) ||
(memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
(memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
net->ralink_cap_exist)
pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
- else if(net->atheros_cap_exist)
+ else if (net->atheros_cap_exist)
pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
- else if(memcmp(net->bssid, CISCO_BROADCOM, 3)==0)
+ else if (memcmp(net->bssid, CISCO_BROADCOM, 3)==0)
pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
else
pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
@@ -515,9 +515,9 @@ static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
static u8 HTIOTActIsCCDFsync(u8 *PeerMacAddr)
{
u8 retValue = 0;
- if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
- (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
- (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
+ if ((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
+ (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
{
retValue = 1;
}
@@ -556,7 +556,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
return;
}
memset(posHTCap, 0, *len);
- if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
+ if (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
{
u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
@@ -569,7 +569,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
//HT capability info
pCapELE->AdvCoding = 0; // This feature is not supported now!!
- if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
{
pCapELE->ChlWidth = 0;
}
@@ -610,13 +610,13 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
//Supported MCS set
memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
+ if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
pCapELE->MCS[1] &= 0x7f;
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
+ if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
pCapELE->MCS[1] &= 0xbf;
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
+ if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
pCapELE->MCS[1] &= 0x00;
// 2008.06.12
@@ -624,7 +624,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
{
int i;
- for(i = 1; i< 16; i++)
+ for (i = 1; i< 16; i++)
pCapELE->MCS[i] = 0;
}
@@ -638,7 +638,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
//Antenna Selection Capabilities
pCapELE->ASCap = 0;
//add 2 to give space for element ID and len when construct frames
- if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
+ if (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
*len = 30 + 2;
else
*len = 26 + 2;
@@ -805,7 +805,7 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS)
//legacy rate routine handled at selectedrate
//no MCS rate
- for(i=0;i<=15;i++){
+ for (i=0;i<=15;i++){
pOperateMCS[i] = 0;
}
break;
@@ -862,27 +862,27 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF
IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
return false;
}
- for(i=0; i<16; i++)
+ for (i=0; i<16; i++)
availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
- for(i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
{
- if(availableMcsRate[i] != 0)
+ if (availableMcsRate[i] != 0)
break;
}
- if(i == 16)
+ if (i == 16)
return false;
- for(i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
{
if (availableMcsRate[i] != 0)
{
bitMap = availableMcsRate[i];
- for(j = 0; j < 8; j++)
+ for (j = 0; j < 8; j++)
{
if ((bitMap%2) != 0)
{
- if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
+ if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
mcsRate = (8*i+j);
}
bitMap >>= 1;
@@ -910,7 +910,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS,
u8 i=0;
// filter out operational rate set not supported by AP, the length of it is 16
- for(i=0;i<=15;i++){
+ for (i=0;i<=15;i++){
pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
}
@@ -922,14 +922,14 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS,
HT_PickMCSRate(ieee, pOperateMCS);
// For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
- if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
pOperateMCS[1] = 0;
//
// For RTL819X, we support only MCS0~15.
// And also, we do not know how to use MCS32 now.
//
- for(i=2; i<=15; i++)
+ for (i=2; i<=15; i++)
pOperateMCS[i] = 0;
return true;
@@ -962,7 +962,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
else
pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
- if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
+ if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
else
pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
@@ -1008,7 +1008,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
- if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
+ if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
else
pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
@@ -1022,10 +1022,10 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
// <1> Decide AMPDU Factor
// By Emily
- if(!pHTInfo->bRegRT2RTAggregation)
+ if (!pHTInfo->bRegRT2RTAggregation)
{
// Decide AMPDU Factor according to protocol handshake
- if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
+ if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
else
pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
@@ -1043,7 +1043,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
}else
{
- if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
+ if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
else
pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
@@ -1052,11 +1052,11 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
// <2> Set AMPDU Minimum MPDU Start Spacing
// 802.11n 3.0 section 9.7d.3
- if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
+ if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
else
pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
- if(ieee->pairwise_key_type != KEY_TYPE_NA )
+ if (ieee->pairwise_key_type != KEY_TYPE_NA )
pHTInfo->CurrentMPDUDensity = 7; // 8us
// Force TX AMSDU
@@ -1083,7 +1083,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
// Handle Ralink AP bad MCS rate set condition. Joseph.
// This fix the bug of Ralink AP. This may be removed in the future.
- if(pPeerHTCap->MCS[0] == 0)
+ if (pPeerHTCap->MCS[0] == 0)
pPeerHTCap->MCS[0] = 0xff;
HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
@@ -1092,7 +1092,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
// Config MIMO Power Save setting
//
pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
- if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
+ if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
pMcsFilter = MCS_FILTER_1SS;
else
pMcsFilter = MCS_FILTER_ALL;
@@ -1230,14 +1230,14 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802
pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
// Save HTCap and HTInfo information Element
- if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
+ if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
- if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
+ if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
// Check whether RT to RT aggregation mode is enabled
- if(pHTInfo->bRegRT2RTAggregation)
+ if (pHTInfo->bRegRT2RTAggregation)
{
pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
@@ -1255,28 +1255,28 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802
// Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
pHTInfo->IOTAction = 0;
bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
bIOTAction = HTIOTActIsDisableMCS15(ieee);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee, pNetwork->bssid);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
- if(bIOTAction)
+ if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
@@ -1303,7 +1303,7 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_
//
// Config current operation mode.
//
- if(pNetwork->bssht.bdHTInfoLen != 0)
+ if (pNetwork->bssht.bdHTInfoLen != 0)
pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
//
@@ -1341,7 +1341,7 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
// u32 flags = 0;
- if(!pHTInfo->bRegBW40MHz)
+ if (!pHTInfo->bRegBW40MHz)
return;
@@ -1357,12 +1357,12 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt
return;
}
//if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
- if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
+ if (Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
{
// Handle Illegal extension channel offset!!
- if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
+ if (ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
Offset = HT_EXTCHNL_OFFSET_NO_EXT;
- if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
+ if (Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
pHTInfo->bCurBW40MHz = true;
pHTInfo->CurSTAExtChnlOffset = Offset;
} else {
@@ -1391,11 +1391,11 @@ void HTSetConnectBwModeCallback(struct ieee80211_device *ieee)
IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __func__);
- if(pHTInfo->bCurBW40MHz)
+ if (pHTInfo->bCurBW40MHz)
{
- if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
+ if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
- else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
+ else if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
else
ieee->set_chan(ieee->dev, ieee->current_network.channel);
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7a0dbc0fa18e..a4df95cc7f60 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4996,7 +4996,7 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf)
kfree(priv->pFirmware);
priv->pFirmware = NULL;
rtl8192_usb_deleteendpoints(dev);
- mdelay(10);
+ usleep_range(10000, 11000);
}
free_ieee80211(dev);
RT_TRACE(COMP_DOWN, "wlan driver removed\n");
diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
index e1b81d34f1ad..e25b058dec26 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -539,13 +539,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12);
if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n");
- mdelay(1);
+ usleep_range(1000, 2000);
/*DbgPrint("hi, vivi, strange\n");*/
for (i = 0; i <= 30; i++) {
read_nic_byte(dev, 0x1ba, &Pwr_Flag);
if (Pwr_Flag == 0) {
- mdelay(1);
+ usleep_range(1000, 2000);
continue;
}
read_nic_word(dev, 0x13c, &Avg_TSSI_Meas);
diff --git a/drivers/staging/rtl8723bs/Makefile b/drivers/staging/rtl8723bs/Makefile
index f236acfd3afa..a12cf8dd8ed9 100644
--- a/drivers/staging/rtl8723bs/Makefile
+++ b/drivers/staging/rtl8723bs/Makefile
@@ -23,7 +23,7 @@ r8723bs-y = \
hal/hal_com_phycfg.o \
hal/hal_btcoex.o \
hal/hal_sdio.o \
- hal/Hal8723BPwrSeq.o \
+ hal/hal_pwr_seq.o \
hal/HalPhyRf.o \
hal/HalPwrSeqCmd.o \
hal/odm.o \
diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 0b530ea7fd81..45c05527a57a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_AP_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
index 79aa02afad01..adac915a2153 100644
--- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c
+++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include <drv_types.h>
#include <rtw_debug.h>
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 9e132f943687..830be63391b7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_CMD_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c
index b5dd244fee8f..f852fde47350 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_DEBUG_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c
index 35031a7a5dc5..5eea02cfce1f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c
+++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_EEPROM_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c
index 44b92ef5db92..bbf6f3fa21ea 100644
--- a/drivers/staging/rtl8723bs/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_EFUSE_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 74750dbce379..0822e440204e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _IEEE80211_C
diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 6bd5a4741e79..d341069097e2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*
diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index e5354cec8dd5..35ca825a7e5a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_IOCTL_SET_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index c13e514a655a..cc4f115e082c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_MLME_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 589fab24bb25..a81e13011c49 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_MLME_EXT_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_odm.c b/drivers/staging/rtl8723bs/core/rtw_odm.c
index edbcaeb9f8c2..93e8f17d2574 100644
--- a/drivers/staging/rtl8723bs/core/rtw_odm.c
+++ b/drivers/staging/rtl8723bs/core/rtw_odm.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include <drv_types.h>
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 85f7769ecc2d..110bbe340b78 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_PWRCTRL_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 86f995b8a88b..02f821d42658 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_RECV_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_rf.c b/drivers/staging/rtl8723bs/core/rtw_rf.c
index 07f5577cc073..a5095a4ef690 100644
--- a/drivers/staging/rtl8723bs/core/rtw_rf.c
+++ b/drivers/staging/rtl8723bs/core/rtw_rf.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_RF_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index aadf67bd0559..612277a555d2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_SECURITY_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index 03dd6848daa1..82716fd5c6f0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_STA_MGT_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index f6dc26c8bd3d..2b3eb6f8ddc5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_WLAN_UTIL_C_
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index be54186fb223..aaabffb0a199 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTW_XMIT_C_
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
index 37f42bfc55ed..eb6e07ef5dad 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "Mp_Precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
index 880bd63d36a5..cdffa391bd9d 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/* The following is for 8723B 1ANT BT Co-exist definition */
#define BT_INFO_8723B_1ANT_B_FTP BIT7
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
index 33610d39333f..cb62fc0a0f9c 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "Mp_Precomp.h"
@@ -2198,7 +2190,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
BTC_MSG_ALGORITHM,
ALGO_TRACE_FW_DETAIL,
(
- "[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
+ "[BTCoex], PsTdma type mismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
pCoexDm->curPsTdma,
pCoexDm->psTdmaDuAdjType
)
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
index 5a0fed69eda7..df973fcda48c 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/* The following is for 8723B 2Ant BT Co-exist definition */
#define BT_INFO_8723B_2ANT_B_FTP BIT7
diff --git a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
index 38414dd8adbd..aad86570b59c 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HALBTC_OUT_SRC_H__
#define __HALBTC_OUT_SRC_H__
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
index 951585467ab1..bae59e515348 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#include <linux/kernel.h>
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
index 41fe0ba16914..c1fbe91cd4f3 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#ifndef __INC_MP_BB_HW_IMG_8723B_H
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
index 7f8afa1be1ca..3c8e26aba406 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#include <linux/kernel.h>
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
index ae5dd3ccf939..788fdca1337b 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#ifndef __INC_MP_MAC_HW_IMG_8723B_H
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
index fadfcbd91858..ba42b4d2a9c4 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#include <linux/kernel.h>
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
index 98aa2ba97fa9..36a47437f974 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of version 2 of the GNU General Public License as
-* published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
******************************************************************************/
#ifndef __INC_MP_RF_HW_IMG_8723B_H
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.c b/drivers/staging/rtl8723bs/hal/HalPhyRf.c
index 9adcc3098463..beb4002a40e1 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf.c
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/* include "Mp_Precomp.h" */
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.h b/drivers/staging/rtl8723bs/hal/HalPhyRf.h
index bd7462d4ed91..3d6f68bc61d7 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf.h
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_PHY_RF_H__
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
index a99a863be656..2ee25b2471de 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include <drv_types.h>
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
index ae4eca144606..a4d5150007be 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_PHY_RF_8723B_H__
diff --git a/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
index 334d680b9b1c..c24156873fed 100644
--- a/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
+++ b/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*++
Copyright (c) Realtek Semiconductor Corp. All rights reserved.
diff --git a/drivers/staging/rtl8723bs/hal/Mp_Precomp.h b/drivers/staging/rtl8723bs/hal/Mp_Precomp.h
index 248b9fb3886a..3ed1142a9896 100644
--- a/drivers/staging/rtl8723bs/hal/Mp_Precomp.h
+++ b/drivers/staging/rtl8723bs/hal/Mp_Precomp.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __MP_PRECOMP_H__
#define __MP_PRECOMP_H__
diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
index 7d4df5a8832e..14284b1867f3 100644
--- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c
+++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define __HAL_BTCOEX_C__
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c
index 1cef1d77977c..7f8ec55b08f1 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_COM_C_
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 93d6cc478706..3922d0308a81 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_COM_PHYCFG_C_
diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c
index 3463f40d6a31..4a4d17b44ba6 100644
--- a/drivers/staging/rtl8723bs/hal/hal_intf.c
+++ b/drivers/staging/rtl8723bs/hal/hal_intf.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_INTF_C_
diff --git a/drivers/staging/rtl8723bs/hal/hal_phy.c b/drivers/staging/rtl8723bs/hal/hal_phy.c
index c0a899df7aaf..ebaefcaf5f2a 100644
--- a/drivers/staging/rtl8723bs/hal/hal_phy.c
+++ b/drivers/staging/rtl8723bs/hal/hal_phy.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_PHY_C_
diff --git a/drivers/staging/rtl8723bs/hal/Hal8723BPwrSeq.c b/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
index 0376806335d3..589e7aae7bbd 100644
--- a/drivers/staging/rtl8723bs/hal/Hal8723BPwrSeq.c
+++ b/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*
@@ -25,7 +17,7 @@ Major Change History:
*/
-#include "Hal8723BPwrSeq.h"
+#include "hal_pwr_seq.h"
/* drivers should parse below arrays and do the corresponding actions */
/* 3 Power on Array */
diff --git a/drivers/staging/rtl8723bs/hal/hal_sdio.c b/drivers/staging/rtl8723bs/hal/hal_sdio.c
index e147c69e7222..2d61b09ebce6 100644
--- a/drivers/staging/rtl8723bs/hal/hal_sdio.c
+++ b/drivers/staging/rtl8723bs/hal/hal_sdio.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_SDIO_C_
diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c
index ff43bb26950b..7de5161e2ac4 100644
--- a/drivers/staging/rtl8723bs/hal/odm.c
+++ b/drivers/staging/rtl8723bs/hal/odm.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h
index 1037b88e8f08..a4153a660d32 100644
--- a/drivers/staging/rtl8723bs/hal/odm.h
+++ b/drivers/staging/rtl8723bs/hal/odm.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/hal/odm_AntDiv.c b/drivers/staging/rtl8723bs/hal/odm_AntDiv.c
index e0b20562ccd6..d5415eecdd7f 100644
--- a/drivers/staging/rtl8723bs/hal/odm_AntDiv.c
+++ b/drivers/staging/rtl8723bs/hal/odm_AntDiv.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
//============================================================
diff --git a/drivers/staging/rtl8723bs/hal/odm_AntDiv.h b/drivers/staging/rtl8723bs/hal/odm_AntDiv.h
index 92cdad55b7a4..c9496d561c91 100644
--- a/drivers/staging/rtl8723bs/hal/odm_AntDiv.h
+++ b/drivers/staging/rtl8723bs/hal/odm_AntDiv.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMANTDIV_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
index 178aaab3f76c..a73304639226 100644
--- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
+++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
index 0c92899d9967..81db63efe286 100644
--- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
+++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMCFOTRACK_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c
index f02eb63a45ce..a12fdce77eae 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DIG.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.h b/drivers/staging/rtl8723bs/hal/odm_DIG.h
index e27a69126086..f6777e97a24a 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DIG.h
+++ b/drivers/staging/rtl8723bs/hal/odm_DIG.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMDIG_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
index 6af017562539..e18c9d65eee2 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
index b435cae4ab63..dba19271d526 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMDYNAMICBBPOWERSAVING_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
index d24e5f712c20..17f90f4cc1ad 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.h b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.h
index 35cdbab6d965..e2d244324ebe 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.h
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMDYNAMICTXPOWER_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
index 8d53cb73cea5..acc64fa8f166 100644
--- a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
+++ b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
index b0590abe87f0..bc574d2ad065 100644
--- a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
+++ b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMEDCATURBOCHECK_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
index 9e161f080c57..ee2c293e4f59 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
index fdb4f8579ff9..d3af1caaa73c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
index af7b44e29092..6ca799816c08 100644
--- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
+++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
index 3f650912f4ab..a7f13a85559c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
+++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
*****************************************************************************/
#ifndef __ODMNOISEMONITOR_H__
#define __ODMNOISEMONITOR_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_PathDiv.c b/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
index 2735ebfb6be3..4d22360934f6 100644
--- a/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
+++ b/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_PathDiv.h b/drivers/staging/rtl8723bs/hal/odm_PathDiv.h
index becde2e2a9ee..7a5bc00c3682 100644
--- a/drivers/staging/rtl8723bs/hal/odm_PathDiv.h
+++ b/drivers/staging/rtl8723bs/hal/odm_PathDiv.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODMPATHDIV_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c
index 0e4ce2741737..ecf0045fcad9 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c
+++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h
index 0700351a2b74..96ef1cc41a96 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h
+++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODM_RTL8723B_H__
#define __ODM_RTL8723B_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
index cdc9f38438d1..39f989bf3410 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
+++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
index a6b3d21e6463..12dfc58a6da0 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
+++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __INC_ODM_REGCONFIG_H_8723B
#define __INC_ODM_REGCONFIG_H_8723B
diff --git a/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h b/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h
index dc20e6165911..f2c0707aad4c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h
+++ b/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODM_REGDEFINE11N_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_debug.c b/drivers/staging/rtl8723bs/hal/odm_debug.c
index 28cf0a66ff93..b92422c8fb8e 100644
--- a/drivers/staging/rtl8723bs/hal/odm_debug.c
+++ b/drivers/staging/rtl8723bs/hal/odm_debug.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include "odm_precomp.h"
diff --git a/drivers/staging/rtl8723bs/hal/odm_debug.h b/drivers/staging/rtl8723bs/hal/odm_debug.h
index ff131361248c..3e58cb806c8c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_debug.h
+++ b/drivers/staging/rtl8723bs/hal/odm_debug.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODM_DBG_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_interface.h b/drivers/staging/rtl8723bs/hal/odm_interface.h
index 8ad0a0afca57..63f374f0bda7 100644
--- a/drivers/staging/rtl8723bs/hal/odm_interface.h
+++ b/drivers/staging/rtl8723bs/hal/odm_interface.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/hal/odm_precomp.h b/drivers/staging/rtl8723bs/hal/odm_precomp.h
index f543bdb31a89..b5b0c0ed02fc 100644
--- a/drivers/staging/rtl8723bs/hal/odm_precomp.h
+++ b/drivers/staging/rtl8723bs/hal/odm_precomp.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODM_PRECOMP_H__
diff --git a/drivers/staging/rtl8723bs/hal/odm_reg.h b/drivers/staging/rtl8723bs/hal/odm_reg.h
index 2496dcef7a9f..1ec6ffd69dbe 100644
--- a/drivers/staging/rtl8723bs/hal/odm_reg.h
+++ b/drivers/staging/rtl8723bs/hal/odm_reg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/* File Name: odm_reg.h */
/* Description: */
diff --git a/drivers/staging/rtl8723bs/hal/odm_types.h b/drivers/staging/rtl8723bs/hal/odm_types.h
index 9e3d072b03db..28f42c9c3dd7 100644
--- a/drivers/staging/rtl8723bs/hal/odm_types.h
+++ b/drivers/staging/rtl8723bs/hal/odm_types.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __ODM_TYPES_H__
#define __ODM_TYPES_H__
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
index 69eed62b7c94..9f4a10aaa774 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTL8723B_CMD_C_
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
index b16255984f4e..6b6fc835c601 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/* Description: */
/* This file is for 92CE/92CU dynamic mechanism only */
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index 0ce9b47d644d..592917fc00aa 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HAL_INIT_C_
@@ -433,29 +425,29 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
goto exit;
}
- pFirmware->szFwBuffer = kmemdup(fw->data, fw->size, GFP_KERNEL);
- if (!pFirmware->szFwBuffer) {
+ pFirmware->fw_buffer_sz = kmemdup(fw->data, fw->size, GFP_KERNEL);
+ if (!pFirmware->fw_buffer_sz) {
rtStatus = _FAIL;
goto exit;
}
- pFirmware->ulFwLength = fw->size;
+ pFirmware->fw_length = fw->size;
release_firmware(fw);
- if (pFirmware->ulFwLength > FW_8723B_SIZE) {
+ if (pFirmware->fw_length > FW_8723B_SIZE) {
rtStatus = _FAIL;
- DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", pFirmware->ulFwLength, FW_8723B_SIZE);
+ DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", pFirmware->fw_length, FW_8723B_SIZE);
goto release_fw1;
}
- pFirmwareBuf = pFirmware->szFwBuffer;
- FirmwareLen = pFirmware->ulFwLength;
+ pFirmwareBuf = pFirmware->fw_buffer_sz;
+ FirmwareLen = pFirmware->fw_length;
/* To Check Fw header. Added by tynli. 2009.12.04. */
pFwHdr = (struct rt_firmware_hdr *)pFirmwareBuf;
- pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->Version);
- pHalData->FirmwareSubVersion = le16_to_cpu(pFwHdr->Subversion);
- pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature);
+ pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->version);
+ pHalData->FirmwareSubVersion = le16_to_cpu(pFwHdr->subversion);
+ pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->signature);
DBG_871X(
"%s: fw_ver =%x fw_subver =%04x sig = 0x%x, Month =%02x, Date =%02x, Hour =%02x, Minute =%02x\n",
@@ -463,10 +455,10 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
pHalData->FirmwareVersion,
pHalData->FirmwareSubVersion,
pHalData->FirmwareSignature,
- pFwHdr->Month,
- pFwHdr->Date,
- pFwHdr->Hour,
- pFwHdr->Minute
+ pFwHdr->month,
+ pFwHdr->date,
+ pFwHdr->hour,
+ pFwHdr->minute
);
if (IS_FW_HEADER_EXIST_8723B(pFwHdr)) {
@@ -518,7 +510,7 @@ fwdl_stat:
);
exit:
- kfree(pFirmware->szFwBuffer);
+ kfree(pFirmware->fw_buffer_sz);
kfree(pFirmware);
release_fw1:
kfree(pBTFirmware);
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index e34d133075c0..50428f688859 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTL8723B_PHYCFG_C_
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
index f6aeb2630398..aa45a8421ebe 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/******************************************************************************
*
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
index 14bfbe3be0ca..76c8e6e9e6bc 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTL8723B_REDESC_C_
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index 5d5cd4d01156..85077947b9b8 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTL8723BS_RECV_C_
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index 6281dfa1a3ca..10b3f9733bad 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RTL8723BS_XMIT_C_
diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
index 1af77add6af4..3c65a9c02bbd 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _SDIO_HALINIT_C_
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index ab2ff53a8e57..d6b93e1f78d8 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
*******************************************************************************/
#define _SDIO_OPS_C_
diff --git a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
index fbb83db4fb60..fb80901f0788 100644
--- a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
+++ b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*****************************************************************************
*
diff --git a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
index 5bb9f5a04734..7040cfc507d8 100644
--- a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
+++ b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HALPWRSEQCMD_H__
#define __HALPWRSEQCMD_H__
diff --git a/drivers/staging/rtl8723bs/include/HalVerDef.h b/drivers/staging/rtl8723bs/include/HalVerDef.h
index a9e8609303b9..160f34efbfd5 100644
--- a/drivers/staging/rtl8723bs/include/HalVerDef.h
+++ b/drivers/staging/rtl8723bs/include/HalVerDef.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_VERSION_DEF_H__
#define __HAL_VERSION_DEF_H__
diff --git a/drivers/staging/rtl8723bs/include/autoconf.h b/drivers/staging/rtl8723bs/include/autoconf.h
index 09ed29f4efbd..196aca3aed7b 100644
--- a/drivers/staging/rtl8723bs/include/autoconf.h
+++ b/drivers/staging/rtl8723bs/include/autoconf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index abadea07466d..bab9811aeb5f 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __BASIC_TYPES_H__
#define __BASIC_TYPES_H__
diff --git a/drivers/staging/rtl8723bs/include/cmd_osdep.h b/drivers/staging/rtl8723bs/include/cmd_osdep.h
index 3ad3ace86fd4..0749936df032 100644
--- a/drivers/staging/rtl8723bs/include/cmd_osdep.h
+++ b/drivers/staging/rtl8723bs/include/cmd_osdep.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __CMD_OSDEP_H_
#define __CMD_OSDEP_H_
diff --git a/drivers/staging/rtl8723bs/include/drv_conf.h b/drivers/staging/rtl8723bs/include/drv_conf.h
index 3e1ed0717ed8..7fc88b07a25e 100644
--- a/drivers/staging/rtl8723bs/include/drv_conf.h
+++ b/drivers/staging/rtl8723bs/include/drv_conf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __DRV_CONF_H__
#define __DRV_CONF_H__
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index 16b81b1a3f33..c57f290f605a 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*-------------------------------------------------------------------------------
diff --git a/drivers/staging/rtl8723bs/include/drv_types_sdio.h b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
index aef9bf71ab25..23bf30ece2df 100644
--- a/drivers/staging/rtl8723bs/include/drv_types_sdio.h
+++ b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __DRV_TYPES_SDIO_H__
#define __DRV_TYPES_SDIO_H__
diff --git a/drivers/staging/rtl8723bs/include/ethernet.h b/drivers/staging/rtl8723bs/include/ethernet.h
index bd7099497b95..59899ab52aab 100644
--- a/drivers/staging/rtl8723bs/include/ethernet.h
+++ b/drivers/staging/rtl8723bs/include/ethernet.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
/*! \file */
#ifndef __INC_ETHERNET_H
diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h
index 7ee59c07fbf9..4066b0a1450c 100644
--- a/drivers/staging/rtl8723bs/include/hal_btcoex.h
+++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_BTCOEX_H__
#define __HAL_BTCOEX_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h
index 3e9ed3b66632..d1c5b3193043 100644
--- a/drivers/staging/rtl8723bs/include/hal_com.h
+++ b/drivers/staging/rtl8723bs/include/hal_com.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_COMMON_H__
#define __HAL_COMMON_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_com_h2c.h b/drivers/staging/rtl8723bs/include/hal_com_h2c.h
index 86b0c42295c2..7dbae5e2050e 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_h2c.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_h2c.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __COMMON_H2C_H__
#define __COMMON_H2C_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
index bcd81f50581f..c5184315f82f 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_COM_PHYCFG_H__
#define __HAL_COM_PHYCFG_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_com_reg.h b/drivers/staging/rtl8723bs/include/hal_com_reg.h
index fbf33dba1757..31a187b35810 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_reg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_reg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_COMMON_REG_H__
#define __HAL_COMMON_REG_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h
index 74a1db1eac38..7d782659a84f 100644
--- a/drivers/staging/rtl8723bs/include/hal_data.h
+++ b/drivers/staging/rtl8723bs/include/hal_data.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_DATA_H__
#define __HAL_DATA_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h
index 276089ad4864..19ceb4aa753e 100644
--- a/drivers/staging/rtl8723bs/include/hal_intf.h
+++ b/drivers/staging/rtl8723bs/include/hal_intf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_INTF_H__
#define __HAL_INTF_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_pg.h b/drivers/staging/rtl8723bs/include/hal_pg.h
index ba2a0b0c5b2f..0b7a8adf5c74 100644
--- a/drivers/staging/rtl8723bs/include/hal_pg.h
+++ b/drivers/staging/rtl8723bs/include/hal_pg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_PG_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_phy.h b/drivers/staging/rtl8723bs/include/hal_phy.h
index 15f192697957..c6b9bf139ef6 100644
--- a/drivers/staging/rtl8723bs/include/hal_phy.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_PHY_H__
#define __HAL_PHY_H__
diff --git a/drivers/staging/rtl8723bs/include/Hal8723BPhyCfg.h b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
index 22250411ed6c..640427f407e3 100644
--- a/drivers/staging/rtl8723bs/include/Hal8723BPhyCfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __INC_HAL8723BPHYCFG_H__
#define __INC_HAL8723BPHYCFG_H__
diff --git a/drivers/staging/rtl8723bs/include/hal_phy_reg.h b/drivers/staging/rtl8723bs/include/hal_phy_reg.h
index 518095269497..682cdd6655ab 100644
--- a/drivers/staging/rtl8723bs/include/hal_phy_reg.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy_reg.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_PHY_REG_H__
#define __HAL_PHY_REG_H__
diff --git a/drivers/staging/rtl8723bs/include/Hal8723BPhyReg.h b/drivers/staging/rtl8723bs/include/hal_phy_reg_8723b.h
index 84a08e0092dd..b0b1ac1090fc 100644
--- a/drivers/staging/rtl8723bs/include/Hal8723BPhyReg.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy_reg_8723b.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __INC_HAL8723BPHYREG_H__
#define __INC_HAL8723BPHYREG_H__
diff --git a/drivers/staging/rtl8723bs/include/Hal8723BPwrSeq.h b/drivers/staging/rtl8723bs/include/hal_pwr_seq.h
index 130a94879805..130a94879805 100644
--- a/drivers/staging/rtl8723bs/include/Hal8723BPwrSeq.h
+++ b/drivers/staging/rtl8723bs/include/hal_pwr_seq.h
diff --git a/drivers/staging/rtl8723bs/include/hal_sdio.h b/drivers/staging/rtl8723bs/include/hal_sdio.h
index 691a02e980a3..3fc8acb430e5 100644
--- a/drivers/staging/rtl8723bs/include/hal_sdio.h
+++ b/drivers/staging/rtl8723bs/include/hal_sdio.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __HAL_SDIO_H_
#define __HAL_SDIO_H_
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h
index c8e5251c2760..974e922f54fa 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __IEEE80211_H
#define __IEEE80211_H
diff --git a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
index 2d42e0c2deff..931599d8b08a 100644
--- a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
+++ b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __IOCTL_CFG80211_H__
#define __IOCTL_CFG80211_H__
diff --git a/drivers/staging/rtl8723bs/include/mlme_osdep.h b/drivers/staging/rtl8723bs/include/mlme_osdep.h
index 69fd5543a3b1..f0d19637fb0f 100644
--- a/drivers/staging/rtl8723bs/include/mlme_osdep.h
+++ b/drivers/staging/rtl8723bs/include/mlme_osdep.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __MLME_OSDEP_H_
#define __MLME_OSDEP_H_
diff --git a/drivers/staging/rtl8723bs/include/osdep_intf.h b/drivers/staging/rtl8723bs/include/osdep_intf.h
index cd738da3bec9..0ea91a111da3 100644
--- a/drivers/staging/rtl8723bs/include/osdep_intf.h
+++ b/drivers/staging/rtl8723bs/include/osdep_intf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __OSDEP_INTF_H_
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h
index e62ed71e1d80..76d619585046 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __OSDEP_SERVICE_H_
#define __OSDEP_SERVICE_H_
diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 711863d74a01..58d1e1019241 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __OSDEP_LINUX_SERVICE_H_
#define __OSDEP_LINUX_SERVICE_H_
diff --git a/drivers/staging/rtl8723bs/include/recv_osdep.h b/drivers/staging/rtl8723bs/include/recv_osdep.h
index a480874a2f2a..6fea0e948271 100644
--- a/drivers/staging/rtl8723bs/include/recv_osdep.h
+++ b/drivers/staging/rtl8723bs/include/recv_osdep.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RECV_OSDEP_H_
#define __RECV_OSDEP_H_
diff --git a/drivers/staging/rtl8723bs/include/rtl8192c_recv.h b/drivers/staging/rtl8723bs/include/rtl8192c_recv.h
index 3e1be0092df4..c77d172de7d0 100644
--- a/drivers/staging/rtl8723bs/include/rtl8192c_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtl8192c_recv.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTL8192C_RECV_H_
#define _RTL8192C_RECV_H_
diff --git a/drivers/staging/rtl8723bs/include/rtl8192c_rf.h b/drivers/staging/rtl8723bs/include/rtl8192c_rf.h
index 97900a31b326..ad684add8dd6 100644
--- a/drivers/staging/rtl8723bs/include/rtl8192c_rf.h
+++ b/drivers/staging/rtl8723bs/include/rtl8192c_rf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTL8192C_RF_H_
#define _RTL8192C_RF_H_
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h b/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
index 8d610646ad17..ecfd2d383ac2 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_CMD_H__
#define __RTL8723B_CMD_H__
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_dm.h b/drivers/staging/rtl8723bs/include/rtl8723b_dm.h
index cc64b38ead2a..1d2da5286e7c 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_dm.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_dm.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_DM_H__
#define __RTL8723B_DM_H__
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
index adaeea115e4d..8f00ced1c697 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_HAL_H__
#define __RTL8723B_HAL_H__
@@ -24,165 +16,179 @@
#include "rtl8723b_xmit.h"
#include "rtl8723b_cmd.h"
#include "rtw_mp.h"
-#include "Hal8723BPwrSeq.h"
-#include "Hal8723BPhyReg.h"
-#include "Hal8723BPhyCfg.h"
+#include "hal_pwr_seq.h"
+#include "hal_phy_reg_8723b.h"
+#include "hal_phy_cfg.h"
/* */
-/* RTL8723B From file */
+/* RTL8723B From file */
/* */
- #define RTL8723B_FW_IMG "rtl8723b/FW_NIC.bin"
- #define RTL8723B_FW_WW_IMG "rtl8723b/FW_WoWLAN.bin"
- #define RTL8723B_PHY_REG "rtl8723b/PHY_REG.txt"
- #define RTL8723B_PHY_RADIO_A "rtl8723b/RadioA.txt"
- #define RTL8723B_PHY_RADIO_B "rtl8723b/RadioB.txt"
- #define RTL8723B_TXPWR_TRACK "rtl8723b/TxPowerTrack.txt"
- #define RTL8723B_AGC_TAB "rtl8723b/AGC_TAB.txt"
- #define RTL8723B_PHY_MACREG "rtl8723b/MAC_REG.txt"
- #define RTL8723B_PHY_REG_PG "rtl8723b/PHY_REG_PG.txt"
- #define RTL8723B_PHY_REG_MP "rtl8723b/PHY_REG_MP.txt"
- #define RTL8723B_TXPWR_LMT "rtl8723b/TXPWR_LMT.txt"
+#define RTL8723B_FW_IMG "rtl8723b/FW_NIC.bin"
+#define RTL8723B_FW_WW_IMG "rtl8723b/FW_WoWLAN.bin"
+#define RTL8723B_PHY_REG "rtl8723b/PHY_REG.txt"
+#define RTL8723B_PHY_RADIO_A "rtl8723b/RadioA.txt"
+#define RTL8723B_PHY_RADIO_B "rtl8723b/RadioB.txt"
+#define RTL8723B_TXPWR_TRACK "rtl8723b/TxPowerTrack.txt"
+#define RTL8723B_AGC_TAB "rtl8723b/AGC_TAB.txt"
+#define RTL8723B_PHY_MACREG "rtl8723b/MAC_REG.txt"
+#define RTL8723B_PHY_REG_PG "rtl8723b/PHY_REG_PG.txt"
+#define RTL8723B_PHY_REG_MP "rtl8723b/PHY_REG_MP.txt"
+#define RTL8723B_TXPWR_LMT "rtl8723b/TXPWR_LMT.txt"
/* */
-/* RTL8723B From header */
+/* RTL8723B From header */
/* */
-#define FW_8723B_SIZE 0x8000
-#define FW_8723B_START_ADDRESS 0x1000
-#define FW_8723B_END_ADDRESS 0x1FFF /* 0x5FFF */
+#define FW_8723B_SIZE 0x8000
+#define FW_8723B_START_ADDRESS 0x1000
+#define FW_8723B_END_ADDRESS 0x1FFF /* 0x5FFF */
-#define IS_FW_HEADER_EXIST_8723B(_pFwHdr) ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x5300)
+#define IS_FW_HEADER_EXIST_8723B(fw_hdr) \
+ ((le16_to_cpu(fw_hdr->signature) & 0xFFF0) == 0x5300)
struct rt_firmware {
- u32 ulFwLength;
- u8 *szFwBuffer;
+ u32 fw_length;
+ u8 *fw_buffer_sz;
};
-/* This structure must be cared byte-ordering */
+/* This structure must be carefully byte-ordered. */
struct rt_firmware_hdr {
/* 8-byte alinment required */
/* LONG WORD 0 ---- */
- __le16 Signature; /* 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut */
- u8 Category; /* AP/NIC and USB/PCI */
- u8 Function; /* Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions */
- __le16 Version; /* FW Version */
- __le16 Subversion; /* FW Subversion, default 0x00 */
+ __le16 signature; /* 92C0: test chip; 92C, 88C0: test chip;
+ * 88C1: MP A-cut; 92C1: MP A-cut */
+ u8 category; /* AP/NIC and USB/PCI */
+ u8 function; /* Reserved for different FW function indications,
+ * for further use when driver needs to download
+ * different FW in different conditions. */
+ __le16 version; /* FW Version */
+ __le16 subversion; /* FW Subversion, default 0x00 */
/* LONG WORD 1 ---- */
- u8 Month; /* Release time Month field */
- u8 Date; /* Release time Date field */
- u8 Hour; /* Release time Hour field */
- u8 Minute; /* Release time Minute field */
- __le16 RamCodeSize; /* The size of RAM code */
- __le16 Rsvd2;
+ u8 month; /* Release time Month field */
+ u8 date; /* Release time Date field */
+ u8 hour; /* Release time Hour field */
+ u8 minute; /* Release time Minute field */
+
+ __le16 ram_code_size; /* The size of RAM code */
+ __le16 rsvd2;
/* LONG WORD 2 ---- */
- __le32 SvnIdx; /* The SVN entry index */
- __le32 Rsvd3;
+ __le32 svn_idx; /* The SVN entry index */
+ __le32 rsvd3;
/* LONG WORD 3 ---- */
- __le32 Rsvd4;
- __le32 Rsvd5;
+ __le32 rsvd4;
+ __le32 rsvd5;
};
-#define DRIVER_EARLY_INT_TIME_8723B 0x05
-#define BCN_DMA_ATIME_INT_TIME_8723B 0x02
+#define DRIVER_EARLY_INT_TIME_8723B 0x05
+#define BCN_DMA_ATIME_INT_TIME_8723B 0x02
-/* for 8723B */
-/* TX 32K, RX 16K, Page size 128B for TX, 8B for RX */
-#define PAGE_SIZE_TX_8723B 128
-#define PAGE_SIZE_RX_8723B 8
+/* for 8723B */
+/* TX 32K, RX 16K, Page size 128B for TX, 8B for RX */
+#define PAGE_SIZE_TX_8723B 128
+#define PAGE_SIZE_RX_8723B 8
-#define RX_DMA_SIZE_8723B 0x4000 /* 16K */
-#define RX_DMA_RESERVED_SIZE_8723B 0x80 /* 128B, reserved for tx report */
-#define RX_DMA_BOUNDARY_8723B (RX_DMA_SIZE_8723B - RX_DMA_RESERVED_SIZE_8723B - 1)
+#define RX_DMA_SIZE_8723B 0x4000 /* 16K */
+#define RX_DMA_RESERVED_SIZE_8723B 0x80 /* 128B, reserved for tx report */
+#define RX_DMA_BOUNDARY_8723B \
+ (RX_DMA_SIZE_8723B - RX_DMA_RESERVED_SIZE_8723B - 1)
-
-/* Note: We will divide number of page equally for each queue other than public queue! */
+/* Note: We will divide number of pages equally for each queue other than the
+ * public queue!
+ */
/* For General Reserved Page Number(Beacon Queue is reserved page) */
/* Beacon:2, PS-Poll:1, Null Data:1, Qos Null Data:1, BT Qos Null Data:1 */
-#define BCNQ_PAGE_NUM_8723B 0x08
-#define BCNQ1_PAGE_NUM_8723B 0x00
+#define BCNQ_PAGE_NUM_8723B 0x08
+#define BCNQ1_PAGE_NUM_8723B 0x00
#ifdef CONFIG_PNO_SUPPORT
#undef BCNQ1_PAGE_NUM_8723B
-#define BCNQ1_PAGE_NUM_8723B 0x00 /* 0x04 */
+#define BCNQ1_PAGE_NUM_8723B 0x00 /* 0x04 */
#endif
-#define MAX_RX_DMA_BUFFER_SIZE_8723B 0x2800 /* RX 10K */
-/* For WoWLan , more reserved page */
+#define MAX_RX_DMA_BUFFER_SIZE_8723B 0x2800 /* RX 10K */
+
+/* For WoWLan, more reserved page */
/* ARP Rsp:1, RWC:1, GTK Info:1, GTK RSP:2, GTK EXT MEM:2, PNO: 6 */
#ifdef CONFIG_WOWLAN
-#define WOWLAN_PAGE_NUM_8723B 0x07
+#define WOWLAN_PAGE_NUM_8723B 0x07
#else
-#define WOWLAN_PAGE_NUM_8723B 0x00
+#define WOWLAN_PAGE_NUM_8723B 0x00
#endif
#ifdef CONFIG_PNO_SUPPORT
#undef WOWLAN_PAGE_NUM_8723B
-#define WOWLAN_PAGE_NUM_8723B 0x0d
+#define WOWLAN_PAGE_NUM_8723B 0x0d
#endif
#ifdef CONFIG_AP_WOWLAN
-#define AP_WOWLAN_PAGE_NUM_8723B 0x02
+#define AP_WOWLAN_PAGE_NUM_8723B 0x02
#endif
-#define TX_TOTAL_PAGE_NUMBER_8723B (0xFF - BCNQ_PAGE_NUM_8723B - BCNQ1_PAGE_NUM_8723B - WOWLAN_PAGE_NUM_8723B)
-#define TX_PAGE_BOUNDARY_8723B (TX_TOTAL_PAGE_NUMBER_8723B + 1)
+#define TX_TOTAL_PAGE_NUMBER_8723B \
+ (0xFF - BCNQ_PAGE_NUM_8723B - \
+ BCNQ1_PAGE_NUM_8723B - \
+ WOWLAN_PAGE_NUM_8723B)
+#define TX_PAGE_BOUNDARY_8723B (TX_TOTAL_PAGE_NUMBER_8723B + 1)
-#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B TX_TOTAL_PAGE_NUMBER_8723B
-#define WMM_NORMAL_TX_PAGE_BOUNDARY_8723B (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B + 1)
+#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B TX_TOTAL_PAGE_NUMBER_8723B
+#define WMM_NORMAL_TX_PAGE_BOUNDARY_8723B \
+ (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B + 1)
-/* For Normal Chip Setting */
-/* (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B */
-#define NORMAL_PAGE_NUM_HPQ_8723B 0x0C
-#define NORMAL_PAGE_NUM_LPQ_8723B 0x02
-#define NORMAL_PAGE_NUM_NPQ_8723B 0x02
+/* For Normal Chip Setting */
+/* (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B */
+#define NORMAL_PAGE_NUM_HPQ_8723B 0x0C
+#define NORMAL_PAGE_NUM_LPQ_8723B 0x02
+#define NORMAL_PAGE_NUM_NPQ_8723B 0x02
/* Note: For Normal Chip Setting, modify later */
-#define WMM_NORMAL_PAGE_NUM_HPQ_8723B 0x30
-#define WMM_NORMAL_PAGE_NUM_LPQ_8723B 0x20
-#define WMM_NORMAL_PAGE_NUM_NPQ_8723B 0x20
+#define WMM_NORMAL_PAGE_NUM_HPQ_8723B 0x30
+#define WMM_NORMAL_PAGE_NUM_LPQ_8723B 0x20
+#define WMM_NORMAL_PAGE_NUM_NPQ_8723B 0x20
#include "HalVerDef.h"
#include "hal_com.h"
-#define EFUSE_OOB_PROTECT_BYTES 15
+#define EFUSE_OOB_PROTECT_BYTES 15
#define HAL_EFUSE_MEMORY
-#define HWSET_MAX_SIZE_8723B 512
-#define EFUSE_REAL_CONTENT_LEN_8723B 512
-#define EFUSE_MAP_LEN_8723B 512
-#define EFUSE_MAX_SECTION_8723B 64
+#define HWSET_MAX_SIZE_8723B 512
+#define EFUSE_REAL_CONTENT_LEN_8723B 512
+#define EFUSE_MAP_LEN_8723B 512
+#define EFUSE_MAX_SECTION_8723B 64
-#define EFUSE_IC_ID_OFFSET 506 /* For some inferiority IC purpose. added by Roger, 2009.09.02. */
-#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN_8723B)
+#define EFUSE_IC_ID_OFFSET 506 /* For some inferiority IC purpose.
+ * Added by Roger, 2009.09.02. */
+#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN_8723B)
-#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */
-#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */
+#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */
+#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */
/* */
-/* EFUSE for BT definition */
+/* EFUSE for BT definition */
/* */
-#define EFUSE_BT_REAL_BANK_CONTENT_LEN 512
-#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */
-#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */
-#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */
+#define EFUSE_BT_REAL_BANK_CONTENT_LEN 512
+#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */
+#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */
+#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */
-#define EFUSE_PROTECT_BYTES_BANK 16
+#define EFUSE_PROTECT_BYTES_BANK 16
-/* Description: Determine the types of C2H events that are the same in driver and Fw. */
-/* Fisrt constructed by tynli. 2009.10.09. */
-typedef enum _C2H_EVT
-{
+/* Description: Determine the types of C2H events that are the same in driver
+ * and FW; First constructed by tynli. 2009.10.09.
+ */
+typedef enum _C2H_EVT {
C2H_DBG = 0,
C2H_TSF = 1,
C2H_AP_RPT_RSP = 2,
- C2H_CCX_TX_RPT = 3, /* The FW notify the report of the specific tx packet. */
+ C2H_CCX_TX_RPT = 3, /* The FW notify the report
+ * of the specific tx packet. */
C2H_BT_RSSI = 4,
C2H_BT_OP_MODE = 5,
C2H_EXT_RA_RPT = 6,
@@ -192,24 +198,24 @@ typedef enum _C2H_EVT
MAX_C2HEVENT
} C2H_EVT;
-typedef struct _C2H_EVT_HDR
-{
+typedef struct _C2H_EVT_HDR {
u8 CmdID;
u8 CmdLen;
u8 CmdSeq;
} __attribute__((__packed__)) C2H_EVT_HDR, *PC2H_EVT_HDR;
-typedef enum tag_Package_Definition
-{
- PACKAGE_DEFAULT,
- PACKAGE_QFN68,
- PACKAGE_TFBGA90,
- PACKAGE_TFBGA80,
- PACKAGE_TFBGA79
-}PACKAGE_TYPE_E;
+typedef enum tag_Package_Definition {
+ PACKAGE_DEFAULT,
+ PACKAGE_QFN68,
+ PACKAGE_TFBGA90,
+ PACKAGE_TFBGA80,
+ PACKAGE_TFBGA79
+} PACKAGE_TYPE_E;
-#define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
-#define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
+#define INCLUDE_MULTI_FUNC_BT(_Adapter) \
+ (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
+#define INCLUDE_MULTI_FUNC_GPS(_Adapter) \
+ (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
/* rtl8723a_hal_init.c */
s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw);
@@ -225,28 +231,40 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter);
u8 GetEEPROMSize8723B(struct adapter *padapter);
void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent);
void Hal_EfuseParseIDCode(struct adapter *padapter, u8 *hwinfo);
-void Hal_EfuseParseTxPowerInfo_8723B(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail);
-void Hal_EfuseParseBTCoexistInfo_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseEEPROMVer_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseChnlPlan_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseCustomerID_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseAntennaDiversity_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseXtal_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseThermalMeter_8723B(struct adapter *padapter, u8 *hwinfo, u8 AutoLoadFail);
-void Hal_EfuseParsePackageType_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
-void Hal_EfuseParseVoltage_8723B(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
+void Hal_EfuseParseTxPowerInfo_8723B(struct adapter *padapter, u8 *PROMContent,
+ bool AutoLoadFail);
+void Hal_EfuseParseBTCoexistInfo_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseEEPROMVer_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseChnlPlan_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseCustomerID_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseAntennaDiversity_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseXtal_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseThermalMeter_8723B(struct adapter *padapter, u8 *hwinfo,
+ u8 AutoLoadFail);
+void Hal_EfuseParsePackageType_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
+void Hal_EfuseParseVoltage_8723B(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length);
void rtl8723b_set_hal_ops(struct hal_ops *pHalFunc);
void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
-u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval);
-u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval);
+u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+ void *pval);
+u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+ void *pval);
/* register */
void rtl8723b_InitBeaconParameters(struct adapter *padapter);
-void _InitBurstPktLen_8723BS(struct adapter * Adapter);
+void _InitBurstPktLen_8723BS(struct adapter *adapter);
void _8051Reset8723(struct adapter *padapter);
#ifdef CONFIG_WOWLAN
void Hal_DetectWoWMode(struct adapter *padapter);
@@ -256,24 +274,25 @@ void rtl8723b_start_thread(struct adapter *padapter);
void rtl8723b_stop_thread(struct adapter *padapter);
#if defined(CONFIG_CHECK_BT_HANG)
-void rtl8723bs_init_checkbthang_workqueue(struct adapter * adapter);
-void rtl8723bs_free_checkbthang_workqueue(struct adapter * adapter);
-void rtl8723bs_cancle_checkbthang_workqueue(struct adapter * adapter);
-void rtl8723bs_hal_check_bt_hang(struct adapter * adapter);
+void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter);
+void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter);
+void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter);
+void rtl8723bs_hal_check_bt_hang(struct adapter *adapter);
#endif
#ifdef CONFIG_GPIO_WAKEUP
void HalSetOutPutGPIO(struct adapter *padapter, u8 index, u8 OutPutValue);
#endif
-int FirmwareDownloadBT(struct adapter * Adapter, struct rt_firmware *firmware);
+int FirmwareDownloadBT(struct adapter *adapter, struct rt_firmware *firmware);
void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len);
s32 c2h_id_filter_ccx_8723b(u8 *buf);
s32 c2h_handler_8723b(struct adapter *padapter, u8 *pC2hEvent);
-u8 MRateToHwRate8723B(u8 rate);
-u8 HwRateToMRate8723B(u8 rate);
+u8 MRateToHwRate8723B(u8 rate);
+u8 HwRateToMRate8723B(u8 rate);
-void Hal_ReadRFGainOffset(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail);
+void Hal_ReadRFGainOffset(struct adapter *padapter, u8 *hwinfo,
+ bool AutoLoadFail);
#endif
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
index 7218424dae99..31ae83f2557f 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_RECV_H__
#define __RTL8723B_RECV_H__
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
index f5aa1b09a608..1c16183caf9b 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_RF_H__
#define __RTL8723B_RF_H__
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_spec.h b/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
index 1906ff2038f5..9149fe598545 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
*******************************************************************************/
#ifndef __RTL8723B_SPEC_H__
#define __RTL8723B_SPEC_H__
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
index 3bea5d5dd82b..23a6069c3e5d 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTL8723B_XMIT_H__
#define __RTL8723B_XMIT_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_ap.h b/drivers/staging/rtl8723bs/include/rtw_ap.h
index 3c2d1e912a9d..fd56c9db16a9 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ap.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ap.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_AP_H_
#define __RTW_AP_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_beamforming.h b/drivers/staging/rtl8723bs/include/rtw_beamforming.h
index 69711e41c50b..031496c8c02c 100644
--- a/drivers/staging/rtl8723bs/include/rtw_beamforming.h
+++ b/drivers/staging/rtl8723bs/include/rtw_beamforming.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_BEAMFORMING_H_
#define __RTW_BEAMFORMING_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_br_ext.h b/drivers/staging/rtl8723bs/include/rtw_br_ext.h
index c942535a7961..5eaeb3c9a97c 100644
--- a/drivers/staging/rtl8723bs/include/rtw_br_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_br_ext.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_BR_EXT_H_
#define _RTW_BR_EXT_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h
index 9a5c3f40bddb..53f49c6b2fcd 100644
--- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h
+++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_BTCOEX_H__
#define __RTW_BTCOEX_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_byteorder.h b/drivers/staging/rtl8723bs/include/rtw_byteorder.h
index ffbbcec77a0d..f76fbfbed4c7 100644
--- a/drivers/staging/rtl8723bs/include/rtw_byteorder.h
+++ b/drivers/staging/rtl8723bs/include/rtw_byteorder.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTL871X_BYTEORDER_H_
#define _RTL871X_BYTEORDER_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h
index 286d329b7a4f..1530d0ea1d51 100644
--- a/drivers/staging/rtl8723bs/include/rtw_cmd.h
+++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_CMD_H_
#define __RTW_CMD_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_debug.h b/drivers/staging/rtl8723bs/include/rtw_debug.h
index 625e2a39a861..216d9492575e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_debug.h
+++ b/drivers/staging/rtl8723bs/include/rtw_debug.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_DEBUG_H__
#define __RTW_DEBUG_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_eeprom.h b/drivers/staging/rtl8723bs/include/rtw_eeprom.h
index 2e292bf9cf51..1fcd79fa1c21 100644
--- a/drivers/staging/rtl8723bs/include/rtw_eeprom.h
+++ b/drivers/staging/rtl8723bs/include/rtw_eeprom.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_EEPROM_H__
#define __RTW_EEPROM_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_efuse.h b/drivers/staging/rtl8723bs/include/rtw_efuse.h
index 5d3778a3204b..9d9a5a3e336d 100644
--- a/drivers/staging/rtl8723bs/include/rtw_efuse.h
+++ b/drivers/staging/rtl8723bs/include/rtw_efuse.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_EFUSE_H__
#define __RTW_EFUSE_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_event.h b/drivers/staging/rtl8723bs/include/rtw_event.h
index 2bf23de7e516..ee80aa21eb10 100644
--- a/drivers/staging/rtl8723bs/include/rtw_event.h
+++ b/drivers/staging/rtl8723bs/include/rtw_event.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_EVENT_H_
#define _RTW_EVENT_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_ht.h b/drivers/staging/rtl8723bs/include/rtw_ht.h
index 20ca0b7b481c..952c804dd0fd 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ht.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ht.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_HT_H_
#define _RTW_HT_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 0341d0d35375..4f8be55da65d 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_IO_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_ioctl.h b/drivers/staging/rtl8723bs/include/rtw_ioctl.h
index c19e179fc426..7179591cb01d 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ioctl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ioctl.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_IOCTL_H_
#define _RTW_IOCTL_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
index ebf233559f67..f0457e91d00f 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_IOCTL_SET_H_
#define __RTW_IOCTL_SET_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h
index 2e4f12b54929..1ea9ea0e8d2e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_MLME_H_
#define __RTW_MLME_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 6613dea2b283..4c3141882143 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_MLME_EXT_H_
#define __RTW_MLME_EXT_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h
index 88ace11e42e9..839084733201 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mp.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mp.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_MP_H_
#define _RTW_MP_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_odm.h b/drivers/staging/rtl8723bs/include/rtw_odm.h
index 961ae2c218f9..263e92cfea96 100644
--- a/drivers/staging/rtl8723bs/include/rtw_odm.h
+++ b/drivers/staging/rtl8723bs/include/rtw_odm.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_ODM_H__
#define __RTW_ODM_H__
diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
index faf91022f54a..72df6cffe62e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_PWRCTRL_H_
#define __RTW_PWRCTRL_H_
@@ -38,19 +30,18 @@
#define BTCOEX_ALIVE BIT(4)
-enum Power_Mgnt
-{
- PS_MODE_ACTIVE = 0 ,
- PS_MODE_MIN ,
- PS_MODE_MAX ,
- PS_MODE_DTIM , /* PS_MODE_SELF_DEFINED */
- PS_MODE_VOIP ,
- PS_MODE_UAPSD_WMM ,
- PS_MODE_UAPSD ,
- PS_MODE_IBSS ,
- PS_MODE_WWLAN ,
- PM_Radio_Off ,
- PM_Card_Disable ,
+enum Power_Mgnt {
+ PS_MODE_ACTIVE = 0,
+ PS_MODE_MIN,
+ PS_MODE_MAX,
+ PS_MODE_DTIM, /* PS_MODE_SELF_DEFINED */
+ PS_MODE_VOIP,
+ PS_MODE_UAPSD_WMM,
+ PS_MODE_UAPSD,
+ PS_MODE_IBSS,
+ PS_MODE_WWLAN,
+ PM_Radio_Off,
+ PM_Card_Disable,
PS_MODE_NUM,
};
diff --git a/drivers/staging/rtl8723bs/include/rtw_qos.h b/drivers/staging/rtl8723bs/include/rtw_qos.h
index ce6d9142bc5a..1f28837f6c27 100644
--- a/drivers/staging/rtl8723bs/include/rtw_qos.h
+++ b/drivers/staging/rtl8723bs/include/rtw_qos.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h
index d4986f5685c5..1f53c1c7b0da 100644
--- a/drivers/staging/rtl8723bs/include/rtw_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtw_recv.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_RECV_H_
#define _RTW_RECV_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_rf.h b/drivers/staging/rtl8723bs/include/rtw_rf.h
index f9becab7f7ad..d3a8e4b7069a 100644
--- a/drivers/staging/rtl8723bs/include/rtw_rf.h
+++ b/drivers/staging/rtl8723bs/include/rtw_rf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_RF_H_
#define __RTW_RF_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h
index d5af72b2335d..bea184452edd 100644
--- a/drivers/staging/rtl8723bs/include/rtw_security.h
+++ b/drivers/staging/rtl8723bs/include/rtw_security.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_SECURITY_H_
#define __RTW_SECURITY_H_
diff --git a/drivers/staging/rtl8723bs/include/rtw_version.h b/drivers/staging/rtl8723bs/include/rtw_version.h
index 628d987c3e86..55e907b097ae 100644
--- a/drivers/staging/rtl8723bs/include/rtw_version.h
+++ b/drivers/staging/rtl8723bs/include/rtw_version.h
@@ -1,2 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
#define DRIVERVERSION "v4.3.5.5_12290.20140916_BTCOEX20140507-4E40"
#define BTCOEXVERSION "BTCOEX20140507-4E40"
diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h
index 11571649cd2c..a75b668d09a6 100644
--- a/drivers/staging/rtl8723bs/include/rtw_xmit.h
+++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _RTW_XMIT_H_
#define _RTW_XMIT_H_
diff --git a/drivers/staging/rtl8723bs/include/sdio_hal.h b/drivers/staging/rtl8723bs/include/sdio_hal.h
index 8fd8bbeda2d8..6fae19dd0cbd 100644
--- a/drivers/staging/rtl8723bs/include/sdio_hal.h
+++ b/drivers/staging/rtl8723bs/include/sdio_hal.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __SDIO_HAL_H__
#define __SDIO_HAL_H__
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops.h b/drivers/staging/rtl8723bs/include/sdio_ops.h
index 8fffc652cf0c..0f117ff1fbbe 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __SDIO_OPS_H__
#define __SDIO_OPS_H__
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops_linux.h b/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
index bd62caec409f..16a03adbc2cf 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __SDIO_OPS_LINUX_H__
#define __SDIO_OPS_LINUX_H__
diff --git a/drivers/staging/rtl8723bs/include/sdio_osintf.h b/drivers/staging/rtl8723bs/include/sdio_osintf.h
index 86673682fb4f..146b44f95e29 100644
--- a/drivers/staging/rtl8723bs/include/sdio_osintf.h
+++ b/drivers/staging/rtl8723bs/include/sdio_osintf.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __SDIO_OSINTF_H__
#define __SDIO_OSINTF_H__
diff --git a/drivers/staging/rtl8723bs/include/sta_info.h b/drivers/staging/rtl8723bs/include/sta_info.h
index 84fa116fc5da..b9df42d0677e 100644
--- a/drivers/staging/rtl8723bs/include/sta_info.h
+++ b/drivers/staging/rtl8723bs/include/sta_info.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __STA_INFO_H_
#define __STA_INFO_H_
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index 530d698f50d9..08bc79840b23 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef _WIFI_H_
#define _WIFI_H_
@@ -976,7 +968,7 @@ enum HT_CAP_AMPDU_FACTOR {
#define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A
#define P2P_STATUS_FAIL_USER_REJECT 0x0B
-/* Value of Inviation Flags Attribute */
+/* Value of Invitation Flags Attribute */
#define P2P_INVITATION_FLAGS_PERSISTENT BIT(0)
#define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \
@@ -1082,15 +1074,15 @@ enum P2P_STATE {
P2P_STATE_GONEGO_ING = 9, /* Doing the group owner negoitation handshake */
P2P_STATE_GONEGO_OK = 10, /* finish the group negoitation handshake with success */
P2P_STATE_GONEGO_FAIL = 11, /* finish the group negoitation handshake with failure */
- P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /* receiving the P2P Inviation request and match with the profile. */
+ P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /* receiving the P2P Invitation request and match with the profile. */
P2P_STATE_PROVISIONING_ING = 13, /* Doing the P2P WPS */
P2P_STATE_PROVISIONING_DONE = 14, /* Finish the P2P WPS */
P2P_STATE_TX_INVITE_REQ = 15, /* Transmit the P2P Invitation request */
P2P_STATE_RX_INVITE_RESP_OK = 16, /* Receiving the P2P Invitation response */
- P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, /* receiving the P2P Inviation request and dismatch with the profile. */
- P2P_STATE_RECV_INVITE_REQ_GO = 18, /* receiving the P2P Inviation request and this wifi is GO. */
- P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /* receiving the P2P Inviation request to join an existing P2P Group. */
- P2P_STATE_RX_INVITE_RESP_FAIL = 20, /* recveing the P2P Inviation response with failure */
+ P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, /* receiving the P2P Invitation request and mismatch with the profile. */
+ P2P_STATE_RECV_INVITE_REQ_GO = 18, /* receiving the P2P Invitation request and this wifi is GO. */
+ P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /* receiving the P2P Invitation request to join an existing P2P Group. */
+ P2P_STATE_RX_INVITE_RESP_FAIL = 20, /* recveing the P2P Invitation response with failure */
P2P_STATE_RX_INFOR_NOREADY = 21, /* receiving p2p negoitation response with information is not available */
P2P_STATE_TX_INFOR_NOREADY = 22, /* sending p2p negoitation response with information is not available */
};
diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
index af78d97980fa..bdb14a84e5a5 100644
--- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __WLAN_BSSDEF_H__
#define __WLAN_BSSDEF_H__
diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h
index 46909ff7339c..377b453de199 100644
--- a/drivers/staging/rtl8723bs/include/xmit_osdep.h
+++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __XMIT_OSDEP_H_
#define __XMIT_OSDEP_H_
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 46bc2e512557..02178e25fbb8 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _IOCTL_CFG80211_C_
@@ -2472,7 +2464,7 @@ static int rtw_cfg80211_monitor_if_close(struct net_device *ndev)
return ret;
}
-static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev)
+static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev)
{
int ret = 0;
int rtap_len;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index b26533983864..39502156f652 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _IOCTL_LINUX_C_
diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index a4ef5789d794..da4bd5292b0a 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index fc5e3d4739c0..ace68f023b49 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _OS_INTFS_C_
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index f4221952dd1b..e14d7cc411c9 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index b43e24c3a23a..67ec336264e5 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _RECV_OSDEP_C_
diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
index 49c8684dc25b..d8e7ad1ed842 100644
--- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
+++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#include <drv_types.h>
diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.h b/drivers/staging/rtl8723bs/os_dep/rtw_proc.h
index f633663fa790..c7e6f62b61ef 100644
--- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.h
+++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.h
@@ -1,16 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#ifndef __RTW_PROC_H__
#define __RTW_PROC_H__
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 99c407ba0874..22191c9584ad 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _HCI_INTF_C_
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 3108a625ada3..43a9d922e3aa 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
*******************************************************************************/
#define _SDIO_OPS_LINUX_C_
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 21e1b811f997..4da0c6f323d1 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
******************************************************************************/
#define _XMIT_OSDEP_C_
diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index eea00035a735..e46e47d93d7d 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/base.h b/drivers/staging/rtlwifi/base.h
index b7f92b32978e..4299ca181365 100644
--- a/drivers/staging/rtlwifi/base.h
+++ b/drivers/staging/rtlwifi/base.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h b/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
index d78cd9394373..90d0f2462303 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
+++ b/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
index 157395b85405..ade271cb4aab 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h
index 583e99dc5cc9..f1bf83001164 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c b/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c
index 5b826403ed66..7e6071059a95 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h b/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h
index 212e0c8404fa..c99aa6ff1d7f 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c b/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c
index 43d628a71611..ad7b6c42840b 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h b/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h
index 464774e6e7b4..5910fe1a1fb0 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
index 493011a54e64..4d1f9bf53c53 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h
index 8913983b8ad8..fd65de2ac8b5 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/rtl_btc.c b/drivers/staging/rtlwifi/btcoexist/rtl_btc.c
index 18a4f5b43b5a..dfd47b88e54b 100644
--- a/drivers/staging/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/staging/rtlwifi/btcoexist/rtl_btc.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2013 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/btcoexist/rtl_btc.h b/drivers/staging/rtlwifi/btcoexist/rtl_btc.h
index 8c996055de71..0141f4641ef0 100644
--- a/drivers/staging/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/staging/rtlwifi/btcoexist/rtl_btc.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2010 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/cam.c b/drivers/staging/rtlwifi/cam.c
index ca1c9e36d976..e8572d654655 100644
--- a/drivers/staging/rtlwifi/cam.c
+++ b/drivers/staging/rtlwifi/cam.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/cam.h b/drivers/staging/rtlwifi/cam.h
index b25729e15b75..3f1d8b5a13a5 100644
--- a/drivers/staging/rtlwifi/cam.h
+++ b/drivers/staging/rtlwifi/cam.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index 3ec039498208..ca37f7511c4d 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/core.h b/drivers/staging/rtlwifi/core.h
index 4c2b69412621..991af1abf8ca 100644
--- a/drivers/staging/rtlwifi/core.h
+++ b/drivers/staging/rtlwifi/core.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index be8d72cb63db..c041bc315616 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/debug.h b/drivers/staging/rtlwifi/debug.h
index ac942477f629..666d7bc80c48 100644
--- a/drivers/staging/rtlwifi/debug.h
+++ b/drivers/staging/rtlwifi/debug.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c
index d74c80d512c9..d7c7d146a84d 100644
--- a/drivers/staging/rtlwifi/efuse.c
+++ b/drivers/staging/rtlwifi/efuse.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/efuse.h b/drivers/staging/rtlwifi/efuse.h
index 0a23305b0b7a..5335d3ee6da7 100644
--- a/drivers/staging/rtlwifi/efuse.h
+++ b/drivers/staging/rtlwifi/efuse.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_2_platform.h b/drivers/staging/rtlwifi/halmac/halmac_2_platform.h
index 26e60cb873eb..262304deb7fc 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_2_platform.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_2_platform.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h
index 04e44aed9b45..9013baefcede 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c
index b2a5aed75dca..c68b9e82c2e7 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c
index 0edd1f5a04a8..08f6536840cf 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h
index 79a6072ef2ef..03bbec32a3e3 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c
index 6b729fe4c096..aea481bb2403 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h
index cf21e3d25607..072cd40fd339 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c
index e25e2b0ebb4c..a716fb532170 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h
index c68ea0039703..b47c50863f06 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c
index 4d708d841bad..a6b6d7fa2689 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h
index 07ffb3baf7c0..75c83f7f031e 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c
index 5f27eb172430..2eaf362ca8c3 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h
index 3a99fd5675e0..8ba7bee0a99b 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c
index 5f1dff8d9e3b..bcc402838bc0 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h
index 5ac2b15477c0..8488fc5f98ee 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h
index ea1206744902..ec9b10277450 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
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 448b1379d220..acd7930e417d 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h
index 5debd1ff3abd..6c6eb85a09a3 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c
index fa97cac34742..8462f23b652e 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h
index 34969fc5c03e..dc4d98bcc68c 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c
index 69b26a5a3cf3..979821ea54a1 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h
index ee441eee24d6..2a891b0f6ab8 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c
index 17d7c3cc62ec..0bd6abdd0a68 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h
index a3d2a6abd91b..befa4a5415db 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
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 c4cb217d3d1f..53f55f129a76 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h
index 1b59301d1158..86d59d9b76f3 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_api.c b/drivers/staging/rtlwifi/halmac/halmac_api.c
index 0886a4611da0..e75eb42009c8 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_api.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_api.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_api.h b/drivers/staging/rtlwifi/halmac/halmac_api.h
index 917a64601053..4922cc8ce6f2 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_api.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_api.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_bit2.h b/drivers/staging/rtlwifi/halmac/halmac_bit2.h
index 1c7fe5d7df64..5f0f8528d136 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_bit2.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_bit2.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h b/drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h
index 7d02553f229e..481ea6d01ca5 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_fw_info.h b/drivers/staging/rtlwifi/halmac/halmac_fw_info.h
index dad8be311ff2..eb4558d0b62c 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_fw_info.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_fw_info.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h b/drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h
index 0e99967f3663..45b5f8780baf 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h b/drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h
index 7adc3cdb38c9..58e47584cedc 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h b/drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h
index 5f23cba6d067..04cee38c33f9 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h b/drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h
index 273d4c0e338a..bc9fb8e8bf5a 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h b/drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h
index 4331e2ae14c2..f58077539e33 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h b/drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h
index db7aac4de843..ce39f0868419 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h b/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h
index 41780676508e..a2552b27367b 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h b/drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h
index 13a65a4754b0..802142be607d 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_reg2.h b/drivers/staging/rtlwifi/halmac/halmac_reg2.h
index bebf974ed949..34ab11d8d97b 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_reg2.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_reg2.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h b/drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h
index 4bc59b127412..48d5dc0df858 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h b/drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h
index 59ff1fecf73f..d5ff89c91ab3 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h b/drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h
index 62817d808fbb..c030f2597176 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h b/drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h
index 442120a14839..5f960e2ae8c7 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h b/drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h
index 8256c3605072..413004eef0b7 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h b/drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h
index 8967699e3784..7760a6b42d98 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h b/drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h
index d5c9da247ca3..e1cfcfdf1990 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h b/drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h
index 43c2261ab083..fd3f80bd752d 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h b/drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h
index fd1aa39c4bed..ca32f1b5f80a 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h b/drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h
index 02177c5faddf..73b973d90137 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_type.h b/drivers/staging/rtlwifi/halmac/halmac_type.h
index 0bf842435080..51d758b6433b 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_type.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_type.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/halmac_usb_reg.h b/drivers/staging/rtlwifi/halmac/halmac_usb_reg.h
index d6e721ea7463..27910a4adb4e 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_usb_reg.h
+++ b/drivers/staging/rtlwifi/halmac/halmac_usb_reg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 66f0a6dfc52c..ae433aa6ebbb 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.h b/drivers/staging/rtlwifi/halmac/rtl_halmac.h
index 51a3684f30d8..aa511dad8d16 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.h
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/pci.c b/drivers/staging/rtlwifi/pci.c
index d56810eabde7..4bb5703bd715 100644
--- a/drivers/staging/rtlwifi/pci.c
+++ b/drivers/staging/rtlwifi/pci.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/pci.h b/drivers/staging/rtlwifi/pci.h
index 3fb56c845a61..7535ac24bfbb 100644
--- a/drivers/staging/rtlwifi/pci.h
+++ b/drivers/staging/rtlwifi/pci.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/halphyrf_ce.c b/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
index 5986892e767e..f77847c4206a 100644
--- a/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
+++ b/drivers/staging/rtlwifi/phydm/halphyrf_ce.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/halphyrf_ce.h b/drivers/staging/rtlwifi/phydm/halphyrf_ce.h
index e5d6257efb2b..c542efc7d0e0 100644
--- a/drivers/staging/rtlwifi/phydm/halphyrf_ce.h
+++ b/drivers/staging/rtlwifi/phydm/halphyrf_ce.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/mp_precomp.h b/drivers/staging/rtlwifi/phydm/mp_precomp.h
index b313de511ed6..8e9caca695ff 100644
--- a/drivers/staging/rtlwifi/phydm/mp_precomp.h
+++ b/drivers/staging/rtlwifi/phydm/mp_precomp.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm.c b/drivers/staging/rtlwifi/phydm/phydm.c
index 8b2a180cc13c..985978d3decc 100644
--- a/drivers/staging/rtlwifi/phydm/phydm.c
+++ b/drivers/staging/rtlwifi/phydm/phydm.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm.h b/drivers/staging/rtlwifi/phydm/phydm.h
index 5812ff427ead..8c3ad3f56273 100644
--- a/drivers/staging/rtlwifi/phydm/phydm.h
+++ b/drivers/staging/rtlwifi/phydm/phydm.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_acs.c b/drivers/staging/rtlwifi/phydm/phydm_acs.c
index eae5a0a24b9b..f47b245e77e3 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_acs.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_acs.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_acs.h b/drivers/staging/rtlwifi/phydm/phydm_acs.h
index 51d72b72bd6f..c6516b871fdb 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_acs.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_acs.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
index 103a774f9c8f..58ec3999391c 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.h b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.h
index fdb39b4f9df2..a88c34cd30e0 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_adaptivity.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_adaptivity.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c
index 158dd5d05de4..42020101380a 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h
index 460931489be3..300a22b075e0 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_antdiv.c b/drivers/staging/rtlwifi/phydm/phydm_antdiv.c
index 39d3c6947556..5a62e6b73a10 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_antdiv.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_antdiv.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_antdiv.h b/drivers/staging/rtlwifi/phydm/phydm_antdiv.h
index ebbff2f56c5e..4a58163bda4c 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_antdiv.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_antdiv.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_beamforming.h b/drivers/staging/rtlwifi/phydm/phydm_beamforming.h
index adc04ba4e218..a0bcdb620698 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_beamforming.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_beamforming.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_ccx.c b/drivers/staging/rtlwifi/phydm/phydm_ccx.c
index 2e0dc68757dc..57138606d9be 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_ccx.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_ccx.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_ccx.h b/drivers/staging/rtlwifi/phydm/phydm_ccx.h
index a3517f4642f9..b3e3e0bae582 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_ccx.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_ccx.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_cfotracking.c b/drivers/staging/rtlwifi/phydm/phydm_cfotracking.c
index 2ec8444f31a7..cf35601efe94 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_cfotracking.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_cfotracking.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_cfotracking.h b/drivers/staging/rtlwifi/phydm/phydm_cfotracking.h
index e8436a31019d..1ab015669dea 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_cfotracking.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_cfotracking.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.c b/drivers/staging/rtlwifi/phydm/phydm_debug.c
index e18ba2cca2bd..b5b69d5f1a41 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_debug.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_debug.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.h b/drivers/staging/rtlwifi/phydm/phydm_debug.h
index f442f7c19595..1010bf61ca3c 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_debug.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_debug.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dfs.h b/drivers/staging/rtlwifi/phydm/phydm_dfs.h
index 59a1d08cf381..c0358253d79a 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dfs.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_dfs.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.c b/drivers/staging/rtlwifi/phydm/phydm_dig.c
index f851ff12dc35..3115e7bdc749 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dig.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_dig.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.h b/drivers/staging/rtlwifi/phydm/phydm_dig.h
index af70aaec3b19..f618b4dd1fd3 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dig.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_dig.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h b/drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h
index 9f3cb2468c02..61e29df5c3f9 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c b/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c
index 7661c499aeb1..d3f74d1506b4 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h b/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h
index e7394c475395..3ea68066ccdb 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c b/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c
index ebb43342b80b..afe650e5313f 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h b/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h
index 10bad1209db2..afde69db6ad2 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c
index 753a9b9834e4..cd12512628c0 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h
index 5845b108a001..c10b5fcc6f4e 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_features.h b/drivers/staging/rtlwifi/phydm/phydm_features.h
index a12361c6a1a0..b4ff293280f7 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_features.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_features.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c
index 0a1f11a926e4..4bf86e5a451f 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h
index ec94c61df2b9..6ad5e0292a97 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c b/drivers/staging/rtlwifi/phydm/phydm_interface.c
index 2f9bf6708c54..f5ecde505153 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.h b/drivers/staging/rtlwifi/phydm/phydm_interface.h
index 53ba5585bf33..6ef289201d9d 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_iqk.h b/drivers/staging/rtlwifi/phydm/phydm_iqk.h
index 0d45bf099aeb..0ed21e06fc33 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_iqk.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_iqk.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_kfree.c b/drivers/staging/rtlwifi/phydm/phydm_kfree.c
index 5f3582341806..1a52500f97a1 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_kfree.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_kfree.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_kfree.h b/drivers/staging/rtlwifi/phydm/phydm_kfree.h
index fa1627e3662d..feeeb69d5202 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_kfree.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_kfree.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c b/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c
index 8d79a5add1b4..63f52623a8cf 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h b/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h
index a711b7954985..7bce088678d3 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c b/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c
index 48e73eb1622b..c98de4bb3c57 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h b/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h
index 757d7720d931..eb635de2d693 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_pre_define.h b/drivers/staging/rtlwifi/phydm/phydm_pre_define.h
index 6c301fe87b3d..ce9a076b32cb 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_pre_define.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_pre_define.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_precomp.h b/drivers/staging/rtlwifi/phydm/phydm_precomp.h
index bada15c4d2d8..39988d532340 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_precomp.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_precomp.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_psd.c b/drivers/staging/rtlwifi/phydm/phydm_psd.c
index 48f8776bc8f9..badc514ac0be 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_psd.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_psd.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_psd.h b/drivers/staging/rtlwifi/phydm/phydm_psd.h
index aeb70751d80b..0fd45c1cb6ec 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_psd.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_psd.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_rainfo.c b/drivers/staging/rtlwifi/phydm/phydm_rainfo.c
index e10a91aeebee..b46791a727c7 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_rainfo.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_rainfo.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
@@ -722,7 +711,7 @@ void phydm_update_hal_ra_mask(void *dm_void, u32 wireless_mode, u8 rf_type,
phydm_BW = phydm_trans_platform_bw(dm, BW);
ODM_RT_TRACE(dm, ODM_COMP_RA_MASK,
- "Platfoem original RA Mask = (( 0x %x | %x ))\n",
+ "Platform original RA Mask = (( 0x %x | %x ))\n",
ratr_bitmap_msb, ratr_bitmap);
switch (wireless_mode) {
@@ -996,7 +985,7 @@ static void phydm_ra_common_info_update(void *dm_void)
}
ODM_RT_TRACE(
dm, ODM_COMP_RATE_ADAPTIVE,
- "MACID[%d], Highest Tx order Update for power traking: %d\n",
+ "MACID[%d], Highest Tx order Update for power tracking: %d\n",
(ra_tab->highest_client_tx_rate_order),
(ra_tab->highest_client_tx_order));
}
diff --git a/drivers/staging/rtlwifi/phydm/phydm_rainfo.h b/drivers/staging/rtlwifi/phydm/phydm_rainfo.h
index c14ed9bda0af..6c1f30e758bc 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_rainfo.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_rainfo.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_reg.h b/drivers/staging/rtlwifi/phydm/phydm_reg.h
index d9d878e4c925..562c1199d669 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_reg.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_reg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h b/drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h
index 28d48415ac99..5b59dffc72a5 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_regdefine11n.h b/drivers/staging/rtlwifi/phydm/phydm_regdefine11n.h
index 0b6581c50ab3..765e0a0c8c7b 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_regdefine11n.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_regdefine11n.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/phydm_types.h b/drivers/staging/rtlwifi/phydm/phydm_types.h
index a34ebe876528..082bb03a99d4 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_types.h
+++ b/drivers/staging/rtlwifi/phydm/phydm_types.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
index 29d19f2b300e..52a113d731d9 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h
index 53431998b47e..a12745051678 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
index 70924f002541..aed97e437e76 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h
index d02fdd7a4a53..2f8107bd0205 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
index 0ff3a9a712d6..b8d33d7637b5 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h
index 1340fa9f369b..5e259846c67f 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
index ae3e2278fefd..9e92a81dc6d1 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
@@ -29,7 +18,7 @@
static bool
get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
enum pwrtrack_method method,
- u8 rf_path, u8 tx_power_index_offest)
+ u8 rf_path, u8 tx_power_index_offset)
{
struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void;
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
@@ -42,24 +31,24 @@ get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
ODM_RT_TRACE(
dm, ODM_COMP_TX_PWR_TRACK,
- "Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d, tx_power_index_offest=%d\n",
+ "Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d, tx_power_index_offset=%d\n",
rf_path, cali_info->absolute_ofdm_swing_idx[rf_path],
- tx_power_index_offest);
+ tx_power_index_offset);
- if (tx_power_index_offest > 0XF)
- tx_power_index_offest = 0XF;
+ if (tx_power_index_offset > 0XF)
+ tx_power_index_offset = 0XF;
if (cali_info->absolute_ofdm_swing_idx[rf_path] >= 0 &&
cali_info->absolute_ofdm_swing_idx[rf_path] <=
- tx_power_index_offest) {
+ tx_power_index_offset) {
tx_agc_index = cali_info->absolute_ofdm_swing_idx[rf_path];
tx_bb_swing_index = cali_info->default_ofdm_index;
} else if (cali_info->absolute_ofdm_swing_idx[rf_path] >
- tx_power_index_offest) {
- tx_agc_index = tx_power_index_offest;
+ tx_power_index_offset) {
+ tx_agc_index = tx_power_index_offset;
cali_info->remnant_ofdm_swing_idx[rf_path] =
cali_info->absolute_ofdm_swing_idx[rf_path] -
- tx_power_index_offest;
+ tx_power_index_offset;
tx_bb_swing_index = cali_info->default_ofdm_index +
cali_info->remnant_ofdm_swing_idx[rf_path];
@@ -85,9 +74,9 @@ get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
ODM_RT_TRACE(
dm, ODM_COMP_TX_PWR_TRACK,
- "MixMode Offset Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d cali_info->bb_swing_idx_ofdm[rf_path]=%d tx_power_index_offest=%d\n",
+ "MixMode Offset Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d cali_info->bb_swing_idx_ofdm[rf_path]=%d tx_power_index_offset=%d\n",
rf_path, cali_info->absolute_ofdm_swing_idx[rf_path],
- cali_info->bb_swing_idx_ofdm[rf_path], tx_power_index_offest);
+ cali_info->bb_swing_idx_ofdm[rf_path], tx_power_index_offset);
return true;
}
@@ -97,7 +86,7 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum pwrtrack_method method,
{
struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void;
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
- u8 tx_power_index_offest = 0;
+ u8 tx_power_index_offset = 0;
u8 tx_power_index = 0;
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
@@ -139,11 +128,11 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum pwrtrack_method method,
if (tx_power_index >= 63)
tx_power_index = 63;
- tx_power_index_offest = 63 - tx_power_index;
+ tx_power_index_offset = 63 - tx_power_index;
ODM_RT_TRACE(dm, ODM_COMP_TX_PWR_TRACK,
- "tx_power_index=%d tx_power_index_offest=%d rf_path=%d\n",
- tx_power_index, tx_power_index_offest, rf_path);
+ "tx_power_index=%d tx_power_index_offset=%d rf_path=%d\n",
+ tx_power_index, tx_power_index_offset, rf_path);
if (method ==
BBSWING) { /*use for mp driver clean power tracking status*/
@@ -178,7 +167,7 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum pwrtrack_method method,
switch (rf_path) {
case ODM_RF_PATH_A:
get_mix_mode_tx_agc_bb_swing_offset_8822b(
- dm, method, rf_path, tx_power_index_offest);
+ dm, method, rf_path, tx_power_index_offset);
odm_set_bb_reg(
dm, 0xC94, (BIT(29) | BIT(28) | BIT(27) |
BIT(26) | BIT(25)),
@@ -201,7 +190,7 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum pwrtrack_method method,
case ODM_RF_PATH_B:
get_mix_mode_tx_agc_bb_swing_offset_8822b(
- dm, method, rf_path, tx_power_index_offest);
+ dm, method, rf_path, tx_power_index_offset);
odm_set_bb_reg(
dm, 0xE94, (BIT(29) | BIT(28) | BIT(27) |
BIT(26) | BIT(25)),
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h
index 4f3bfe316ee9..794ee33ea7df 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c
index 26d1022e851c..776096164b80 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h
index 279ef06298e2..5c5370af6ece 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c
index e2c72af16150..3ce49322b686 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h
index ea19deb512d5..246518e8bf8f 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c
index 644fca822c61..8f96c77974cc 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h
index 4817cf6b1ed9..4606427bd273 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c
index 59adabda09de..a05c8aa53b0e 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h
index af91a6f958ed..788258e8c3d1 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h b/drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h
index ad0d32fce0a9..53fd51aacdf2 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl_phydm.c b/drivers/staging/rtlwifi/phydm/rtl_phydm.c
index 85e490d3601f..9930ed954abb 100644
--- a/drivers/staging/rtlwifi/phydm/rtl_phydm.c
+++ b/drivers/staging/rtlwifi/phydm/rtl_phydm.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/rtl_phydm.h b/drivers/staging/rtlwifi/phydm/rtl_phydm.h
index 483d2418699b..b98d502ef196 100644
--- a/drivers/staging/rtlwifi/phydm/rtl_phydm.h
+++ b/drivers/staging/rtlwifi/phydm/rtl_phydm.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h b/drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h
index 6cacca12d792..b85c5e17efdf 100644
--- a/drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h
+++ b/drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h b/drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h
index 5c92c4326f7e..2554fcc991de 100644
--- a/drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h
+++ b/drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h b/drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h
index 82aeac1ff3e0..cf1ced07e138 100644
--- a/drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h
+++ b/drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h b/drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h
index c5ddd9cb9cd5..4b30f062b7f7 100644
--- a/drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h
+++ b/drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h b/drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h
index 41358fce2875..278eb5d3bd4a 100644
--- a/drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h
+++ b/drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/ps.c b/drivers/staging/rtlwifi/ps.c
index 7856fc5d10bd..0ca0532c73da 100644
--- a/drivers/staging/rtlwifi/ps.c
+++ b/drivers/staging/rtlwifi/ps.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/ps.h b/drivers/staging/rtlwifi/ps.h
index 6c187daced4a..badd0fa7ece6 100644
--- a/drivers/staging/rtlwifi/ps.h
+++ b/drivers/staging/rtlwifi/ps.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/pwrseqcmd.h b/drivers/staging/rtlwifi/pwrseqcmd.h
index f411b7ebb08f..bd8ae84aca4f 100644
--- a/drivers/staging/rtlwifi/pwrseqcmd.h
+++ b/drivers/staging/rtlwifi/pwrseqcmd.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rc.c b/drivers/staging/rtlwifi/rc.c
index c835be91f398..3ebfc67ee345 100644
--- a/drivers/staging/rtlwifi/rc.c
+++ b/drivers/staging/rtlwifi/rc.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rc.h b/drivers/staging/rtlwifi/rc.h
index dcc8520866b7..7f631175fac3 100644
--- a/drivers/staging/rtlwifi/rc.h
+++ b/drivers/staging/rtlwifi/rc.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/regd.c b/drivers/staging/rtlwifi/regd.c
index e0a3ff85edb6..3afd206ce4b1 100644
--- a/drivers/staging/rtlwifi/regd.c
+++ b/drivers/staging/rtlwifi/regd.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/regd.h b/drivers/staging/rtlwifi/regd.h
index 5626015a6d0d..c19e87936ad3 100644
--- a/drivers/staging/rtlwifi/regd.h
+++ b/drivers/staging/rtlwifi/regd.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/def.h b/drivers/staging/rtlwifi/rtl8822be/def.h
index 7942ddfdcf43..596f73691d55 100644
--- a/drivers/staging/rtlwifi/rtl8822be/def.h
+++ b/drivers/staging/rtlwifi/rtl8822be/def.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c
index 483ea85943c3..efec7281511c 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.h b/drivers/staging/rtlwifi/rtl8822be/fw.h
index 3ad7a66e80a3..6e7eb52dba2d 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.h
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/hw.c b/drivers/staging/rtlwifi/rtl8822be/hw.c
index 74386003044f..7947edb239a1 100644
--- a/drivers/staging/rtlwifi/rtl8822be/hw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/hw.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/hw.h b/drivers/staging/rtlwifi/rtl8822be/hw.h
index a91c276c5794..cf3536113f06 100644
--- a/drivers/staging/rtlwifi/rtl8822be/hw.h
+++ b/drivers/staging/rtlwifi/rtl8822be/hw.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/led.c b/drivers/staging/rtlwifi/rtl8822be/led.c
index 0054c892dce6..6d6e1f271e18 100644
--- a/drivers/staging/rtlwifi/rtl8822be/led.c
+++ b/drivers/staging/rtlwifi/rtl8822be/led.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/led.h b/drivers/staging/rtlwifi/rtl8822be/led.h
index 9c0a2290df7d..9a19e17cf3a4 100644
--- a/drivers/staging/rtlwifi/rtl8822be/led.h
+++ b/drivers/staging/rtlwifi/rtl8822be/led.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/phy.c b/drivers/staging/rtlwifi/rtl8822be/phy.c
index 6697aee9317f..048904d783fc 100644
--- a/drivers/staging/rtlwifi/rtl8822be/phy.c
+++ b/drivers/staging/rtlwifi/rtl8822be/phy.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/phy.h b/drivers/staging/rtlwifi/rtl8822be/phy.h
index 5c33f16bcaa4..f33b086a0167 100644
--- a/drivers/staging/rtlwifi/rtl8822be/phy.h
+++ b/drivers/staging/rtlwifi/rtl8822be/phy.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/reg.h b/drivers/staging/rtlwifi/rtl8822be/reg.h
index 0dca5dccf49a..8f0ec5b18c33 100644
--- a/drivers/staging/rtlwifi/rtl8822be/reg.h
+++ b/drivers/staging/rtlwifi/rtl8822be/reg.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/sw.c b/drivers/staging/rtlwifi/rtl8822be/sw.c
index 91b784b6d1c5..7825e85ed091 100644
--- a/drivers/staging/rtlwifi/rtl8822be/sw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/sw.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/sw.h b/drivers/staging/rtlwifi/rtl8822be/sw.h
index 931eba98bd80..0983a8e9605b 100644
--- a/drivers/staging/rtlwifi/rtl8822be/sw.h
+++ b/drivers/staging/rtlwifi/rtl8822be/sw.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/trx.c b/drivers/staging/rtlwifi/rtl8822be/trx.c
index 87e15e419252..8fff2ea344eb 100644
--- a/drivers/staging/rtlwifi/rtl8822be/trx.c
+++ b/drivers/staging/rtlwifi/rtl8822be/trx.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/rtl8822be/trx.h b/drivers/staging/rtlwifi/rtl8822be/trx.h
index db769f3c4cd6..d7ba7f3e58b7 100644
--- a/drivers/staging/rtlwifi/rtl8822be/trx.h
+++ b/drivers/staging/rtlwifi/rtl8822be/trx.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2016 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/stats.c b/drivers/staging/rtlwifi/stats.c
index 96eb14c92c01..149b665a0e5c 100644
--- a/drivers/staging/rtlwifi/stats.c
+++ b/drivers/staging/rtlwifi/stats.c
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/stats.h b/drivers/staging/rtlwifi/stats.h
index bd0108f93182..aa4f30d40af0 100644
--- a/drivers/staging/rtlwifi/stats.h
+++ b/drivers/staging/rtlwifi/stats.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/rtlwifi/wifi.h b/drivers/staging/rtlwifi/wifi.h
index a23bb1719e35..012fb618840b 100644
--- a/drivers/staging/rtlwifi/wifi.h
+++ b/drivers/staging/rtlwifi/wifi.h
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
diff --git a/drivers/staging/sm750fb/TODO b/drivers/staging/sm750fb/TODO
index f710ab15abfe..481409eb3fb3 100644
--- a/drivers/staging/sm750fb/TODO
+++ b/drivers/staging/sm750fb/TODO
@@ -9,8 +9,11 @@ TODO:
- must be ported to the atomic kms framework in the drm subsystem (which will
give you a basic fbdev driver for free)
+Note:
+- This driver will be removed from staging after the drm driver is ready
+- The drm driver is getting ready at https://gitlab.com/sudipm/sm750/tree/sm750
+
Please send any patches to
Greg Kroah-Hartman <greg@kroah.com>
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Teddy Wang <teddy.wang@siliconmotion.com>
- Sudip Mukherjee <sudip@vectorindia.org>
diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c
index 461f131644a2..1371ced2f5ca 100644
--- a/drivers/staging/speakup/buffers.c
+++ b/drivers/staging/speakup/buffers.c
@@ -77,6 +77,10 @@ void synth_buffer_add(u16 ch)
*buff_in++ = ch;
if (buff_in > buffer_end)
buff_in = synth_buffer;
+ /* We have written something to the speech synthesis, so we are not
+ * paused any more.
+ */
+ spk_paused = false;
}
u16 synth_buffer_getc(void)
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index af30b7099bed..869f40ebf1a7 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -67,6 +67,8 @@ short spk_punc_mask;
int spk_punc_level, spk_reading_punc;
char spk_str_caps_start[MAXVARLEN + 1] = "\0";
char spk_str_caps_stop[MAXVARLEN + 1] = "\0";
+char spk_str_pause[MAXVARLEN + 1] = "\0";
+bool spk_paused;
const struct st_bits_data spk_punc_info[] = {
{"none", "", 0},
{"some", "/$%&@", SOME},
@@ -1782,6 +1784,10 @@ static void speakup_con_update(struct vc_data *vc)
/* Speakup output, discard */
return;
speakup_date(vc);
+ if (vc->vc_mode == KD_GRAPHICS && !spk_paused && spk_str_pause[0]) {
+ synth_printf("%s", spk_str_pause);
+ spk_paused = true;
+ }
spin_unlock_irqrestore(&speakup_info.spinlock, flags);
}
diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h
index 3d8bda8b9620..e4f4f00be2dc 100644
--- a/drivers/staging/speakup/speakup.h
+++ b/drivers/staging/speakup/speakup.h
@@ -94,7 +94,8 @@ extern struct spk_synth *synth;
extern char spk_pitch_buff[];
extern u_char *spk_our_keys[];
extern short spk_punc_masks[];
-extern char spk_str_caps_start[], spk_str_caps_stop[];
+extern char spk_str_caps_start[], spk_str_caps_stop[], spk_str_pause[];
+extern bool spk_paused;
extern const struct st_bits_data spk_punc_info[];
extern u_char spk_key_buf[600];
extern char *spk_characters[];
diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c
index aa0c900f79f2..7df1a84297f6 100644
--- a/drivers/staging/speakup/speakup_dummy.c
+++ b/drivers/staging/speakup/speakup_dummy.c
@@ -21,6 +21,7 @@
static struct var_t vars[] = {
{ CAPS_START, .u.s = {"CAPS_START\n" } },
{ CAPS_STOP, .u.s = {"CAPS_STOP\n" } },
+ { PAUSE, .u.s = {"PAUSE\n"} },
{ RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } },
{ PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } },
{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
index 0a1a7c259ab0..a61bc41b82d7 100644
--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -35,6 +35,7 @@ static int misc_registered;
static struct var_t vars[] = {
{ CAPS_START, .u.s = {"\x01+3p" } },
{ CAPS_STOP, .u.s = {"\x01-3p" } },
+ { PAUSE, .u.n = {"\x01P" } },
{ RATE, .u.n = {"\x01%ds", 2, 0, 9, 0, 0, NULL } },
{ PITCH, .u.n = {"\x01%dp", 5, 0, 9, 0, 0, NULL } },
{ VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
@@ -154,7 +155,7 @@ static char *get_initstring(void)
var = synth_soft.vars;
while (var->var_id != MAXVARS) {
if (var->var_id != CAPS_START && var->var_id != CAPS_STOP &&
- var->var_id != DIRECT)
+ var->var_id != PAUSE && var->var_id != DIRECT)
cp = cp + sprintf(cp, var->u.n.synth_fmt,
var->u.n.value);
var++;
diff --git a/drivers/staging/speakup/spk_types.h b/drivers/staging/speakup/spk_types.h
index 4203bed90b4f..3e082dc3d45c 100644
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -42,7 +42,7 @@ enum var_id_t {
SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
ATTRIB_BLEEP, BLEEPS,
- RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, DIRECT,
+ RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, DIRECT, PAUSE,
CAPS_START, CAPS_STOP, CHARTAB,
MAXVARS
};
diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
index 321405532a8e..54a76b6752ad 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -45,6 +45,7 @@ static struct st_var_header var_headers[] = {
{ "lang", LANG, VAR_NUM, NULL, NULL },
{ "chartab", CHARTAB, VAR_PROC, NULL, NULL },
{ "direct", DIRECT, VAR_NUM, NULL, NULL },
+ { "pause", PAUSE, VAR_STRING, spk_str_pause, NULL },
};
static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL };
diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
index 92dceb557886..f734e835b382 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -849,7 +849,7 @@ static bool vnic_hit_low_watermark(struct visornic_devdata *devdata,
*
* Return: NETDEV_TX_OK.
*/
-static int visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
+static netdev_tx_t visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
{
struct visornic_devdata *devdata;
int len, firstfraglen, padlen;
diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c
index 973b3bcc04b1..9d2018cd544e 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -61,7 +61,8 @@ void vbox_enable_accel(struct vbox_private *vbox)
if (vbox->vbva_info[i].vbva)
continue;
- vbva = (void __force *)vbox->vbva_buffers + i * VBVA_MIN_BUFFER_SIZE;
+ vbva = (void __force *)vbox->vbva_buffers +
+ i * VBVA_MIN_BUFFER_SIZE;
if (!vbva_enable(&vbox->vbva_info[i],
vbox->guest_pool, vbva, i)) {
/* very old host or driver error. */
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index b265fe924556..5c7ea237893e 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -573,7 +573,7 @@ static int vbox_get_modes(struct drm_connector *connector)
return num_modes;
}
-static int vbox_mode_valid(struct drm_connector *connector,
+static enum drm_mode_status vbox_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig
index f5aaf7d629f0..98064ce2c2b4 100644
--- a/drivers/staging/vc04_services/Kconfig
+++ b/drivers/staging/vc04_services/Kconfig
@@ -1,6 +1,5 @@
menuconfig BCM_VIDEOCORE
tristate "Broadcom VideoCore support"
- depends on HAS_DMA
depends on OF
depends on RASPBERRYPI_FIRMWARE || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
default y
diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile
index fb26b826e640..afe43fa5a6d7 100644
--- a/drivers/staging/vc04_services/Makefile
+++ b/drivers/staging/vc04_services/Makefile
@@ -13,5 +13,5 @@ vchiq-objs := \
obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/
obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/
-ccflags-y += -DVCOS_VERIFY_BKPTS=1 -Idrivers/staging/vc04_services -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000
+ccflags-y += -Idrivers/staging/vc04_services -D__VCCOREVER__=0x04000000
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
index a4a48f31f1a3..f0cefa1b7b0f 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
@@ -22,7 +22,6 @@
/* ---- Include Files -------------------------------------------------------- */
-#include "interface/vchi/vchi.h"
#include "vc_vchi_audioserv_defs.h"
/* ---- Private Constants and Types ------------------------------------------ */
@@ -360,14 +359,46 @@ static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance)
return 0;
}
+int bcm2835_new_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx)
+{
+ int ret;
+
+ /* Initialize and create a VCHI connection */
+ ret = vchi_initialise(&vchi_ctx->vchi_instance);
+ if (ret) {
+ LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
+ __func__, ret);
+
+ return -EIO;
+ }
+
+ ret = vchi_connect(NULL, 0, vchi_ctx->vchi_instance);
+ if (ret) {
+ LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
+ __func__, ret);
+
+ kfree(vchi_ctx->vchi_instance);
+ vchi_ctx->vchi_instance = NULL;
+
+ return -EIO;
+ }
+
+ return 0;
+}
+
+void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx)
+{
+ /* Close the VCHI connection - it will also free vchi_instance */
+ WARN_ON(vchi_disconnect(vchi_ctx->vchi_instance));
+
+ vchi_ctx->vchi_instance = NULL;
+}
+
static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream)
{
- static VCHI_INSTANCE_T vchi_instance;
- static VCHI_CONNECTION_T *vchi_connection;
- static int initted;
struct bcm2835_audio_instance *instance =
(struct bcm2835_audio_instance *)alsa_stream->instance;
- int ret;
+ struct bcm2835_vchi_ctx *vhci_ctx = alsa_stream->chip->vchi_ctx;
LOG_INFO("%s: start\n", __func__);
BUG_ON(instance);
@@ -379,28 +410,9 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
return 0;
}
- /* Initialize and create a VCHI connection */
- if (!initted) {
- ret = vchi_initialise(&vchi_instance);
- if (ret) {
- LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
- __func__, ret);
-
- return -EIO;
- }
- ret = vchi_connect(NULL, 0, vchi_instance);
- if (ret) {
- LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
- __func__, ret);
-
- kfree(vchi_instance);
- return -EIO;
- }
- initted = 1;
- }
-
/* Initialize an instance of the audio service */
- instance = vc_vchi_audio_init(vchi_instance, &vchi_connection, 1);
+ instance = vc_vchi_audio_init(vhci_ctx->vchi_instance,
+ &vhci_ctx->vchi_connection, 1);
if (IS_ERR(instance)) {
LOG_ERR("%s: failed to initialize audio service\n", __func__);
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
index 0ed21dd08170..da0fa34501fa 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
@@ -54,6 +54,36 @@ static int snd_devm_add_child(struct device *dev, struct device *child)
return 0;
}
+static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res)
+{
+ struct bcm2835_vchi_ctx *vchi_ctx = res;
+
+ bcm2835_free_vchi_ctx(vchi_ctx);
+}
+
+static int bcm2835_devm_add_vchi_ctx(struct device *dev)
+{
+ struct bcm2835_vchi_ctx *vchi_ctx;
+ int ret;
+
+ vchi_ctx = devres_alloc(bcm2835_devm_free_vchi_ctx, sizeof(*vchi_ctx),
+ GFP_KERNEL);
+ if (!vchi_ctx)
+ return -ENOMEM;
+
+ memset(vchi_ctx, 0, sizeof(*vchi_ctx));
+
+ ret = bcm2835_new_vchi_ctx(vchi_ctx);
+ if (ret) {
+ devres_free(vchi_ctx);
+ return ret;
+ }
+
+ devres_add(dev, vchi_ctx);
+
+ return 0;
+}
+
static void snd_bcm2835_release(struct device *dev)
{
struct bcm2835_chip *chip = dev_get_drvdata(dev);
@@ -95,8 +125,6 @@ static int snd_bcm2835_dev_free(struct snd_device *device)
struct bcm2835_chip *chip = device->device_data;
struct snd_card *card = chip->card;
- /* TODO: free pcm, ctl */
-
snd_device_free(card, chip);
return 0;
@@ -122,6 +150,13 @@ static int snd_bcm2835_create(struct snd_card *card,
chip->card = card;
+ chip->vchi_ctx = devres_find(card->dev->parent,
+ bcm2835_devm_free_vchi_ctx, NULL, NULL);
+ if (!chip->vchi_ctx) {
+ kfree(chip);
+ return -ENODEV;
+ }
+
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
if (err) {
kfree(chip);
@@ -392,6 +427,10 @@ static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev)
numchans);
}
+ err = bcm2835_devm_add_vchi_ctx(dev);
+ if (err)
+ return err;
+
err = snd_add_child_devices(dev, numchans);
if (err)
return err;
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
index dc6ec915f9f5..5dc427240a1d 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
@@ -15,6 +15,8 @@
#include <sound/pcm-indirect.h>
#include <linux/workqueue.h>
+#include "interface/vchi/vchi.h"
+
/*
* #define AUDIO_DEBUG_ENABLE
* #define AUDIO_VERBOSE_DEBUG_ENABLE
@@ -86,6 +88,11 @@ enum snd_bcm2835_ctrl {
PCM_PLAYBACK_DEVICE,
};
+struct bcm2835_vchi_ctx {
+ VCHI_INSTANCE_T vchi_instance;
+ VCHI_CONNECTION_T *vchi_connection;
+};
+
/* definition of the chip-specific record */
struct bcm2835_chip {
struct snd_card *card;
@@ -104,6 +111,8 @@ struct bcm2835_chip {
unsigned int opened;
unsigned int spdif_status;
struct mutex audio_mutex;
+
+ struct bcm2835_vchi_ctx *vchi_ctx;
};
struct bcm2835_alsa_stream {
@@ -142,6 +151,9 @@ int snd_bcm2835_new_simple_pcm(struct bcm2835_chip *chip,
int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip);
int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip);
+int bcm2835_new_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx);
+void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx);
+
int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream);
int bcm2835_audio_close(struct bcm2835_alsa_stream *alsa_stream);
int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream,
diff --git a/drivers/staging/vc04_services/bcm2835-camera/TODO b/drivers/staging/vc04_services/bcm2835-camera/TODO
index 0ab9e88d769a..cefce72d814f 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/TODO
+++ b/drivers/staging/vc04_services/bcm2835-camera/TODO
@@ -21,14 +21,3 @@ less copy it needed to do.
The bulk_receive() does some manual cache flushing that are 32-bit ARM
only, which we should convert to proper cross-platform APIs.
-4) Convert to be a platform driver.
-
-Right now when the module probes, it tries to initialize VCHI and
-errors out if it wasn't ready yet. If bcm2835-v4l2 was built in, then
-VCHI generally isn't ready because it depends on both the firmware and
-mailbox drivers having already loaded.
-
-We should have VCHI create a platform device once it's initialized,
-and have this driver bind to it, so that we automatically load the
-v4l2 module after VCHI loads.
-
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index d2262275a870..ce26741ae9d9 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -23,6 +23,7 @@
#include <media/v4l2-event.h>
#include <media/v4l2-common.h>
#include <linux/delay.h>
+#include <linux/platform_device.h>
#include "mmal-common.h"
#include "mmal-encodings.h"
@@ -78,131 +79,132 @@ static const struct v4l2_fract
/* video formats */
static struct mmal_fmt formats[] = {
{
- .name = "4:2:0, planar, YUV",
- .fourcc = V4L2_PIX_FMT_YUV420,
- .flags = 0,
- .mmal = MMAL_ENCODING_I420,
- .depth = 12,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 1,
- },
- {
- .name = "4:2:2, packed, YUYV",
- .fourcc = V4L2_PIX_FMT_YUYV,
- .flags = 0,
- .mmal = MMAL_ENCODING_YUYV,
- .depth = 16,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 2,
- },
- {
- .name = "RGB24 (LE)",
- .fourcc = V4L2_PIX_FMT_RGB24,
- .flags = 0,
- .mmal = MMAL_ENCODING_RGB24,
- .depth = 24,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 3,
- },
- {
- .name = "JPEG",
- .fourcc = V4L2_PIX_FMT_JPEG,
- .flags = V4L2_FMT_FLAG_COMPRESSED,
- .mmal = MMAL_ENCODING_JPEG,
- .depth = 8,
- .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
- .ybbp = 0,
- },
- {
- .name = "H264",
- .fourcc = V4L2_PIX_FMT_H264,
- .flags = V4L2_FMT_FLAG_COMPRESSED,
- .mmal = MMAL_ENCODING_H264,
- .depth = 8,
- .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
- .ybbp = 0,
- },
- {
- .name = "MJPEG",
- .fourcc = V4L2_PIX_FMT_MJPEG,
- .flags = V4L2_FMT_FLAG_COMPRESSED,
- .mmal = MMAL_ENCODING_MJPEG,
- .depth = 8,
- .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
- .ybbp = 0,
- },
- {
- .name = "4:2:2, packed, YVYU",
- .fourcc = V4L2_PIX_FMT_YVYU,
- .flags = 0,
- .mmal = MMAL_ENCODING_YVYU,
- .depth = 16,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 2,
- },
- {
- .name = "4:2:2, packed, VYUY",
- .fourcc = V4L2_PIX_FMT_VYUY,
- .flags = 0,
- .mmal = MMAL_ENCODING_VYUY,
- .depth = 16,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 2,
- },
- {
- .name = "4:2:2, packed, UYVY",
- .fourcc = V4L2_PIX_FMT_UYVY,
- .flags = 0,
- .mmal = MMAL_ENCODING_UYVY,
- .depth = 16,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 2,
- },
- {
- .name = "4:2:0, planar, NV12",
- .fourcc = V4L2_PIX_FMT_NV12,
- .flags = 0,
- .mmal = MMAL_ENCODING_NV12,
- .depth = 12,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 1,
- },
- {
- .name = "RGB24 (BE)",
- .fourcc = V4L2_PIX_FMT_BGR24,
- .flags = 0,
- .mmal = MMAL_ENCODING_BGR24,
- .depth = 24,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 3,
- },
- {
- .name = "4:2:0, planar, YVU",
- .fourcc = V4L2_PIX_FMT_YVU420,
- .flags = 0,
- .mmal = MMAL_ENCODING_YV12,
- .depth = 12,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 1,
- },
- {
- .name = "4:2:0, planar, NV21",
- .fourcc = V4L2_PIX_FMT_NV21,
- .flags = 0,
- .mmal = MMAL_ENCODING_NV21,
- .depth = 12,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 1,
- },
- {
- .name = "RGB32 (BE)",
- .fourcc = V4L2_PIX_FMT_BGR32,
- .flags = 0,
- .mmal = MMAL_ENCODING_BGRA,
- .depth = 32,
- .mmal_component = MMAL_COMPONENT_CAMERA,
- .ybbp = 4,
- },
+ .name = "4:2:0, planar, YUV",
+ .fourcc = V4L2_PIX_FMT_YUV420,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_I420,
+ .depth = 12,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 1,
+ .remove_padding = 1,
+ }, {
+ .name = "4:2:2, packed, YUYV",
+ .fourcc = V4L2_PIX_FMT_YUYV,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_YUYV,
+ .depth = 16,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 2,
+ .remove_padding = 0,
+ }, {
+ .name = "RGB24 (LE)",
+ .fourcc = V4L2_PIX_FMT_RGB24,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_RGB24,
+ .depth = 24,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 3,
+ .remove_padding = 0,
+ }, {
+ .name = "JPEG",
+ .fourcc = V4L2_PIX_FMT_JPEG,
+ .flags = V4L2_FMT_FLAG_COMPRESSED,
+ .mmal = MMAL_ENCODING_JPEG,
+ .depth = 8,
+ .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
+ .ybbp = 0,
+ .remove_padding = 0,
+ }, {
+ .name = "H264",
+ .fourcc = V4L2_PIX_FMT_H264,
+ .flags = V4L2_FMT_FLAG_COMPRESSED,
+ .mmal = MMAL_ENCODING_H264,
+ .depth = 8,
+ .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
+ .ybbp = 0,
+ .remove_padding = 0,
+ }, {
+ .name = "MJPEG",
+ .fourcc = V4L2_PIX_FMT_MJPEG,
+ .flags = V4L2_FMT_FLAG_COMPRESSED,
+ .mmal = MMAL_ENCODING_MJPEG,
+ .depth = 8,
+ .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
+ .ybbp = 0,
+ .remove_padding = 0,
+ }, {
+ .name = "4:2:2, packed, YVYU",
+ .fourcc = V4L2_PIX_FMT_YVYU,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_YVYU,
+ .depth = 16,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 2,
+ .remove_padding = 0,
+ }, {
+ .name = "4:2:2, packed, VYUY",
+ .fourcc = V4L2_PIX_FMT_VYUY,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_VYUY,
+ .depth = 16,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 2,
+ .remove_padding = 0,
+ }, {
+ .name = "4:2:2, packed, UYVY",
+ .fourcc = V4L2_PIX_FMT_UYVY,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_UYVY,
+ .depth = 16,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 2,
+ .remove_padding = 0,
+ }, {
+ .name = "4:2:0, planar, NV12",
+ .fourcc = V4L2_PIX_FMT_NV12,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_NV12,
+ .depth = 12,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 1,
+ .remove_padding = 1,
+ }, {
+ .name = "RGB24 (BE)",
+ .fourcc = V4L2_PIX_FMT_BGR24,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_BGR24,
+ .depth = 24,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 3,
+ .remove_padding = 0,
+ }, {
+ .name = "4:2:0, planar, YVU",
+ .fourcc = V4L2_PIX_FMT_YVU420,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_YV12,
+ .depth = 12,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 1,
+ .remove_padding = 1,
+ }, {
+ .name = "4:2:0, planar, NV21",
+ .fourcc = V4L2_PIX_FMT_NV21,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_NV21,
+ .depth = 12,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 1,
+ .remove_padding = 1,
+ }, {
+ .name = "RGB32 (BE)",
+ .fourcc = V4L2_PIX_FMT_BGR32,
+ .flags = 0,
+ .mmal = MMAL_ENCODING_BGRA,
+ .depth = 32,
+ .mmal_component = MMAL_COMPONENT_CAMERA,
+ .ybbp = 4,
+ .remove_padding = 0,
+ },
};
static struct mmal_fmt *get_format(struct v4l2_format *f)
@@ -245,8 +247,10 @@ static int queue_setup(struct vb2_queue *vq,
return -EINVAL;
}
- if (*nbuffers < (dev->capture.port->current_buffer.num + 2))
- *nbuffers = (dev->capture.port->current_buffer.num + 2);
+ if (*nbuffers < dev->capture.port->minimum_buffer.num)
+ *nbuffers = dev->capture.port->minimum_buffer.num;
+
+ dev->capture.port->current_buffer.num = *nbuffers;
*nplanes = 1;
@@ -263,16 +267,30 @@ static int queue_setup(struct vb2_queue *vq,
return 0;
}
+static int buffer_init(struct vb2_buffer *vb)
+{
+ struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
+ struct vb2_v4l2_buffer *vb2 = to_vb2_v4l2_buffer(vb);
+ struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb);
+
+ v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n",
+ __func__, dev, vb);
+ buf->buffer = vb2_plane_vaddr(&buf->vb.vb2_buf, 0);
+ buf->buffer_size = vb2_plane_size(&buf->vb.vb2_buf, 0);
+
+ return mmal_vchi_buffer_init(dev->instance, buf);
+}
+
static int buffer_prepare(struct vb2_buffer *vb)
{
struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
unsigned long size;
- v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
- __func__, dev);
+ v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n",
+ __func__, dev, vb);
- BUG_ON(!dev->capture.port);
- BUG_ON(!dev->capture.fmt);
+ if (!dev->capture.port || !dev->capture.fmt)
+ return -ENODEV;
size = dev->capture.stride * dev->capture.height;
if (vb2_plane_size(vb, 0) < size) {
@@ -285,6 +303,17 @@ static int buffer_prepare(struct vb2_buffer *vb)
return 0;
}
+static void buffer_cleanup(struct vb2_buffer *vb)
+{
+ struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
+ struct vb2_v4l2_buffer *vb2 = to_vb2_v4l2_buffer(vb);
+ struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb);
+
+ v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n",
+ __func__, dev, vb);
+ mmal_vchi_buffer_cleanup(buf);
+}
+
static inline bool is_capturing(struct bm2835_mmal_dev *dev)
{
return dev->capture.camera_port ==
@@ -450,10 +479,8 @@ static void buffer_queue(struct vb2_buffer *vb)
int ret;
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
- "%s: dev:%p buf:%p\n", __func__, dev, buf);
-
- buf->buffer = vb2_plane_vaddr(&buf->vb.vb2_buf, 0);
- buf->buffer_size = vb2_plane_size(&buf->vb.vb2_buf, 0);
+ "%s: dev:%p buf:%p, idx %u\n",
+ __func__, dev, buf, vb2->vb2_buf.index);
ret = vchiq_mmal_submit_buffer(dev->instance, dev->capture.port, buf);
if (ret < 0)
@@ -465,7 +492,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
{
struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq);
int ret;
- int parameter_size;
+ u32 parameter_size;
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
__func__, dev);
@@ -617,7 +644,9 @@ static void bm2835_mmal_unlock(struct vb2_queue *vq)
static const struct vb2_ops bm2835_mmal_video_qops = {
.queue_setup = queue_setup,
+ .buf_init = buffer_init,
.buf_prepare = buffer_prepare,
+ .buf_cleanup = buffer_cleanup,
.buf_queue = buffer_queue,
.start_streaming = start_streaming,
.stop_streaming = stop_streaming,
@@ -634,17 +663,19 @@ static int set_overlay_params(struct bm2835_mmal_dev *dev,
struct vchiq_mmal_port *port)
{
struct mmal_parameter_displayregion prev_config = {
- .set = MMAL_DISPLAY_SET_LAYER | MMAL_DISPLAY_SET_ALPHA |
- MMAL_DISPLAY_SET_DEST_RECT | MMAL_DISPLAY_SET_FULLSCREEN,
- .layer = PREVIEW_LAYER,
- .alpha = dev->overlay.global_alpha,
- .fullscreen = 0,
- .dest_rect = {
- .x = dev->overlay.w.left,
- .y = dev->overlay.w.top,
- .width = dev->overlay.w.width,
- .height = dev->overlay.w.height,
- },
+ .set = MMAL_DISPLAY_SET_LAYER |
+ MMAL_DISPLAY_SET_ALPHA |
+ MMAL_DISPLAY_SET_DEST_RECT |
+ MMAL_DISPLAY_SET_FULLSCREEN,
+ .layer = PREVIEW_LAYER,
+ .alpha = dev->overlay.global_alpha,
+ .fullscreen = 0,
+ .dest_rect = {
+ .x = dev->overlay.w.left,
+ .y = dev->overlay.w.top,
+ .width = dev->overlay.w.width,
+ .height = dev->overlay.w.height,
+ },
};
return vchiq_mmal_port_parameter_set(dev->instance, port,
MMAL_PARAMETER_DISPLAYREGION,
@@ -662,7 +693,7 @@ static int vidioc_enum_fmt_vid_overlay(struct file *file, void *priv,
fmt = &formats[f->index];
- strlcpy(f->description, fmt->name, sizeof(f->description));
+ strlcpy((char *)f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
f->flags = fmt->flags;
@@ -820,7 +851,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
return -EINVAL;
inp->type = V4L2_INPUT_TYPE_CAMERA;
- sprintf(inp->name, "Camera %u", inp->index);
+ sprintf((char *)inp->name, "Camera %u", inp->index);
return 0;
}
@@ -848,11 +879,11 @@ static int vidioc_querycap(struct file *file, void *priv,
vchiq_mmal_version(dev->instance, &major, &minor);
- strcpy(cap->driver, "bm2835 mmal");
- snprintf(cap->card, sizeof(cap->card), "mmal service %d.%d",
+ strcpy((char *)cap->driver, "bm2835 mmal");
+ snprintf((char *)cap->card, sizeof(cap->card), "mmal service %d.%d",
major, minor);
- snprintf(cap->bus_info, sizeof(cap->bus_info),
+ snprintf((char *)cap->bus_info, sizeof(cap->bus_info),
"platform:%s", dev->v4l2_dev.name);
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY |
V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
@@ -871,7 +902,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
fmt = &formats[f->index];
- strlcpy(f->description, fmt->name, sizeof(f->description));
+ strlcpy((char *)f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
f->flags = fmt->flags;
@@ -928,9 +959,19 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
&f->fmt.pix.height, MIN_HEIGHT, dev->max_height,
1, 0);
f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp;
+ if (!mfmt->remove_padding) {
+ int align_mask = ((32 * mfmt->depth) >> 3) - 1;
+ /* GPU isn't removing padding, so stride is aligned to 32 */
+ f->fmt.pix.bytesperline =
+ (f->fmt.pix.bytesperline + align_mask) & ~align_mask;
+ v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
+ "Not removing padding, so bytes/line = %d, "
+ "(align_mask %d)\n",
+ f->fmt.pix.bytesperline, align_mask);
+ }
/* Image buffer has to be padded to allow for alignment, even though
- * we then remove that padding before delivering the buffer.
+ * we sometimes then remove that padding before delivering the buffer.
*/
f->fmt.pix.sizeimage = ((f->fmt.pix.height + 15) & ~15) *
(((f->fmt.pix.width + 31) & ~31) * mfmt->depth) >> 3;
@@ -963,8 +1004,10 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev,
struct vchiq_mmal_port *port = NULL, *camera_port = NULL;
struct vchiq_mmal_component *encode_component = NULL;
struct mmal_fmt *mfmt = get_format(f);
+ u32 remove_padding;
- BUG_ON(!mfmt);
+ if (!mfmt)
+ return -EINVAL;
if (dev->capture.encode_component) {
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
@@ -1031,6 +1074,12 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev,
camera_port->format.encoding = MMAL_ENCODING_RGB24;
}
+ remove_padding = mfmt->remove_padding;
+ vchiq_mmal_port_parameter_set(dev->instance,
+ camera_port,
+ MMAL_PARAMETER_NO_IMAGE_PADDING,
+ &remove_padding, sizeof(remove_padding));
+
camera_port->format.encoding_variant = 0;
camera_port->es.video.width = f->fmt.pix.width;
camera_port->es.video.height = f->fmt.pix.height;
@@ -1348,7 +1397,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
{
struct bm2835_mmal_dev *dev = video_drvdata(file);
struct v4l2_fract tpf;
- struct mmal_parameter_rational fps_param;
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -1365,10 +1413,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
parm->parm.capture.readbuffers = 1;
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
- fps_param.num = 0; /* Select variable fps, and then use
- * FPS_RANGE to select the actual limits.
- */
- fps_param.den = 1;
set_framerate_params(dev);
return 0;
@@ -1445,7 +1489,7 @@ static int get_num_cameras(struct vchiq_mmal_instance *instance,
int ret;
struct vchiq_mmal_component *cam_info_component;
struct mmal_parameter_camera_info_t cam_info = {0};
- int param_size = sizeof(cam_info);
+ u32 param_size = sizeof(cam_info);
int i;
/* create a camera_info component */
@@ -1504,13 +1548,12 @@ static int set_camera_parameters(struct vchiq_mmal_instance *instance,
#define MAX_SUPPORTED_ENCODINGS 20
/* MMAL instance and component init */
-static int __init mmal_init(struct bm2835_mmal_dev *dev)
+static int mmal_init(struct bm2835_mmal_dev *dev)
{
int ret;
struct mmal_es_format_local *format;
- u32 bool_true = 1;
u32 supported_encodings[MAX_SUPPORTED_ENCODINGS];
- int param_size;
+ u32 param_size;
struct vchiq_mmal_component *camera;
ret = vchiq_mmal_init(&dev->instance);
@@ -1592,11 +1635,6 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev)
format->es->video.frame_rate.num = 0; /* Rely on fps_range */
format->es->video.frame_rate.den = 1;
- vchiq_mmal_port_parameter_set(dev->instance,
- &camera->output[MMAL_CAMERA_PORT_VIDEO],
- MMAL_PARAMETER_NO_IMAGE_PADDING,
- &bool_true, sizeof(bool_true));
-
format = &camera->output[MMAL_CAMERA_PORT_CAPTURE].format;
format->encoding = MMAL_ENCODING_OPAQUE;
@@ -1618,11 +1656,6 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev)
dev->capture.enc_profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
dev->capture.enc_level = V4L2_MPEG_VIDEO_H264_LEVEL_4_0;
- vchiq_mmal_port_parameter_set(dev->instance,
- &camera->output[MMAL_CAMERA_PORT_CAPTURE],
- MMAL_PARAMETER_NO_IMAGE_PADDING,
- &bool_true, sizeof(bool_true));
-
/* get the preview component ready */
ret = vchiq_mmal_component_init(
dev->instance, "ril.video_render",
@@ -1723,8 +1756,8 @@ unreg_mmal:
return ret;
}
-static int __init bm2835_mmal_init_device(struct bm2835_mmal_dev *dev,
- struct video_device *vfd)
+static int bm2835_mmal_init_device(struct bm2835_mmal_dev *dev,
+ struct video_device *vfd)
{
int ret;
@@ -1803,7 +1836,7 @@ static struct v4l2_format default_v4l2_format = {
.fmt.pix.sizeimage = 1024 * 768,
};
-static int __init bm2835_mmal_init(void)
+static int bcm2835_mmal_probe(struct platform_device *pdev)
{
int ret;
struct bm2835_mmal_dev *dev;
@@ -1923,7 +1956,7 @@ cleanup_gdev:
return ret;
}
-static void __exit bm2835_mmal_exit(void)
+static int bcm2835_mmal_remove(struct platform_device *pdev)
{
int camera;
struct vchiq_mmal_instance *instance = gdev[0]->instance;
@@ -1933,7 +1966,16 @@ static void __exit bm2835_mmal_exit(void)
gdev[camera] = NULL;
}
vchiq_mmal_finalise(instance);
+
+ return 0;
}
-module_init(bm2835_mmal_init);
-module_exit(bm2835_mmal_exit);
+static struct platform_driver bcm2835_camera_driver = {
+ .probe = bcm2835_mmal_probe,
+ .remove = bcm2835_mmal_remove,
+ .driver = {
+ .name = "bcm2835-camera",
+ },
+};
+
+module_platform_driver(bcm2835_camera_driver)
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
index 800e4e7e5f96..a20bf274a4fd 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
@@ -17,7 +17,9 @@
#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
/** Special value signalling that time is not known */
-#define MMAL_TIME_UNKNOWN (1LL<<63)
+#define MMAL_TIME_UNKNOWN BIT_ULL(63)
+
+struct mmal_msg_context;
/* mapping between v4l and mmal video modes */
struct mmal_fmt {
@@ -28,6 +30,9 @@ struct mmal_fmt {
int depth;
u32 mmal_component; /* MMAL component index to be used to encode */
u32 ybbp; /* depth of first Y plane for planar formats */
+ bool remove_padding; /* Does the GPU have to remove padding,
+ * or can we do hide padding via bytesperline.
+ */
};
/* buffer for one video frame */
@@ -40,6 +45,8 @@ struct mmal_buffer {
void *buffer; /* buffer pointer */
unsigned long buffer_size; /* size of allocated buffer */
+
+ struct mmal_msg_context *msg_context;
};
/* */
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
index dd4b4ce72081..3b3ed79cadd9 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
@@ -37,7 +37,7 @@ enum mmal_port_type {
*
* most elements are informational only, the pointer values for
* interogation messages are generally provided as additional
- * strucures within the message. When used to set values only teh
+ * structures within the message. When used to set values only the
* buffer_num, buffer_size and userdata parameters are writable.
*/
struct mmal_port {
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
index 1607bc4c0347..184024dfb8b7 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
@@ -18,6 +18,9 @@
* @{
*/
+#ifndef __MMAL_PARAMETERS_H
+#define __MMAL_PARAMETERS_H
+
/** Common parameter ID group, used with many types of component. */
#define MMAL_PARAMETER_GROUP_COMMON (0<<16)
/** Camera-specific parameter ID group. */
@@ -561,6 +564,14 @@ enum mmal_parameter_displayset {
MMAL_DISPLAY_SET_ALPHA = 0x400,
};
+/* rectangle, used lots so it gets its own struct */
+struct vchiq_mmal_rect {
+ s32 x;
+ s32 y;
+ s32 width;
+ s32 height;
+};
+
struct mmal_parameter_displayregion {
/** Bitfield that indicates which fields are set and should be
* used. All other fields will maintain their current value.
@@ -682,3 +693,5 @@ struct mmal_parameter_camera_info_t {
struct mmal_parameter_camera_info_flash_t
flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
};
+
+#endif
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index a91ef6ea29ce..f5b5ead6347c 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -21,7 +21,6 @@
#include <linux/slab.h>
#include <linux/completion.h>
#include <linux/vmalloc.h>
-#include <linux/btree.h>
#include <asm/cacheflush.h>
#include <media/videobuf2-vmalloc.h>
@@ -111,7 +110,11 @@ struct vchiq_mmal_instance;
/* normal message context */
struct mmal_msg_context {
struct vchiq_mmal_instance *instance;
- u32 handle;
+
+ /* Index in the context_map idr so that we can find the
+ * mmal_msg_context again when servicing the VCHI reply.
+ */
+ int handle;
union {
struct {
@@ -149,111 +152,28 @@ struct mmal_msg_context {
};
-struct vchiq_mmal_context_map {
- /* ensure serialized access to the btree(contention should be low) */
- struct mutex lock;
- struct btree_head32 btree_head;
- u32 last_handle;
-};
-
struct vchiq_mmal_instance {
VCHI_SERVICE_HANDLE_T handle;
/* ensure serialised access to service */
struct mutex vchiq_mutex;
- /* ensure serialised access to bulk operations */
- struct mutex bulk_mutex;
-
/* vmalloc page to receive scratch bulk xfers into */
void *bulk_scratch;
- /* mapping table between context handles and mmal_msg_contexts */
- struct vchiq_mmal_context_map context_map;
+ struct idr context_map;
+ spinlock_t context_map_lock;
/* component to use next */
int component_idx;
struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
};
-static int __must_check
-mmal_context_map_init(struct vchiq_mmal_context_map *context_map)
-{
- mutex_init(&context_map->lock);
- context_map->last_handle = 0;
- return btree_init32(&context_map->btree_head);
-}
-
-static void mmal_context_map_destroy(struct vchiq_mmal_context_map *context_map)
-{
- mutex_lock(&context_map->lock);
- btree_destroy32(&context_map->btree_head);
- mutex_unlock(&context_map->lock);
-}
-
-static u32
-mmal_context_map_create_handle(struct vchiq_mmal_context_map *context_map,
- struct mmal_msg_context *msg_context,
- gfp_t gfp)
-{
- u32 handle;
-
- mutex_lock(&context_map->lock);
-
- while (1) {
- /* just use a simple count for handles, but do not use 0 */
- context_map->last_handle++;
- if (!context_map->last_handle)
- context_map->last_handle++;
-
- handle = context_map->last_handle;
-
- /* check if the handle is already in use */
- if (!btree_lookup32(&context_map->btree_head, handle))
- break;
- }
-
- if (btree_insert32(&context_map->btree_head, handle,
- msg_context, gfp)) {
- /* probably out of memory */
- mutex_unlock(&context_map->lock);
- return 0;
- }
-
- mutex_unlock(&context_map->lock);
- return handle;
-}
-
-static struct mmal_msg_context *
-mmal_context_map_lookup_handle(struct vchiq_mmal_context_map *context_map,
- u32 handle)
-{
- struct mmal_msg_context *msg_context;
-
- if (!handle)
- return NULL;
-
- mutex_lock(&context_map->lock);
-
- msg_context = btree_lookup32(&context_map->btree_head, handle);
-
- mutex_unlock(&context_map->lock);
- return msg_context;
-}
-
-static void
-mmal_context_map_destroy_handle(struct vchiq_mmal_context_map *context_map,
- u32 handle)
-{
- mutex_lock(&context_map->lock);
- btree_remove32(&context_map->btree_head, handle);
- mutex_unlock(&context_map->lock);
-}
-
static struct mmal_msg_context *
get_msg_context(struct vchiq_mmal_instance *instance)
{
struct mmal_msg_context *msg_context;
+ int handle;
/* todo: should this be allocated from a pool to avoid kzalloc */
msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
@@ -261,32 +181,40 @@ get_msg_context(struct vchiq_mmal_instance *instance)
if (!msg_context)
return ERR_PTR(-ENOMEM);
- msg_context->instance = instance;
- msg_context->handle =
- mmal_context_map_create_handle(&instance->context_map,
- msg_context,
- GFP_KERNEL);
+ /* Create an ID that will be passed along with our message so
+ * that when we service the VCHI reply, we can look up what
+ * message is being replied to.
+ */
+ spin_lock(&instance->context_map_lock);
+ handle = idr_alloc(&instance->context_map, msg_context,
+ 0, 0, GFP_KERNEL);
+ spin_unlock(&instance->context_map_lock);
- if (!msg_context->handle) {
+ if (handle < 0) {
kfree(msg_context);
- return ERR_PTR(-ENOMEM);
+ return ERR_PTR(handle);
}
+ msg_context->instance = instance;
+ msg_context->handle = handle;
+
return msg_context;
}
static struct mmal_msg_context *
-lookup_msg_context(struct vchiq_mmal_instance *instance, u32 handle)
+lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
{
- return mmal_context_map_lookup_handle(&instance->context_map,
- handle);
+ return idr_find(&instance->context_map, handle);
}
static void
release_msg_context(struct mmal_msg_context *msg_context)
{
- mmal_context_map_destroy_handle(&msg_context->instance->context_map,
- msg_context->handle);
+ struct vchiq_mmal_instance *instance = msg_context->instance;
+
+ spin_lock(&instance->context_map_lock);
+ idr_remove(&instance->context_map, msg_context->handle);
+ spin_unlock(&instance->context_map_lock);
kfree(msg_context);
}
@@ -321,8 +249,6 @@ static void buffer_work_cb(struct work_struct *work)
msg_context->u.bulk.dts,
msg_context->u.bulk.pts);
- /* release message context */
- release_msg_context(msg_context);
}
/* enqueue a bulk receive for a given message context */
@@ -331,23 +257,12 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,
struct mmal_msg_context *msg_context)
{
unsigned long rd_len;
- unsigned long flags = 0;
int ret;
- /* bulk mutex stops other bulk operations while we have a
- * receive in progress - released in callback
- */
- ret = mutex_lock_interruptible(&instance->bulk_mutex);
- if (ret != 0)
- return ret;
-
rd_len = msg->u.buffer_from_host.buffer_header.length;
- /* take buffer from queue */
- spin_lock_irqsave(&msg_context->u.bulk.port->slock, flags);
- if (list_empty(&msg_context->u.bulk.port->buffers)) {
- spin_unlock_irqrestore(&msg_context->u.bulk.port->slock, flags);
- pr_err("buffer list empty trying to submit bulk receive\n");
+ if (!msg_context->u.bulk.buffer) {
+ pr_err("bulk.buffer not configured - error in buffer_from_host\n");
/* todo: this is a serious error, we should never have
* committed a buffer_to_host operation to the mmal
@@ -359,18 +274,9 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,
* waiting bulk receive?
*/
- mutex_unlock(&instance->bulk_mutex);
-
return -EINVAL;
}
- msg_context->u.bulk.buffer =
- list_entry(msg_context->u.bulk.port->buffers.next,
- struct mmal_buffer, list);
- list_del(&msg_context->u.bulk.buffer->list);
-
- spin_unlock_irqrestore(&msg_context->u.bulk.port->slock, flags);
-
/* ensure we do not overrun the available buffer */
if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
rd_len = msg_context->u.bulk.buffer->buffer_size;
@@ -401,11 +307,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,
vchi_service_release(instance->handle);
- if (ret != 0) {
- /* callback will not be clearing the mutex */
- mutex_unlock(&instance->bulk_mutex);
- }
-
return ret;
}
@@ -415,13 +316,6 @@ static int dummy_bulk_receive(struct vchiq_mmal_instance *instance,
{
int ret;
- /* bulk mutex stops other bulk operations while we have a
- * receive in progress - released in callback
- */
- ret = mutex_lock_interruptible(&instance->bulk_mutex);
- if (ret != 0)
- return ret;
-
/* zero length indicates this was a dummy transfer */
msg_context->u.bulk.buffer_used = 0;
@@ -437,11 +331,6 @@ static int dummy_bulk_receive(struct vchiq_mmal_instance *instance,
vchi_service_release(instance->handle);
- if (ret != 0) {
- /* callback will not be clearing the mutex */
- mutex_unlock(&instance->bulk_mutex);
- }
-
return ret;
}
@@ -450,31 +339,6 @@ static int inline_receive(struct vchiq_mmal_instance *instance,
struct mmal_msg *msg,
struct mmal_msg_context *msg_context)
{
- unsigned long flags = 0;
-
- /* take buffer from queue */
- spin_lock_irqsave(&msg_context->u.bulk.port->slock, flags);
- if (list_empty(&msg_context->u.bulk.port->buffers)) {
- spin_unlock_irqrestore(&msg_context->u.bulk.port->slock, flags);
- pr_err("buffer list empty trying to receive inline\n");
-
- /* todo: this is a serious error, we should never have
- * committed a buffer_to_host operation to the mmal
- * port without the buffer to back it up (with
- * underflow handling) and there is no obvious way to
- * deal with this. Less bad than the bulk case as we
- * can just drop this on the floor but...unhelpful
- */
- return -EINVAL;
- }
-
- msg_context->u.bulk.buffer =
- list_entry(msg_context->u.bulk.port->buffers.next,
- struct mmal_buffer, list);
- list_del(&msg_context->u.bulk.buffer->list);
-
- spin_unlock_irqrestore(&msg_context->u.bulk.port->slock, flags);
-
memcpy(msg_context->u.bulk.buffer->buffer,
msg->u.buffer_from_host.short_data,
msg->u.buffer_from_host.payload_in_message);
@@ -494,25 +358,23 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
struct mmal_msg m;
int ret;
- pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
+ if (!port->enabled)
+ return -EINVAL;
- /* bulk mutex stops other bulk operations while we
- * have a receive in progress
- */
- if (mutex_lock_interruptible(&instance->bulk_mutex))
- return -EINTR;
+ pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
/* get context */
- msg_context = get_msg_context(instance);
- if (IS_ERR(msg_context)) {
- ret = PTR_ERR(msg_context);
- goto unlock;
+ if (!buf->msg_context) {
+ pr_err("%s: msg_context not allocated, buf %p\n", __func__,
+ buf);
+ return -EINVAL;
}
+ msg_context = buf->msg_context;
/* store bulk message context for when data arrives */
msg_context->u.bulk.instance = instance;
msg_context->u.bulk.port = port;
- msg_context->u.bulk.buffer = NULL; /* not valid until bulk xfer */
+ msg_context->u.bulk.buffer = buf;
msg_context->u.bulk.buffer_used = 0;
/* initialise work structure ready to schedule callback */
@@ -557,54 +419,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
sizeof(struct mmal_msg_header) +
sizeof(m.u.buffer_from_host));
- if (ret != 0) {
- release_msg_context(msg_context);
- /* todo: is this correct error value? */
- }
-
vchi_service_release(instance->handle);
-unlock:
- mutex_unlock(&instance->bulk_mutex);
-
- return ret;
-}
-
-/* submit a buffer to the mmal sevice
- *
- * the buffer_from_host uses size data from the ports next available
- * mmal_buffer and deals with there being no buffer available by
- * incrementing the underflow for later
- */
-static int port_buffer_from_host(struct vchiq_mmal_instance *instance,
- struct vchiq_mmal_port *port)
-{
- int ret;
- struct mmal_buffer *buf;
- unsigned long flags = 0;
-
- if (!port->enabled)
- return -EINVAL;
-
- /* peek buffer from queue */
- spin_lock_irqsave(&port->slock, flags);
- if (list_empty(&port->buffers)) {
- port->buffer_underflow++;
- spin_unlock_irqrestore(&port->slock, flags);
- return -ENOSPC;
- }
-
- buf = list_entry(port->buffers.next, struct mmal_buffer, list);
-
- spin_unlock_irqrestore(&port->slock, flags);
-
- /* issue buffer to mmal service */
- ret = buffer_from_host(instance, port, buf);
- if (ret) {
- pr_err("adding buffer header failed\n");
- /* todo: how should this be dealt with */
- }
-
return ret;
}
@@ -680,9 +496,6 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
msg->u.buffer_from_host.payload_in_message;
}
- /* replace the buffer header */
- port_buffer_from_host(instance, msg_context->u.bulk.port);
-
/* schedule the port callback */
schedule_work(&msg_context->u.bulk.work);
}
@@ -690,13 +503,6 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
struct mmal_msg_context *msg_context)
{
- /* bulk receive operation complete */
- mutex_unlock(&msg_context->u.bulk.instance->bulk_mutex);
-
- /* replace the buffer header */
- port_buffer_from_host(msg_context->u.bulk.instance,
- msg_context->u.bulk.port);
-
msg_context->u.bulk.status = 0;
/* schedule the port callback */
@@ -708,13 +514,6 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
{
pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
- /* bulk receive operation complete */
- mutex_unlock(&msg_context->u.bulk.instance->bulk_mutex);
-
- /* replace the buffer header */
- port_buffer_from_host(msg_context->u.bulk.instance,
- msg_context->u.bulk.port);
-
msg_context->u.bulk.status = -EINTR;
schedule_work(&msg_context->u.bulk.work);
@@ -1482,7 +1281,14 @@ static int port_disable(struct vchiq_mmal_instance *instance,
ret = port_action_port(instance, port,
MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
if (ret == 0) {
- /* drain all queued buffers on port */
+ /*
+ * Drain all queued buffers on port. This should only
+ * apply to buffers that have been queued before the port
+ * has been enabled. If the port has been enabled and buffers
+ * passed, then the buffers should have been removed from this
+ * list, and we should get the relevant callbacks via VCHIQ
+ * to release the buffers.
+ */
spin_lock_irqsave(&port->slock, flags);
list_for_each_safe(buf_head, q, &port->buffers) {
@@ -1511,7 +1317,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port)
{
unsigned int hdr_count;
- struct list_head *buf_head;
+ struct list_head *q, *buf_head;
int ret;
if (port->enabled)
@@ -1537,7 +1343,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
if (port->buffer_cb) {
/* send buffer headers to videocore */
hdr_count = 1;
- list_for_each(buf_head, &port->buffers) {
+ list_for_each_safe(buf_head, q, &port->buffers) {
struct mmal_buffer *mmalbuf;
mmalbuf = list_entry(buf_head, struct mmal_buffer,
@@ -1546,6 +1352,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
if (ret)
goto done;
+ list_del(buf_head);
hdr_count++;
if (hdr_count > port->current_buffer.num)
break;
@@ -1758,23 +1565,42 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
struct mmal_buffer *buffer)
{
unsigned long flags = 0;
+ int ret;
- spin_lock_irqsave(&port->slock, flags);
- list_add_tail(&buffer->list, &port->buffers);
- spin_unlock_irqrestore(&port->slock, flags);
-
- /* the port previously underflowed because it was missing a
- * mmal_buffer which has just been added, submit that buffer
- * to the mmal service.
- */
- if (port->buffer_underflow) {
- port_buffer_from_host(instance, port);
- port->buffer_underflow--;
+ ret = buffer_from_host(instance, port, buffer);
+ if (ret == -EINVAL) {
+ /* Port is disabled. Queue for when it is enabled. */
+ spin_lock_irqsave(&port->slock, flags);
+ list_add_tail(&buffer->list, &port->buffers);
+ spin_unlock_irqrestore(&port->slock, flags);
}
return 0;
}
+int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
+ struct mmal_buffer *buf)
+{
+ struct mmal_msg_context *msg_context = get_msg_context(instance);
+
+ if (IS_ERR(msg_context))
+ return (PTR_ERR(msg_context));
+
+ buf->msg_context = msg_context;
+ return 0;
+}
+
+int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
+{
+ struct mmal_msg_context *msg_context = buf->msg_context;
+
+ if (msg_context)
+ release_msg_context(msg_context);
+ buf->msg_context = NULL;
+
+ return 0;
+}
+
/* Initialise a mmal component and its ports
*
*/
@@ -1965,7 +1791,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
vfree(instance->bulk_scratch);
- mmal_context_map_destroy(&instance->context_map);
+ idr_destroy(&instance->context_map);
kfree(instance);
@@ -2024,16 +1850,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
return -ENOMEM;
mutex_init(&instance->vchiq_mutex);
- mutex_init(&instance->bulk_mutex);
instance->bulk_scratch = vmalloc(PAGE_SIZE);
- status = mmal_context_map_init(&instance->context_map);
- if (status) {
- pr_err("Failed to init context map (status=%d)\n", status);
- kfree(instance);
- return status;
- }
+ spin_lock_init(&instance->context_map_lock);
+ idr_init_base(&instance->context_map, 1);
params.callback_param = instance;
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
index b1f22b6dca10..22b839ecd5f0 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
@@ -32,14 +32,6 @@ enum vchiq_mmal_es_type {
MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
};
-/* rectangle, used lots so it gets its own struct */
-struct vchiq_mmal_rect {
- s32 x;
- s32 y;
- s32 width;
- s32 height;
-};
-
struct vchiq_mmal_port_buffer {
unsigned int num; /* number of buffers */
u32 size; /* size of buffers */
@@ -79,10 +71,6 @@ struct vchiq_mmal_port {
struct list_head buffers;
/* lock to serialise adding and removing buffers from list */
spinlock_t slock;
- /* count of how many buffer header refils have failed because
- * there was no buffer to satisfy them
- */
- int buffer_underflow;
/* callback on buffer completion */
vchiq_mmal_buffer_cb buffer_cb;
/* callback context */
@@ -168,4 +156,7 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
struct mmal_buffer *buf);
+int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
+ struct mmal_buffer *buf);
+int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
#endif /* MMAL_VCHIQ_H */
diff --git a/drivers/staging/vc04_services/interface/vchi/TODO b/drivers/staging/vc04_services/interface/vchi/TODO
index 86708c7c8ec3..0b3ec75ff627 100644
--- a/drivers/staging/vc04_services/interface/vchi/TODO
+++ b/drivers/staging/vc04_services/interface/vchi/TODO
@@ -40,17 +40,12 @@ should properly handle a module unload. This also includes that all
resouces must be freed (kthreads, debugfs entries, ...) and global
variables avoided.
-5) Fix stack hog
-
-Running make checkstack shows that vchiq_dump_service_use_state() has
-an extensive stack usage. Maybe other functions are also affected.
-
-6) Cleanup logging mechanism
+5) Cleanup logging mechanism
The driver should probably be using the standard kernel logging mechanisms
such as dev_info, dev_dbg, and friends.
-7) Documentation
+6) Documentation
A short top-down description of this driver's architecture (function of
kthreads, userspace, limitations) could be very helpful for reviewers.
diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h
index 76e10fe65d9b..8eb2bb9f0fe2 100644
--- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h
+++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h
@@ -97,12 +97,10 @@ typedef enum {
VCHI_CALLBACK_PEER_RESUMED,
VCHI_CALLBACK_FORCED_POWER_OFF,
-#ifdef USE_VCHIQ_ARM
// some extra notifications provided by vchiq_arm
VCHI_CALLBACK_SERVICE_OPENED,
VCHI_CALLBACK_BULK_RECEIVE_ABORTED,
VCHI_CALLBACK_BULK_TRANSMIT_ABORTED,
-#endif
VCHI_CALLBACK_REASON_MAX
} VCHI_CALLBACK_REASON_T;
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 afdd3e944f3f..e76720903064 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
@@ -475,7 +475,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
/* do not try and release vmalloc pages */
} else {
actual_pages = get_user_pages_fast(
- (unsigned long)buf & PAGE_MASK,
+ (unsigned long)buf & PAGE_MASK,
num_pages,
type == PAGELIST_READ,
pages);
@@ -582,8 +582,8 @@ free_pagelist(struct vchiq_pagelist_info *pagelistinfo,
struct page **pages = pagelistinfo->pages;
unsigned int num_pages = pagelistinfo->num_pages;
- vchiq_log_trace(vchiq_arm_log_level, "free_pagelist - %pK, %d",
- pagelistinfo->pagelist, actual);
+ vchiq_log_trace(vchiq_arm_log_level, "%s - %pK, %d",
+ __func__, pagelistinfo->pagelist, actual);
/*
* NOTE: dma_unmap_sg must be called before the
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 24d456b0a6f0..aaa264f3b598 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -168,6 +168,7 @@ static VCHIQ_STATE_T g_state;
static struct class *vchiq_class;
static struct device *vchiq_dev;
static DEFINE_SPINLOCK(msg_queue_spinlock);
+static struct platform_device *bcm2835_camera;
static const char *const ioctl_names[] = {
"CONNECT",
@@ -215,7 +216,7 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out)
state = vchiq_get_state();
if (state)
break;
- udelay(500);
+ usleep_range(500, 600);
}
if (i == VCHIQ_INIT_RETRIES) {
vchiq_log_error(vchiq_core_log_level,
@@ -563,7 +564,7 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason,
/* Out of space - wait for the client */
DEBUG_TRACE(SERVICE_CALLBACK_LINE);
vchiq_log_trace(vchiq_arm_log_level,
- "add_completion - completion queue full");
+ "%s - completion queue full", __func__);
DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT);
if (down_interruptible(&instance->remove_event) != 0) {
vchiq_log_info(vchiq_arm_log_level,
@@ -641,9 +642,9 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header,
return VCHIQ_SUCCESS;
vchiq_log_trace(vchiq_arm_log_level,
- "service_callback - service %lx(%d,%p), reason %d, header %lx, "
+ "%s - service %lx(%d,%p), reason %d, header %lx, "
"instance %lx, bulk_userdata %lx",
- (unsigned long)user_service,
+ __func__, (unsigned long)user_service,
service->localport, user_service->userdata,
reason, (unsigned long)header,
(unsigned long)instance, (unsigned long)bulk_userdata);
@@ -679,12 +680,12 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header,
if (down_interruptible(&user_service->remove_event)
!= 0) {
vchiq_log_info(vchiq_arm_log_level,
- "service_callback interrupted");
+ "%s interrupted", __func__);
DEBUG_TRACE(SERVICE_CALLBACK_LINE);
return VCHIQ_RETRY;
} else if (instance->closing) {
vchiq_log_info(vchiq_arm_log_level,
- "service_callback closing");
+ "%s closing", __func__);
DEBUG_TRACE(SERVICE_CALLBACK_LINE);
return VCHIQ_ERROR;
}
@@ -740,8 +741,8 @@ user_service_free(void *userdata)
static void close_delivered(USER_SERVICE_T *user_service)
{
vchiq_log_info(vchiq_arm_log_level,
- "close_delivered(handle=%x)",
- user_service->service->handle);
+ "%s(handle=%x)",
+ __func__, user_service->service->handle);
if (user_service->close_pending) {
/* Allow the underlying service to be culled */
@@ -872,8 +873,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
DEBUG_INITIALISE(g_state.local)
vchiq_log_trace(vchiq_arm_log_level,
- "vchiq_ioctl - instance %pK, cmd %s, arg %lx",
- instance,
+ "%s - instance %pK, cmd %s, arg %lx",
+ __func__, instance,
((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg);
@@ -2078,8 +2079,8 @@ vchiq_release(struct inode *inode, struct file *file)
int i;
vchiq_log_info(vchiq_arm_log_level,
- "vchiq_release: instance=%lx",
- (unsigned long)instance);
+ "%s: instance=%lx",
+ __func__, (unsigned long)instance);
if (!state) {
ret = -EPERM;
@@ -2128,9 +2129,11 @@ vchiq_release(struct inode *inode, struct file *file)
while (user_service->msg_remove !=
user_service->msg_insert) {
- VCHIQ_HEADER_T *header = user_service->
- msg_queue[user_service->msg_remove &
- (MSG_QUEUE_SIZE - 1)];
+ VCHIQ_HEADER_T *header;
+ int m = user_service->msg_remove &
+ (MSG_QUEUE_SIZE - 1);
+
+ header = user_service->msg_queue[m];
user_service->msg_remove++;
spin_unlock(&msg_queue_spinlock);
@@ -2666,8 +2669,7 @@ start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state)
{
del_timer(&arm_state->suspend_timer);
arm_state->suspend_timer.expires = jiffies +
- msecs_to_jiffies(arm_state->
- suspend_timer_timeout);
+ msecs_to_jiffies(arm_state->suspend_timer_timeout);
add_timer(&arm_state->suspend_timer);
arm_state->suspend_timer_running = 1;
}
@@ -3019,7 +3021,6 @@ vchiq_check_suspend(VCHIQ_STATE_T *state)
out:
vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__);
- return;
}
int
@@ -3414,13 +3415,18 @@ vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle)
return ret;
}
+struct service_data_struct {
+ int fourcc;
+ int clientid;
+ int use_count;
+};
+
void
vchiq_dump_service_use_state(VCHIQ_STATE_T *state)
{
VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state);
- int i, j = 0;
- /* Only dump 64 services */
- static const int local_max_services = 64;
+ struct service_data_struct *service_data;
+ int i, found = 0;
/* If there's more than 64 services, only dump ones with
* non-zero counts */
int only_nonzero = 0;
@@ -3431,25 +3437,25 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state)
int peer_count;
int vc_use_count;
int active_services;
- struct service_data_struct {
- int fourcc;
- int clientid;
- int use_count;
- } service_data[local_max_services];
if (!arm_state)
return;
+ service_data = kmalloc_array(MAX_SERVICES, sizeof(*service_data),
+ GFP_KERNEL);
+ if (!service_data)
+ return;
+
read_lock_bh(&arm_state->susp_res_lock);
vc_suspend_state = arm_state->vc_suspend_state;
vc_resume_state = arm_state->vc_resume_state;
peer_count = arm_state->peer_use_count;
vc_use_count = arm_state->videocore_use_count;
active_services = state->unused_service;
- if (active_services > local_max_services)
+ if (active_services > MAX_SERVICES)
only_nonzero = 1;
- for (i = 0; (i < active_services) && (j < local_max_services); i++) {
+ for (i = 0; i < active_services; i++) {
VCHIQ_SERVICE_T *service_ptr = state->services[i];
if (!service_ptr)
@@ -3461,9 +3467,12 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state)
if (service_ptr->srvstate == VCHIQ_SRVSTATE_FREE)
continue;
- service_data[j].fourcc = service_ptr->base.fourcc;
- service_data[j].clientid = service_ptr->client_id;
- service_data[j++].use_count = service_ptr->service_use_count;
+ service_data[found].fourcc = service_ptr->base.fourcc;
+ service_data[found].clientid = service_ptr->client_id;
+ service_data[found].use_count = service_ptr->service_use_count;
+ found++;
+ if (found >= MAX_SERVICES)
+ break;
}
read_unlock_bh(&arm_state->susp_res_lock);
@@ -3478,10 +3487,9 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state)
if (only_nonzero)
vchiq_log_warning(vchiq_susp_log_level, "Too many active "
"services (%d). Only dumping up to first %d services "
- "with non-zero use-count", active_services,
- local_max_services);
+ "with non-zero use-count", active_services, found);
- for (i = 0; i < j; i++) {
+ for (i = 0; i < found; i++) {
vchiq_log_warning(vchiq_susp_log_level,
"----- %c%c%c%c:%d service count %d %s",
VCHIQ_FOURCC_AS_4CHARS(service_data[i].fourcc),
@@ -3494,6 +3502,8 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state)
vchiq_log_warning(vchiq_susp_log_level,
"--- Overall vchiq instance use count %d", vc_use_count);
+ kfree(service_data);
+
vchiq_dump_platform_use_state(state);
}
@@ -3629,6 +3639,10 @@ static int vchiq_probe(struct platform_device *pdev)
VCHIQ_VERSION, VCHIQ_VERSION_MIN,
MAJOR(vchiq_devid), MINOR(vchiq_devid));
+ bcm2835_camera = platform_device_register_data(&pdev->dev,
+ "bcm2835-camera", -1,
+ NULL, 0);
+
return 0;
failed_debugfs_init:
@@ -3646,6 +3660,7 @@ failed_platform_init:
static int vchiq_remove(struct platform_device *pdev)
{
+ platform_device_unregister(bcm2835_camera);
vchiq_debugfs_deinit();
device_destroy(vchiq_class, vchiq_devid);
class_destroy(vchiq_class);
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 5d28fff46557..7642ced31436 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -601,6 +601,7 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking)
}
if (tx_pos == (state->slot_queue_available * VCHIQ_SLOT_SIZE)) {
+ up(&state->slot_available_event);
pr_warn("%s: invalid tx_pos: %d\n", __func__, tx_pos);
return NULL;
}
@@ -619,10 +620,9 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking)
/* Called by the recycle thread. */
static void
-process_free_queue(VCHIQ_STATE_T *state)
+process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length)
{
VCHIQ_SHARED_STATE_T *local = state->local;
- BITSET_T service_found[BITSET_SIZE(VCHIQ_MAX_SERVICES)];
int slot_queue_available;
/* Find slots which have been freed by the other side, and return them
@@ -655,7 +655,7 @@ process_free_queue(VCHIQ_STATE_T *state)
/* Initialise the bitmask for services which have used this
** slot */
- BITSET_ZERO(service_found);
+ memset(service_found, 0, length);
pos = 0;
@@ -1197,8 +1197,8 @@ release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info,
SLOT_INDEX_FROM_INFO(state, slot_info);
state->remote->slot_queue_recycle = slot_queue_recycle + 1;
vchiq_log_info(vchiq_core_log_level,
- "%d: release_slot %d - recycle->%x",
- state->id, SLOT_INDEX_FROM_INFO(state, slot_info),
+ "%d: %s %d - recycle->%x", state->id, __func__,
+ SLOT_INDEX_FROM_INFO(state, slot_info),
state->remote->slot_queue_recycle);
/* A write barrier is necessary, but remote_event_signal
@@ -2182,11 +2182,20 @@ recycle_func(void *v)
{
VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v;
VCHIQ_SHARED_STATE_T *local = state->local;
+ BITSET_T *found;
+ size_t length;
+
+ length = sizeof(*found) * BITSET_SIZE(VCHIQ_MAX_SERVICES);
+
+ found = kmalloc_array(BITSET_SIZE(VCHIQ_MAX_SERVICES), sizeof(*found),
+ GFP_KERNEL);
+ if (!found)
+ return -ENOMEM;
while (1) {
remote_event_wait(state, &local->recycle);
- process_free_queue(state);
+ process_free_queue(state, found, length);
}
return 0;
}
@@ -2329,8 +2338,8 @@ vchiq_init_slots(void *mem_base, int mem_size)
if (num_slots < 4) {
vchiq_log_error(vchiq_core_log_level,
- "vchiq_init_slots - insufficient memory %x bytes",
- mem_size);
+ "%s - insufficient memory %x bytes",
+ __func__, mem_size);
return NULL;
}
@@ -2544,7 +2553,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero,
return VCHIQ_ERROR;
}
set_user_nice(state->slot_handler_thread, -19);
- wake_up_process(state->slot_handler_thread);
snprintf(threadname, sizeof(threadname), "vchiq-recy/%d", state->id);
state->recycle_thread = kthread_create(&recycle_func,
@@ -2554,10 +2562,9 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero,
vchiq_loud_error_header();
vchiq_loud_error("couldn't create thread %s", threadname);
vchiq_loud_error_footer();
- return VCHIQ_ERROR;
+ goto fail_free_handler_thread;
}
set_user_nice(state->recycle_thread, -19);
- wake_up_process(state->recycle_thread);
snprintf(threadname, sizeof(threadname), "vchiq-sync/%d", state->id);
state->sync_thread = kthread_create(&sync_func,
@@ -2567,9 +2574,12 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero,
vchiq_loud_error_header();
vchiq_loud_error("couldn't create thread %s", threadname);
vchiq_loud_error_footer();
- return VCHIQ_ERROR;
+ goto fail_free_recycle_thread;
}
set_user_nice(state->sync_thread, -20);
+
+ wake_up_process(state->slot_handler_thread);
+ wake_up_process(state->recycle_thread);
wake_up_process(state->sync_thread);
vchiq_states[0] = state;
@@ -2578,6 +2588,13 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero,
local->initialised = 1;
return status;
+
+fail_free_recycle_thread:
+ kthread_stop(state->recycle_thread);
+fail_free_handler_thread:
+ kthread_stop(state->slot_handler_thread);
+
+ return VCHIQ_ERROR;
}
/* Called from application thread when a client or server service is created. */
@@ -2861,9 +2878,9 @@ close_service_complete(VCHIQ_SERVICE_T *service, int failstate)
break;
default:
vchiq_log_error(vchiq_core_log_level,
- "close_service_complete(%x) called in state %s",
+ "%s(%x) called in state %s", __func__,
service->handle, srvstate_names[service->srvstate]);
- WARN(1, "close_service_complete in unexpected state\n");
+ WARN(1, "%s in unexpected state\n", __func__);
return VCHIQ_ERROR;
}
@@ -2915,9 +2932,9 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd)
case VCHIQ_SRVSTATE_CLOSEWAIT:
if (close_recvd)
vchiq_log_error(vchiq_core_log_level,
- "vchiq_close_service_internal(1) called "
+ "%s(1) called "
"in state %s",
- srvstate_names[service->srvstate]);
+ __func__, srvstate_names[service->srvstate]);
else if (is_server) {
if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
status = VCHIQ_ERROR;
@@ -3024,7 +3041,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd)
default:
vchiq_log_error(vchiq_core_log_level,
- "vchiq_close_service_internal(%d) called in state %s",
+ "%s(%d) called in state %s", __func__,
close_recvd, srvstate_names[service->srvstate]);
break;
}
@@ -3145,8 +3162,8 @@ vchiq_pause_internal(VCHIQ_STATE_T *state)
break;
default:
vchiq_log_error(vchiq_core_log_level,
- "vchiq_pause_internal in state %s\n",
- conn_state_names[state->conn_state]);
+ "%s in state %s\n",
+ __func__, conn_state_names[state->conn_state]);
status = VCHIQ_ERROR;
VCHIQ_STATS_INC(state, error_count);
break;
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 afc1d8144a84..10deb5745dda 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
@@ -147,7 +147,6 @@ vchiq_static_assert((sizeof(BITSET_T) * 8) == 32);
#define BITSET_SIZE(b) ((b + 31) >> 5)
#define BITSET_WORD(b) (b >> 5)
#define BITSET_BIT(b) (1 << (b & 31))
-#define BITSET_ZERO(bs) memset(bs, 0, sizeof(bs))
#define BITSET_IS_SET(bs, b) (bs[BITSET_WORD(b)] & BITSET_BIT(b))
#define BITSET_SET(bs, b) (bs[BITSET_WORD(b)] |= BITSET_BIT(b))
#define BITSET_CLR(bs, b) (bs[BITSET_WORD(b)] &= ~BITSET_BIT(b))
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 29984f9795c7..dddc828390d0 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
@@ -590,7 +590,6 @@ static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason,
VCHI_CALLBACK_MSG_AVAILABLE, NULL);
goto done;
- break;
case VCHIQ_BULK_TRANSMIT_DONE:
service->callback(service->callback_param,
diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index ea0a4b57852c..52e9e6b90b56 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -557,10 +557,7 @@ CARDvSafeResetTx(
*
* Return Value: none
*/
-void
-CARDvSafeResetRx(
- struct vnt_private *priv
-)
+void CARDvSafeResetRx(struct vnt_private *priv)
{
unsigned int uu;
struct vnt_rx_desc *pDesc;
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index fbc4bc68144c..1ab0e8562d40 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -19,6 +19,7 @@
* device_print_info - print out resource
* device_rx_srv - rx service function
* device_alloc_rx_buf - rx buffer pre-allocated function
+ * device_free_rx_buf - free rx buffer function
* device_free_tx_buf - free tx buffer function
* device_init_rd0_ring- initial rd dma0 ring
* device_init_rd1_ring- initial rd dma1 ring
@@ -124,14 +125,15 @@ static int vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent);
static void device_free_info(struct vnt_private *priv);
static void device_print_info(struct vnt_private *priv);
-static void device_init_rd0_ring(struct vnt_private *priv);
-static void device_init_rd1_ring(struct vnt_private *priv);
-static void device_init_td0_ring(struct vnt_private *priv);
-static void device_init_td1_ring(struct vnt_private *priv);
+static int device_init_rd0_ring(struct vnt_private *priv);
+static int device_init_rd1_ring(struct vnt_private *priv);
+static int device_init_td0_ring(struct vnt_private *priv);
+static int device_init_td1_ring(struct vnt_private *priv);
static int device_rx_srv(struct vnt_private *priv, unsigned int idx);
static int device_tx_srv(struct vnt_private *priv, unsigned int idx);
static bool device_alloc_rx_buf(struct vnt_private *, struct vnt_rx_desc *);
+static void device_free_rx_buf(struct vnt_private *priv, struct vnt_rx_desc *rd);
static void device_init_registers(struct vnt_private *priv);
static void device_free_tx_buf(struct vnt_private *, struct vnt_tx_desc *);
static void device_free_td0_ring(struct vnt_private *priv);
@@ -528,20 +530,28 @@ static void device_free_rings(struct vnt_private *priv)
priv->tx0_bufs, priv->tx_bufs_dma0);
}
-static void device_init_rd0_ring(struct vnt_private *priv)
+static int device_init_rd0_ring(struct vnt_private *priv)
{
int i;
dma_addr_t curr = priv->rd0_pool_dma;
struct vnt_rx_desc *desc;
+ int ret;
/* Init the RD0 ring entries */
for (i = 0; i < priv->opts.rx_descs0;
i ++, curr += sizeof(struct vnt_rx_desc)) {
desc = &priv->aRD0Ring[i];
desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL);
+ if (!desc->rd_info) {
+ ret = -ENOMEM;
+ goto err_free_desc;
+ }
- if (!device_alloc_rx_buf(priv, desc))
+ if (!device_alloc_rx_buf(priv, desc)) {
dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
+ ret = -ENOMEM;
+ goto err_free_rd;
+ }
desc->next = &priv->aRD0Ring[(i + 1) % priv->opts.rx_descs0];
desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc));
@@ -550,22 +560,44 @@ static void device_init_rd0_ring(struct vnt_private *priv)
if (i > 0)
priv->aRD0Ring[i-1].next_desc = cpu_to_le32(priv->rd0_pool_dma);
priv->pCurrRD[0] = &priv->aRD0Ring[0];
+
+ return 0;
+
+err_free_rd:
+ kfree(desc->rd_info);
+
+err_free_desc:
+ while (--i) {
+ desc = &priv->aRD0Ring[i];
+ device_free_rx_buf(priv, desc);
+ kfree(desc->rd_info);
+ }
+
+ return ret;
}
-static void device_init_rd1_ring(struct vnt_private *priv)
+static int device_init_rd1_ring(struct vnt_private *priv)
{
int i;
dma_addr_t curr = priv->rd1_pool_dma;
struct vnt_rx_desc *desc;
+ int ret;
/* Init the RD1 ring entries */
for (i = 0; i < priv->opts.rx_descs1;
i ++, curr += sizeof(struct vnt_rx_desc)) {
desc = &priv->aRD1Ring[i];
desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL);
+ if (!desc->rd_info) {
+ ret = -ENOMEM;
+ goto err_free_desc;
+ }
- if (!device_alloc_rx_buf(priv, desc))
+ if (!device_alloc_rx_buf(priv, desc)) {
dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
+ ret = -ENOMEM;
+ goto err_free_rd;
+ }
desc->next = &priv->aRD1Ring[(i+1) % priv->opts.rx_descs1];
desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc));
@@ -574,6 +606,20 @@ static void device_init_rd1_ring(struct vnt_private *priv)
if (i > 0)
priv->aRD1Ring[i-1].next_desc = cpu_to_le32(priv->rd1_pool_dma);
priv->pCurrRD[1] = &priv->aRD1Ring[0];
+
+ return 0;
+
+err_free_rd:
+ kfree(desc->rd_info);
+
+err_free_desc:
+ while (--i) {
+ desc = &priv->aRD1Ring[i];
+ device_free_rx_buf(priv, desc);
+ kfree(desc->rd_info);
+ }
+
+ return ret;
}
static void device_free_rd0_ring(struct vnt_private *priv)
@@ -582,13 +628,8 @@ static void device_free_rd0_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.rx_descs0; i++) {
struct vnt_rx_desc *desc = &priv->aRD0Ring[i];
- struct vnt_rd_info *rd_info = desc->rd_info;
-
- dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
- priv->rx_buf_sz, DMA_FROM_DEVICE);
-
- dev_kfree_skb(rd_info->skb);
+ device_free_rx_buf(priv, desc);
kfree(desc->rd_info);
}
}
@@ -599,28 +640,28 @@ static void device_free_rd1_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.rx_descs1; i++) {
struct vnt_rx_desc *desc = &priv->aRD1Ring[i];
- struct vnt_rd_info *rd_info = desc->rd_info;
-
- dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
- priv->rx_buf_sz, DMA_FROM_DEVICE);
-
- dev_kfree_skb(rd_info->skb);
+ device_free_rx_buf(priv, desc);
kfree(desc->rd_info);
}
}
-static void device_init_td0_ring(struct vnt_private *priv)
+static int device_init_td0_ring(struct vnt_private *priv)
{
int i;
dma_addr_t curr;
struct vnt_tx_desc *desc;
+ int ret;
curr = priv->td0_pool_dma;
for (i = 0; i < priv->opts.tx_descs[0];
i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD0Rings[i];
desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL);
+ if (!desc->td_info) {
+ ret = -ENOMEM;
+ goto err_free_desc;
+ }
desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ;
desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ;
@@ -632,13 +673,24 @@ static void device_init_td0_ring(struct vnt_private *priv)
if (i > 0)
priv->apTD0Rings[i-1].next_desc = cpu_to_le32(priv->td0_pool_dma);
priv->apTailTD[0] = priv->apCurrTD[0] = &priv->apTD0Rings[0];
+
+ return 0;
+
+err_free_desc:
+ while (--i) {
+ desc = &priv->apTD0Rings[i];
+ kfree(desc->td_info);
+ }
+
+ return ret;
}
-static void device_init_td1_ring(struct vnt_private *priv)
+static int device_init_td1_ring(struct vnt_private *priv)
{
int i;
dma_addr_t curr;
struct vnt_tx_desc *desc;
+ int ret;
/* Init the TD ring entries */
curr = priv->td1_pool_dma;
@@ -646,6 +698,10 @@ static void device_init_td1_ring(struct vnt_private *priv)
i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD1Rings[i];
desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL);
+ if (!desc->td_info) {
+ ret = -ENOMEM;
+ goto err_free_desc;
+ }
desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ;
desc->td_info->buf_dma = priv->tx_bufs_dma1 + i * PKT_BUF_SZ;
@@ -657,6 +713,16 @@ static void device_init_td1_ring(struct vnt_private *priv)
if (i > 0)
priv->apTD1Rings[i-1].next_desc = cpu_to_le32(priv->td1_pool_dma);
priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
+
+ return 0;
+
+err_free_desc:
+ while (--i) {
+ desc = &priv->apTD1Rings[i];
+ kfree(desc->td_info);
+ }
+
+ return ret;
}
static void device_free_td0_ring(struct vnt_private *priv)
@@ -745,6 +811,16 @@ static bool device_alloc_rx_buf(struct vnt_private *priv,
return true;
}
+static void device_free_rx_buf(struct vnt_private *priv,
+ struct vnt_rx_desc *rd)
+{
+ struct vnt_rd_info *rd_info = rd->rd_info;
+
+ dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
+ priv->rx_buf_sz, DMA_FROM_DEVICE);
+ dev_kfree_skb(rd_info->skb);
+}
+
static const u8 fallback_rate0[5][5] = {
{RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
{RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
@@ -1161,14 +1237,22 @@ static int vnt_start(struct ieee80211_hw *hw)
IRQF_SHARED, "vt6655", priv);
if (ret) {
dev_dbg(&priv->pcid->dev, "failed to start irq\n");
- return ret;
+ goto err_free_rings;
}
dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n");
- device_init_rd0_ring(priv);
- device_init_rd1_ring(priv);
- device_init_td0_ring(priv);
- device_init_td1_ring(priv);
+ ret = device_init_rd0_ring(priv);
+ if (ret)
+ goto err_free_irq;
+ ret = device_init_rd1_ring(priv);
+ if (ret)
+ goto err_free_rd0_ring;
+ ret = device_init_td0_ring(priv);
+ if (ret)
+ goto err_free_rd1_ring;
+ ret = device_init_td1_ring(priv);
+ if (ret)
+ goto err_free_td0_ring;
device_init_registers(priv);
@@ -1178,6 +1262,18 @@ static int vnt_start(struct ieee80211_hw *hw)
ieee80211_wake_queues(hw);
return 0;
+
+err_free_td0_ring:
+ device_free_td0_ring(priv);
+err_free_rd1_ring:
+ device_free_rd1_ring(priv);
+err_free_rd0_ring:
+ device_free_rd0_ring(priv);
+err_free_irq:
+ free_irq(priv->pcid->irq, priv);
+err_free_rings:
+ device_free_rings(priv);
+ return ret;
}
static void vnt_stop(struct ieee80211_hw *hw)
diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO
index ae61b55f14fd..d123324bd5c9 100644
--- a/drivers/staging/wilc1000/TODO
+++ b/drivers/staging/wilc1000/TODO
@@ -1,7 +1,4 @@
TODO:
-- remove the defined feature as kernel versions
-- remove OS wrapper functions
-- remove custom debug and tracing functions
- rework comments and function headers(also coding style)
- Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the multiplexer
@@ -9,10 +6,9 @@ TODO:
implementation of each message handler into the callsite of the function
that currently queues the 'host_if_msg'.
- make spi and sdio components coexist in one build
-- turn compile-time platform configuration (BEAGLE_BOARD,
- PANDA_BOARD, PLAT_WMS8304, PLAT_RKXXXX, CUSTOMER_PLATFORM, ...)
- into run-time options that are read from DT
- support soft-ap and p2p mode
- support resume/suspend function
-- replace SIOCDEVPRIVATE commands with generic API functions
-- use wext-core handling instead of private SIOCSIWPRIV implementation
+- convert all uses of the old GPIO API from <linux/gpio.h> to the
+ GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
+ lines from device tree, ACPI or board files, board files should
+ use <linux/gpio/machine.h>
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index db66b1cc80b3..44816024f79c 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "coreconfigurator.h"
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
-#include <linux/errno.h>
-#include <linux/slab.h>
+
#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
BEACON_INTERVAL_LEN + CAP_INFO_LEN)
@@ -210,16 +207,6 @@ static inline u16 get_cap_info(u8 *data)
return cap_info;
}
-static inline u16 get_assoc_resp_cap_info(u8 *data)
-{
- u16 cap_info;
-
- cap_info = data[0];
- cap_info |= (data[1] << 8);
-
- return cap_info;
-}
-
static inline u16 get_asoc_status(u8 *data)
{
u16 asoc_status;
@@ -228,16 +215,6 @@ static inline u16 get_asoc_status(u8 *data)
return (asoc_status << 8) | data[2];
}
-static inline u16 get_asoc_id(u8 *data)
-{
- u16 asoc_id;
-
- asoc_id = data[4];
- asoc_id |= (data[5] << 8);
-
- return asoc_id;
-}
-
static u8 *get_tim_elm(u8 *msa, u16 rx_len, u16 tag_param_offset)
{
u16 index;
@@ -272,78 +249,68 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
{
struct network_info *network_info = NULL;
u8 msg_type = 0;
- u8 msg_id = 0;
- u16 msg_len = 0;
-
- u16 wid_id = (u16)WID_NIL;
u16 wid_len = 0;
u8 *wid_val = NULL;
+ u8 *msa = NULL;
+ u16 rx_len = 0;
+ u8 *tim_elm = NULL;
+ u8 *ies = NULL;
+ u16 ies_len = 0;
+ u8 index = 0;
+ u32 tsf_lo;
+ u32 tsf_hi;
msg_type = msg_buffer[0];
if ('N' != msg_type)
return -EFAULT;
- msg_id = msg_buffer[1];
- msg_len = MAKE_WORD16(msg_buffer[2], msg_buffer[3]);
- wid_id = MAKE_WORD16(msg_buffer[4], msg_buffer[5]);
wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]);
wid_val = &msg_buffer[8];
- {
- u8 *msa = NULL;
- u16 rx_len = 0;
- u8 *tim_elm = NULL;
- u8 *ies = NULL;
- u16 ies_len = 0;
- u8 index = 0;
- u32 tsf_lo;
- u32 tsf_hi;
-
- network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
- if (!network_info)
- return -ENOMEM;
+ network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
+ if (!network_info)
+ return -ENOMEM;
- network_info->rssi = wid_val[0];
+ network_info->rssi = wid_val[0];
- msa = &wid_val[1];
+ msa = &wid_val[1];
- rx_len = wid_len - 1;
- network_info->cap_info = get_cap_info(msa);
- network_info->tsf_lo = get_beacon_timestamp_lo(msa);
+ rx_len = wid_len - 1;
+ network_info->cap_info = get_cap_info(msa);
+ network_info->tsf_lo = get_beacon_timestamp_lo(msa);
- tsf_lo = get_beacon_timestamp_lo(msa);
- tsf_hi = get_beacon_timestamp_hi(msa);
+ tsf_lo = get_beacon_timestamp_lo(msa);
+ tsf_hi = get_beacon_timestamp_hi(msa);
- network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32);
+ network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32);
- get_ssid(msa, network_info->ssid, &network_info->ssid_len);
- get_BSSID(msa, network_info->bssid);
+ get_ssid(msa, network_info->ssid, &network_info->ssid_len);
+ get_BSSID(msa, network_info->bssid);
- network_info->ch = get_current_channel_802_11n(msa, rx_len
- + FCS_LEN);
+ network_info->ch = get_current_channel_802_11n(msa, rx_len
+ + FCS_LEN);
- index = MAC_HDR_LEN + TIME_STAMP_LEN;
+ index = MAC_HDR_LEN + TIME_STAMP_LEN;
- network_info->beacon_period = get_beacon_period(msa + index);
+ network_info->beacon_period = get_beacon_period(msa + index);
- index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
+ index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
- tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index);
- if (tim_elm)
- network_info->dtim_period = tim_elm[3];
- ies = &msa[TAG_PARAM_OFFSET];
- ies_len = rx_len - TAG_PARAM_OFFSET;
+ tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index);
+ if (tim_elm)
+ network_info->dtim_period = tim_elm[3];
+ ies = &msa[TAG_PARAM_OFFSET];
+ ies_len = rx_len - TAG_PARAM_OFFSET;
- if (ies_len > 0) {
- network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
- if (!network_info->ies) {
- kfree(network_info);
- return -ENOMEM;
- }
+ if (ies_len > 0) {
+ network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
+ if (!network_info->ies) {
+ kfree(network_info);
+ return -ENOMEM;
}
- network_info->ies_len = ies_len;
}
+ network_info->ies_len = ies_len;
*ret_network_info = network_info;
@@ -351,38 +318,23 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
}
s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
- struct connect_resp_info **ret_connect_resp_info)
+ struct connect_info *ret_conn_info)
{
- struct connect_resp_info *connect_resp_info = NULL;
- u16 assoc_resp_len = 0;
u8 *ies = NULL;
u16 ies_len = 0;
- connect_resp_info = kzalloc(sizeof(*connect_resp_info), GFP_KERNEL);
- if (!connect_resp_info)
- return -ENOMEM;
-
- assoc_resp_len = (u16)buffer_len;
-
- connect_resp_info->status = get_asoc_status(buffer);
- if (connect_resp_info->status == SUCCESSFUL_STATUSCODE) {
- connect_resp_info->capability = get_assoc_resp_cap_info(buffer);
- connect_resp_info->assoc_id = get_asoc_id(buffer);
-
+ ret_conn_info->status = get_asoc_status(buffer);
+ if (ret_conn_info->status == SUCCESSFUL_STATUSCODE) {
ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
- ies_len = assoc_resp_len - (CAP_INFO_LEN + STATUS_CODE_LEN +
- AID_LEN);
+ ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN +
+ AID_LEN);
- connect_resp_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
- if (!connect_resp_info->ies) {
- kfree(connect_resp_info);
+ ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL);
+ if (!ret_conn_info->resp_ies)
return -ENOMEM;
- }
- connect_resp_info->ies_len = ies_len;
+ ret_conn_info->resp_ies_len = ies_len;
}
- *ret_connect_resp_info = connect_resp_info;
-
return 0;
}
diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h
index 3f5da8c58815..55b5531856f8 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -1,34 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-/*!
- * @file coreconfigurator.h
- * @brief
- * @author
- * @sa coreconfigurator.c
- * @date 1 Mar 2012
- * @version 1.0
- */
-
#ifndef CORECONFIGURATOR_H
#define CORECONFIGURATOR_H
#include "wilc_wlan_if.h"
-#define NUM_BASIC_SWITCHES 45
-#define NUM_FHSS_SWITCHES 0
-
#define NUM_RSSI 5
-#ifdef MAC_802_11N
-#define NUM_11N_BASIC_SWITCHES 25
-#define NUM_11N_HUT_SWITCHES 47
-#else
-#define NUM_11N_BASIC_SWITCHES 0
-#define NUM_11N_HUT_SWITCHES 0
-#endif
-
#define MAC_HDR_LEN 24
-#define MAX_SSID_LEN 33
#define FCS_LEN 4
#define TIME_STAMP_LEN 8
#define BEACON_INTERVAL_LEN 2
@@ -41,13 +19,8 @@
#define GET_CFG 1
#define MAX_STRING_LEN 256
-#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN
-#define SURVEY_RESULT_LENGTH 44
#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN
-#define MAC_CONNECTED 1
-#define MAC_DISCONNECTED 0
-
#define MAKE_WORD16(lsb, msb) ((((u16)(msb) << 8) & 0xFF00) | (lsb))
#define MAKE_WORD32(lsw, msw) ((((u32)(msw) << 16) & 0xFFFF0000) | (lsw))
@@ -98,14 +71,6 @@ struct network_info {
u64 tsf_hi;
};
-struct connect_resp_info {
- u16 capability;
- u16 status;
- u16 assoc_id;
- u8 *ies;
- u16 ies_len;
-};
-
struct connect_info {
u8 bssid[6];
u8 *req_ies;
@@ -124,7 +89,7 @@ struct disconnect_info {
s32 wilc_parse_network_info(u8 *msg_buffer,
struct network_info **ret_network_info);
s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
- struct connect_resp_info **ret_connect_resp_info);
+ struct connect_info *ret_conn_info);
void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 885f5fcead77..0aaae33f97b9 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1,18 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/completion.h>
-#include <linux/list.h>
-#include <linux/workqueue.h>
-#include "host_interface.h"
-#include <linux/spinlock.h>
-#include <linux/errno.h>
-#include "coreconfigurator.h"
-#include "wilc_wlan.h"
-#include "wilc_wlan_if.h"
-#include <linux/etherdevice.h>
#include "wilc_wfi_netdevice.h"
#define HOST_IF_MSG_SCAN 0
@@ -53,14 +39,13 @@
#define HOST_IF_SCAN_TIMEOUT 4000
#define HOST_IF_CONNECT_TIMEOUT 9500
-#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
-#define BA_SESSION_DEFAULT_TIMEOUT 1000
-#define BLOCK_ACK_REQ_SIZE 0x14
#define FALSE_FRMWR_CHANNEL 100
#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
#define DEFAULT_LINK_SPEED 72
+#define REAL_JOIN_REQ 0
+
struct host_if_wpa_attr {
u8 *key;
const u8 *mac_addr;
@@ -232,7 +217,7 @@ struct join_bss_param {
static struct host_if_drv *terminated_handle;
bool wilc_optaining_ip;
-static u8 P2P_LISTEN_STATE;
+static u8 p2p_listen_state;
static struct workqueue_struct *hif_workqueue;
static struct completion hif_thread_comp;
static struct completion hif_driver_comp;
@@ -245,19 +230,12 @@ u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
-static bool scan_while_connected;
-
static s8 rssi;
static u8 set_ip[2][4];
static u8 get_ip[2][4];
static u32 inactive_time;
-static u8 del_beacon;
static u32 clients_count;
-#define REAL_JOIN_REQ 0
-#define FLUSHED_JOIN_REQ 1
-#define FLUSHED_BYTE_POS 79
-
static void *host_int_parse_join_bss_param(struct network_info *info);
static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt);
@@ -599,7 +577,7 @@ static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *param)
wid_list[i].size = sizeof(char);
hif_drv->cfg_values.preamble_type = preamble_type;
} else {
- netdev_err(vif->ndev, "Preamle Range(0~2) over\n");
+ netdev_err(vif->ndev, "Preamble Range(0~2) over\n");
goto unlock;
}
i++;
@@ -842,11 +820,6 @@ static s32 handle_scan(struct wilc_vif *vif, struct scan_attr *scan_info)
wid_list[index].val = (s8 *)&scan_info->src;
index++;
- if (hif_drv->hif_state == HOST_IF_CONNECTED)
- scan_while_connected = true;
- else if (hif_drv->hif_state == HOST_IF_IDLE)
- scan_while_connected = false;
-
result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
index,
wilc_get_vif_idx(vif));
@@ -1144,10 +1117,8 @@ error:
}
conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP,
- &conn_info,
- MAC_DISCONNECTED,
- NULL,
- conn_attr->arg);
+ &conn_info, MAC_STATUS_DISCONNECTED,
+ NULL, conn_attr->arg);
hif_drv->hif_state = HOST_IF_IDLE;
kfree(conn_info.req_ies);
conn_info.req_ies = NULL;
@@ -1185,8 +1156,6 @@ static s32 handle_connect_timeout(struct wilc_vif *vif)
hif_drv->hif_state = HOST_IF_IDLE;
- scan_while_connected = false;
-
memset(&info, 0, sizeof(struct connect_info));
if (hif_drv->usr_conn_req.conn_result) {
@@ -1197,15 +1166,16 @@ static s32 handle_connect_timeout(struct wilc_vif *vif)
if (hif_drv->usr_conn_req.ies) {
info.req_ies_len = hif_drv->usr_conn_req.ies_len;
- info.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
- memcpy(info.req_ies,
- hif_drv->usr_conn_req.ies,
- hif_drv->usr_conn_req.ies_len);
+ info.req_ies = kmemdup(hif_drv->usr_conn_req.ies,
+ hif_drv->usr_conn_req.ies_len,
+ GFP_KERNEL);
+ if (!info.req_ies)
+ return -ENOMEM;
}
hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
&info,
- MAC_DISCONNECTED,
+ MAC_STATUS_DISCONNECTED,
NULL,
hif_drv->usr_conn_req.arg);
@@ -1327,62 +1297,47 @@ static inline void host_int_free_user_conn_req(struct host_if_drv *hif_drv)
static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
u8 mac_status)
{
- struct connect_resp_info *connect_resp_info = NULL;
struct connect_info conn_info;
struct host_if_drv *hif_drv = vif->hif_drv;
memset(&conn_info, 0, sizeof(struct connect_info));
- if (mac_status == MAC_CONNECTED) {
- u32 rcvd_assoc_resp_info_len;
+ if (mac_status == MAC_STATUS_CONNECTED) {
+ u32 assoc_resp_info_len;
memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
host_int_get_assoc_res_info(vif, rcv_assoc_resp,
MAX_ASSOC_RESP_FRAME_SIZE,
- &rcvd_assoc_resp_info_len);
+ &assoc_resp_info_len);
- if (rcvd_assoc_resp_info_len != 0) {
+ if (assoc_resp_info_len != 0) {
s32 err = 0;
- err = wilc_parse_assoc_resp_info(rcv_assoc_resp, rcvd_assoc_resp_info_len,
- &connect_resp_info);
- if (err) {
+ err = wilc_parse_assoc_resp_info(rcv_assoc_resp,
+ assoc_resp_info_len,
+ &conn_info);
+ if (err)
netdev_err(vif->ndev,
"wilc_parse_assoc_resp_info() returned error %d\n",
err);
- } else {
- conn_info.status = connect_resp_info->status;
-
- if (conn_info.status == SUCCESSFUL_STATUSCODE &&
- connect_resp_info->ies) {
- conn_info.resp_ies = kmemdup(connect_resp_info->ies,
- connect_resp_info->ies_len,
- GFP_KERNEL);
- if (conn_info.resp_ies)
- conn_info.resp_ies_len = connect_resp_info->ies_len;
- }
-
- kfree(connect_resp_info->ies);
- kfree(connect_resp_info);
- }
}
}
- if (mac_status == MAC_CONNECTED &&
+ if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status != SUCCESSFUL_STATUSCODE) {
netdev_err(vif->ndev,
- "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
+ "Received MAC status is MAC_STATUS_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
eth_zero_addr(wilc_connected_ssid);
- } else if (mac_status == MAC_DISCONNECTED) {
- netdev_err(vif->ndev, "Received MAC status is MAC_DISCONNECTED\n");
+ } else if (mac_status == MAC_STATUS_DISCONNECTED) {
+ netdev_err(vif->ndev, "Received MAC status is MAC_STATUS_DISCONNECTED\n");
eth_zero_addr(wilc_connected_ssid);
}
if (hif_drv->usr_conn_req.bssid) {
memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6);
- if (mac_status == MAC_CONNECTED &&
+ if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status == SUCCESSFUL_STATUSCODE) {
memcpy(hif_drv->assoc_bssid,
hif_drv->usr_conn_req.bssid, ETH_ALEN);
@@ -1402,7 +1357,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
&conn_info, mac_status, NULL,
hif_drv->usr_conn_req.arg);
- if (mac_status == MAC_CONNECTED &&
+ if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status == SUCCESSFUL_STATUSCODE) {
wilc_set_power_mgmt(vif, 0, 0);
@@ -1413,7 +1368,6 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
jiffies + msecs_to_jiffies(10000));
} else {
hif_drv->hif_state = HOST_IF_IDLE;
- scan_while_connected = false;
}
kfree(conn_info.resp_ies);
@@ -1428,6 +1382,7 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif)
{
struct disconnect_info disconn_info;
struct host_if_drv *hif_drv = vif->hif_drv;
+ wilc_connect_result conn_result = hif_drv->usr_conn_req.conn_result;
memset(&disconn_info, 0, sizeof(struct disconnect_info));
@@ -1440,13 +1395,12 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif)
disconn_info.ie = NULL;
disconn_info.ie_len = 0;
- if (hif_drv->usr_conn_req.conn_result) {
+ if (conn_result) {
wilc_optaining_ip = false;
wilc_set_power_mgmt(vif, 0, 0);
- hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
- NULL, 0, &disconn_info,
- hif_drv->usr_conn_req.arg);
+ conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, 0,
+ &disconn_info, hif_drv->usr_conn_req.arg);
} else {
netdev_err(vif->ndev, "Connect result NULL\n");
}
@@ -1455,7 +1409,6 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif)
host_int_free_user_conn_req(hif_drv);
hif_drv->hif_state = HOST_IF_IDLE;
- scan_while_connected = false;
}
static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif,
@@ -1463,13 +1416,7 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif,
{
s32 result = 0;
u8 msg_type = 0;
- u8 msg_id = 0;
- u16 msg_len = 0;
- u16 wid_id = (u16)WID_NIL;
- u8 wid_len = 0;
u8 mac_status;
- u8 mac_status_reason_code;
- u8 mac_status_additional_info;
struct host_if_drv *hif_drv = vif->hif_drv;
if (!rcvd_info->buffer) {
@@ -1503,19 +1450,13 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif,
return -EFAULT;
}
- msg_id = rcvd_info->buffer[1];
- msg_len = MAKE_WORD16(rcvd_info->buffer[2], rcvd_info->buffer[3]);
- wid_id = MAKE_WORD16(rcvd_info->buffer[4], rcvd_info->buffer[5]);
- wid_len = rcvd_info->buffer[6];
mac_status = rcvd_info->buffer[7];
- mac_status_reason_code = rcvd_info->buffer[8];
- mac_status_additional_info = rcvd_info->buffer[9];
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
host_int_parse_assoc_resp_info(vif, mac_status);
- } else if ((mac_status == MAC_DISCONNECTED) &&
+ } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
(hif_drv->hif_state == HOST_IF_CONNECTED)) {
host_int_handle_disconnect(vif);
- } else if ((mac_status == MAC_DISCONNECTED) &&
+ } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
(hif_drv->usr_scan_req.scan_result)) {
del_timer(&hif_drv->scan_timer);
if (hif_drv->usr_scan_req.scan_result)
@@ -1529,15 +1470,46 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif,
return result;
}
+static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key)
+{
+ int i;
+ int ret;
+ struct wid wid;
+ u8 *key_buf;
+
+ key_buf = kmalloc((hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1,
+ GFP_KERNEL);
+ if (!key_buf)
+ return -ENOMEM;
+
+ key_buf[0] = hif_key->attr.pmkid.numpmkid;
+
+ for (i = 0; i < hif_key->attr.pmkid.numpmkid; i++) {
+ memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1),
+ hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
+ memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1),
+ hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
+ }
+
+ wid.id = (u16)WID_PMKID_INFO;
+ wid.type = WID_STR;
+ wid.val = (s8 *)key_buf;
+ wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
+
+ ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+
+ kfree(key_buf);
+
+ return ret;
+}
+
static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
{
- s32 result = 0;
+ int result = 0;
struct wid wid;
struct wid wid_list[5];
- u8 i;
u8 *key_buf;
- s8 s8idxarray[1];
- s8 ret = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
switch (hif_key->type) {
@@ -1556,8 +1528,10 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
key_buf = kmalloc(hif_key->attr.wep.key_len + 2,
GFP_KERNEL);
- if (!key_buf)
- return -ENOMEM;
+ if (!key_buf) {
+ result = -ENOMEM;
+ goto out_wep;
+ }
key_buf[0] = hif_key->attr.wep.index;
key_buf[1] = hif_key->attr.wep.key_len;
@@ -1577,9 +1551,12 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
wilc_get_vif_idx(vif));
kfree(key_buf);
} else if (hif_key->action & ADDKEY) {
- key_buf = kmalloc(hif_key->attr.wep.key_len + 2, GFP_KERNEL);
- if (!key_buf)
- return -ENOMEM;
+ key_buf = kmalloc(hif_key->attr.wep.key_len + 2,
+ GFP_KERNEL);
+ if (!key_buf) {
+ result = -ENOMEM;
+ goto out_wep;
+ }
key_buf[0] = hif_key->attr.wep.index;
memcpy(key_buf + 1, &hif_key->attr.wep.key_len, 1);
memcpy(key_buf + 2, hif_key->attr.wep.key,
@@ -1599,8 +1576,7 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
wid.id = (u16)WID_REMOVE_WEP_KEY;
wid.type = WID_STR;
- s8idxarray[0] = (s8)hif_key->attr.wep.index;
- wid.val = s8idxarray;
+ wid.val = (s8 *)&hif_key->attr.wep.index;
wid.size = 1;
result = wilc_send_config_pkt(vif, SET_CFG,
@@ -1616,6 +1592,7 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
&wid, 1,
wilc_get_vif_idx(vif));
}
+out_wep:
complete(&hif_drv->comp_test_key_block);
break;
@@ -1623,7 +1600,7 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
if (hif_key->action & ADDKEY_AP) {
key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
if (!key_buf) {
- ret = -ENOMEM;
+ result = -ENOMEM;
goto out_wpa_rx_gtk;
}
@@ -1650,11 +1627,10 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
wilc_get_vif_idx(vif));
kfree(key_buf);
- complete(&hif_drv->comp_test_key_block);
} else if (hif_key->action & ADDKEY) {
key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
if (!key_buf) {
- ret = -ENOMEM;
+ result = -ENOMEM;
goto out_wpa_rx_gtk;
}
@@ -1679,21 +1655,18 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key)
wilc_get_vif_idx(vif));
kfree(key_buf);
- complete(&hif_drv->comp_test_key_block);
}
out_wpa_rx_gtk:
+ complete(&hif_drv->comp_test_key_block);
kfree(hif_key->attr.wpa.key);
kfree(hif_key->attr.wpa.seq);
- if (ret)
- return ret;
-
break;
case WPA_PTK:
if (hif_key->action & ADDKEY_AP) {
key_buf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
if (!key_buf) {
- ret = -ENOMEM;
+ result = -ENOMEM;
goto out_wpa_ptk;
}
@@ -1717,12 +1690,10 @@ out_wpa_rx_gtk:
wid_list, 2,
wilc_get_vif_idx(vif));
kfree(key_buf);
- complete(&hif_drv->comp_test_key_block);
} else if (hif_key->action & ADDKEY) {
key_buf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
if (!key_buf) {
- netdev_err(vif->ndev, "No buffer send PTK\n");
- ret = -ENOMEM;
+ result = -ENOMEM;
goto out_wpa_ptk;
}
@@ -1740,37 +1711,15 @@ out_wpa_rx_gtk:
&wid, 1,
wilc_get_vif_idx(vif));
kfree(key_buf);
- complete(&hif_drv->comp_test_key_block);
}
out_wpa_ptk:
+ complete(&hif_drv->comp_test_key_block);
kfree(hif_key->attr.wpa.key);
- if (ret)
- return ret;
-
break;
case PMKSA:
- key_buf = kmalloc((hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
- if (!key_buf)
- return -ENOMEM;
-
- key_buf[0] = hif_key->attr.pmkid.numpmkid;
-
- for (i = 0; i < hif_key->attr.pmkid.numpmkid; i++) {
- memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1), hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
- memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
- }
-
- wid.id = (u16)WID_PMKID_INFO;
- wid.type = WID_STR;
- wid.val = (s8 *)key_buf;
- wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
-
- result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-
- kfree(key_buf);
+ result = wilc_pmksa_key_copy(vif, hif_key);
break;
}
@@ -1833,8 +1782,6 @@ static void handle_disconnect(struct wilc_vif *vif)
netdev_err(vif->ndev, "conn_result = NULL\n");
}
- scan_while_connected = false;
-
hif_drv->hif_state = HOST_IF_IDLE;
eth_zero_addr(hif_drv->assoc_bssid);
@@ -2035,18 +1982,13 @@ static void handle_del_beacon(struct wilc_vif *vif)
{
s32 result = 0;
struct wid wid;
- u8 *cur_byte;
+ u8 del_beacon = 0;
wid.id = (u16)WID_DEL_BEACON;
wid.type = WID_CHAR;
wid.size = sizeof(char);
wid.val = &del_beacon;
- if (!wid.val)
- return;
-
- cur_byte = wid.val;
-
result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
wilc_get_vif_idx(vif));
if (result)
@@ -2156,7 +2098,6 @@ static void handle_del_station(struct wilc_vif *vif, struct del_sta *param)
{
s32 result = 0;
struct wid wid;
- u8 *cur_byte;
wid.id = (u16)WID_REMOVE_STA;
wid.type = WID_BIN;
@@ -2166,9 +2107,7 @@ static void handle_del_station(struct wilc_vif *vif, struct del_sta *param)
if (!wid.val)
goto error;
- cur_byte = wid.val;
-
- ether_addr_copy(cur_byte, param->mac_addr);
+ ether_addr_copy(wid.val, param->mac_addr);
result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
wilc_get_vif_idx(vif));
@@ -2260,19 +2199,16 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
netdev_err(vif->ndev, "Failed to set remain on channel\n");
error:
- {
- P2P_LISTEN_STATE = 1;
- hif_drv->remain_on_ch_timer_vif = vif;
- mod_timer(&hif_drv->remain_on_ch_timer,
- jiffies +
- msecs_to_jiffies(hif_remain_ch->duration));
+ p2p_listen_state = 1;
+ hif_drv->remain_on_ch_timer_vif = vif;
+ mod_timer(&hif_drv->remain_on_ch_timer,
+ jiffies + msecs_to_jiffies(hif_remain_ch->duration));
- if (hif_drv->remain_on_ch.ready)
- hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
+ if (hif_drv->remain_on_ch.ready)
+ hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
- if (hif_drv->remain_on_ch_pending)
- hif_drv->remain_on_ch_pending = 0;
- }
+ if (hif_drv->remain_on_ch_pending)
+ hif_drv->remain_on_ch_pending = 0;
return result;
}
@@ -2317,7 +2253,7 @@ static u32 handle_listen_state_expired(struct wilc_vif *vif,
s32 result = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
- if (P2P_LISTEN_STATE) {
+ if (p2p_listen_state) {
remain_on_chan_flag = false;
wid.id = (u16)WID_REMAIN_ON_CHAN;
wid.type = WID_STR;
@@ -2335,20 +2271,19 @@ static u32 handle_listen_state_expired(struct wilc_vif *vif,
kfree(wid.val);
if (result != 0) {
netdev_err(vif->ndev, "Failed to set remain channel\n");
- goto _done_;
+ return result;
}
if (hif_drv->remain_on_ch.expired) {
hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
hif_remain_ch->id);
}
- P2P_LISTEN_STATE = 0;
+ p2p_listen_state = 0;
} else {
netdev_dbg(vif->ndev, "Not in listen state\n");
result = -EFAULT;
}
-_done_:
return result;
}
@@ -2664,18 +2599,6 @@ static void timer_connect_cb(struct timer_list *t)
wilc_enqueue_cmd(&msg);
}
-s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *sta_addr)
-{
- struct wid wid;
-
- wid.id = (u16)WID_REMOVE_KEY;
- wid.type = WID_STR;
- wid.val = (s8 *)sta_addr;
- wid.size = 6;
-
- return 0;
-}
-
int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
{
int result = 0;
@@ -3335,7 +3258,6 @@ static void get_periodic_rssi(struct timer_list *unused)
int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
{
- int result = 0;
struct host_if_drv *hif_drv;
struct wilc_vif *vif;
struct wilc *wilc;
@@ -3344,15 +3266,12 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
vif = netdev_priv(dev);
wilc = vif->wilc;
- scan_while_connected = false;
-
init_completion(&hif_wait_response);
hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
- if (!hif_drv) {
- result = -ENOMEM;
- goto _fail_;
- }
+ if (!hif_drv)
+ return -ENOMEM;
+
*hif_drv_handler = hif_drv;
for (i = 0; i < wilc->vif_num; i++)
if (dev == wilc->vif[i]->ndev) {
@@ -3363,7 +3282,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
wilc_optaining_ip = false;
- if (clients_count == 0) {
+ if (clients_count == 0) {
init_completion(&hif_thread_comp);
init_completion(&hif_driver_comp);
mutex_init(&hif_deinit_lock);
@@ -3374,12 +3293,12 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
init_completion(&hif_drv->comp_get_rssi);
init_completion(&hif_drv->comp_inactive_time);
- if (clients_count == 0) {
+ if (clients_count == 0) {
hif_workqueue = create_singlethread_workqueue("WILC_wq");
if (!hif_workqueue) {
netdev_err(vif->ndev, "Failed to create workqueue\n");
- result = -ENOMEM;
- goto _fail_;
+ kfree(hif_drv);
+ return -ENOMEM;
}
periodic_rssi_vif = vif;
@@ -3407,8 +3326,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
clients_count++;
-_fail_:
- return result;
+ return 0;
}
int wilc_deinit(struct wilc_vif *vif)
@@ -3443,8 +3361,6 @@ int wilc_deinit(struct wilc_vif *vif)
hif_drv->hif_state = HOST_IF_IDLE;
- scan_while_connected = false;
-
memset(&msg, 0, sizeof(struct host_if_msg));
if (clients_count == 1) {
@@ -3895,150 +3811,167 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
return result;
}
-static void *host_int_parse_join_bss_param(struct network_info *info)
+static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies,
+ u16 *out_index, u8 *pcipher_tc,
+ u8 *auth_total_cnt, u32 tsf_lo,
+ u8 *rates_no)
{
- struct join_bss_param *param = NULL;
- u8 *ies;
- u16 ies_len;
- u16 index = 0;
- u8 rates_no = 0;
u8 ext_rates_no;
u16 offset;
u8 pcipher_cnt;
u8 auth_cnt;
- u8 pcipher_total_cnt = 0;
- u8 auth_total_cnt = 0;
u8 i, j;
+ u16 index = *out_index;
- ies = info->ies;
- ies_len = info->ies_len;
+ if (ies[index] == SUPP_RATES_IE) {
+ *rates_no = ies[index + 1];
+ param->supp_rates[0] = *rates_no;
+ index += 2;
- param = kzalloc(sizeof(*param), GFP_KERNEL);
- if (!param)
- return NULL;
+ for (i = 0; i < *rates_no; i++)
+ param->supp_rates[i + 1] = ies[index + i];
- param->dtim_period = info->dtim_period;
- param->beacon_period = info->beacon_period;
- param->cap_info = info->cap_info;
- memcpy(param->bssid, info->bssid, 6);
- memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
- param->ssid_len = info->ssid_len;
- memset(param->rsn_pcip_policy, 0xFF, 3);
- memset(param->rsn_auth_policy, 0xFF, 3);
+ index += *rates_no;
+ } else if (ies[index] == EXT_SUPP_RATES_IE) {
+ ext_rates_no = ies[index + 1];
+ if (ext_rates_no > (MAX_RATES_SUPPORTED - *rates_no))
+ param->supp_rates[0] = MAX_RATES_SUPPORTED;
+ else
+ param->supp_rates[0] += ext_rates_no;
+ index += 2;
+ for (i = 0; i < (param->supp_rates[0] - *rates_no); i++)
+ param->supp_rates[*rates_no + i + 1] = ies[index + i];
+
+ index += ext_rates_no;
+ } else if (ies[index] == HT_CAPABILITY_IE) {
+ param->ht_capable = true;
+ index += ies[index + 1] + 2;
+ } else if ((ies[index] == WMM_IE) &&
+ (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) &&
+ (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x02) &&
+ ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) &&
+ (ies[index + 7] == 0x01)) {
+ param->wmm_cap = true;
+
+ if (ies[index + 8] & BIT(7))
+ param->uapsd_cap = true;
+ index += ies[index + 1] + 2;
+ } else if ((ies[index] == P2P_IE) &&
+ (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) &&
+ (ies[index + 4] == 0x9a) &&
+ (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) {
+ u16 p2p_cnt;
+
+ param->tsf = tsf_lo;
+ param->noa_enabled = 1;
+ param->idx = ies[index + 9];
+
+ if (ies[index + 10] & BIT(7)) {
+ param->opp_enabled = 1;
+ param->ct_window = ies[index + 10];
+ } else {
+ param->opp_enabled = 0;
+ }
- while (index < ies_len) {
- if (ies[index] == SUPP_RATES_IE) {
- rates_no = ies[index + 1];
- param->supp_rates[0] = rates_no;
- index += 2;
+ param->cnt = ies[index + 11];
+ p2p_cnt = index + 12;
- for (i = 0; i < rates_no; i++)
- param->supp_rates[i + 1] = ies[index + i];
+ memcpy(param->duration, ies + p2p_cnt, 4);
+ p2p_cnt += 4;
- index += rates_no;
- } else if (ies[index] == EXT_SUPP_RATES_IE) {
- ext_rates_no = ies[index + 1];
- if (ext_rates_no > (MAX_RATES_SUPPORTED - rates_no))
- param->supp_rates[0] = MAX_RATES_SUPPORTED;
- else
- param->supp_rates[0] += ext_rates_no;
- index += 2;
- for (i = 0; i < (param->supp_rates[0] - rates_no); i++)
- param->supp_rates[rates_no + i + 1] = ies[index + i];
-
- index += ext_rates_no;
- } else if (ies[index] == HT_CAPABILITY_IE) {
- param->ht_capable = true;
- index += ies[index + 1] + 2;
- } else if ((ies[index] == WMM_IE) &&
- (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) &&
- (ies[index + 4] == 0xF2) &&
- (ies[index + 5] == 0x02) &&
- ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) &&
- (ies[index + 7] == 0x01)) {
- param->wmm_cap = true;
-
- if (ies[index + 8] & BIT(7))
- param->uapsd_cap = true;
- index += ies[index + 1] + 2;
- } else if ((ies[index] == P2P_IE) &&
- (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) &&
- (ies[index + 4] == 0x9a) &&
- (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) {
- u16 p2p_cnt;
-
- param->tsf = info->tsf_lo;
- param->noa_enabled = 1;
- param->idx = ies[index + 9];
-
- if (ies[index + 10] & BIT(7)) {
- param->opp_enabled = 1;
- param->ct_window = ies[index + 10];
- } else {
- param->opp_enabled = 0;
- }
+ memcpy(param->interval, ies + p2p_cnt, 4);
+ p2p_cnt += 4;
- param->cnt = ies[index + 11];
- p2p_cnt = index + 12;
+ memcpy(param->start_time, ies + p2p_cnt, 4);
- memcpy(param->duration, ies + p2p_cnt, 4);
- p2p_cnt += 4;
+ index += ies[index + 1] + 2;
+ } else if ((ies[index] == RSN_IE) ||
+ ((ies[index] == WPA_IE) && (ies[index + 2] == 0x00) &&
+ (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) &&
+ (ies[index + 5] == 0x01))) {
+ u16 rsn_idx = index;
- memcpy(param->interval, ies + p2p_cnt, 4);
- p2p_cnt += 4;
+ if (ies[rsn_idx] == RSN_IE) {
+ param->mode_802_11i = 2;
+ } else {
+ if (param->mode_802_11i == 0)
+ param->mode_802_11i = 1;
+ rsn_idx += 4;
+ }
- memcpy(param->start_time, ies + p2p_cnt, 4);
+ rsn_idx += 7;
+ param->rsn_grp_policy = ies[rsn_idx];
+ rsn_idx++;
+ offset = ies[rsn_idx] * 4;
+ pcipher_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
+ rsn_idx += 2;
- index += ies[index + 1] + 2;
- } else if ((ies[index] == RSN_IE) ||
- ((ies[index] == WPA_IE) && (ies[index + 2] == 0x00) &&
- (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) &&
- (ies[index + 5] == 0x01))) {
- u16 rsn_idx = index;
+ i = *pcipher_tc;
+ j = 0;
+ for (; i < (pcipher_cnt + *pcipher_tc) && i < 3; i++, j++) {
+ u8 *policy = &param->rsn_pcip_policy[i];
- if (ies[rsn_idx] == RSN_IE) {
- param->mode_802_11i = 2;
- } else {
- if (param->mode_802_11i == 0)
- param->mode_802_11i = 1;
- rsn_idx += 4;
- }
+ *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
+ }
- rsn_idx += 7;
- param->rsn_grp_policy = ies[rsn_idx];
- rsn_idx++;
- offset = ies[rsn_idx] * 4;
- pcipher_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
- rsn_idx += 2;
+ *pcipher_tc += pcipher_cnt;
+ rsn_idx += offset;
+
+ offset = ies[rsn_idx] * 4;
- for (i = pcipher_total_cnt, j = 0; i < pcipher_cnt + pcipher_total_cnt && i < 3; i++, j++)
- param->rsn_pcip_policy[i] = ies[rsn_idx + ((j + 1) * 4) - 1];
+ auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
+ rsn_idx += 2;
+ i = *auth_total_cnt;
+ j = 0;
+ for (; i < (*auth_total_cnt + auth_cnt); i++, j++) {
+ u8 *policy = &param->rsn_auth_policy[i];
- pcipher_total_cnt += pcipher_cnt;
- rsn_idx += offset;
+ *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
+ }
- offset = ies[rsn_idx] * 4;
+ *auth_total_cnt += auth_cnt;
+ rsn_idx += offset;
- auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
+ if (ies[index] == RSN_IE) {
+ param->rsn_cap[0] = ies[rsn_idx];
+ param->rsn_cap[1] = ies[rsn_idx + 1];
rsn_idx += 2;
+ }
+ param->rsn_found = true;
+ index += ies[index + 1] + 2;
+ } else {
+ index += ies[index + 1] + 2;
+ }
+
+ *out_index = index;
+}
+
+static void *host_int_parse_join_bss_param(struct network_info *info)
+{
+ struct join_bss_param *param = NULL;
+ u16 index = 0;
+ u8 rates_no = 0;
+ u8 pcipher_total_cnt = 0;
+ u8 auth_total_cnt = 0;
- for (i = auth_total_cnt, j = 0; i < auth_total_cnt + auth_cnt; i++, j++)
- param->rsn_auth_policy[i] = ies[rsn_idx + ((j + 1) * 4) - 1];
+ param = kzalloc(sizeof(*param), GFP_KERNEL);
+ if (!param)
+ return NULL;
- auth_total_cnt += auth_cnt;
- rsn_idx += offset;
+ param->dtim_period = info->dtim_period;
+ param->beacon_period = info->beacon_period;
+ param->cap_info = info->cap_info;
+ memcpy(param->bssid, info->bssid, 6);
+ memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
+ param->ssid_len = info->ssid_len;
+ memset(param->rsn_pcip_policy, 0xFF, 3);
+ memset(param->rsn_auth_policy, 0xFF, 3);
- if (ies[index] == RSN_IE) {
- param->rsn_cap[0] = ies[rsn_idx];
- param->rsn_cap[1] = ies[rsn_idx + 1];
- rsn_idx += 2;
- }
- param->rsn_found = true;
- index += ies[index + 1] + 2;
- } else {
- index += ies[index + 1] + 2;
- }
- }
+ while (index < info->ies_len)
+ host_int_fill_join_bss_param(param, info->ies, &index,
+ &pcipher_total_cnt,
+ &auth_total_cnt, info->tsf_lo,
+ &rates_no);
return (void *)param;
}
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 4b60b1822e91..068b587a9df4 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -49,7 +49,6 @@
#define PMKID_LEN 16
#define WILC_MAX_NUM_PMKIDS 16
#define WILC_ADD_STA_LENGTH 40
-#define SCAN_EVENT_DONE_ABORTED
#define NUM_CONCURRENT_IFC 2
#define DRV_HANDLER_SIZE 5
#define DRV_HANDLER_MASK 0x000000FF
@@ -272,7 +271,7 @@ struct host_if_drv {
u8 assoc_bssid[ETH_ALEN];
struct cfg_param_attr cfg_values;
-
+ /*lock to protect concurrent setting of cfg params*/
struct mutex cfg_values_lock;
struct completion comp_test_key_block;
struct completion comp_test_disconn_block;
@@ -304,7 +303,6 @@ struct add_sta_param {
};
struct wilc_vif;
-s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *sta_addr);
int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
@@ -315,7 +313,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
u8 mode, u8 cipher_mode, u8 index);
s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
- u32 *pu32InactiveTime);
+ u32 *out_val);
int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
u8 index, u32 key_rsc_len, const u8 *key_rsc,
const u8 *rx_mic, const u8 *tx_mic, u8 mode,
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index 169213f24faf..1c7e6e15809c 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -1,15 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
-/*!
- * @file linux_mon.c
- * @brief File Operations OS wrapper functionality
- * @author mdaftedar
- * @sa wilc_wfi_netdevice.h
- * @date 01 MAR 2012
- * @version 1.0
- */
#include "wilc_wfi_cfgoperations.h"
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
struct wilc_wfi_radiotap_hdr {
struct ieee80211_radiotap_header hdr;
@@ -27,22 +17,15 @@ static struct net_device *wilc_wfi_mon; /* global monitor netdev */
static u8 srcadd[6];
static u8 bssid[6];
-static u8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-/**
- * @brief WILC_WFI_monitor_rx
- * @details
- * @param[in]
- * @return int : Return 0 on Success
- * @author mdaftedar
- * @date 12 JUL 2012
- * @version 1.0
- */
#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive*/
#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
-void WILC_WFI_monitor_rx(u8 *buff, u32 size)
+#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \
+ (1 << IEEE80211_RADIOTAP_TX_FLAGS))
+
+void wilc_wfi_monitor_rx(u8 *buff, u32 size)
{
u32 header, pkt_offset;
struct sk_buff *skb = NULL;
@@ -66,22 +49,20 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size)
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
/* hostapd callback mgmt frame */
- skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ skb = dev_alloc_skb(size + sizeof(*cb_hdr));
if (!skb)
return;
skb_put_data(skb, buff, size);
cb_hdr = skb_push(skb, sizeof(*cb_hdr));
- memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ memset(cb_hdr, 0, sizeof(*cb_hdr));
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
- cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
- cb_hdr->hdr.it_present = cpu_to_le32(
- (1 << IEEE80211_RADIOTAP_RATE) |
- (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+ cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
cb_hdr->rate = 5; /* txrate->bitrate / 5; */
@@ -93,7 +74,7 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size)
}
} else {
- skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr));
+ skb = dev_alloc_skb(size + sizeof(*hdr));
if (!skb)
return;
@@ -102,7 +83,7 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size)
hdr = skb_push(skb, sizeof(*hdr));
memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
- hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr));
+ hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
hdr->hdr.it_present = cpu_to_le32
(1 << IEEE80211_RADIOTAP_RATE); /* | */
hdr->rate = 5; /* txrate->bitrate / 5; */
@@ -162,20 +143,11 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
return 0;
}
-/**
- * @brief WILC_WFI_mon_xmit
- * @details
- * @param[in]
- * @return int : Return 0 on Success
- * @author mdaftedar
- * @date 12 JUL 2012
- * @version 1.0
- */
-static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
+static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
struct net_device *dev)
{
u32 rtap_len, ret = 0;
- struct WILC_WFI_mon_priv *mon_priv;
+ struct wilc_wfi_mon_priv *mon_priv;
struct sk_buff *skb2;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
@@ -192,8 +164,8 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
skb_pull(skb, rtap_len);
- if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) {
- skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ if (skb->data[0] == 0xc0 && is_broadcast_ether_addr(&skb->data[4])) {
+ skb2 = dev_alloc_skb(skb->len + sizeof(*cb_hdr));
if (!skb2)
return -ENOMEM;
@@ -204,11 +176,9 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
- cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
- cb_hdr->hdr.it_present = cpu_to_le32(
- (1 << IEEE80211_RADIOTAP_RATE) |
- (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+ cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
cb_hdr->rate = 5; /* txrate->bitrate / 5; */
cb_hdr->tx_flags = 0x0004;
@@ -244,29 +214,20 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
}
static const struct net_device_ops wilc_wfi_netdev_ops = {
- .ndo_start_xmit = WILC_WFI_mon_xmit,
+ .ndo_start_xmit = wilc_wfi_mon_xmit,
};
-/**
- * @brief WILC_WFI_init_mon_interface
- * @details
- * @param[in]
- * @return Pointer to net_device
- * @author mdaftedar
- * @date 12 JUL 2012
- * @version 1.0
- */
-struct net_device *WILC_WFI_init_mon_interface(const char *name,
+struct net_device *wilc_wfi_init_mon_interface(const char *name,
struct net_device *real_dev)
{
- struct WILC_WFI_mon_priv *priv;
+ struct wilc_wfi_mon_priv *priv;
/*If monitor interface is already initialized, return it*/
if (wilc_wfi_mon)
return wilc_wfi_mon;
- wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv));
+ wilc_wfi_mon = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv));
if (!wilc_wfi_mon)
return NULL;
wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP;
@@ -287,16 +248,7 @@ struct net_device *WILC_WFI_init_mon_interface(const char *name,
return wilc_wfi_mon;
}
-/**
- * @brief WILC_WFI_deinit_mon_interface
- * @details
- * @param[in]
- * @return int : Return 0 on Success
- * @author mdaftedar
- * @date 12 JUL 2012
- * @version 1.0
- */
-int WILC_WFI_deinit_mon_interface(void)
+int wilc_wfi_deinit_mon_interface(void)
{
bool rollback_lock = false;
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 38a83bd31671..02e6b1338440 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1,60 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
-#include "wilc_wfi_cfgoperations.h"
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
-
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/gpio.h>
-
#include <linux/kthread.h>
#include <linux/firmware.h>
-
-#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/skbuff.h>
-#include <linux/mutex.h>
-#include <linux/completion.h>
-
-static int dev_state_ev_handler(struct notifier_block *this,
- unsigned long event, void *ptr);
-
-static struct notifier_block g_dev_notifier = {
- .notifier_call = dev_state_ev_handler
-};
-static int wlan_deinit_locks(struct net_device *dev);
-static void wlan_deinitialize_threads(struct net_device *dev);
-
-static void linux_wlan_tx_complete(void *priv, int status);
-static int mac_init_fn(struct net_device *ndev);
-static struct net_device_stats *mac_stats(struct net_device *dev);
-static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd);
-static int wilc_mac_open(struct net_device *ndev);
-static int wilc_mac_close(struct net_device *ndev);
-static void wilc_set_multicast_list(struct net_device *dev);
+#include "wilc_wfi_cfgoperations.h"
bool wilc_enable_ps = true;
-static const struct net_device_ops wilc_netdev_ops = {
- .ndo_init = mac_init_fn,
- .ndo_open = wilc_mac_open,
- .ndo_stop = wilc_mac_close,
- .ndo_start_xmit = wilc_mac_xmit,
- .ndo_do_ioctl = mac_ioctl,
- .ndo_get_stats = mac_stats,
- .ndo_set_rx_mode = wilc_set_multicast_list,
-
-};
-
static int dev_state_ev_handler(struct notifier_block *this,
unsigned long event, void *ptr)
{
@@ -221,19 +176,16 @@ static void deinit_irq(struct net_device *dev)
}
}
-void wilc_mac_indicate(struct wilc *wilc, int flag)
+void wilc_mac_indicate(struct wilc *wilc)
{
int status;
- if (flag == WILC_MAC_INDICATE_STATUS) {
- wilc_wlan_cfg_get_val(WID_STATUS,
- (unsigned char *)&status, 4);
- if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
- wilc->mac_status = status;
- complete(&wilc->sync_event);
- } else {
- wilc->mac_status = status;
- }
+ wilc_wlan_cfg_get_val(WID_STATUS, (unsigned char *)&status, 4);
+ if (wilc->mac_status == MAC_STATUS_INIT) {
+ wilc->mac_status = status;
+ complete(&wilc->sync_event);
+ } else {
+ wilc->mac_status = status;
}
}
@@ -317,7 +269,7 @@ static int linux_wlan_txq_task(void *vp)
return 0;
}
-int wilc_wlan_get_firmware(struct net_device *dev)
+static int wilc_wlan_get_firmware(struct net_device *dev)
{
struct wilc_vif *vif;
struct wilc *wilc;
@@ -338,16 +290,16 @@ int wilc_wlan_get_firmware(struct net_device *dev)
netdev_info(dev, "loading firmware %s\n", firmware);
if (!(&vif->ndev->dev))
- goto _fail_;
+ goto fail;
if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
netdev_err(dev, "%s - firmware not available\n", firmware);
ret = -1;
- goto _fail_;
+ goto fail;
}
wilc->firmware = wilc_firmware;
-_fail_:
+fail:
return ret;
}
@@ -416,197 +368,230 @@ static int linux_wlan_init_test_config(struct net_device *dev,
*(int *)c_val = 1;
if (!wilc_wlan_cfg_set(vif, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = INFRASTRUCTURE;
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = RATE_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = G_MIXED_11B_2_MODE;
if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = G_SHORT_PREAMBLE;
if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = AUTO_PROT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = ACTIVE_SCAN;
if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = SITE_SURVEY_OFF;
if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
*((int *)c_val) = 0xffff;
if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
- goto _fail_;
+ goto fail;
*((int *)c_val) = 2346;
if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = NO_POWERSAVE;
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = OPEN_SYSTEM;
if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
strcpy(c_val, "123456790abcdef1234567890");
if (!wilc_wlan_cfg_set(vif, 0, WID_WEP_KEY_VALUE, c_val,
(strlen(c_val) + 1), 0, 0))
- goto _fail_;
+ goto fail;
strcpy(c_val, "12345678");
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0,
0))
- goto _fail_;
+ goto fail;
strcpy(c_val, "password");
if (!wilc_wlan_cfg_set(vif, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1),
0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 192;
c_val[1] = 168;
c_val[2] = 1;
c_val[3] = 112;
if (!wilc_wlan_cfg_set(vif, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 3;
if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 3;
if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = NORMAL_ACK;
if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1,
0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 48;
if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = 28;
if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
*((int *)c_val) = 100;
if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = REKEY_DISABLE;
if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
*((int *)c_val) = 84600;
if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
- goto _fail_;
+ goto fail;
*((int *)c_val) = 500;
if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = G_SELF_CTS_PROT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = HT_MIXED_MODE;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = DETECT_PROTECT_REPORT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1,
0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = RTS_CTS_NONHT_PROT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = MIMO_MODE;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
- goto _fail_;
+ goto fail;
c_val[0] = 7;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0,
0))
- goto _fail_;
+ goto fail;
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1,
1, 1))
- goto _fail_;
+ goto fail;
return 0;
-_fail_:
+fail:
return -1;
}
-void wilc1000_wlan_deinit(struct net_device *dev)
+static int wlan_deinit_locks(struct net_device *dev)
+{
+ struct wilc_vif *vif;
+ struct wilc *wilc;
+
+ vif = netdev_priv(dev);
+ wilc = vif->wilc;
+
+ mutex_destroy(&wilc->hif_cs);
+ mutex_destroy(&wilc->rxq_cs);
+ mutex_destroy(&wilc->txq_add_to_head_cs);
+
+ return 0;
+}
+
+static void wlan_deinitialize_threads(struct net_device *dev)
+{
+ struct wilc_vif *vif;
+ struct wilc *wl;
+
+ vif = netdev_priv(dev);
+ wl = vif->wilc;
+
+ wl->close = 1;
+
+ complete(&wl->txq_event);
+
+ if (wl->txq_thread) {
+ kthread_stop(wl->txq_thread);
+ wl->txq_thread = NULL;
+ }
+}
+
+static void wilc_wlan_deinitialize(struct net_device *dev)
{
struct wilc_vif *vif;
struct wilc *wl;
@@ -668,21 +653,6 @@ static int wlan_init_locks(struct net_device *dev)
return 0;
}
-static int wlan_deinit_locks(struct net_device *dev)
-{
- struct wilc_vif *vif;
- struct wilc *wilc;
-
- vif = netdev_priv(dev);
- wilc = vif->wilc;
-
- mutex_destroy(&wilc->hif_cs);
- mutex_destroy(&wilc->rxq_cs);
- mutex_destroy(&wilc->txq_add_to_head_cs);
-
- return 0;
-}
-
static int wlan_initialize_threads(struct net_device *dev)
{
struct wilc_vif *vif;
@@ -703,31 +673,13 @@ static int wlan_initialize_threads(struct net_device *dev)
return 0;
}
-static void wlan_deinitialize_threads(struct net_device *dev)
-{
- struct wilc_vif *vif;
- struct wilc *wl;
-
- vif = netdev_priv(dev);
- wl = vif->wilc;
-
- wl->close = 1;
-
- complete(&wl->txq_event);
-
- if (wl->txq_thread) {
- kthread_stop(wl->txq_thread);
- wl->txq_thread = NULL;
- }
-}
-
-int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif)
+static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
{
int ret = 0;
struct wilc *wl = vif->wilc;
if (!wl->initialized) {
- wl->mac_status = WILC_MAC_STATUS_INIT;
+ wl->mac_status = MAC_STATUS_INIT;
wl->close = 0;
wlan_init_locks(dev);
@@ -735,42 +687,42 @@ int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif)
ret = wilc_wlan_init(dev);
if (ret < 0) {
ret = -EIO;
- goto _fail_locks_;
+ goto fail_locks;
}
if (wl->gpio >= 0 && init_irq(dev)) {
ret = -EIO;
- goto _fail_locks_;
+ goto fail_locks;
}
ret = wlan_initialize_threads(dev);
if (ret < 0) {
ret = -EIO;
- goto _fail_wilc_wlan_;
+ goto fail_wilc_wlan;
}
if (!wl->dev_irq_num &&
wl->hif_func->enable_interrupt &&
wl->hif_func->enable_interrupt(wl)) {
ret = -EIO;
- goto _fail_irq_init_;
+ goto fail_irq_init;
}
if (wilc_wlan_get_firmware(dev)) {
ret = -EIO;
- goto _fail_irq_enable_;
+ goto fail_irq_enable;
}
ret = wilc1000_firmware_download(dev);
if (ret < 0) {
ret = -EIO;
- goto _fail_irq_enable_;
+ goto fail_irq_enable;
}
ret = linux_wlan_start_firmware(dev);
if (ret < 0) {
ret = -EIO;
- goto _fail_irq_enable_;
+ goto fail_irq_enable;
}
if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
@@ -788,27 +740,27 @@ int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif)
if (ret < 0) {
netdev_err(dev, "Failed to configure firmware\n");
ret = -EIO;
- goto _fail_fw_start_;
+ goto fail_fw_start;
}
wl->initialized = true;
return 0;
-_fail_fw_start_:
+fail_fw_start:
wilc_wlan_stop(wl);
-_fail_irq_enable_:
+fail_irq_enable:
if (!wl->dev_irq_num &&
wl->hif_func->disable_interrupt)
wl->hif_func->disable_interrupt(wl);
-_fail_irq_init_:
+fail_irq_init:
if (wl->dev_irq_num)
deinit_irq(dev);
wlan_deinitialize_threads(dev);
-_fail_wilc_wlan_:
+fail_wilc_wlan:
wilc_wlan_cleanup(dev);
-_fail_locks_:
+fail_locks:
wlan_deinit_locks(dev);
netdev_err(dev, "WLAN initialization FAILED\n");
} else {
@@ -848,7 +800,7 @@ static int wilc_mac_open(struct net_device *ndev)
if (ret < 0)
return ret;
- ret = wilc1000_wlan_init(ndev, vif);
+ ret = wilc_wlan_initialize(ndev, vif);
if (ret < 0) {
wilc_deinit_host_int(ndev);
return ret;
@@ -871,7 +823,7 @@ static int wilc_mac_open(struct net_device *ndev)
if (!is_valid_ether_addr(ndev->dev_addr)) {
netdev_err(ndev, "Wrong MAC address\n");
wilc_deinit_host_int(ndev);
- wilc1000_wlan_deinit(ndev);
+ wilc_wlan_deinitialize(ndev);
return -EINVAL;
}
@@ -941,7 +893,7 @@ static void linux_wlan_tx_complete(void *priv, int status)
kfree(pv_data);
}
-int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
+netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
{
struct wilc_vif *vif;
struct tx_complete_data *tx_data = NULL;
@@ -1040,8 +992,8 @@ static int wilc_mac_close(struct net_device *ndev)
if (wl->open_ifcs == 0) {
netdev_dbg(ndev, "Deinitializing wilc1000\n");
wl->close = 1;
- wilc1000_wlan_deinit(ndev);
- WILC_WFI_deinit_mon_interface();
+ wilc_wlan_deinitialize(ndev);
+ wilc_wfi_deinit_mon_interface();
}
vif->mac_opened = 0;
@@ -1049,67 +1001,6 @@ static int wilc_mac_close(struct net_device *ndev)
return 0;
}
-static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
-{
- u8 *buff = NULL;
- s8 rssi;
- u32 size = 0;
- struct wilc_vif *vif;
- s32 ret = 0;
- struct wilc *wilc;
-
- vif = netdev_priv(ndev);
- wilc = vif->wilc;
-
- if (!wilc->initialized)
- return 0;
-
- switch (cmd) {
- case SIOCSIWPRIV:
- {
- struct iwreq *wrq = (struct iwreq *)req;
-
- size = wrq->u.data.length;
-
- if (size && wrq->u.data.pointer) {
- buff = memdup_user(wrq->u.data.pointer,
- wrq->u.data.length);
- if (IS_ERR(buff))
- return PTR_ERR(buff);
-
- if (strncasecmp(buff, "RSSI", size) == 0) {
- ret = wilc_get_rssi(vif, &rssi);
- netdev_info(ndev, "RSSI :%d\n", rssi);
-
- rssi += 5;
-
- snprintf(buff, size, "rssi %d", rssi);
-
- if (copy_to_user(wrq->u.data.pointer, buff, size)) {
- netdev_err(ndev, "failed to copy\n");
- ret = -EFAULT;
- goto done;
- }
- }
- }
- }
- break;
-
- default:
- {
- netdev_info(ndev, "Command - %d - has been received\n", cmd);
- ret = -EOPNOTSUPP;
- goto done;
- }
- }
-
-done:
-
- kfree(buff);
-
- return ret;
-}
-
void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
{
unsigned int frame_len = 0;
@@ -1158,7 +1049,7 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
for (i = 0; i < wilc->vif_num; i++) {
vif = netdev_priv(wilc->vif[i]->ndev);
if (vif->monitor_flag) {
- WILC_WFI_monitor_rx(buff, size);
+ wilc_wfi_monitor_rx(buff, size);
return;
}
}
@@ -1166,9 +1057,13 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
vif = netdev_priv(wilc->vif[1]->ndev);
if ((buff[0] == vif->frame_reg[0].type && vif->frame_reg[0].reg) ||
(buff[0] == vif->frame_reg[1].type && vif->frame_reg[1].reg))
- WILC_WFI_p2p_rx(wilc->vif[1]->ndev, buff, size);
+ wilc_wfi_p2p_rx(wilc->vif[1]->ndev, buff, size);
}
+static struct notifier_block g_dev_notifier = {
+ .notifier_call = dev_state_ev_handler
+};
+
void wilc_netdev_cleanup(struct wilc *wilc)
{
int i;
@@ -1198,6 +1093,15 @@ void wilc_netdev_cleanup(struct wilc *wilc)
}
EXPORT_SYMBOL_GPL(wilc_netdev_cleanup);
+static const struct net_device_ops wilc_netdev_ops = {
+ .ndo_init = mac_init_fn,
+ .ndo_open = wilc_mac_open,
+ .ndo_stop = wilc_mac_close,
+ .ndo_start_xmit = wilc_mac_xmit,
+ .ndo_get_stats = mac_stats,
+ .ndo_set_rx_mode = wilc_set_multicast_list,
+};
+
int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
int gpio, const struct wilc_hif_func *ops)
{
@@ -1218,6 +1122,8 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
register_inetaddr_notifier(&g_dev_notifier);
for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ struct wireless_dev *wdev;
+
ndev = alloc_etherdev(sizeof(struct wilc_vif));
if (!ndev)
return -ENOMEM;
@@ -1240,28 +1146,24 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
ndev->netdev_ops = &wilc_netdev_ops;
- {
- struct wireless_dev *wdev;
+ wdev = wilc_create_wiphy(ndev, dev);
- wdev = wilc_create_wiphy(ndev, dev);
+ if (dev)
+ SET_NETDEV_DEV(ndev, dev);
- if (dev)
- SET_NETDEV_DEV(ndev, dev);
-
- if (!wdev) {
- netdev_err(ndev, "Can't register WILC Wiphy\n");
- return -1;
- }
-
- vif->ndev->ieee80211_ptr = wdev;
- vif->ndev->ml_priv = vif;
- wdev->netdev = vif->ndev;
- vif->netstats.rx_packets = 0;
- vif->netstats.tx_packets = 0;
- vif->netstats.rx_bytes = 0;
- vif->netstats.tx_bytes = 0;
+ if (!wdev) {
+ netdev_err(ndev, "Can't register WILC Wiphy\n");
+ return -1;
}
+ vif->ndev->ieee80211_ptr = wdev;
+ vif->ndev->ml_priv = vif;
+ wdev->netdev = vif->ndev;
+ vif->netstats.rx_packets = 0;
+ vif->netstats.tx_packets = 0;
+ vif->netstats.rx_bytes = 0;
+ vif->netstats.tx_bytes = 0;
+
ret = register_netdev(ndev);
if (ret)
return ret;
diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c
index 0deb61a21b27..287c11b58160 100644
--- a/drivers/staging/wilc1000/wilc_debugfs.c
+++ b/drivers/staging/wilc1000/wilc_debugfs.c
@@ -13,8 +13,6 @@
#if defined(WILC_DEBUGFS)
#include <linux/module.h>
#include <linux/debugfs.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
#include "wilc_wlan_if.h"
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index a08899941491..4ab43f97646a 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -5,17 +5,11 @@
* Module Name: wilc_sdio.c
*/
-#include <linux/string.h>
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
-#include "wilc_wfi_netdevice.h"
#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/host.h>
#include <linux/of_gpio.h>
+#include "wilc_wfi_netdevice.h"
+
#define SDIO_MODALIAS "wilc1000_sdio"
#define SDIO_VENDOR_ID_WILC 0x0296
@@ -32,7 +26,8 @@ struct wilc_sdio {
bool irq_gpio;
u32 block_size;
int nint;
-#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in registers 0xf7, 0xf8 */
+/* Max num interrupts allowed in registers 0xf7, 0xf8 */
+#define MAX_NUN_INT_THRPT_ENH2 (5)
int has_thrpt_enh3;
};
@@ -274,7 +269,7 @@ static int sdio_set_func0_csa_address(struct wilc *wilc, u32 adr)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x10c data...\n");
- goto _fail_;
+ goto fail;
}
cmd.address = 0x10d;
@@ -282,7 +277,7 @@ static int sdio_set_func0_csa_address(struct wilc *wilc, u32 adr)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x10d data...\n");
- goto _fail_;
+ goto fail;
}
cmd.address = 0x10e;
@@ -290,11 +285,11 @@ static int sdio_set_func0_csa_address(struct wilc *wilc, u32 adr)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x10e data...\n");
- goto _fail_;
+ goto fail;
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -312,7 +307,7 @@ static int sdio_set_func0_block_size(struct wilc *wilc, u32 block_size)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x10 data...\n");
- goto _fail_;
+ goto fail;
}
cmd.address = 0x11;
@@ -320,11 +315,11 @@ static int sdio_set_func0_block_size(struct wilc *wilc, u32 block_size)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x11 data...\n");
- goto _fail_;
+ goto fail;
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -348,18 +343,18 @@ static int sdio_set_func1_block_size(struct wilc *wilc, u32 block_size)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x110 data...\n");
- goto _fail_;
+ goto fail;
}
cmd.address = 0x111;
cmd.data = (u8)(block_size >> 8);
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed cmd52, set 0x111 data...\n");
- goto _fail_;
+ goto fail;
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -387,7 +382,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
if (ret) {
dev_err(&func->dev,
"Failed cmd 52, read reg (%08x) ...\n", addr);
- goto _fail_;
+ goto fail;
}
} else {
struct sdio_cmd53 cmd;
@@ -396,7 +391,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
* set the AHB address
**/
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
cmd.read_write = 1;
cmd.function = 0;
@@ -410,13 +405,13 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
if (ret) {
dev_err(&func->dev,
"Failed cmd53, write reg (%08x)...\n", addr);
- goto _fail_;
+ goto fail;
}
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -470,13 +465,13 @@ static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
cmd.block_size = block_size;
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
}
ret = wilc_sdio_cmd53(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed cmd53 [%x], block send...\n", addr);
- goto _fail_;
+ goto fail;
}
if (addr > 0)
addr += nblk * block_size;
@@ -493,19 +488,19 @@ static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
}
ret = wilc_sdio_cmd53(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed cmd53 [%x], bytes send...\n", addr);
- goto _fail_;
+ goto fail;
}
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -526,14 +521,14 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
if (ret) {
dev_err(&func->dev,
"Failed cmd 52, read reg (%08x) ...\n", addr);
- goto _fail_;
+ goto fail;
}
*data = cmd.data;
} else {
struct sdio_cmd53 cmd;
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
cmd.read_write = 0;
cmd.function = 0;
@@ -548,7 +543,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
if (ret) {
dev_err(&func->dev,
"Failed cmd53, read reg (%08x)...\n", addr);
- goto _fail_;
+ goto fail;
}
}
@@ -556,7 +551,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
return 1;
-_fail_:
+fail:
return 0;
}
@@ -610,13 +605,13 @@ static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
cmd.block_size = block_size;
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
}
ret = wilc_sdio_cmd53(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed cmd53 [%x], block read...\n", addr);
- goto _fail_;
+ goto fail;
}
if (addr > 0)
addr += nblk * block_size;
@@ -633,19 +628,19 @@ static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
- goto _fail_;
+ goto fail;
}
ret = wilc_sdio_cmd53(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed cmd53 [%x], bytes read...\n", addr);
- goto _fail_;
+ goto fail;
}
}
return 1;
-_fail_:
+fail:
return 0;
}
@@ -684,7 +679,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Fail cmd 52, enable csa...\n");
- goto _fail_;
+ goto fail;
}
/**
@@ -692,7 +687,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
**/
if (!sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) {
dev_err(&func->dev, "Fail cmd 52, set func 0 block size...\n");
- goto _fail_;
+ goto fail;
}
g_sdio.block_size = WILC_SDIO_BLOCK_SIZE;
@@ -708,7 +703,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
if (ret) {
dev_err(&func->dev,
"Fail cmd 52, set IOE register...\n");
- goto _fail_;
+ goto fail;
}
/**
@@ -725,7 +720,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
if (ret) {
dev_err(&func->dev,
"Fail cmd 52, get IOR register...\n");
- goto _fail_;
+ goto fail;
}
if (cmd.data == 0x2)
break;
@@ -733,7 +728,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
if (loop <= 0) {
dev_err(&func->dev, "Fail func 1 is not ready...\n");
- goto _fail_;
+ goto fail;
}
/**
@@ -741,7 +736,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
**/
if (!sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) {
dev_err(&func->dev, "Fail set func 1 block size...\n");
- goto _fail_;
+ goto fail;
}
/**
@@ -755,7 +750,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Fail cmd 52, set IEN register...\n");
- goto _fail_;
+ goto fail;
}
/**
@@ -764,7 +759,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
if (!resume) {
if (!sdio_read_reg(wilc, 0x1000, &chipid)) {
dev_err(&func->dev, "Fail cmd read chip id...\n");
- goto _fail_;
+ goto fail;
}
dev_err(&func->dev, "chipid (%08x)\n", chipid);
if ((chipid & 0xfff) > 0x2a0)
@@ -777,7 +772,7 @@ static int sdio_init(struct wilc *wilc, bool resume)
return 1;
-_fail_:
+fail:
return 0;
}
@@ -885,13 +880,13 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
reg = 0;
}
/* select VMM table 0 */
- if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ if (val & SEL_VMM_TBL0)
reg |= BIT(5);
/* select VMM table 1 */
- if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ if (val & SEL_VMM_TBL1)
reg |= BIT(6);
/* enable VMM */
- if ((val & EN_VMM) == EN_VMM)
+ if (val & EN_VMM)
reg |= BIT(7);
if (reg) {
struct sdio_cmd52 cmd;
@@ -907,7 +902,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
dev_err(&func->dev,
"Failed cmd52, set 0xf8 data (%d) ...\n",
__LINE__);
- goto _fail_;
+ goto fail;
}
}
return 1;
@@ -940,7 +935,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
dev_err(&func->dev,
"Failed cmd52, set 0xf8 data (%d) ...\n",
__LINE__);
- goto _fail_;
+ goto fail;
}
}
if (!ret)
@@ -948,7 +943,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
flags >>= 1;
}
if (!ret)
- goto _fail_;
+ goto fail;
for (i = g_sdio.nint; i < MAX_NUM_INT; i++) {
if (flags & 1)
dev_err(&func->dev,
@@ -961,13 +956,13 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
vmm_ctl = 0;
/* select VMM table 0 */
- if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ if (val & SEL_VMM_TBL0)
vmm_ctl |= BIT(0);
/* select VMM table 1 */
- if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ if (val & SEL_VMM_TBL1)
vmm_ctl |= BIT(1);
/* enable VMM */
- if ((val & EN_VMM) == EN_VMM)
+ if (val & EN_VMM)
vmm_ctl |= BIT(2);
if (vmm_ctl) {
@@ -983,11 +978,11 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
dev_err(&func->dev,
"Failed cmd52, set 0xf6 data (%d) ...\n",
__LINE__);
- goto _fail_;
+ goto fail;
}
}
return 1;
-_fail_:
+fail:
return 0;
}
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 6b392c946a6f..647526387784 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -5,21 +5,9 @@
* Module Name: wilc_spi.c
*/
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/cdev.h>
-#include <linux/uaccess.h>
-#include <linux/device.h>
#include <linux/spi/spi.h>
#include <linux/of_gpio.h>
-#include <linux/string.h>
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
#include "wilc_wfi_netdevice.h"
struct wilc_spi {
@@ -31,9 +19,6 @@ struct wilc_spi {
static struct wilc_spi g_spi;
static const struct wilc_hif_func wilc_hif_spi;
-static int wilc_spi_read(struct wilc *wilc, u32, u8 *, u32);
-static int wilc_spi_write(struct wilc *wilc, u32, u8 *, u32);
-
/********************************************
*
* Crc7
@@ -95,29 +80,29 @@ static u8 crc7(u8 crc, const u8 *buffer, u32 len)
#define CMD_DMA_WRITE 0xc1
#define CMD_DMA_READ 0xc2
-#define CMD_INTERNAL_WRITE 0xc3
-#define CMD_INTERNAL_READ 0xc4
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ 0xc4
#define CMD_TERMINATE 0xc5
-#define CMD_REPEAT 0xc6
-#define CMD_DMA_EXT_WRITE 0xc7
-#define CMD_DMA_EXT_READ 0xc8
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE 0xc7
+#define CMD_DMA_EXT_READ 0xc8
#define CMD_SINGLE_WRITE 0xc9
-#define CMD_SINGLE_READ 0xca
-#define CMD_RESET 0xcf
+#define CMD_SINGLE_READ 0xca
+#define CMD_RESET 0xcf
-#define N_OK 1
-#define N_FAIL 0
-#define N_RESET -1
-#define N_RETRY -2
+#define N_OK 1
+#define N_FAIL 0
+#define N_RESET -1
+#define N_RETRY -2
#define DATA_PKT_SZ_256 256
-#define DATA_PKT_SZ_512 512
+#define DATA_PKT_SZ_512 512
#define DATA_PKT_SZ_1K 1024
#define DATA_PKT_SZ_4K (4 * 1024)
#define DATA_PKT_SZ_8K (8 * 1024)
-#define DATA_PKT_SZ DATA_PKT_SZ_8K
+#define DATA_PKT_SZ DATA_PKT_SZ_8K
-#define USE_SPI_DMA 0
+#define USE_SPI_DMA 0
static int wilc_bus_probe(struct spi_device *spi)
{
@@ -527,8 +512,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
if (wilc_spi_rx(wilc, &b[ix], nbytes)) {
dev_err(&spi->dev,
"Failed block read, bus err\n");
- result = N_FAIL;
- goto _error_;
+ return N_FAIL;
}
/*
@@ -537,8 +521,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
if (!g_spi.crc_off && wilc_spi_rx(wilc, crc, 2)) {
dev_err(&spi->dev,
"Failed block crc read, bus err\n");
- result = N_FAIL;
- goto _error_;
+ return N_FAIL;
}
ix += nbytes;
@@ -604,7 +587,6 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
sz -= nbytes;
}
}
-_error_:
return result;
}
@@ -620,28 +602,23 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
*/
ix = 0;
do {
- if (sz <= DATA_PKT_SZ)
+ if (sz <= DATA_PKT_SZ) {
nbytes = sz;
- else
+ order = 0x3;
+ } else {
nbytes = DATA_PKT_SZ;
+ if (ix == 0)
+ order = 0x1;
+ else
+ order = 0x02;
+ }
/*
* Write command
*/
cmd = 0xf0;
- if (ix == 0) {
- if (sz <= DATA_PKT_SZ)
-
- order = 0x3;
- else
- order = 0x1;
- } else {
- if (sz <= DATA_PKT_SZ)
- order = 0x3;
- else
- order = 0x2;
- }
cmd |= order;
+
if (wilc_spi_tx(wilc, &cmd, 1)) {
dev_err(&spi->dev,
"Failed data block cmd write, bus error...\n");
@@ -748,7 +725,6 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
struct spi_device *spi = to_spi_device(wilc->dev);
int result;
- u8 cmd = CMD_DMA_EXT_WRITE;
/*
* has to be greated than 4
@@ -756,7 +732,7 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (size <= 4)
return 0;
- result = spi_cmd_complete(wilc, cmd, addr, NULL, size, 0);
+ result = spi_cmd_complete(wilc, CMD_DMA_EXT_WRITE, addr, NULL, size, 0);
if (result != N_OK) {
dev_err(&spi->dev,
"Failed cmd, write block (%08x)...\n", addr);
@@ -801,13 +777,12 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data)
static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
struct spi_device *spi = to_spi_device(wilc->dev);
- u8 cmd = CMD_DMA_EXT_READ;
int result;
if (size <= 4)
return 0;
- result = spi_cmd_complete(wilc, cmd, addr, buf, size, 0);
+ result = spi_cmd_complete(wilc, CMD_DMA_EXT_READ, addr, buf, size, 0);
if (result != N_OK) {
dev_err(&spi->dev, "Failed cmd, read block (%08x)...\n", addr);
return 0;
@@ -920,13 +895,12 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
if (!ret) {
dev_err(&spi->dev,
"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
- goto _fail_;
+ return ret;
}
tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
*size = tmp;
}
-_fail_:
return ret;
}
@@ -950,7 +924,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
if (!ret) {
dev_err(&spi->dev,
"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
- goto _fail_;
+ return ret;
}
tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
@@ -980,7 +954,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
*int_status = tmp;
-_fail_:
return ret;
}
@@ -1018,7 +991,7 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
dev_err(&spi->dev,
"Failed wilc_spi_write_reg, set reg %x ...\n",
0x10c8 + i * 4);
- goto _fail_;
+ return ret;
}
for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
if (flags & 1)
@@ -1031,29 +1004,29 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
tbl_ctl = 0;
/* select VMM table 0 */
- if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ if (val & SEL_VMM_TBL0)
tbl_ctl |= BIT(0);
/* select VMM table 1 */
- if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ if (val & SEL_VMM_TBL1)
tbl_ctl |= BIT(1);
ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl);
if (!ret) {
dev_err(&spi->dev, "fail write reg vmm_tbl_ctl...\n");
- goto _fail_;
+ return ret;
}
- if ((val & EN_VMM) == EN_VMM) {
+ if (val & EN_VMM) {
/*
* enable vmm transfer.
*/
ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1);
if (!ret) {
dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n");
- goto _fail_;
+ return ret;
}
}
-_fail_:
+
return ret;
}
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 730d64f2f46a..e248702ee519 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
#include "wilc_wfi_cfgoperations.h"
-#include "host_interface.h"
-#include <linux/errno.h>
#define NO_ENCRYPT 0
#define ENCRYPT_ENABLED BIT(0)
@@ -79,9 +77,6 @@ static const struct wiphy_wowlan_support wowlan_support = {
.flags = WIPHY_WOWLAN_ANY
};
-#define WILC_WFI_DWELL_PASSIVE 100
-#define WILC_WFI_DWELL_ACTIVE 40
-
#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
#define DEFAULT_LINK_SPEED 72
@@ -90,7 +85,7 @@ static const struct wiphy_wowlan_support wowlan_support = {
static struct network_info last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
static u32 last_scanned_cnt;
struct timer_list wilc_during_ip_timer;
-static struct timer_list hAgingTimer;
+static struct timer_list aging_timer;
static u8 op_ifcs;
#define CHAN2G(_channel, _freq, _flags) { \
@@ -153,49 +148,35 @@ static u8 p2p_recv_random;
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
static bool wilc_ie;
-static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
+static struct ieee80211_supported_band wilc_band_2ghz = {
.channels = ieee80211_2ghz_channels,
.n_channels = ARRAY_SIZE(ieee80211_2ghz_channels),
.bitrates = ieee80211_bitrates,
.n_bitrates = ARRAY_SIZE(ieee80211_bitrates),
};
-struct add_key_params {
- u8 key_idx;
- bool pairwise;
- u8 *mac_addr;
-};
-
-static struct add_key_params g_add_gtk_key_params;
-static struct wilc_wfi_key g_key_gtk_params;
-static struct add_key_params g_add_ptk_key_params;
-static struct wilc_wfi_key g_key_ptk_params;
-static struct wilc_wfi_wep_key g_key_wep_params;
-static bool g_ptk_keys_saved;
-static bool g_gtk_keys_saved;
-static bool g_wep_keys_saved;
-
#define AGING_TIME (9 * 1000)
-#define during_ip_time 15000
+#define DURING_IP_TIME_OUT 15000
static void clear_shadow_scan(void)
{
int i;
- if (op_ifcs == 0) {
- del_timer_sync(&hAgingTimer);
+ if (op_ifcs != 0)
+ return;
- for (i = 0; i < last_scanned_cnt; i++) {
- if (last_scanned_shadow[last_scanned_cnt].ies) {
- kfree(last_scanned_shadow[i].ies);
- last_scanned_shadow[last_scanned_cnt].ies = NULL;
- }
+ del_timer_sync(&aging_timer);
- kfree(last_scanned_shadow[i].join_params);
- last_scanned_shadow[i].join_params = NULL;
+ for (i = 0; i < last_scanned_cnt; i++) {
+ if (last_scanned_shadow[last_scanned_cnt].ies) {
+ kfree(last_scanned_shadow[i].ies);
+ last_scanned_shadow[last_scanned_cnt].ies = NULL;
}
- last_scanned_cnt = 0;
+
+ kfree(last_scanned_shadow[i].join_params);
+ last_scanned_shadow[i].join_params = NULL;
}
+ last_scanned_cnt = 0;
}
static u32 get_rssi_avg(struct network_info *network_info)
@@ -270,26 +251,25 @@ static void remove_network_from_shadow(struct timer_list *unused)
int i, j;
for (i = 0; i < last_scanned_cnt; i++) {
- if (time_after(now, last_scanned_shadow[i].time_scan +
- (unsigned long)(SCAN_RESULT_EXPIRE))) {
- kfree(last_scanned_shadow[i].ies);
- last_scanned_shadow[i].ies = NULL;
+ if (!time_after(now, last_scanned_shadow[i].time_scan +
+ (unsigned long)(SCAN_RESULT_EXPIRE)))
+ continue;
+ kfree(last_scanned_shadow[i].ies);
+ last_scanned_shadow[i].ies = NULL;
- kfree(last_scanned_shadow[i].join_params);
+ kfree(last_scanned_shadow[i].join_params);
- for (j = i; (j < last_scanned_cnt - 1); j++)
- last_scanned_shadow[j] = last_scanned_shadow[j + 1];
+ for (j = i; (j < last_scanned_cnt - 1); j++)
+ last_scanned_shadow[j] = last_scanned_shadow[j + 1];
- last_scanned_cnt--;
- }
+ last_scanned_cnt--;
}
- if (last_scanned_cnt != 0) {
- mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
- }
+ if (last_scanned_cnt != 0)
+ mod_timer(&aging_timer, jiffies + msecs_to_jiffies(AGING_TIME));
}
-static void clear_duringIP(struct timer_list *unused)
+static void clear_during_ip(struct timer_list *unused)
{
wilc_optaining_ip = false;
}
@@ -300,7 +280,7 @@ static int is_network_in_shadow(struct network_info *nw_info, void *user_void)
int i;
if (last_scanned_cnt == 0) {
- mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
+ mod_timer(&aging_timer, jiffies + msecs_to_jiffies(AGING_TIME));
state = -1;
} else {
for (i = 0; i < last_scanned_cnt; i++) {
@@ -320,6 +300,7 @@ static void add_network_to_shadow(struct network_info *nw_info,
int ap_found = is_network_in_shadow(nw_info, user_void);
u32 ap_index = 0;
u8 rssi_index = 0;
+ struct network_info *shadow_nw_info;
if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW)
return;
@@ -330,37 +311,37 @@ static void add_network_to_shadow(struct network_info *nw_info,
} else {
ap_index = ap_found;
}
- rssi_index = last_scanned_shadow[ap_index].rssi_history.index;
- last_scanned_shadow[ap_index].rssi_history.samples[rssi_index++] = nw_info->rssi;
+ shadow_nw_info = &last_scanned_shadow[ap_index];
+ rssi_index = shadow_nw_info->rssi_history.index;
+ shadow_nw_info->rssi_history.samples[rssi_index++] = nw_info->rssi;
if (rssi_index == NUM_RSSI) {
rssi_index = 0;
- last_scanned_shadow[ap_index].rssi_history.full = true;
+ shadow_nw_info->rssi_history.full = true;
}
- last_scanned_shadow[ap_index].rssi_history.index = rssi_index;
- last_scanned_shadow[ap_index].rssi = nw_info->rssi;
- last_scanned_shadow[ap_index].cap_info = nw_info->cap_info;
- last_scanned_shadow[ap_index].ssid_len = nw_info->ssid_len;
- memcpy(last_scanned_shadow[ap_index].ssid,
- nw_info->ssid, nw_info->ssid_len);
- memcpy(last_scanned_shadow[ap_index].bssid,
- nw_info->bssid, ETH_ALEN);
- last_scanned_shadow[ap_index].beacon_period = nw_info->beacon_period;
- last_scanned_shadow[ap_index].dtim_period = nw_info->dtim_period;
- last_scanned_shadow[ap_index].ch = nw_info->ch;
- last_scanned_shadow[ap_index].ies_len = nw_info->ies_len;
- last_scanned_shadow[ap_index].tsf_hi = nw_info->tsf_hi;
+ shadow_nw_info->rssi_history.index = rssi_index;
+ shadow_nw_info->rssi = nw_info->rssi;
+ shadow_nw_info->cap_info = nw_info->cap_info;
+ shadow_nw_info->ssid_len = nw_info->ssid_len;
+ memcpy(shadow_nw_info->ssid, nw_info->ssid, nw_info->ssid_len);
+ memcpy(shadow_nw_info->bssid, nw_info->bssid, ETH_ALEN);
+ shadow_nw_info->beacon_period = nw_info->beacon_period;
+ shadow_nw_info->dtim_period = nw_info->dtim_period;
+ shadow_nw_info->ch = nw_info->ch;
+ shadow_nw_info->tsf_hi = nw_info->tsf_hi;
if (ap_found != -1)
- kfree(last_scanned_shadow[ap_index].ies);
- last_scanned_shadow[ap_index].ies = kmalloc(nw_info->ies_len,
- GFP_KERNEL);
- memcpy(last_scanned_shadow[ap_index].ies,
- nw_info->ies, nw_info->ies_len);
- last_scanned_shadow[ap_index].time_scan = jiffies;
- last_scanned_shadow[ap_index].time_scan_cached = jiffies;
- last_scanned_shadow[ap_index].found = 1;
+ kfree(shadow_nw_info->ies);
+ shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len,
+ GFP_KERNEL);
+ if (shadow_nw_info->ies)
+ shadow_nw_info->ies_len = nw_info->ies_len;
+ else
+ shadow_nw_info->ies_len = 0;
+ shadow_nw_info->time_scan = jiffies;
+ shadow_nw_info->time_scan_cached = jiffies;
+ shadow_nw_info->found = 1;
if (ap_found != -1)
- kfree(last_scanned_shadow[ap_index].join_params);
- last_scanned_shadow[ap_index].join_params = join_params;
+ kfree(shadow_nw_info->join_params);
+ shadow_nw_info->join_params = join_params;
}
static void cfg_scan_result(enum scan_event scan_event,
@@ -369,7 +350,7 @@ static void cfg_scan_result(enum scan_event scan_event,
{
struct wilc_priv *priv;
struct wiphy *wiphy;
- s32 s32Freq;
+ s32 freq;
struct ieee80211_channel *channel;
struct cfg80211_bss *bss = NULL;
@@ -388,9 +369,9 @@ static void cfg_scan_result(enum scan_event scan_event,
((s32)network_info->rssi * 100) > 100))
return;
- s32Freq = ieee80211_channel_to_frequency((s32)network_info->ch,
- NL80211_BAND_2GHZ);
- channel = ieee80211_get_channel(wiphy, s32Freq);
+ freq = ieee80211_channel_to_frequency((s32)network_info->ch,
+ NL80211_BAND_2GHZ);
+ channel = ieee80211_get_channel(wiphy, freq);
if (!channel)
return;
@@ -468,6 +449,17 @@ static void cfg_scan_result(enum scan_event scan_event,
}
}
+static inline bool wilc_wfi_cfg_scan_time_expired(int i)
+{
+ unsigned long now = jiffies;
+
+ if (time_after(now, last_scanned_shadow[i].time_scan_cached +
+ (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ))))
+ return true;
+ else
+ return false;
+}
+
int wilc_connecting;
static void cfg_connect_result(enum conn_event conn_disconn_evt,
@@ -496,7 +488,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
connect_status = conn_info->status;
- if (mac_status == MAC_DISCONNECTED &&
+ if (mac_status == MAC_STATUS_DISCONNECTED &&
conn_info->status == SUCCESSFUL_STATUSCODE) {
connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
wilc_wlan_set_bssid(priv->dev, null_bssid,
@@ -513,17 +505,14 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
bool scan_refresh = false;
u32 i;
- memcpy(priv->associated_bss, conn_info->bssid, ETH_ALEN);
+ memcpy(priv->associated_bss, conn_info->bssid,
+ ETH_ALEN);
for (i = 0; i < last_scanned_cnt; i++) {
if (memcmp(last_scanned_shadow[i].bssid,
conn_info->bssid,
ETH_ALEN) == 0) {
- unsigned long now = jiffies;
-
- if (time_after(now,
- last_scanned_shadow[i].time_scan_cached +
- (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ))))
+ if (wilc_wfi_cfg_scan_time_expired(i))
scan_refresh = true;
break;
@@ -535,9 +524,11 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
}
cfg80211_connect_result(dev, conn_info->bssid,
- conn_info->req_ies, conn_info->req_ies_len,
- conn_info->resp_ies, conn_info->resp_ies_len,
- connect_status, GFP_KERNEL);
+ conn_info->req_ies,
+ conn_info->req_ies_len,
+ conn_info->resp_ies,
+ conn_info->resp_ies_len, connect_status,
+ GFP_KERNEL);
} else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
wilc_optaining_ip = false;
p2p_local_random = 0x01;
@@ -554,9 +545,9 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
else if (!wfi_drv->IFC_UP && dev == wl->vif[1]->ndev)
disconn_info->reason = 1;
- cfg80211_disconnected(dev, disconn_info->reason, disconn_info->ie,
- disconn_info->ie_len, false,
- GFP_KERNEL);
+ cfg80211_disconnected(dev, disconn_info->reason,
+ disconn_info->ie, disconn_info->ie_len,
+ false, GFP_KERNEL);
}
}
@@ -582,6 +573,49 @@ static int set_channel(struct wiphy *wiphy,
return result;
}
+static inline int
+wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request,
+ struct hidden_network *ntwk)
+{
+ int i;
+ int slot_id = 0;
+
+ ntwk->net_info = kcalloc(request->n_ssids, sizeof(*ntwk->net_info),
+ GFP_KERNEL);
+ if (!ntwk->net_info)
+ goto out;
+
+ ntwk->n_ssids = request->n_ssids;
+
+ for (i = 0; i < request->n_ssids; i++) {
+ if (request->ssids[i].ssid_len > 0) {
+ struct hidden_net_info *info = &ntwk->net_info[slot_id];
+
+ info->ssid = kmemdup(request->ssids[i].ssid,
+ request->ssids[i].ssid_len,
+ GFP_KERNEL);
+ if (!info->ssid)
+ goto out_free;
+
+ info->ssid_len = request->ssids[i].ssid_len;
+ slot_id++;
+ } else {
+ ntwk->n_ssids -= 1;
+ }
+ }
+ return 0;
+
+out_free:
+
+ for (i = 0; i < slot_id; i++)
+ kfree(ntwk->net_info[i].ssid);
+
+ kfree(ntwk->net_info);
+out:
+
+ return -ENOMEM;
+}
+
static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
{
struct wilc_priv *priv;
@@ -602,27 +636,17 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
priv->cfg_scanning = true;
if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
- for (i = 0; i < request->n_channels; i++)
- scan_ch_list[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
+ for (i = 0; i < request->n_channels; i++) {
+ u16 freq = request->channels[i]->center_freq;
+
+ scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
+ }
if (request->n_ssids >= 1) {
- hidden_ntwk.net_info =
- kmalloc_array(request->n_ssids,
- sizeof(struct hidden_network),
- GFP_KERNEL);
- if (!hidden_ntwk.net_info)
+ if (wilc_wfi_cfg_alloc_fill_ssid(request,
+ &hidden_ntwk))
return -ENOMEM;
- hidden_ntwk.n_ssids = request->n_ssids;
-
- for (i = 0; i < request->n_ssids; i++) {
- if (request->ssids[i].ssid_len != 0) {
- hidden_ntwk.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
- memcpy(hidden_ntwk.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
- hidden_ntwk.net_info[i].ssid_len = request->ssids[i].ssid_len;
- } else {
- hidden_ntwk.n_ssids -= 1;
- }
- }
+
ret = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN,
scan_ch_list,
request->n_channels,
@@ -653,9 +677,9 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
s32 ret = 0;
u32 i;
u32 sel_bssi_idx = UINT_MAX;
- u8 u8security = NO_ENCRYPT;
+ u8 security = NO_ENCRYPT;
enum AUTHTYPE auth_type = ANY;
-
+ u32 cipher_group;
struct wilc_priv *priv;
struct host_if_drv *wfi_drv;
struct network_info *nw_info = NULL;
@@ -700,50 +724,41 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
return ret;
}
- memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
- memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
-
- if (sme->crypto.cipher_group != NO_ENCRYPT) {
- if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
- u8security = ENCRYPT_ENABLED | WEP;
+ memset(priv->wep_key, 0, sizeof(priv->wep_key));
+ memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
- priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
- memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
+ cipher_group = sme->crypto.cipher_group;
+ if (cipher_group != NO_ENCRYPT) {
+ if (cipher_group == WLAN_CIPHER_SUITE_WEP40) {
+ security = ENCRYPT_ENABLED | WEP;
- g_key_wep_params.key_len = sme->key_len;
- g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
- memcpy(g_key_wep_params.key, sme->key, sme->key_len);
- g_key_wep_params.key_idx = sme->key_idx;
- g_wep_keys_saved = true;
+ priv->wep_key_len[sme->key_idx] = sme->key_len;
+ memcpy(priv->wep_key[sme->key_idx], sme->key,
+ sme->key_len);
wilc_set_wep_default_keyid(vif, sme->key_idx);
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
sme->key_idx);
- } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
- u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+ } else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) {
+ security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
- priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
- memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
-
- g_key_wep_params.key_len = sme->key_len;
- g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
- memcpy(g_key_wep_params.key, sme->key, sme->key_len);
- g_key_wep_params.key_idx = sme->key_idx;
- g_wep_keys_saved = true;
+ priv->wep_key_len[sme->key_idx] = sme->key_len;
+ memcpy(priv->wep_key[sme->key_idx], sme->key,
+ sme->key_len);
wilc_set_wep_default_keyid(vif, sme->key_idx);
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
sme->key_idx);
- } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
- if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP)
- u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
+ } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
+ if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
+ security = ENCRYPT_ENABLED | WPA2 | TKIP;
else
- u8security = ENCRYPT_ENABLED | WPA2 | AES;
- } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
- if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP)
- u8security = ENCRYPT_ENABLED | WPA | TKIP;
+ security = ENCRYPT_ENABLED | WPA2 | AES;
+ } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
+ if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
+ security = ENCRYPT_ENABLED | WPA | TKIP;
else
- u8security = ENCRYPT_ENABLED | WPA | AES;
+ security = ENCRYPT_ENABLED | WPA | AES;
} else {
ret = -ENOTSUPP;
netdev_err(dev, "Not supported cipher\n");
@@ -755,14 +770,16 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) ||
(sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
- if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP)
- u8security = u8security | TKIP;
+ u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i];
+
+ if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP)
+ security = security | TKIP;
else
- u8security = u8security | AES;
+ security = security | AES;
}
}
- switch (sme->auth_type) {
+ switch (sme->auth_type) {
case NL80211_AUTHTYPE_OPEN_SYSTEM:
auth_type = OPEN_SYSTEM;
break;
@@ -790,7 +807,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
ret = wilc_set_join_req(vif, nw_info->bssid, sme->ssid,
sme->ssid_len, sme->ie, sme->ie_len,
cfg_connect_result, (void *)priv,
- u8security, auth_type,
+ security, auth_type,
nw_info->ch,
nw_info->join_params);
if (ret != 0) {
@@ -803,7 +820,8 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
return ret;
}
-static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
+static int disconnect(struct wiphy *wiphy, struct net_device *dev,
+ u16 reason_code)
{
s32 ret = 0;
struct wilc_priv *priv;
@@ -845,203 +863,161 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_co
return ret;
}
+static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv,
+ u8 key_index,
+ struct key_params *params)
+{
+ priv->wep_key_len[key_index] = params->key_len;
+ memcpy(priv->wep_key[key_index], params->key, params->key_len);
+}
+
+static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx)
+{
+ if (!priv->wilc_gtk[idx]) {
+ priv->wilc_gtk[idx] = kzalloc(sizeof(*priv->wilc_gtk[idx]),
+ GFP_KERNEL);
+ if (!priv->wilc_gtk[idx])
+ return -ENOMEM;
+ }
+
+ if (!priv->wilc_ptk[idx]) {
+ priv->wilc_ptk[idx] = kzalloc(sizeof(*priv->wilc_ptk[idx]),
+ GFP_KERNEL);
+ if (!priv->wilc_ptk[idx])
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static int wilc_wfi_cfg_copy_wpa_info(struct wilc_wfi_key *key_info,
+ struct key_params *params)
+{
+ kfree(key_info->key);
+
+ key_info->key = kmemdup(params->key, params->key_len, GFP_KERNEL);
+ if (!key_info->key)
+ return -ENOMEM;
+
+ kfree(key_info->seq);
+
+ if (params->seq_len > 0) {
+ key_info->seq = kmemdup(params->seq, params->seq_len,
+ GFP_KERNEL);
+ if (!key_info->seq)
+ return -ENOMEM;
+ }
+
+ key_info->cipher = params->cipher;
+ key_info->key_len = params->key_len;
+ key_info->seq_len = params->seq_len;
+
+ return 0;
+}
+
static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
- bool pairwise,
- const u8 *mac_addr, struct key_params *params)
+ bool pairwise, const u8 *mac_addr, struct key_params *params)
{
s32 ret = 0, keylen = params->key_len;
struct wilc_priv *priv;
const u8 *rx_mic = NULL;
const u8 *tx_mic = NULL;
- u8 u8mode = NO_ENCRYPT;
- u8 u8gmode = NO_ENCRYPT;
- u8 u8pmode = NO_ENCRYPT;
- enum AUTHTYPE auth_type = ANY;
- struct wilc *wl;
+ u8 mode = NO_ENCRYPT;
+ u8 op_mode;
struct wilc_vif *vif;
priv = wiphy_priv(wiphy);
vif = netdev_priv(netdev);
- wl = vif->wilc;
- switch (params->cipher) {
+ switch (params->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
- priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
- memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
-
- auth_type = OPEN_SYSTEM;
+ wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
- u8mode = ENCRYPT_ENABLED | WEP;
+ mode = ENCRYPT_ENABLED | WEP;
else
- u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+ mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
- wilc_add_wep_key_bss_ap(vif, params->key,
- params->key_len, key_index,
- u8mode, auth_type);
+ ret = wilc_add_wep_key_bss_ap(vif, params->key,
+ params->key_len,
+ key_index, mode,
+ OPEN_SYSTEM);
break;
}
- if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
- priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
- memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
+ if (memcmp(params->key, priv->wep_key[key_index],
+ params->key_len)) {
+ wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
- wilc_add_wep_key_bss_sta(vif, params->key,
- params->key_len, key_index);
+ ret = wilc_add_wep_key_bss_sta(vif, params->key,
+ params->key_len,
+ key_index);
}
break;
case WLAN_CIPHER_SUITE_TKIP:
case WLAN_CIPHER_SUITE_CCMP:
- if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
- if (!priv->wilc_gtk[key_index]) {
- priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
- priv->wilc_gtk[key_index]->key = NULL;
- priv->wilc_gtk[key_index]->seq = NULL;
- }
- if (!priv->wilc_ptk[key_index]) {
- priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
- priv->wilc_ptk[key_index]->key = NULL;
- priv->wilc_ptk[key_index]->seq = NULL;
+ if (priv->wdev->iftype == NL80211_IFTYPE_AP ||
+ priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
+ struct wilc_wfi_key *key;
+
+ ret = wilc_wfi_cfg_allocate_wpa_entry(priv, key_index);
+ if (ret)
+ return -ENOMEM;
+
+ if (params->key_len > 16 &&
+ params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+ tx_mic = params->key + 24;
+ rx_mic = params->key + 16;
+ keylen = params->key_len - 16;
}
if (!pairwise) {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
- u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
+ mode = ENCRYPT_ENABLED | WPA | TKIP;
else
- u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
+ mode = ENCRYPT_ENABLED | WPA2 | AES;
- priv->wilc_groupkey = u8gmode;
-
- if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
- tx_mic = params->key + 24;
- rx_mic = params->key + 16;
- keylen = params->key_len - 16;
- }
- kfree(priv->wilc_gtk[key_index]->key);
-
- priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
- memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
- kfree(priv->wilc_gtk[key_index]->seq);
-
- if (params->seq_len > 0) {
- priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
- memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
- }
-
- priv->wilc_gtk[key_index]->cipher = params->cipher;
- priv->wilc_gtk[key_index]->key_len = params->key_len;
- priv->wilc_gtk[key_index]->seq_len = params->seq_len;
-
- wilc_add_rx_gtk(vif, params->key, keylen,
- key_index, params->seq_len,
- params->seq, rx_mic,
- tx_mic, AP_MODE, u8gmode);
+ priv->wilc_groupkey = mode;
+ key = priv->wilc_gtk[key_index];
} else {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
- u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
+ mode = ENCRYPT_ENABLED | WPA | TKIP;
else
- u8pmode = priv->wilc_groupkey | AES;
-
- if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
- tx_mic = params->key + 24;
- rx_mic = params->key + 16;
- keylen = params->key_len - 16;
- }
-
- kfree(priv->wilc_ptk[key_index]->key);
- priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
- memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
-
- kfree(priv->wilc_ptk[key_index]->seq);
- if (params->seq_len > 0) {
- priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
- memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
- }
+ mode = priv->wilc_groupkey | AES;
- priv->wilc_ptk[key_index]->cipher = params->cipher;
- priv->wilc_ptk[key_index]->key_len = params->key_len;
- priv->wilc_ptk[key_index]->seq_len = params->seq_len;
-
- wilc_add_ptk(vif, params->key, keylen,
- mac_addr, rx_mic, tx_mic,
- AP_MODE, u8pmode, key_index);
+ key = priv->wilc_ptk[key_index];
}
- break;
- }
-
- {
- u8mode = 0;
- if (!pairwise) {
- if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
- rx_mic = params->key + 24;
- tx_mic = params->key + 16;
- keylen = params->key_len - 16;
- }
+ ret = wilc_wfi_cfg_copy_wpa_info(key, params);
+ if (ret)
+ return -ENOMEM;
- if (!g_gtk_keys_saved && netdev == wl->vif[0]->ndev) {
- g_add_gtk_key_params.key_idx = key_index;
- g_add_gtk_key_params.pairwise = pairwise;
- if (!mac_addr) {
- g_add_gtk_key_params.mac_addr = NULL;
- } else {
- g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
- memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
- }
- g_key_gtk_params.key_len = params->key_len;
- g_key_gtk_params.seq_len = params->seq_len;
- g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
- memcpy(g_key_gtk_params.key, params->key, params->key_len);
- if (params->seq_len > 0) {
- g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
- memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
- }
- g_key_gtk_params.cipher = params->cipher;
- g_gtk_keys_saved = true;
- }
+ op_mode = AP_MODE;
+ } else {
+ if (params->key_len > 16 &&
+ params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+ rx_mic = params->key + 24;
+ tx_mic = params->key + 16;
+ keylen = params->key_len - 16;
+ }
- wilc_add_rx_gtk(vif, params->key, keylen,
- key_index, params->seq_len,
- params->seq, rx_mic,
- tx_mic, STATION_MODE,
- u8mode);
- } else {
- if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
- rx_mic = params->key + 24;
- tx_mic = params->key + 16;
- keylen = params->key_len - 16;
- }
+ op_mode = STATION_MODE;
+ }
- if (!g_ptk_keys_saved && netdev == wl->vif[0]->ndev) {
- g_add_ptk_key_params.key_idx = key_index;
- g_add_ptk_key_params.pairwise = pairwise;
- if (!mac_addr) {
- g_add_ptk_key_params.mac_addr = NULL;
- } else {
- g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
- memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
- }
- g_key_ptk_params.key_len = params->key_len;
- g_key_ptk_params.seq_len = params->seq_len;
- g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
- memcpy(g_key_ptk_params.key, params->key, params->key_len);
- if (params->seq_len > 0) {
- g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
- memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
- }
- g_key_ptk_params.cipher = params->cipher;
- g_ptk_keys_saved = true;
- }
+ if (!pairwise)
+ ret = wilc_add_rx_gtk(vif, params->key, keylen,
+ key_index, params->seq_len,
+ params->seq, rx_mic, tx_mic,
+ op_mode, mode);
+ else
+ ret = wilc_add_ptk(vif, params->key, keylen, mac_addr,
+ rx_mic, tx_mic, op_mode, mode,
+ key_index);
- wilc_add_ptk(vif, params->key, keylen,
- mac_addr, rx_mic, tx_mic,
- STATION_MODE, u8mode, key_index);
- }
- }
break;
default:
@@ -1066,14 +1042,7 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
wl = vif->wilc;
if (netdev == wl->vif[0]->ndev) {
- g_ptk_keys_saved = false;
- g_gtk_keys_saved = false;
- g_wep_keys_saved = false;
-
- kfree(g_key_wep_params.key);
- g_key_wep_params.key = NULL;
-
- if (priv->wilc_gtk[key_index] != NULL) {
+ if (priv->wilc_gtk[key_index]) {
kfree(priv->wilc_gtk[key_index]->key);
priv->wilc_gtk[key_index]->key = NULL;
kfree(priv->wilc_gtk[key_index]->seq);
@@ -1083,7 +1052,7 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
priv->wilc_gtk[key_index] = NULL;
}
- if (priv->wilc_ptk[key_index] != NULL) {
+ if (priv->wilc_ptk[key_index]) {
kfree(priv->wilc_ptk[key_index]->key);
priv->wilc_ptk[key_index]->key = NULL;
kfree(priv->wilc_ptk[key_index]->seq);
@@ -1091,27 +1060,13 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
kfree(priv->wilc_ptk[key_index]);
priv->wilc_ptk[key_index] = NULL;
}
-
- kfree(g_key_ptk_params.key);
- g_key_ptk_params.key = NULL;
- kfree(g_key_ptk_params.seq);
- g_key_ptk_params.seq = NULL;
-
- kfree(g_key_gtk_params.key);
- g_key_gtk_params.key = NULL;
- kfree(g_key_gtk_params.seq);
- g_key_gtk_params.seq = NULL;
}
- if (key_index >= 0 && key_index <= 3) {
- if (priv->WILC_WFI_wep_key_len[key_index]) {
- memset(priv->WILC_WFI_wep_key[key_index], 0,
- priv->WILC_WFI_wep_key_len[key_index]);
- priv->WILC_WFI_wep_key_len[key_index] = 0;
- wilc_remove_wep_key(vif, key_index);
- }
- } else {
- wilc_remove_key(priv->hif_drv, mac_addr);
+ if (key_index <= 3 && priv->wep_key_len[key_index]) {
+ memset(priv->wep_key[key_index], 0,
+ priv->wep_key_len[key_index]);
+ priv->wep_key_len[key_index] = 0;
+ wilc_remove_wep_key(vif, key_index);
}
return 0;
@@ -1173,7 +1128,9 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
- if (!(memcmp(mac, priv->assoc_stainfo.sta_associated_bss[i], ETH_ALEN))) {
+ if (!(memcmp(mac,
+ priv->assoc_stainfo.sta_associated_bss[i],
+ ETH_ALEN))) {
associatedsta = i;
break;
}
@@ -1188,18 +1145,16 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
wilc_get_inactive_time(vif, mac, &inactive_time);
sinfo->inactive_time = 1000 * inactive_time;
- }
-
- if (vif->iftype == STATION_MODE) {
+ } else if (vif->iftype == STATION_MODE) {
struct rf_info stats;
wilc_get_statistics(vif, &stats);
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
- BIT(NL80211_STA_INFO_RX_PACKETS) |
- BIT(NL80211_STA_INFO_TX_PACKETS) |
- BIT(NL80211_STA_INFO_TX_FAILED) |
- BIT(NL80211_STA_INFO_TX_BITRATE);
+ BIT(NL80211_STA_INFO_RX_PACKETS) |
+ BIT(NL80211_STA_INFO_TX_PACKETS) |
+ BIT(NL80211_STA_INFO_TX_FAILED) |
+ BIT(NL80211_STA_INFO_TX_BITRATE);
sinfo->signal = stats.rssi;
sinfo->rx_packets = stats.rx_cnt;
@@ -1236,20 +1191,20 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
if (changed & WIPHY_PARAM_RETRY_SHORT) {
cfg_param_val.flag |= RETRY_SHORT;
- cfg_param_val.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
+ cfg_param_val.short_retry_limit = wiphy->retry_short;
}
if (changed & WIPHY_PARAM_RETRY_LONG) {
cfg_param_val.flag |= RETRY_LONG;
- cfg_param_val.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
+ cfg_param_val.long_retry_limit = wiphy->retry_long;
}
if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
cfg_param_val.flag |= FRAG_THRESHOLD;
- cfg_param_val.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
+ cfg_param_val.frag_threshold = wiphy->frag_threshold;
}
if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
cfg_param_val.flag |= RTS_THRESHOLD;
- cfg_param_val.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
+ cfg_param_val.rts_threshold = wiphy->rts_threshold;
}
ret = wilc_hif_set_cfg(vif, &cfg_param_val);
@@ -1306,7 +1261,8 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
ETH_ALEN)) {
- memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
+ memset(&priv->pmkid_list.pmkidlist[i], 0,
+ sizeof(struct host_if_pmkid));
break;
}
}
@@ -1409,13 +1365,50 @@ static void wilc_wfi_cfg_parse_tx_action(u8 *buf, u32 len, bool oper_ch,
op_channel_attr_index);
}
-void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size)
+static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff,
+ u32 size)
+{
+ int i;
+ u8 subtype;
+ struct wilc_vif *vif = netdev_priv(priv->dev);
+
+ subtype = buff[P2P_PUB_ACTION_SUBTYPE];
+ if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && !wilc_ie) {
+ for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
+ if (!memcmp(p2p_vendor_spec, &buff[i], 6)) {
+ p2p_recv_random = buff[i + 6];
+ wilc_ie = true;
+ break;
+ }
+ }
+ }
+
+ if (p2p_local_random <= p2p_recv_random) {
+ netdev_dbg(vif->ndev,
+ "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n",
+ p2p_local_random, p2p_recv_random);
+ return;
+ }
+
+ if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP ||
+ subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) {
+ for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
+ if (buff[i] == P2PELEM_ATTR_ID &&
+ !(memcmp(p2p_oui, &buff[i + 2], 4))) {
+ wilc_wfi_cfg_parse_rx_action(&buff[i + 6],
+ size - (i + 6));
+ break;
+ }
+ }
+ }
+}
+
+void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size)
{
struct wilc_priv *priv;
u32 header, pkt_offset;
struct host_if_drv *wfi_drv;
- u32 i = 0;
- s32 s32Freq;
+ s32 freq;
priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
wfi_drv = (struct host_if_drv *)priv->hif_drv;
@@ -1425,75 +1418,57 @@ void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size)
pkt_offset = GET_PKT_OFFSET(header);
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
- if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
- cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, true, GFP_KERNEL);
- return;
- } else {
- if (pkt_offset & IS_MGMT_STATUS_SUCCES)
- cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, true, GFP_KERNEL);
- else
- cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, false, GFP_KERNEL);
- return;
- }
- } else {
- s32Freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ);
+ bool ack = false;
- if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
- if (priv->cfg_scanning && time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) {
- netdev_dbg(dev, "Receiving action wrong ch\n");
- return;
- }
- if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
- switch (buff[ACTION_SUBTYPE_ID]) {
- case GAS_INITIAL_REQ:
- break;
+ if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP ||
+ pkt_offset & IS_MGMT_STATUS_SUCCES)
+ ack = true;
- case GAS_INITIAL_RSP:
- break;
+ cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size,
+ ack, GFP_KERNEL);
+ return;
+ }
- case PUBLIC_ACT_VENDORSPEC:
- if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
- if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
- if (!wilc_ie) {
- for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
- if (!memcmp(p2p_vendor_spec, &buff[i], 6)) {
- p2p_recv_random = buff[i + 6];
- wilc_ie = true;
- break;
- }
- }
- }
- }
- if (p2p_local_random > p2p_recv_random) {
- if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP ||
- buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
- for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
- if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buff[i + 2], 4))) {
- wilc_wfi_cfg_parse_rx_action(&buff[i + 6], size - (i + 6));
- break;
- }
- }
- }
- } else {
- netdev_dbg(dev, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random);
- }
- }
-
- if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (wilc_ie)) {
- cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
- return;
- }
- break;
+ freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ);
- default:
- netdev_dbg(dev, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
- break;
- }
- }
- }
+ if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) {
+ cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0);
+ return;
+ }
- cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0);
+ if (priv->cfg_scanning &&
+ time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) {
+ netdev_dbg(dev, "Receiving action wrong ch\n");
+ return;
}
+ if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
+ u8 subtype = buff[P2P_PUB_ACTION_SUBTYPE];
+
+ switch (buff[ACTION_SUBTYPE_ID]) {
+ case GAS_INITIAL_REQ:
+ case GAS_INITIAL_RSP:
+ break;
+
+ case PUBLIC_ACT_VENDORSPEC:
+ if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4))
+ wilc_wfi_cfg_parse_rx_vendor_spec(priv, buff,
+ size);
+
+ if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) &&
+ wilc_ie)
+ size -= 7;
+
+ break;
+
+ default:
+ netdev_dbg(dev,
+ "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n",
+ buff[ACTION_SUBTYPE_ID]);
+ break;
+ }
+ }
+
+ cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0);
}
static void wilc_wfi_mgmt_tx_complete(void *priv, int status)
@@ -1521,18 +1496,16 @@ static void wilc_wfi_remain_on_channel_ready(void *priv_data)
static void wilc_wfi_remain_on_channel_expired(void *data, u32 session_id)
{
- struct wilc_priv *priv;
+ struct wilc_priv *priv = data;
+ struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params;
- priv = data;
+ if (session_id != params->listen_session_id)
+ return;
- if (session_id == priv->remain_on_ch_params.listen_session_id) {
- priv->p2p_listen_state = false;
+ priv->p2p_listen_state = false;
- cfg80211_remain_on_channel_expired(priv->wdev,
- priv->remain_on_ch_params.listen_cookie,
- priv->remain_on_ch_params.listen_ch,
- GFP_KERNEL);
- }
+ cfg80211_remain_on_channel_expired(priv->wdev, params->listen_cookie,
+ params->listen_ch, GFP_KERNEL);
}
static int remain_on_channel(struct wiphy *wiphy,
@@ -1580,6 +1553,55 @@ static int cancel_remain_on_channel(struct wiphy *wiphy,
priv->remain_on_ch_params.listen_session_id);
}
+static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx,
+ struct cfg80211_mgmt_tx_params *params,
+ u8 iftype, u32 buf_len)
+{
+ const u8 *buf = params->buf;
+ size_t len = params->len;
+ u32 i;
+ u8 subtype = buf[P2P_PUB_ACTION_SUBTYPE];
+
+ if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) {
+ if (p2p_local_random == 1 &&
+ p2p_recv_random < p2p_local_random) {
+ get_random_bytes(&p2p_local_random, 1);
+ p2p_local_random++;
+ }
+ }
+
+ if (p2p_local_random <= p2p_recv_random || !(subtype == GO_NEG_REQ ||
+ subtype == GO_NEG_RSP ||
+ subtype == P2P_INV_REQ ||
+ subtype == P2P_INV_RSP))
+ return;
+
+ for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
+ if (buf[i] == P2PELEM_ATTR_ID &&
+ !memcmp(p2p_oui, &buf[i + 2], 4)) {
+ bool oper_ch = false;
+ u8 *tx_buff = &mgmt_tx->buff[i + 6];
+
+ if (subtype == P2P_INV_REQ || subtype == P2P_INV_RSP)
+ oper_ch = true;
+
+ wilc_wfi_cfg_parse_tx_action(tx_buff, len - (i + 6),
+ oper_ch, iftype);
+
+ break;
+ }
+ }
+
+ if (subtype != P2P_INV_REQ && subtype != P2P_INV_RSP) {
+ int vendor_spec_len = sizeof(p2p_vendor_spec);
+
+ memcpy(&mgmt_tx->buff[len], p2p_vendor_spec,
+ vendor_spec_len);
+ mgmt_tx->buff[len + vendor_spec_len] = p2p_local_random;
+ mgmt_tx->size = buf_len;
+ }
+}
+
static int mgmt_tx(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct cfg80211_mgmt_tx_params *params,
@@ -1593,9 +1615,9 @@ static int mgmt_tx(struct wiphy *wiphy,
struct p2p_mgmt_data *mgmt_tx;
struct wilc_priv *priv;
struct host_if_drv *wfi_drv;
- u32 i;
struct wilc_vif *vif;
u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random);
+ int ret = 0;
vif = netdev_priv(wdev->netdev);
priv = wiphy_priv(wiphy);
@@ -1605,92 +1627,75 @@ static int mgmt_tx(struct wiphy *wiphy,
priv->tx_cookie = *cookie;
mgmt = (const struct ieee80211_mgmt *)buf;
- if (ieee80211_is_mgmt(mgmt->frame_control)) {
- mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
- if (!mgmt_tx)
- return -EFAULT;
+ if (!ieee80211_is_mgmt(mgmt->frame_control))
+ goto out;
- mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
- if (!mgmt_tx->buff) {
- kfree(mgmt_tx);
- return -ENOMEM;
- }
+ mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL);
+ if (!mgmt_tx) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
+ if (!mgmt_tx->buff) {
+ ret = -ENOMEM;
+ kfree(mgmt_tx);
+ goto out;
+ }
+
+ memcpy(mgmt_tx->buff, buf, len);
+ mgmt_tx->size = len;
+
+ if (ieee80211_is_probe_resp(mgmt->frame_control)) {
+ wilc_set_mac_chnl_num(vif, chan->hw_value);
+ curr_channel = chan->hw_value;
+ goto out_txq_add_pkt;
+ }
- memcpy(mgmt_tx->buff, buf, len);
- mgmt_tx->size = len;
+ if (!ieee80211_is_action(mgmt->frame_control))
+ goto out_txq_add_pkt;
- if (ieee80211_is_probe_resp(mgmt->frame_control)) {
+ if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
+ if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
+ buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
wilc_set_mac_chnl_num(vif, chan->hw_value);
curr_channel = chan->hw_value;
- } else if (ieee80211_is_action(mgmt->frame_control)) {
- if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
- if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
- buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
- wilc_set_mac_chnl_num(vif,
- chan->hw_value);
- curr_channel = chan->hw_value;
- }
- switch (buf[ACTION_SUBTYPE_ID]) {
- case GAS_INITIAL_REQ:
- break;
+ }
+ switch (buf[ACTION_SUBTYPE_ID]) {
+ case GAS_INITIAL_REQ:
+ case GAS_INITIAL_RSP:
+ break;
- case GAS_INITIAL_RSP:
- break;
+ case PUBLIC_ACT_VENDORSPEC:
+ if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4))
+ wilc_wfi_cfg_tx_vendor_spec(mgmt_tx, params,
+ vif->iftype,
+ buf_len);
+ else
+ netdev_dbg(vif->ndev,
+ "Not a P2P public action frame\n");
- case PUBLIC_ACT_VENDORSPEC:
- {
- if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
- if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
- if (p2p_local_random == 1 && p2p_recv_random < p2p_local_random) {
- get_random_bytes(&p2p_local_random, 1);
- p2p_local_random++;
- }
- }
-
- if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP ||
- buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
- if (p2p_local_random > p2p_recv_random) {
- for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
- if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buf[i + 2], 4))) {
- if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
- wilc_wfi_cfg_parse_tx_action(&mgmt_tx->buff[i + 6], len - (i + 6), true, vif->iftype);
- else
- wilc_wfi_cfg_parse_tx_action(&mgmt_tx->buff[i + 6], len - (i + 6), false, vif->iftype);
- break;
- }
- }
-
- if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
- memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, sizeof(p2p_vendor_spec));
- mgmt_tx->buff[len + sizeof(p2p_vendor_spec)] = p2p_local_random;
- mgmt_tx->size = buf_len;
- }
- }
- }
-
- } else {
- netdev_dbg(vif->ndev, "Not a P2P public action frame\n");
- }
+ break;
- break;
- }
+ default:
+ netdev_dbg(vif->ndev,
+ "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n",
+ buf[ACTION_SUBTYPE_ID]);
+ break;
+ }
+ }
- default:
- {
- netdev_dbg(vif->ndev, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
- break;
- }
- }
- }
+ wfi_drv->p2p_timeout = (jiffies + msecs_to_jiffies(wait));
- wfi_drv->p2p_timeout = (jiffies + msecs_to_jiffies(wait));
- }
+out_txq_add_pkt:
- wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx,
- mgmt_tx->buff, mgmt_tx->size,
- wilc_wfi_mgmt_tx_complete);
- }
- return 0;
+ wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx,
+ mgmt_tx->buff, mgmt_tx->size,
+ wilc_wfi_mgmt_tx_complete);
+
+out:
+
+ return ret;
}
static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
@@ -1734,24 +1739,18 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
switch (frame_type) {
case PROBE_REQ:
- {
vif->frame_reg[0].type = frame_type;
vif->frame_reg[0].reg = reg;
- }
- break;
+ break;
case ACTION:
- {
vif->frame_reg[1].type = frame_type;
vif->frame_reg[1].reg = reg;
- }
- break;
+ break;
default:
- {
break;
}
- }
if (!wl->initialized)
return;
@@ -1866,7 +1865,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
case NL80211_IFTYPE_P2P_GO:
wilc_optaining_ip = true;
mod_timer(&wilc_during_ip_timer,
- jiffies + msecs_to_jiffies(during_ip_time));
+ jiffies + msecs_to_jiffies(DURING_IP_TIME_OUT));
wilc_set_operation_mode(vif, AP_MODE);
dev->ieee80211_ptr->iftype = type;
priv->wdev->iftype = type;
@@ -1888,12 +1887,10 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_ap_settings *settings)
{
struct cfg80211_beacon_data *beacon = &settings->beacon;
- struct wilc_priv *priv;
s32 ret = 0;
struct wilc *wl;
struct wilc_vif *vif;
- priv = wiphy_priv(wiphy);
vif = netdev_priv(dev);
wl = vif->wilc;
@@ -1964,7 +1961,8 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev,
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
memcpy(sta_params.bssid, mac, ETH_ALEN);
- memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, ETH_ALEN);
+ memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac,
+ ETH_ALEN);
sta_params.aid = params->aid;
sta_params.rates_len = params->supported_rates_len;
sta_params.rates = params->supported_rates;
@@ -1994,6 +1992,7 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev,
s32 ret = 0;
struct wilc_priv *priv;
struct wilc_vif *vif;
+ struct sta_info *info;
if (!wiphy)
return -EFAULT;
@@ -2001,16 +2000,17 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev,
priv = wiphy_priv(wiphy);
vif = netdev_priv(dev);
- if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
- if (!mac)
- ret = wilc_del_allstation(vif,
- priv->assoc_stainfo.sta_associated_bss);
+ if (!(vif->iftype == AP_MODE || vif->iftype == GO_MODE))
+ return ret;
- ret = wilc_del_station(vif, mac);
+ info = &priv->assoc_stainfo;
- if (ret)
- netdev_err(dev, "Host delete station fail\n");
- }
+ if (!mac)
+ ret = wilc_del_allstation(vif, info->sta_associated_bss);
+
+ ret = wilc_del_station(vif, mac);
+ if (ret)
+ netdev_err(dev, "Host delete station fail\n");
return ret;
}
@@ -2018,14 +2018,12 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev,
const u8 *mac, struct station_parameters *params)
{
s32 ret = 0;
- struct wilc_priv *priv;
struct add_sta_param sta_params = { {0} };
struct wilc_vif *vif;
if (!wiphy)
return -EFAULT;
- priv = wiphy_priv(wiphy);
vif = netdev_priv(dev);
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
@@ -2065,7 +2063,7 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
vif = netdev_priv(priv->wdev->netdev);
if (type == NL80211_IFTYPE_MONITOR) {
- new_ifc = WILC_WFI_init_mon_interface(name, vif->ndev);
+ new_ifc = wilc_wfi_init_mon_interface(name, vif->ndev);
if (new_ifc) {
vif = netdev_priv(priv->wdev->netdev);
vif->monitor_flag = 1;
@@ -2196,7 +2194,7 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void)
{
struct wireless_dev *wdev;
- wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
+ wdev = kzalloc(sizeof(*wdev), GFP_KERNEL);
if (!wdev)
goto _fail_;
@@ -2204,13 +2202,13 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void)
if (!wdev->wiphy)
goto _fail_mem_;
- WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
- WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
- WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
- WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
- WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
+ wilc_band_2ghz.ht_cap.ht_supported = 1;
+ wilc_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
+ wilc_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+ wilc_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
+ wilc_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
- wdev->wiphy->bands[NL80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
+ wdev->wiphy->bands[NL80211_BAND_2GHZ] = &wilc_band_2ghz;
return wdev;
@@ -2220,7 +2218,8 @@ _fail_:
return NULL;
}
-struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *dev)
+struct wireless_dev *wilc_create_wiphy(struct net_device *net,
+ struct device *dev)
{
struct wilc_priv *priv;
struct wireless_dev *wdev;
@@ -2272,8 +2271,8 @@ int wilc_init_host_int(struct net_device *net)
priv = wdev_priv(net->ieee80211_ptr);
if (op_ifcs == 0) {
- timer_setup(&hAgingTimer, remove_network_from_shadow, 0);
- timer_setup(&wilc_during_ip_timer, clear_duringIP, 0);
+ timer_setup(&aging_timer, remove_network_from_shadow, 0);
+ timer_setup(&wilc_during_ip_timer, clear_during_ip, 0);
}
op_ifcs++;
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
index dfb7ec272935..a69103b44958 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
@@ -1,23 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
-/*!
- * @file wilc_wfi_cfgoperations.h
- * @brief Definitions for the network module
- * @author syounan
- * @sa wilc_oswrapper.h top level OS wrapper file
- * @date 31 Aug 2010
- * @version 1.0
- */
#ifndef NM_WFI_CFGOPERATIONS
#define NM_WFI_CFGOPERATIONS
#include "wilc_wfi_netdevice.h"
-struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *dev);
+struct wireless_dev *wilc_create_wiphy(struct net_device *net,
+ struct device *dev);
void wilc_free_wiphy(struct net_device *net);
int wilc_deinit_host_int(struct net_device *net);
int wilc_init_host_int(struct net_device *net);
-void WILC_WFI_monitor_rx(u8 *buff, u32 size);
-int WILC_WFI_deinit_mon_interface(void);
-struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev);
+void wilc_wfi_monitor_rx(u8 *buff, u32 size);
+int wilc_wfi_deinit_mon_interface(void);
+struct net_device *wilc_wfi_init_mon_interface(const char *name,
+ struct net_device *real_dev);
void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
u16 frame_type, bool reg);
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index d62c4f1cddc6..f2b07e8aedd7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -1,60 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
-/*!
- * @file wilc_wfi_netdevice.h
- * @brief Definitions for the network module
- * @author mdaftedar
- * @date 01 MAR 2012
- * @version 1.0
- */
#ifndef WILC_WFI_NETDEVICE
#define WILC_WFI_NETDEVICE
-#define WILC_WFI_RX_INTR 0x0001
-#define WILC_WFI_TX_INTR 0x0002
-
-#define WILC_WFI_TIMEOUT 5
-#define WILC_MAX_NUM_PMKIDS 16
-#define PMKID_LEN 16
-#define PMKID_FOUND 1
- #define NUM_STA_ASSOCIATED 8
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/time.h>
-#include <linux/in.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/ip.h>
#include <linux/tcp.h>
-#include <linux/skbuff.h>
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <net/ieee80211_radiotap.h>
#include <linux/if_arp.h>
-#include <linux/in6.h>
-#include <asm/checksum.h>
+
#include "host_interface.h"
#include "wilc_wlan.h"
-#include <linux/wireless.h>
-#include <linux/completion.h>
-#include <linux/mutex.h>
-#define FLOW_CONTROL_LOWER_THRESHOLD 128
-#define FLOW_CONTROL_UPPER_THRESHOLD 256
+#define FLOW_CONTROL_LOWER_THRESHOLD 128
+#define FLOW_CONTROL_UPPER_THRESHOLD 256
-enum stats_flags {
- WILC_WFI_RX_PKT = BIT(0),
- WILC_WFI_TX_PKT = BIT(1),
-};
+#define WILC_MAX_NUM_PMKIDS 16
+#define PMKID_LEN 16
+#define PMKID_FOUND 1
+#define NUM_STA_ASSOCIATED 8
+
+#define NUM_REG_FRAME 2
-struct WILC_WFI_stats {
+struct wilc_wfi_stats {
unsigned long rx_packets;
unsigned long tx_packets;
unsigned long rx_bytes;
@@ -69,8 +36,6 @@ struct WILC_WFI_stats {
* packets in and out, so there is place for a packet
*/
-#define num_reg_frame 2
-
struct wilc_wfi_key {
u8 *key;
u8 *seq;
@@ -112,20 +77,13 @@ struct wilc_priv {
struct net_device_stats stats;
u8 monitor_flag;
int status;
- struct WILC_WFI_packet *ppool;
- struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
- int rx_int_enabled;
- int tx_packetlen;
- u8 *tx_packetdata;
struct sk_buff *skb;
- spinlock_t lock;
struct net_device *dev;
- struct napi_struct napi;
struct host_if_drv *hif_drv;
struct host_if_pmkid_attr pmkid_list;
- struct WILC_WFI_stats netstats;
- u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
- u8 WILC_WFI_wep_key_len[4];
+ struct wilc_wfi_stats netstats;
+ u8 wep_key[4][WLAN_KEY_LEN_WEP104];
+ u8 wep_key_len[4];
/* The real interface that the monitor is on */
struct net_device *real_ndev;
struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
@@ -150,7 +108,7 @@ struct wilc_vif {
u8 iftype;
int monitor_flag;
int mac_opened;
- struct frame_reg frame_reg[num_reg_frame];
+ struct frame_reg frame_reg[NUM_REG_FRAME];
struct net_device_stats netstats;
struct wilc *wilc;
u8 src_addr[ETH_ALEN];
@@ -172,10 +130,11 @@ struct wilc {
u8 vif_num;
struct wilc_vif *vif[NUM_CONCURRENT_IFC];
u8 open_ifcs;
-
+ /*protect head of transmit queue*/
struct mutex txq_add_to_head_cs;
+ /*protect txq_entry_t transmit queue*/
spinlock_t txq_spinlock;
-
+ /*protect rxq_entry_t receiver queue*/
struct mutex rxq_cs;
struct mutex hif_cs;
@@ -218,20 +177,16 @@ struct wilc {
struct rf_info dummy_statistics;
};
-struct WILC_WFI_mon_priv {
+struct wilc_wfi_mon_priv {
struct net_device *real_ndev;
};
-int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif);
-
void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
-void wilc_mac_indicate(struct wilc *wilc, int flag);
+void wilc_mac_indicate(struct wilc *wilc);
void wilc_netdev_cleanup(struct wilc *wilc);
int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
int gpio, const struct wilc_hif_func *ops);
-void wilc1000_wlan_deinit(struct net_device *dev);
void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
-int wilc_wlan_get_firmware(struct net_device *dev);
int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
#endif
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index bcbb92323a0a..d4ebbf67e50b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#include <linux/completion.h>
-#include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
#include "wilc_wfi_netdevice.h"
#include "wilc_wlan_cfg.h"
@@ -819,12 +816,7 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size)
if (wilc->cfg_seq_no == rsp.seq_no)
complete(&wilc->cfg_event);
} else if (rsp.type == WILC_CFG_RSP_STATUS) {
- wilc_mac_indicate(wilc,
- WILC_MAC_INDICATE_STATUS);
-
- } else if (rsp.type == WILC_CFG_RSP_SCAN) {
- wilc_mac_indicate(wilc,
- WILC_MAC_INDICATE_SCAN);
+ wilc_mac_indicate(wilc);
}
}
}
@@ -996,11 +988,11 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
if (!ret) {
ret = -EIO;
- goto _fail_;
+ goto fail;
}
} while (offset < buffer_size);
-_fail_:
+fail:
kfree(dma_buffer);
@@ -1421,12 +1413,12 @@ int wilc_wlan_init(struct net_device *dev)
if (!wilc->hif_func->hif_init(wilc, false)) {
ret = -EIO;
- goto _fail_;
+ goto fail;
}
if (!wilc_wlan_cfg_init()) {
ret = -ENOBUFS;
- goto _fail_;
+ goto fail;
}
if (!wilc->tx_buffer)
@@ -1434,7 +1426,7 @@ int wilc_wlan_init(struct net_device *dev)
if (!wilc->tx_buffer) {
ret = -ENOBUFS;
- goto _fail_;
+ goto fail;
}
if (!wilc->rx_buffer)
@@ -1442,17 +1434,17 @@ int wilc_wlan_init(struct net_device *dev)
if (!wilc->rx_buffer) {
ret = -ENOBUFS;
- goto _fail_;
+ goto fail;
}
if (!init_chip(dev)) {
ret = -EIO;
- goto _fail_;
+ goto fail;
}
return 1;
-_fail_:
+fail:
kfree(wilc->rx_buffer);
wilc->rx_buffer = NULL;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index fa157a67b045..a5b9c68e1b9c 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -202,13 +202,6 @@
/********************************************
*
- * Debug Type
- *
- ********************************************/
-typedef void (*wilc_debug_func)(u32, char *, ...);
-
-/********************************************
- *
* Tx/Rx Queue Structure
*
********************************************/
@@ -222,7 +215,7 @@ struct txq_entry_t {
int buffer_size;
void *priv;
int status;
- void (*tx_complete_func)(void *, int);
+ void (*tx_complete_func)(void *priv, int status);
};
struct rxq_entry_t {
@@ -238,18 +231,18 @@ struct rxq_entry_t {
********************************************/
struct wilc;
struct wilc_hif_func {
- int (*hif_init)(struct wilc *, bool resume);
- int (*hif_deinit)(struct wilc *);
- int (*hif_read_reg)(struct wilc *, u32, u32 *);
- int (*hif_write_reg)(struct wilc *, u32, u32);
- int (*hif_block_rx)(struct wilc *, u32, u8 *, u32);
- int (*hif_block_tx)(struct wilc *, u32, u8 *, u32);
- int (*hif_read_int)(struct wilc *, u32 *);
- int (*hif_clear_int_ext)(struct wilc *, u32);
- int (*hif_read_size)(struct wilc *, u32 *);
- int (*hif_block_tx_ext)(struct wilc *, u32, u8 *, u32);
- int (*hif_block_rx_ext)(struct wilc *, u32, u8 *, u32);
- int (*hif_sync_ext)(struct wilc *, int);
+ int (*hif_init)(struct wilc *wilc, bool resume);
+ int (*hif_deinit)(struct wilc *wilc);
+ int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data);
+ int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data);
+ int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+ int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+ int (*hif_read_int)(struct wilc *wilc, u32 *int_status);
+ int (*hif_clear_int_ext)(struct wilc *wilc, u32 val);
+ int (*hif_read_size)(struct wilc *wilc, u32 *size);
+ int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+ int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+ int (*hif_sync_ext)(struct wilc *wilc, int nint);
int (*enable_interrupt)(struct wilc *nic);
void (*disable_interrupt)(struct wilc *nic);
};
@@ -298,9 +291,9 @@ void wilc_chip_sleep_manually(struct wilc *wilc);
void wilc_enable_tcp_ack_filter(bool value);
int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc);
-int wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
-void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
+void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
void host_wakeup_notify(struct wilc *wilc);
void host_sleep_notify(struct wilc *wilc);
extern bool wilc_enable_ps;
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index 2b44f4cc56b7..c0b9b700f4d7 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -8,7 +8,6 @@
/* */
/* ///////////////////////////////////////////////////////////////////////// */
-#include <linux/string.h>
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
#include "wilc_wlan_cfg.h"
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
index e186509ad334..e4a7bf5df65b 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -21,7 +21,6 @@
#define HIF_SDIO (0)
#define HIF_SPI BIT(0)
-#define HIF_SDIO_GPIO_IRQ BIT(2)
/********************************************
*
@@ -48,12 +47,9 @@ struct sdio_cmd53 {
u32 block_size;
};
-#define WILC_MAC_INDICATE_STATUS 0x1
-#define WILC_MAC_STATUS_INIT -1
-#define WILC_MAC_STATUS_READY 0
-#define WILC_MAC_STATUS_CONNECT 1
-
-#define WILC_MAC_INDICATE_SCAN 0x2
+#define MAC_STATUS_INIT -1
+#define MAC_STATUS_CONNECTED 1
+#define MAC_STATUS_DISCONNECTED 0
struct tx_complete_data {
int size;
@@ -120,10 +116,6 @@ enum {
G_AUTO_PREAMBLE = 2, /* Auto Preamble Selection */
};
-#define MAC_CONNECTED 1
-#define MAC_DISCONNECTED 0
-
-#define SCAN_DONE TRUE
enum {
PASSIVE_SCAN = 0,
ACTIVE_SCAN = 1,
@@ -741,7 +733,7 @@ enum {
WID_DEL_BEACON = 0x00CA,
- WID_LOGTerminal_Switch = 0x00CD,
+ WID_LOG_TERMINAL_SWITCH = 0x00CD,
WID_TX_POWER = 0x00CE,
/* EMAC Short WID list */
/* RTS Threshold */
diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index 85c3af00abd2..67a944c0d690 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* hfa384x.h
*
* Defines the constants and data structures for the hfa384x
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 555711bc12f0..33e97ffbb436 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -202,7 +202,7 @@ static void unlocked_usbctlx_complete(struct hfa384x *hw,
struct hfa384x_usbctlx *ctlx);
struct usbctlx_completor {
- int (*complete)(struct usbctlx_completor *);
+ int (*complete)(struct usbctlx_completor *completor);
};
static int
@@ -3417,7 +3417,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
/* Attach the rxmeta, set some stuff */
p80211skb_rxmeta_attach(wlandev, skb);
- rxmeta = P80211SKB_RXMETA(skb);
+ rxmeta = p80211skb_rxmeta(skb);
rxmeta->mactime = usbin->rxfrm.desc.time;
rxmeta->rxrate = usbin->rxfrm.desc.rate;
rxmeta->signal = usbin->rxfrm.desc.signal - hw->dbmadjust;
@@ -3439,8 +3439,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
default:
netdev_warn(hw->wlandev->netdev, "Received frame on unsupported port=%d\n",
- HFA384x_RXSTATUS_MACPORT_GET(
- usbin->rxfrm.desc.status));
+ HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status));
break;
}
}
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 855b424f6423..91debcf20646 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -497,7 +497,7 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
/* jkriegl: only process signal/noise if requested by iwspy */
if (wlandev->spy_number)
orinoco_spy_gather(wlandev, eth_hdr(skb)->h_source,
- P80211SKB_RXMETA(skb));
+ p80211skb_rxmeta(skb));
/* Free the metadata */
p80211skb_rxmeta_detach(skb);
@@ -563,7 +563,7 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb)
pr_debug("Called w/ null skb.\n");
return;
}
- frmmeta = P80211SKB_FRMMETA(skb);
+ frmmeta = p80211skb_frmmeta(skb);
if (!frmmeta) { /* no magic */
pr_debug("Called w/ bad frmmeta magic.\n");
return;
@@ -605,7 +605,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
struct p80211_frmmeta *frmmeta;
/* If these already have metadata, we error out! */
- if (P80211SKB_RXMETA(skb)) {
+ if (p80211skb_rxmeta(skb)) {
netdev_err(wlandev->netdev,
"%s: RXmeta already attached!\n", wlandev->name);
result = 0;
@@ -654,7 +654,7 @@ void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
{
struct p80211_frmmeta *meta;
- meta = P80211SKB_FRMMETA(skb);
+ meta = p80211skb_frmmeta(skb);
if (meta && meta->rx)
p80211skb_rxmeta_detach(skb);
else
diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h
index 28459dcea4b1..827002ca9930 100644
--- a/drivers/staging/wlan-ng/p80211conv.h
+++ b/drivers/staging/wlan-ng/p80211conv.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211conv.h
*
* Ether/802.11 conversions and packet buffer routines
@@ -63,16 +63,6 @@
#define P80211_FRMMETA_MAGIC 0x802110
-#define P80211SKB_FRMMETA(s) \
- (((((struct p80211_frmmeta *)((s)->cb))->magic) == \
- P80211_FRMMETA_MAGIC) ? \
- ((struct p80211_frmmeta *)((s)->cb)) : \
- (NULL))
-
-#define P80211SKB_RXMETA(s) \
- (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : \
- ((struct p80211_rxmeta *)(NULL)))
-
struct p80211_rxmeta {
struct wlandevice *wlandev;
@@ -98,6 +88,20 @@ void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb);
int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb);
void p80211skb_rxmeta_detach(struct sk_buff *skb);
+static inline struct p80211_frmmeta *p80211skb_frmmeta(struct sk_buff *skb)
+{
+ struct p80211_frmmeta *frmmeta = (struct p80211_frmmeta *)skb->cb;
+
+ return frmmeta->magic == P80211_FRMMETA_MAGIC ? frmmeta : NULL;
+}
+
+static inline struct p80211_rxmeta *p80211skb_rxmeta(struct sk_buff *skb)
+{
+ struct p80211_frmmeta *frmmeta = p80211skb_frmmeta(skb);
+
+ return frmmeta ? frmmeta->rx : NULL;
+}
+
/*
* Frame capture header. (See doc/capturefrm.txt)
*/
diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h
index 133d70c08ecf..26b178721414 100644
--- a/drivers/staging/wlan-ng/p80211hdr.h
+++ b/drivers/staging/wlan-ng/p80211hdr.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211hdr.h
*
* Macros, types, and functions for handling 802.11 MAC headers
diff --git a/drivers/staging/wlan-ng/p80211ioctl.h b/drivers/staging/wlan-ng/p80211ioctl.h
index d8cde1d8870b..ed65ac57adbe 100644
--- a/drivers/staging/wlan-ng/p80211ioctl.h
+++ b/drivers/staging/wlan-ng/p80211ioctl.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211ioctl.h
*
* Declares constants and types for the p80211 ioctls
diff --git a/drivers/staging/wlan-ng/p80211metadef.h b/drivers/staging/wlan-ng/p80211metadef.h
index 4ac2f08a520a..e63b4b557d0a 100644
--- a/drivers/staging/wlan-ng/p80211metadef.h
+++ b/drivers/staging/wlan-ng/p80211metadef.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* This file is GENERATED AUTOMATICALLY. DO NOT EDIT OR MODIFY.
* --------------------------------------------------------------------
*
diff --git a/drivers/staging/wlan-ng/p80211metastruct.h b/drivers/staging/wlan-ng/p80211metastruct.h
index 15b7c08e210d..5602ec606074 100644
--- a/drivers/staging/wlan-ng/p80211metastruct.h
+++ b/drivers/staging/wlan-ng/p80211metastruct.h
@@ -1,49 +1,49 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* This file is GENERATED AUTOMATICALLY. DO NOT EDIT OR MODIFY.
-* --------------------------------------------------------------------
-*
-* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
-* --------------------------------------------------------------------
-*
-* linux-wlan
-*
-* The contents of this file are subject to the Mozilla Public
-* License Version 1.1 (the "License"); you may not use this file
-* except in compliance with the License. You may obtain a copy of
-* the License at http://www.mozilla.org/MPL/
-*
-* Software distributed under the License is distributed on an "AS
-* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-* implied. See the License for the specific language governing
-* rights and limitations under the License.
-*
-* Alternatively, the contents of this file may be used under the
-* terms of the GNU Public License version 2 (the "GPL"), in which
-* case the provisions of the GPL are applicable instead of the
-* above. If you wish to allow the use of your version of this file
-* only under the terms of the GPL and not to allow others to use
-* your version of this file under the MPL, indicate your decision
-* by deleting the provisions above and replace them with the notice
-* and other provisions required by the GPL. If you do not delete
-* the provisions above, a recipient may use your version of this
-* file under either the MPL or the GPL.
-*
-* --------------------------------------------------------------------
-*
-* Inquiries regarding the linux-wlan Open Source project can be
-* made directly to:
-*
-* AbsoluteValue Systems Inc.
-* info@linux-wlan.com
-* http://www.linux-wlan.com
-*
-* --------------------------------------------------------------------
-*
-* Portions of the development of this software were funded by
-* Intersil Corporation as part of PRISM(R) chipset product development.
-*
-* --------------------------------------------------------------------
-*/
+ * --------------------------------------------------------------------
+ *
+ * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
+ * --------------------------------------------------------------------
+ *
+ * linux-wlan
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * terms of the GNU Public License version 2 (the "GPL"), in which
+ * case the provisions of the GPL are applicable instead of the
+ * above. If you wish to allow the use of your version of this file
+ * only under the terms of the GPL and not to allow others to use
+ * your version of this file under the MPL, indicate your decision
+ * by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL. If you do not delete
+ * the provisions above, a recipient may use your version of this
+ * file under either the MPL or the GPL.
+ *
+ * --------------------------------------------------------------------
+ *
+ * Inquiries regarding the linux-wlan Open Source project can be
+ * made directly to:
+ *
+ * AbsoluteValue Systems Inc.
+ * info@linux-wlan.com
+ * http://www.linux-wlan.com
+ *
+ * --------------------------------------------------------------------
+ *
+ * Portions of the development of this software were funded by
+ * Intersil Corporation as part of PRISM(R) chipset product development.
+ *
+ * --------------------------------------------------------------------
+ */
#ifndef _P80211MKMETASTRUCT_H
#define _P80211MKMETASTRUCT_H
diff --git a/drivers/staging/wlan-ng/p80211mgmt.h b/drivers/staging/wlan-ng/p80211mgmt.h
index 3c12929858cb..c045c08e1991 100644
--- a/drivers/staging/wlan-ng/p80211mgmt.h
+++ b/drivers/staging/wlan-ng/p80211mgmt.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211mgmt.h
*
* Macros, types, and functions to handle 802.11 mgmt frames
diff --git a/drivers/staging/wlan-ng/p80211msg.h b/drivers/staging/wlan-ng/p80211msg.h
index ae119ecd74b0..114066526df4 100644
--- a/drivers/staging/wlan-ng/p80211msg.h
+++ b/drivers/staging/wlan-ng/p80211msg.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211msg.h
*
* Macros, constants, types, and funcs for req and ind messages
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index ec9cc00ee241..8258cb5a335d 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -95,8 +95,8 @@
static int p80211knetdev_init(struct net_device *netdev);
static int p80211knetdev_open(struct net_device *netdev);
static int p80211knetdev_stop(struct net_device *netdev);
-static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
- struct net_device *netdev);
+static netdev_tx_t p80211knetdev_hard_start_xmit(struct sk_buff *skb,
+ struct net_device *netdev);
static void p80211knetdev_set_multicast_list(struct net_device *dev);
static int p80211knetdev_do_ioctl(struct net_device *dev, struct ifreq *ifr,
int cmd);
@@ -321,8 +321,8 @@ static void p80211netdev_rx_bh(unsigned long arg)
* zero on success, non-zero on failure.
*----------------------------------------------------------------
*/
-static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
- struct net_device *netdev)
+static netdev_tx_t p80211knetdev_hard_start_xmit(struct sk_buff *skb,
+ struct net_device *netdev)
{
int result = 0;
int txresult = -1;
diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h
index cebbe746a52f..d48466d943b4 100644
--- a/drivers/staging/wlan-ng/p80211netdev.h
+++ b/drivers/staging/wlan-ng/p80211netdev.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211netdev.h
*
* WLAN net device structure and functions
@@ -180,11 +180,11 @@ struct wlandevice {
int (*close)(struct wlandevice *wlandev);
void (*reset)(struct wlandevice *wlandev);
int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb,
- union p80211_hdr *p80211_hdr,
- struct p80211_metawep *p80211_wep);
+ union p80211_hdr *p80211_hdr,
+ struct p80211_metawep *p80211_wep);
int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg);
int (*set_multicast_list)(struct wlandevice *wlandev,
- struct net_device *dev);
+ struct net_device *dev);
void (*tx_timeout)(struct wlandevice *wlandev);
/* 802.11 State */
diff --git a/drivers/staging/wlan-ng/p80211req.h b/drivers/staging/wlan-ng/p80211req.h
index 20be2c3af4c1..c04053f3b02b 100644
--- a/drivers/staging/wlan-ng/p80211req.h
+++ b/drivers/staging/wlan-ng/p80211req.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* p80211req.h
*
* Request handling functions
diff --git a/drivers/staging/wlan-ng/p80211types.h b/drivers/staging/wlan-ng/p80211types.h
index 94420562c418..388357bbcbf5 100644
--- a/drivers/staging/wlan-ng/p80211types.h
+++ b/drivers/staging/wlan-ng/p80211types.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/*
* p80211types.h
*
diff --git a/drivers/staging/wlan-ng/prism2mgmt.h b/drivers/staging/wlan-ng/prism2mgmt.h
index 564c3f4a3e03..17bc1ee0d498 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.h
+++ b/drivers/staging/wlan-ng/prism2mgmt.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
+/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
/* prism2mgmt.h
*
* Declares the mgmt command handler functions
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index fed0b8ceca6f..914970249680 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -764,16 +764,16 @@ static int prism2sta_getcardinfo(struct wlandevice *wlandev)
if (hw->cap_sup_sta.id == 0x04) {
netdev_info(wlandev->netdev,
- "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
- hw->cap_sup_sta.role, hw->cap_sup_sta.id,
- hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
- hw->cap_sup_sta.top);
+ "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
+ hw->cap_sup_sta.role, hw->cap_sup_sta.id,
+ hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
+ hw->cap_sup_sta.top);
} else {
netdev_info(wlandev->netdev,
- "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
- hw->cap_sup_sta.role, hw->cap_sup_sta.id,
- hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
- hw->cap_sup_sta.top);
+ "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
+ hw->cap_sup_sta.role, hw->cap_sup_sta.id,
+ hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
+ hw->cap_sup_sta.top);
}
/* Compatibility range, primary f/w actor, CFI supplier */
@@ -1189,7 +1189,6 @@ void prism2sta_processing_defer(struct work_struct *data)
inf = (struct hfa384x_inf_frame *)skb->data;
prism2sta_inf_authreq_defer(wlandev, inf);
}
-
}
/* Now let's handle the linkstatus stuff */
@@ -1241,9 +1240,9 @@ void prism2sta_processing_defer(struct work_struct *data)
/* Collect the BSSID, and set state to allow tx */
result = hfa384x_drvr_getconfig(hw,
- HFA384x_RID_CURRENTBSSID,
- wlandev->bssid,
- WLAN_BSSID_LEN);
+ HFA384x_RID_CURRENTBSSID,
+ wlandev->bssid,
+ WLAN_BSSID_LEN);
if (result) {
pr_debug
("getconfig(0x%02x) failed, result = %d\n",
@@ -1260,14 +1259,13 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_CURRENTSSID, result);
return;
}
- prism2mgmt_bytestr2pstr(
- (struct hfa384x_bytestr *)&ssid,
- (struct p80211pstrd *)&wlandev->ssid);
+ prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
+ (struct p80211pstrd *)&wlandev->ssid);
/* Collect the port status */
result = hfa384x_drvr_getconfig16(hw,
- HFA384x_RID_PORTSTATUS,
- &portstatus);
+ HFA384x_RID_PORTSTATUS,
+ &portstatus);
if (result) {
pr_debug
("getconfig(0x%02x) failed, result = %d\n",
@@ -1404,7 +1402,7 @@ void prism2sta_processing_defer(struct work_struct *data)
&joinreq,
HFA384x_RID_JOINREQUEST_LEN);
netdev_info(wlandev->netdev,
- "linkstatus=ASSOCFAIL (re-submitting join)\n");
+ "linkstatus=ASSOCFAIL (re-submitting join)\n");
} else {
netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
}
@@ -1501,7 +1499,7 @@ static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
if (i >= hw->authlist.cnt) {
if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
netdev_warn(wlandev->netdev,
- "assocstatus info frame received for non-authenticated station.\n");
+ "assocstatus info frame received for non-authenticated station.\n");
} else {
hw->authlist.assoc[i] =
(rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
@@ -1509,7 +1507,7 @@ static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
netdev_warn(wlandev->netdev,
-"authfail assocstatus info frame received for authenticated station.\n");
+ "authfail assocstatus info frame received for authenticated station.\n");
}
}
@@ -1674,9 +1672,8 @@ static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
rec.status = cpu_to_le16(P80211ENUM_status_ap_full);
} else {
- ether_addr_copy(
- hw->authlist.addr[hw->authlist.cnt],
- rec.address);
+ ether_addr_copy(hw->authlist.addr[hw->authlist.cnt],
+ rec.address);
hw->authlist.cnt++;
added = 1;
}
@@ -1697,8 +1694,8 @@ static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
if (added)
hw->authlist.cnt--;
netdev_err(wlandev->netdev,
- "setconfig(authenticatestation) failed, result=%d\n",
- result);
+ "setconfig(authenticatestation) failed, result=%d\n",
+ result);
}
}
@@ -1937,9 +1934,8 @@ void prism2sta_commsqual_defer(struct work_struct *data)
/* It only makes sense to poll these in non-IBSS */
if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
- result = hfa384x_drvr_getconfig(
- hw, HFA384x_RID_DBMCOMMSQUALITY,
- &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
+ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY,
+ &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
if (result) {
netdev_err(wlandev->netdev, "error fetching commsqual\n");
diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
index 1fc7abd28b0b..730ead1a46df 100644
--- a/include/linux/iio/adc/ad_sigma_delta.h
+++ b/include/linux/iio/adc/ad_sigma_delta.h
@@ -127,7 +127,7 @@ void ad_sd_cleanup_buffer_and_trigger(struct iio_dev *indio_dev);
int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
#define __AD_SD_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
- _storagebits, _shift, _extend_name, _type) \
+ _storagebits, _shift, _extend_name, _type, _mask_all) \
{ \
.type = (_type), \
.differential = (_channel2 == -1 ? 0 : 1), \
@@ -139,7 +139,7 @@ int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_OFFSET), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
- .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
+ .info_mask_shared_by_all = _mask_all, \
.scan_index = (_si), \
.scan_type = { \
.sign = 'u', \
@@ -153,25 +153,35 @@ int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
#define AD_SD_DIFF_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
_storagebits, _shift) \
__AD_SD_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
- _storagebits, _shift, NULL, IIO_VOLTAGE)
+ _storagebits, _shift, NULL, IIO_VOLTAGE, \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ))
#define AD_SD_SHORTED_CHANNEL(_si, _channel, _address, _bits, \
_storagebits, _shift) \
__AD_SD_CHANNEL(_si, _channel, _channel, _address, _bits, \
- _storagebits, _shift, "shorted", IIO_VOLTAGE)
+ _storagebits, _shift, "shorted", IIO_VOLTAGE, \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ))
#define AD_SD_CHANNEL(_si, _channel, _address, _bits, \
_storagebits, _shift) \
__AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \
- _storagebits, _shift, NULL, IIO_VOLTAGE)
+ _storagebits, _shift, NULL, IIO_VOLTAGE, \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ))
+
+#define AD_SD_CHANNEL_NO_SAMP_FREQ(_si, _channel, _address, _bits, \
+ _storagebits, _shift) \
+ __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \
+ _storagebits, _shift, NULL, IIO_VOLTAGE, 0)
#define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _shift) \
__AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \
- _storagebits, _shift, NULL, IIO_TEMP)
+ _storagebits, _shift, NULL, IIO_TEMP, \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ))
#define AD_SD_SUPPLY_CHANNEL(_si, _channel, _address, _bits, _storagebits, \
_shift) \
__AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \
- _storagebits, _shift, "supply", IIO_VOLTAGE)
+ _storagebits, _shift, "supply", IIO_VOLTAGE, \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ))
#endif
diff --git a/include/linux/iio/adc/stm32-dfsdm-adc.h b/include/linux/iio/adc/stm32-dfsdm-adc.h
index e7dc7a542a4e..0da298b41737 100644
--- a/include/linux/iio/adc/stm32-dfsdm-adc.h
+++ b/include/linux/iio/adc/stm32-dfsdm-adc.h
@@ -9,6 +9,8 @@
#ifndef STM32_DFSDM_ADC_H
#define STM32_DFSDM_ADC_H
+#include <linux/iio/iio.h>
+
int stm32_dfsdm_get_buff_cb(struct iio_dev *iio_dev,
int (*cb)(const void *data, size_t size,
void *private),
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
index 2edf68dc7336..ce16445411ac 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h
+++ b/include/linux/iio/common/cros_ec_sensors_core.h
@@ -16,7 +16,9 @@
#ifndef __CROS_EC_SENSORS_CORE_H
#define __CROS_EC_SENSORS_CORE_H
+#include <linux/iio/iio.h>
#include <linux/irqreturn.h>
+#include <linux/mfd/cros_ec.h>
enum {
CROS_EC_SENSOR_X,
@@ -103,6 +105,7 @@ int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev, unsigned long scan_mask,
int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev, unsigned long scan_mask,
s16 *data);
+struct platform_device;
/**
* cros_ec_sensors_core_init() - basic initialization of the core structure
* @pdev: platform device created for the sensors
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 11579fd4126e..a74cb177dc6f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -183,18 +183,18 @@ struct iio_event_spec {
* @address: Driver specific identifier.
* @scan_index: Monotonic index to give ordering in scans when read
* from a buffer.
- * @scan_type: sign: 's' or 'u' to specify signed or unsigned
- * realbits: Number of valid bits of data
- * storagebits: Realbits + padding
- * shift: Shift right by this before masking out
- * realbits.
- * repeat: Number of times real/storage bits
- * repeats. When the repeat element is
- * more than 1, then the type element in
- * sysfs will show a repeat value.
- * Otherwise, the number of repetitions is
- * omitted.
- * endianness: little or big endian
+ * @scan_type: struct describing the scan type
+ * @scan_type.sign: 's' or 'u' to specify signed or unsigned
+ * @scan_type.realbits: Number of valid bits of data
+ * @scan_type.storagebits: Realbits + padding
+ * @scan_type.shift: Shift right by this before masking out
+ * realbits.
+ * @scan_type.repeat: Number of times real/storage bits repeats.
+ * When the repeat element is more than 1, then
+ * the type element in sysfs will show a repeat
+ * value. Otherwise, the number of repetitions
+ * is omitted.
+ * @scan_type.endianness: little or big endian
* @info_mask_separate: What information is to be exported that is specific to
* this channel.
* @info_mask_separate_available: What availability information is to be
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7aed92624531..cff690998657 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -965,6 +965,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
"pointer type mismatch in container_of()"); \
((type *)(__mptr - offsetof(type, member))); })
+/**
+ * container_of_safe - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
+ */
+#define container_of_safe(ptr, type, member) ({ \
+ void *__mptr = (void *)(ptr); \
+ BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
+ !__same_type(*(ptr), void), \
+ "pointer type mismatch in container_of()"); \
+ IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
+ ((type *)(__mptr - offsetof(type, member))); })
+
/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/include/linux/platform_data/tsl2772.h b/include/linux/platform_data/tsl2772.h
new file mode 100644
index 000000000000..f8ade15a35e2
--- /dev/null
+++ b/include/linux/platform_data/tsl2772.h
@@ -0,0 +1,101 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Device driver for monitoring ambient light intensity (lux)
+ * and proximity (prox) within the TAOS TSL2772 family of devices.
+ *
+ * Copyright (c) 2012, TAOS Corporation.
+ * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
+ */
+
+#ifndef __TSL2772_H
+#define __TSL2772_H
+
+struct tsl2772_lux {
+ unsigned int ch0;
+ unsigned int ch1;
+};
+
+/* Max number of segments allowable in LUX table */
+#define TSL2772_MAX_LUX_TABLE_SIZE 6
+/* The default LUX tables all have 3 elements. */
+#define TSL2772_DEF_LUX_TABLE_SZ 3
+#define TSL2772_DEFAULT_TABLE_BYTES (sizeof(struct tsl2772_lux) * \
+ TSL2772_DEF_LUX_TABLE_SZ)
+
+/* Proximity diode to use */
+#define TSL2772_DIODE0 0x01
+#define TSL2772_DIODE1 0x02
+#define TSL2772_DIODE_BOTH 0x03
+
+/* LED Power */
+#define TSL2772_100_mA 0x00
+#define TSL2772_50_mA 0x01
+#define TSL2772_25_mA 0x02
+#define TSL2772_13_mA 0x03
+
+/**
+ * struct tsl2772_settings - Settings for the tsl2772 driver
+ * @als_time: Integration time of the ALS channel ADCs in 2.73 ms
+ * increments. Total integration time is
+ * (256 - als_time) * 2.73.
+ * @als_gain: Index into the tsl2772_als_gain array.
+ * @als_gain_trim: Default gain trim to account for aperture effects.
+ * @wait_time: Time between proximity and ALS cycles in 2.73
+ * periods.
+ * @prox_time: Integration time of the proximity ADC in 2.73 ms
+ * increments. Total integration time is
+ * (256 - prx_time) * 2.73.
+ * @prox_gain: Index into the tsl2772_prx_gain array.
+ * @als_prox_config: The value of the ALS / Proximity configuration
+ * register.
+ * @als_cal_target: Known external ALS reading for calibration.
+ * @als_persistence: H/W Filters, Number of 'out of limits' ALS readings.
+ * @als_interrupt_en: Enable/Disable ALS interrupts
+ * @als_thresh_low: CH0 'low' count to trigger interrupt.
+ * @als_thresh_high: CH0 'high' count to trigger interrupt.
+ * @prox_persistence: H/W Filters, Number of 'out of limits' proximity
+ * readings.
+ * @prox_interrupt_en: Enable/Disable proximity interrupts.
+ * @prox_thres_low: Low threshold proximity detection.
+ * @prox_thres_high: High threshold proximity detection.
+ * @prox_pulse_count: Number if proximity emitter pulses.
+ * @prox_max_samples_cal: The number of samples that are taken when performing
+ * a proximity calibration.
+ * @prox_diode Which diode(s) to use for driving the external
+ * LED(s) for proximity sensing.
+ * @prox_power The amount of power to use for the external LED(s).
+ */
+struct tsl2772_settings {
+ int als_time;
+ int als_gain;
+ int als_gain_trim;
+ int wait_time;
+ int prox_time;
+ int prox_gain;
+ int als_prox_config;
+ int als_cal_target;
+ u8 als_persistence;
+ bool als_interrupt_en;
+ int als_thresh_low;
+ int als_thresh_high;
+ u8 prox_persistence;
+ bool prox_interrupt_en;
+ int prox_thres_low;
+ int prox_thres_high;
+ int prox_pulse_count;
+ int prox_max_samples_cal;
+ int prox_diode;
+ int prox_power;
+};
+
+/**
+ * struct tsl2772_platform_data - Platform callback, glass and defaults
+ * @platform_lux_table: Device specific glass coefficents
+ * @platform_default_settings: Device specific power on defaults
+ */
+struct tsl2772_platform_data {
+ struct tsl2772_lux platform_lux_table[TSL2772_MAX_LUX_TABLE_SIZE];
+ struct tsl2772_settings *platform_default_settings;
+};
+
+#endif /* __TSL2772_H */
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index f0c6f54a8b2f..3040830d7797 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -248,7 +248,7 @@ void print_usage(void)
"Capture, convert and output data from IIO device buffer\n"
" -a Auto-activate all available channels\n"
" -A Force-activate ALL channels\n"
- " -c <n> Do n conversions\n"
+ " -c <n> Do n conversions, or loop forever if n < 0\n"
" -e Disable wait for event (new data)\n"
" -g Use trigger-less mode\n"
" -l <n> Set buffer length to n samples\n"
@@ -330,11 +330,14 @@ static const struct option longopts[] = {
int main(int argc, char **argv)
{
- unsigned long num_loops = 2;
+ unsigned long long num_loops = 2;
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;
- int ret, c, i, j, toread;
+ ssize_t i;
+ unsigned long long j;
+ unsigned long toread;
+ int ret, c;
int fp = -1;
int num_channels = 0;
@@ -366,7 +369,7 @@ int main(int argc, char **argv)
break;
case 'c':
errno = 0;
- num_loops = strtoul(optarg, &dummy, 10);
+ num_loops = strtoll(optarg, &dummy, 10);
if (errno) {
ret = -errno;
goto error;
@@ -634,7 +637,7 @@ int main(int argc, char **argv)
goto error;
}
- for (j = 0; j < num_loops; j++) {
+ for (j = 0; j < num_loops || num_loops < 0; j++) {
if (!noevents) {
struct pollfd pfd = {
.fd = fp,